@moneko/core 4.4.4 → 4.5.0-beta.1
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/bin/build-dev.mjs +1 -1
- package/lib/bin/build.mjs +1 -1
- package/lib/bin/start.mjs +1 -1
- package/lib/commom/setup-env.d.mts +1 -1
- package/lib/commom/setup-env.mjs +1 -1
- package/lib/config.mjs +1 -1
- package/lib/dev.mjs +1 -1
- package/lib/plugin/exposes-declararion.mjs +1 -1
- package/lib/plugin/module-federation.mjs +1 -1
- package/lib/service-worker/precaching.js +1 -1
- package/lib/utils/dts.d.mts +5 -0
- package/lib/utils/dts.mjs +1 -1
- package/lib/utils/fetch-module-federation-dts.mjs +1 -1
- package/lib/vm/dts.mjs +1 -1
- package/package.json +13 -12
- package/typings/global.d.ts +1 -1
package/lib/bin/build-dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{argv as
|
|
1
|
+
import{argv as o,exit as e}from"node:process";import{ink as r,println as m}from"@moneko/utils";import t from"../commom/setup-env.mjs";import{CUSTOMCONFIG as i}from"../common/paths.mjs";export async function build(){let s=o[3],p=o[4],n=o.slice(5);s||(m(r(`type: 无效值 ${r(s,"245")}`,"red")),e(1));let c=n.indexOf("no-verify");-1!==c&&n.splice(c,1),await t("development",s,p,n,!0,i);try{await import("../build-dev.mjs")}catch(o){m(r(Error(o).message,"red")),e(1)}}
|
package/lib/bin/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as o}from"node:path";import{argv as t,exit as e}from"node:process";import{ink as s,println as i,removeDir as r}from"@moneko/utils";import m from"../commom/setup-env.mjs";import{cwd as
|
|
1
|
+
import{join as o}from"node:path";import{argv as t,exit as e}from"node:process";import{ink as s,println as i,removeDir as r}from"@moneko/utils";import m from"../commom/setup-env.mjs";import{CUSTOMCONFIG as n}from"../common/paths.mjs";import{cwd as p,swcCachePath as c}from"./utils/config.mjs";import{getSwcOption as l}from"./utils/setup-swcrc.mjs";import{lesscCommonjs as d}from"./lessc.mjs";import a from"./tsc.mjs";export async function build(){let j=t[3],u=t[4],f=t.slice(5);j||(i(s(`type: 无效值 ${s(j,"245")}`,"red")),e(1));let x=!f.includes("no-docs"),y=!f.includes("no-lib"),_=!f.includes("no-es"),g=!f.includes("no-dts"),v=f.filter(o=>!["no-docs","no-es","no-lib"].includes(o));if(await m("production",j,u,v,!0,n),"library"===j){let t="solid"===u?await import("@moneko/convert/solid"):await import("@moneko/convert"),{CONFIG:e}=await import("../config.mjs"),s="swc"===e.dts,i=[y&&{type:"commonjs",dir:"lib",msg:"Convert to CommonJS"},_&&{type:"es6",dir:"es",msg:"Convert to ES Module"}].filter(Boolean);for(let m=0,n=i.length;m<n;m++){if(r(o(p,`./${i[m].dir}`)),"react"===u){let o=await l();"es6"===i[m].type&&(o.jsc.target="es2015"),o.jsc.experimental.emitIsolatedDts=g&&s,o.jsc.experimental.cacheRoot=c,o.module.type=i[m].type,t.convert({outDir:i[m].dir,inputDir:"components",ignore:[/^.*\/__*__\//,/\.test\.(js|ts)x?$/,/\.DS_Store/,/\.mdx?$/,/^.*\/examples\//,/\.d\.(cj|mj|j|t|ct|mt)sx?$/],options:o})}else if("solid"===u){let o={jsxOptions:e.jsxDomExpressions,presetEnvOption:{modules:"commonjs"}};"es6"===i[m].type&&(o.presetEnvOption.modules=!1),t.convertSolid({outDir:i[m].dir,inputDir:"components",ignore:[/^.*\/__*__\//,/\.test\.(js|ts)x?$/,/\.DS_Store/,/\.mdx?$/,/^.*\/examples\//,/\.d\.(cj|mj|j|t|ct|mt)sx?$/],options:o})}"commonjs"===i[m].type&&d(),g&&!s&&a(i[m].dir)}}if("library"!==j||x&&"library"===j)try{await import("../build.mjs")}catch(o){i(s(Error(o).message,"red")),e(1)}}
|
package/lib/bin/start.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{argv as e,exit as o}from"node:process";import{ink as r,println as
|
|
1
|
+
import{argv as e,exit as o}from"node:process";import{ink as r,println as m}from"@moneko/utils";import t from"../commom/setup-env.mjs";import{CUSTOMCONFIG as i}from"../common/paths.mjs";async function s(){let s=e[3],p=e[4],n=e.slice(5);s||(m(r(`type: 无效值 ${r(s,"245")}`,"red")),o(1));let a=n.indexOf("no-verify");-1!==a&&n.splice(a,1),await t("development",s,p,n,!1,i);try{await import("../dev.mjs")}catch(e){m(r(Error(e).message,"red")),o(1)}}export default s;
|
|
@@ -5,5 +5,5 @@ interface SetupEnv {
|
|
|
5
5
|
IS_BUILD: boolean;
|
|
6
6
|
[key: string]: string | boolean | number;
|
|
7
7
|
}
|
|
8
|
-
declare function setupEnv(mode: string, type: string, framework: string, args: string[], IS_BUILD: boolean): Promise<SetupEnv>;
|
|
8
|
+
declare function setupEnv(mode: string, type: string, framework: string, args: string[], IS_BUILD: boolean, custom_env?: string): Promise<SetupEnv>;
|
|
9
9
|
export default setupEnv;
|
package/lib/commom/setup-env.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{env as e}from"node:process";import{loadFile as t}from"@moneko/utils";async function r(r,i,
|
|
1
|
+
import{env as e}from"node:process";import{loadFile as t}from"@moneko/utils";async function r(r,n,i,s,a,o){let l=[".env",".env/.env",r&&`.${r}.env`,r&&`.env/.${r}.env`,o&&`.${o}.env`,o&&`.env/.${o}.env`],c={NODE_ENV:r,APPTYPE:n,FRAMEWORK:i,IS_BUILD:a};return s.forEach(e=>{let[t,r]=e.replace(/^--/,"").split("=");Object.assign(c,{[`__args__${t}__`]:r||!0})}),(await Promise.all(l.map(t))).forEach(e=>{e&&Object.assign(c,e.split("\n").reduce((e,t)=>{if(!t||t.trim().startsWith("#"))return e;let[r,...n]=t.split("=");if(!r)return e;let i=n.join("=").trim();return e[r.trim()]=i.replace(/^["']|["']$/g,""),e},{}))}),Object.keys(c).forEach(t=>{let r=c[t];e[t]!==r&&(e[t]=c[t])}),c}export default r;
|
package/lib/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e,relative as o}from"node:path";import t from"node:process";import{merge as a}from"webpack-merge";import n from"./commom/paths.mjs";import
|
|
1
|
+
import{join as e,relative as o}from"node:path";import t from"node:process";import{merge as a}from"webpack-merge";import n,{CUSTOMCONFIG as s}from"./commom/paths.mjs";import r from"./commom/setup-env.mjs";import i from"./options/jsx-dom-expressions.mjs";import l from"./options/split-chunk.mjs";import{getConfigWithTypescript as m,isFunction as p,node_modules as c,resolveProgram as u}from"./utils/index.mjs";import{initDts as d}from"./vm/dts.mjs";import{APPTYPE as f,FRAMEWORK as h,frameworkVersion as g,isCI as v,isDev as x,isLibrary as P,isMobile as C,isReact as b,jsxImportSource as j,mainDirectory as k,NODE_ENV as w,PACKAGENAME as O}from"./process-env.mjs";let I=[/(app|vm|docs|example):[a-zA-Z_0-9]/,"@moneko","neko-ui",".cache/http/data","@element-plus","ant-design-vue","element-plus","element-ui","ng-zorro-antd","@mui","@du","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design","monaco-editor"];export async function getConfig(e){let o=m(e).default;return(p(o)?await o(t):o)??{}}let S=await r(w,f,h,[],"true"===t.env.IS_BUILD,s),[y,M]=await Promise.all([getConfig(n.configPath),getConfig(n.customConfigPath)]),z={mode:w,strict:!1,devtool:"true"!==t.env.IS_BUILD&&x?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:"",namespace:O,moduleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]",fallbackModuleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]"},env:S,basename:"/",publicPath:"auto",rem:{designSize:C?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":u(k)},b&&g<18?{"react/package.json":c("react/package.json"),"react/jsx-runtime":c("react/jsx-runtime.js"),"react/jsx-dev-runtime":c("react/jsx-dev-runtime.js")}:{}),moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3,open:!0},htmlPluginOption:{title:O.toLocaleUpperCase(),favicon:o(n.programPath,`${n.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:l,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:I,js:I,media:I,font:I,wasm:[]},mdx:{jsx:!1,development:x,jsxImportSource:j,providerImportSource:`@moneko/${h}/mdx`},jsxDomExpressions:i,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:v},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==h,bundleId:"com.moneko.bid",bundles:[],stylelint:{},eslint:{lintDirtyModulesOnly:!1},minChunkSize:1e3,compression:!1,manifest:{filename:"site.webmanifest"},corepack:!0,reactJsxRuntime:"automatic"};P&&(z.alias=Object.assign(z.alias,{"@pkg":n.componentsPath,[O]:n.componentsPath}));let D=z;(!1===(D=a(D,y,M)).devtool||!1===D.sourceMap)&&(D.sourceMap=!1,D.devtool=!1),"true"===t.env.CODESPACES&&(D.devServer.https=!1),!1===D.devServer.https&&"darwin"===t.platform&&(D.devServer.open=!1),D.htmlPluginOption&&(D.htmlPluginOption.tags||(D.htmlPluginOption.tags=[]),D.fixBrowserRouter&&D.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))"}),D.manifest&&(D.manifest.publicPath||(D.manifest.publicPath=D.basename),D.htmlPluginOption.tags.push({href:e(D.manifest.publicPath,D.manifest.filename).replaceAll(/\\/g,"/"),tag:"link",rel:"manifest"})));export const CONFIG=D;export const PUBLICPATH="auto"===CONFIG.publicPath?"":CONFIG.publicPath;d(CONFIG);
|
package/lib/dev.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{relative as r}from"node:path";import i from"node:process";import{URL as s}from"node:url";import{ink as n,print as a,println as m,progressBar as l}from"@moneko/utils";import p from"webpack";import c from"webpack-hot-middleware";import{merge as f}from"webpack-merge";import{diffObject as h}from"./commom/diff-object.mjs";import d,{config_files as u}from"./commom/paths.mjs";import g from"./commom/rule.mjs";import w from"./commom/sigint-exit.mjs";import{devLog as y,PORT as $}from"./dev/config.mjs";import j from"./dev/generate-progress-html.mjs";import v from"./dev/server.mjs";import b from"./options/reslove.mjs";import{ESLintPlugin as x}from"./plugin/eslint.mjs";import{StylelintPlugin as C}from"./plugin/stylelint.mjs";import{empty as _}from"./utils/index.mjs";import{CONFIG as P,getConfig as S}from"./config.mjs";import{createDevelopmentConfiguration as k}from"./create-development-configuration.mjs";import{outputFileSystem as E}from"./file-system.mjs";import{isLibrary as B,refresh as H}from"./process-env.mjs";let I=!1,O="/____progress____",T={percentage:0,info:""},q="/__hmr__",G=new URLSearchParams({name:"client",path:q.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!H,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),L=await k({watchOptions:{stdin:!0,aggregateTimeout:300,ignored:g.node_modules},entry:{main:[`${b.hotMiddlewareClient}?${G}`]},plugins:[new p.WatchIgnorePlugin({paths:[g.node_modules,/\.d\.ts$/]}),new p.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";I||(T.info=r,T.percentage=e,I=1===e);let s=P.bar;if(s){let t=s.name||"Build";s.quiet?i.stdout.write(`${r}
|
|
2
|
-
`):(l(e||0,1,{msg:r,name:t,barColor:s.barColor,nameColor:s.nameColor,barBgColor:s.barBgColor,msgColor:s.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})]});function U(e){let t=e.join(","),o=[r(d.programPath,`${P.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(r(d.programPath,`${P.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}P.eslint&&L.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:U(["js","jsx","ts","tsx","json","html","vue"]),...P.eslint})),P.stylelint&&L.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:U(["css","scss","sass","less","ts","tsx","js","jsx"]),...P.stylelint}));let F=p(L);if(!F)throw Error("无法创建编译器");F.outputFileSystem=E;let N=F.watch(F.options.watchOptions,y);if(!N)throw Error("无法创建监视器");F.hooks.done.tap("client-log",e=>{y(null,e)});let R=`${P.basename}/${q}`.replace(/\/+/g,"/"),J=c(F,{log:!1,path:R,heartbeat:2e3}),K=await v({port:$,root_dir:F.options.output.path,fileSystem:F.outputFileSystem,headers:P.devServer.headers,https:P.devServer.https,host:P.devServer.host,open:P.devServer.open,basename:P.basename,onRequest(e,t){if(!t.writableEnded){if("GET"===e.method){let o=new s(`${P.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if(o.pathname===O)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(T)),!0;if(!I)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(j(O,T)),!0;if(o.pathname===R&&"text/event-stream"===e.headers.accept)return J(e,t,_),!0}return!1}}});function M(){i.exit(0)}K.on("close",()=>{N.close(_),J.close()});let W=await Promise.all(u.map(S)),z=f(W[0]||{},W[1]||{});u.forEach(function(t){o(t,async function(){var o;let[r,s]=await Promise.all(u.map(S)),l=f(r||{},s||{}),p=h(z,l);1===Object.keys(p).length&&"proxy"in p?(a(n(
|
|
2
|
+
`):(l(e||0,1,{msg:r,name:t,barColor:s.barColor,nameColor:s.nameColor,barBgColor:s.barBgColor,msgColor:s.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})]});function U(e){let t=e.join(","),o=[r(d.programPath,`${P.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(r(d.programPath,`${P.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}P.eslint&&L.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:U(["js","jsx","ts","tsx","json","html","vue"]),...P.eslint})),P.stylelint&&L.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:U(["css","scss","sass","less","ts","tsx","js","jsx"]),...P.stylelint}));let F=p(L);if(!F)throw Error("无法创建编译器");F.outputFileSystem=E;let N=F.watch(F.options.watchOptions,y);if(!N)throw Error("无法创建监视器");F.hooks.done.tap("client-log",e=>{y(null,e)});let R=`${P.basename}/${q}`.replace(/\/+/g,"/"),J=c(F,{log:!1,path:R,heartbeat:2e3}),K=await v({port:$,root_dir:F.options.output.path,fileSystem:F.outputFileSystem,headers:P.devServer.headers,https:P.devServer.https,host:P.devServer.host,open:P.devServer.open,basename:P.basename,onRequest(e,t){if(!t.writableEnded){if("GET"===e.method){let o=new s(`${P.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if(o.pathname===O)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(T)),!0;if(!I)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(j(O,T)),!0;if(o.pathname===R&&"text/event-stream"===e.headers.accept)return J(e,t,_),!0}return!1}}});function M(){i.exit(0)}K.on("close",()=>{N.close(_),J.close()});let W=await Promise.all(u.map(S)),z=f(W[0]||{},W[1]||{});u.forEach(function(t){o(t,async function(){var o;let[r,s]=await Promise.all(u.map(S)),l=f(r||{},s||{}),p=h(z,l);1===Object.keys(p).length&&"proxy"in p?(a(n("代理更新中...","yellow"),!0),a(n("代理更新完成...","green"),!0),P.proxy=l.proxy,z.proxy=l.proxy,z=l):(z=l,m(n(`检测到工程配置${n(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=$,e(A?`netstat -ano | findstr :${o}`:`lsof -i :${o} -t`,(e,t)=>{if(e){m(n(`查找端口 ${o} 时发生错误: ${e.message}`,"red")),m(n("请尝试手动重启程序","yellow"));return}let r=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),s=A?r[0]?.split(/\s+/).pop()?.trim():r[0]?.trim();if(!s)return void m(n(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{i.kill(Number(s),"SIGHUP")}catch(e){m(n(`终止进程 ${s} 时发生错误: ${e.message}`,"red"))}}))})});let A="win32"===i.platform;i.on("SIGHUP",function(){let e;K.close(),(e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"})).unref(),e.on("close",M)}),i.on("exit",function(){K.close()}),w(M);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e,parse as t,resolve as o,sep as s}from"node:path";import{fileURLToPath as i}from"node:url";import{Worker as r}from"node:worker_threads";import{fileExists as a,loadFile as n}from"@moneko/utils";import m from"webpack";import{module_federation_schema as p}from"../process-env.mjs";import l from"../utils/create-types.mjs";
|
|
1
|
+
import{join as e,parse as t,resolve as o,sep as s}from"node:path";import{fileURLToPath as i}from"node:url";import{Worker as r}from"node:worker_threads";import{fileExists as a,loadFile as n}from"@moneko/utils";import m from"webpack";import{module_federation_schema as p}from"../process-env.mjs";import l from"../utils/create-types.mjs";export class ModuleFederationExposesDeclarationPlugin{constructor(e){this.name="ModuleFederationExposesDeclarationPlugin",this.assetName="module-federation.d.ts",this.dts="",this.option=e,this.worker=new r(i(new URL("../worker/dts.mjs",import.meta.url))),this.worker.setMaxListeners(0),this.worker.postMessage({options:{compilerOptions:{isolatedModules:!1,outFile:this.assetName,verbatimModuleSyntax:!1},include:[...Object.values(e.exposes),"typings/**/*.d.ts"]}}),this.worker.once("message",e=>{this.dts=e,this.worker.terminate()})}apply(i){let{exposes:r}=this.option,h=Object.keys(r).map(e=>{let t=e.replace(/\.tsx?$/i,"");return{key:e,name:t,path:o(`types/${this.option.name}/${t}.d.ts`),originPath:r[e]}});i.hooks.thisCompilation.tap({name:this.name,stage:i.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},o=>{o.hooks.processAssets.tapPromise(this.name,async()=>{let i=h.map(async o=>{if(a(o.originPath)){let i=t(o.originPath),r=`export * from '${t(i.dir).name}/${i.name}'`;if("public-path"===i.name){let e=await n(o.originPath.replace(/\.mjs$/,".d.mts"));e&&(r=e)}return[l(e(this.option.name,o.name),r),l(e(p,this.option.name,o.name).replace(s,":"),r)].join("\n")}return""}),r=await Promise.all(i);r.unshift(this.dts),o.emitAsset("module-federation.d.ts",new m.sources.RawSource(r.join("\n")),{javascriptModule:!1})})})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e,relative as
|
|
1
|
+
import{join as e,parse as t,relative as r,sep as o}from"node:path";import s from"webpack";import m from"../commom/module-resolve.mjs";import a from"../commom/paths.mjs";import{CONFIG as l}from"../config.mjs";import n from"../utils/fetch-module-federation-dts.mjs";import{resolveProgram as p}from"../utils/index.mjs";import{mf_vm as i}from"../vm/mf.mjs";import{ModuleFederationExposesDeclarationPlugin as f}from"./exposes-declararion.mjs";import{ExternalRemotesPlugin as h}from"./external-remotes.mjs";let u=s.NormalModuleReplacementPlugin,c=s.container.ModuleFederationPlugin,d={},$=[];function x(e,r){let s=e.replaceAll(o,"/").replace(/\.tsx?$/i,""),m=t(r);i.setData(s,{type:".tsx",source:()=>{if(r.startsWith(a.nodeModules)){let e=r.substring(a.nodeModules.length).split("node_modules").pop()?.replaceAll(o,"/").replace(/^\//,"");return`export * from '${e}';`}return r.startsWith(l.alias["@"])?`export * from '@/${t(m.dir).name}/${m.name}'`:"export {};"}})}let y=l.moduleFederation?.map(t=>{let o={},s={},l={};if(Array.isArray(t.remotes))for(let e=0,r=t.remotes.length;e<r;e++){let r=t.remotes[e],o=r.alias||r.name,m=r.filename||"remote_entry.js";if(s[o]=`${r.name}@${r.host}/${m}`,Array.isArray(r.library))for(let e=0,t=r.library.length;e<t;e++)d[r.library[e]]=`${o}/${r.library[e]}`;n(r.host,r.name)}if(Array.isArray(t.exposes)){t.exposes.length>0&&!t.exposes.find(e=>"public-path"===e)&&t.exposes.push({name:"public-path",path:`./${r(a.programPath,e(a.corePath,"./polyfills/public-path.mjs"))}`});for(let e=0,r=t.exposes.length;e<r;e++){let r=t.exposes[e];if("string"==typeof r){let e=r.startsWith(".");o[`./${r}`]=m(e?p(r):r),e&&(l[r]=o[`./${r}`],x(`${t.name}/${r}`,l[r]))}else if("[object Object]"===Object.prototype.toString.call(r)){let e=r.path.startsWith(".");o[`./${r.name}`]=m(e?p(r.path):r.path),e&&(l[`./${r.name}`]=o[`./${r.name}`],x(`${t.name}/${r.name}`,l[`./${r.name}`]))}}t.exposes?.length&&$.push(new f({exposes:l,name:t.name}))}return new c({filename:"remote_entry.js",...t,remotes:s,exposes:o})});y.length>0&&(y.push(new h),y.push(new u(/(.*)/,e=>{d[e.request]&&(e.request=d[e.request])})),$.forEach(e=>y.push(e))),l.env.injectRemoteReactRefresh=Object.keys(d).includes("react-dom");export default y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{projectName as t,version as e}from"app:info";let a=self;export async function precaching(){let i=`${t}-core-${e}`,n=`${t}-runtime-${e}`;async function s(t){let e=await caches.open(n),a=await e.match(t);if(a)return a;let i=await fetch(t);return i.ok&&"basic"===i.type&&e.put(t,i.clone()),i}async function c(t){let e=await caches.open(n);try{let a=await fetch(t);return a.ok&&"basic"===a.type&&e.put(t,a.clone()),a}catch{let a=await e.match(t);if(a)return a;return new Response("Offline",{status:503,statusText:"Offline"})}}a.addEventListener("install",t=>{t.waitUntil((async()=>{let t=await caches.open(i),e=await fetch("/app-resource.json").then(t=>t.json()),n=(await Promise.allSettled(e.map(t=>t.startsWith("/")?t:`/${t}`).map(e=>t.add(e)))).filter(t=>"fulfilled"===t.status).length;console.info(`[SW] Precaching ${n}/${e.length} assets`),await a.skipWaiting()})())}),a.addEventListener("activate",t=>{t.waitUntil((async()=>{let t=await caches.keys();await Promise.all(t.filter(t=>![i,n].includes(t)).map(t=>caches.delete(t))),await a.clients.claim(),(await a.clients.matchAll({type:"window"})).forEach(t=>{t.postMessage({type:"SW_UPDATED",version:e})})})())}),a.addEventListener("fetch",t=>{let{request:e}=t;if("GET"!==e.method)return;let a=new URL(e.url);"navigate"===e.mode?t.respondWith(c(e)):a.origin===location.origin&&/\.(js|css|png|jpg|jpeg|svg|webp|woff2?)$/.test(a.pathname)&&t.respondWith(s(e))}),a.addEventListener("message",t=>{t.data?.type==="SKIP_WAITING"&&a.skipWaiting()})}
|
|
1
|
+
import{projectName as t,version as e}from"app:info";let a=self;export async function precaching(){let i=`${t}-core-${e}`,n=`${t}-runtime-${e}`;async function s(t){let e=await caches.open(n),a=await e.match(t);if(a)return a;let i=await fetch(t);return i.ok&&"basic"===i.type&&e.put(t,i.clone()),i}async function c(t){let e=await caches.open(n);try{let a=await fetch(t);return a.ok&&"basic"===a.type&&e.put(t,a.clone()),a}catch{let a=await e.match(t);if(a)return a;return new Response("Offline",{status:503,statusText:"Offline"})}}a.addEventListener("install",t=>{t.waitUntil((async()=>{let t=await caches.open(i),e=await fetch(new URL("/app-resource.json",__webpack_public_path__)).then(t=>t.json()),n=(await Promise.allSettled(e.filter(t=>!t.endsWith(".map")).map(t=>t.startsWith("/")?t:`/${t}`).map(e=>t.add(e)))).filter(t=>"fulfilled"===t.status).length;console.info(`[SW] Precaching ${n}/${e.length} assets`),await a.skipWaiting()})())}),a.addEventListener("activate",t=>{t.waitUntil((async()=>{let t=await caches.keys();await Promise.all(t.filter(t=>![i,n].includes(t)).map(t=>caches.delete(t))),await a.clients.claim(),(await a.clients.matchAll({type:"window"})).forEach(t=>{t.postMessage({type:"SW_UPDATED",version:e})})})())}),a.addEventListener("fetch",t=>{let{request:e}=t;if("GET"!==e.method)return;let a=new URL(e.url);"navigate"===e.mode?t.respondWith(c(e)):a.origin===location.origin&&/\.(js|css|png|jpg|jpeg|svg|webp|woff2?)$/.test(a.pathname)&&t.respondWith(s(e))}),a.addEventListener("message",t=>{t.data?.type==="SKIP_WAITING"&&a.skipWaiting()})}
|
package/lib/utils/dts.d.mts
CHANGED
package/lib/utils/dts.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"typescript";import t from"../commom/rule.mjs";let i={declaration:!0,emitDeclarationOnly:!0,target:e.ScriptTarget.ESNext,skipLibCheck:!0,checkJs:!1,skipDefaultLibCheck:!0,noResolve:!0,types:[],noEmitOnError:!1,noImplicitAny:!1,noImplicitThis:!1,noImplicitReturns:!1,noUnusedLocals:!1,noUnusedParameters:!1,noFallthroughCasesInSwitch:!1,strictNullChecks:!1,strictFunctionTypes:!1,strictBindCallApply:!1,strictPropertyInitialization:!1,strict:!1};export function generateDeclaration(r,a){let s=(t.js.test(a)?a:`${a}.ts`).replace(/^\.+/,""),n="";return e.createProgram([s],i,{getSourceFile:t=>{if(t===s)return e.createSourceFile(t,r,i.target)},writeFile:(e,t)=>{e.endsWith(".d.ts")&&(n=t)},getDefaultLibFileName:()=>"lib.d.ts",getCurrentDirectory:()=>"",getCanonicalFileName:e=>e,useCaseSensitiveFileNames:()=>!0,getNewLine:()=>"\n",fileExists:()=>!0,readFile:()=>"",directoryExists:()=>!0,getDirectories:()=>[]}).emit(),n}export function getExportKeys(t,i){let r=new Set;for(let a of e.createSourceFile(i,t,e.ScriptTarget.Latest,!0).statements)if(e.isExportDeclaration(a)){if(a.exportClause&&e.isNamedExports(a.exportClause))for(let e of a.exportClause.elements)r.add(e.name.text)}else if(e.isExportAssignment(a))r.add("default");else if((e.isVariableStatement(a)||e.isFunctionDeclaration(a)||e.isClassDeclaration(a))&&a.modifiers?.some(t=>t.kind===e.SyntaxKind.ExportKeyword)){if(e.isFunctionDeclaration(a)||e.isClassDeclaration(a))a.name&&r.add(a.name.text);else if(e.isVariableStatement(a))for(let t of a.declarationList.declarations)e.isIdentifier(t.name)&&r.add(t.name.text)}return Array.from(r)}
|
|
1
|
+
import e from"typescript";import t from"../commom/rule.mjs";let i={declaration:!0,emitDeclarationOnly:!0,target:e.ScriptTarget.ESNext,skipLibCheck:!0,checkJs:!1,skipDefaultLibCheck:!0,noResolve:!0,types:[],noEmitOnError:!1,noImplicitAny:!1,noImplicitThis:!1,noImplicitReturns:!1,noUnusedLocals:!1,noUnusedParameters:!1,noFallthroughCasesInSwitch:!1,strictNullChecks:!1,strictFunctionTypes:!1,strictBindCallApply:!1,strictPropertyInitialization:!1,strict:!1};export function extractMfModules(t){let i=e.createSourceFile("temp.ts",t,e.ScriptTarget.Latest,!0),r=[];return!function t(i){if(e.isModuleDeclaration(i)){let e=i.name.text;if(e.startsWith("mf:")){let t=e.substring(3);r.push(t)}}e.forEachChild(i,t)}(i),r}export function generateDeclaration(r,a){let s=(t.js.test(a)?a:`${a}.ts`).replace(/^\.+/,""),n="";return e.createProgram([s],i,{getSourceFile:t=>{if(t===s)return e.createSourceFile(t,r,i.target)},writeFile:(e,t)=>{e.endsWith(".d.ts")&&(n=t)},getDefaultLibFileName:()=>"lib.d.ts",getCurrentDirectory:()=>"",getCanonicalFileName:e=>e,useCaseSensitiveFileNames:()=>!0,getNewLine:()=>"\n",fileExists:()=>!0,readFile:()=>"",directoryExists:()=>!0,getDirectories:()=>[]}).emit(),n}export function getExportKeys(t,i){let r=new Set;for(let a of e.createSourceFile(i,t,e.ScriptTarget.Latest,!0).statements)if(e.isExportDeclaration(a)){if(a.exportClause&&e.isNamedExports(a.exportClause))for(let e of a.exportClause.elements)r.add(e.name.text)}else if(e.isExportAssignment(a))r.add("default");else if((e.isVariableStatement(a)||e.isFunctionDeclaration(a)||e.isClassDeclaration(a))&&a.modifiers?.some(t=>t.kind===e.SyntaxKind.ExportKeyword)){if(e.isFunctionDeclaration(a)||e.isClassDeclaration(a))a.name&&r.add(a.name.text);else if(e.isVariableStatement(a))for(let t of a.declarationList.declarations)e.isIdentifier(t.name)&&r.add(t.name.text)}return Array.from(r)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{request as t}from"@moneko/request";import{updateFile as o}from"@moneko/utils";import
|
|
1
|
+
import{request as t}from"@moneko/request";import{updateFile as o}from"@moneko/utils";import r from"../commom/log.mjs";import{CACHE_NAME as m}from"../process-env.mjs";import{mf_vm as e}from"../vm/mf.mjs";import{extractMfModules as s}from"./dts.mjs";import{node_modules as p}from"./index.mjs";async function i(i,f){try{let r=`${i.startsWith("//")?`http:${i}`:i}/module-federation.d.ts`,a=await t(r,{responseType:"text",rejectUnauthorized:!1});s(a).forEach(t=>{e.has(t)||e.setData(t,{type:".ts",source:()=>`export * from '${t}'`})}),o(p(`@types/${m}/${f}.d.ts`),a)}catch(t){r(t)}}export default i;
|
package/lib/vm/dts.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e}from"node:path";import{loadFileSync as t,updateFile as o,updateFileSync as r}from"@moneko/utils";import s from"../commom/paths.mjs";import n from"../commom/reactive-object.mjs";import{readJson as m}from"../commom/read-json.mjs";import{app_schema as a,APPTYPE as i,CACHE_NAME as p,FRAMEWORK as d,framework as
|
|
1
|
+
import{join as e}from"node:path";import{loadFileSync as t,updateFile as o,updateFileSync as r}from"@moneko/utils";import s from"../commom/paths.mjs";import n from"../commom/reactive-object.mjs";import{readJson as m}from"../commom/read-json.mjs";import{app_schema as a,APPTYPE as i,CACHE_NAME as p,FRAMEWORK as d,framework as l,frameworkVersionStr as c,packageJson as v,service_worker_schema as f,SSR as u,virtual_schema as j}from"../process-env.mjs";import $ from"../utils/create-types.mjs";import{generateDeclaration as y}from"../utils/dts.mjs";import{convertToCamelCase as h,transformModule as g}from"../utils/index.mjs";export const dts_path=e(s.nodeModules,"@types",p,"index.d.ts");export const vm_dts=new n({});export function getEnvDts(e){return`${e};declare global {import AppEnv from '${a}:env';type ImportMetaEnv = Readonly<typeof AppEnv>;interface ImportMeta {readonly env: ImportMetaEnv;}namespace NodeJS {interface ProcessEnv extends ImportMetaEnv {readonly [key: string]: string | number | boolean | undefined;}}}`}vm_dts.on("change",()=>{let e=Object.values(vm_dts.data).join("\n");o(dts_path,e)});export function initDts(o){let n=$(`${a}:env`,y(getEnvDts(g(o.env)),`${a}:env`));vm_dts.setData(`${a}:env`,n);let M=$(`${a}:info`,y(g({...m(e(s.programPath,"package.json")),projectName:h(v.name),ssr:u,type:i,frameworkVersion:c,framework:l,base:o.basename,routerMode:o.routerMode,prefixCls:o.prefixCls,theme:o.theme}),`${a}:info`));vm_dts.setData(`${a}:info`,M),vm_dts.setData(`${f}:precaching`,$(`${f}:precaching`,t(e(s.corePath,"./service-worker/precaching.d.ts"))||"")),o.virtualModule&&Object.keys(o.virtualModule).map(e=>{let t=g(o.virtualModule[e]),r=`${j}:${e}`;vm_dts.setData(r,$(r,y(t,r)))});let x=o.moduleFederation?.flatMap(e=>Array.isArray(e.remotes)?e.remotes.map(e=>e.name):[]).filter(Boolean);r(dts_path,Object.values(vm_dts.data).join("\n")),r(e(s.nodeModules,"@moneko/init.d.json"),JSON.stringify({extends:`@moneko/${d}/base`,compilerOptions:{types:[`@moneko/${d}/env.d.ts`,`@types/${p}/index.d.ts`,...x.map(e=>`@types/${p}/${e}.d.ts`)]}}))}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0-beta.1",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -115,7 +115,8 @@
|
|
|
115
115
|
"default": "./lib/lint/stylelint/config.mjs"
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
|
-
"./package.json": "./package.json"
|
|
118
|
+
"./package.json": "./package.json",
|
|
119
|
+
"./lib/polyfills/public-path.mjs": "./lib/polyfills/public-path.mjs"
|
|
119
120
|
},
|
|
120
121
|
"keywords": [
|
|
121
122
|
"moneko",
|
|
@@ -129,24 +130,24 @@
|
|
|
129
130
|
"license": "MIT",
|
|
130
131
|
"dependencies": {
|
|
131
132
|
"@moneko/convert": "1.2.0",
|
|
132
|
-
"@moneko/eslint": "1.11.
|
|
133
|
+
"@moneko/eslint": "1.11.1",
|
|
133
134
|
"@moneko/mdx": "1.0.3",
|
|
134
135
|
"@moneko/raw-import": "1.3.0",
|
|
135
136
|
"@moneko/request": "1.6.2",
|
|
136
|
-
"@moneko/stylelint": "1.8.
|
|
137
|
+
"@moneko/stylelint": "1.8.2",
|
|
137
138
|
"@moneko/transform-imports": "1.4.0",
|
|
138
139
|
"@moneko/utils": "0.3.3",
|
|
139
|
-
"@swc/core": "1.15.
|
|
140
|
+
"@swc/core": "1.15.10",
|
|
140
141
|
"browserslist": "4.28.1",
|
|
141
|
-
"core-js": "3.
|
|
142
|
-
"core-js-compat": "3.
|
|
142
|
+
"core-js": "3.48.0",
|
|
143
|
+
"core-js-compat": "3.48.0",
|
|
143
144
|
"husky": "9.1.7",
|
|
144
145
|
"less": "4.5.1",
|
|
145
146
|
"less-loader": "12.3.0",
|
|
146
|
-
"lightningcss": "1.
|
|
147
|
+
"lightningcss": "1.31.1",
|
|
147
148
|
"marked-completed": "1.2.15",
|
|
148
|
-
"memfs": "4.
|
|
149
|
-
"swc-loader": "0.2.
|
|
149
|
+
"memfs": "4.56.10",
|
|
150
|
+
"swc-loader": "0.2.7",
|
|
150
151
|
"typescript": "5.9.3",
|
|
151
152
|
"webpack": "5.104.1",
|
|
152
153
|
"webpack-hot-middleware": "2.26.1",
|
|
@@ -157,7 +158,7 @@
|
|
|
157
158
|
"@types/stylis": "4.2.7",
|
|
158
159
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
159
160
|
"@types/webpack-hot-middleware": "2.25.12",
|
|
160
|
-
"sass": "1.97.
|
|
161
|
+
"sass": "1.97.3",
|
|
161
162
|
"sass-loader": "16.0.6",
|
|
162
163
|
"solid-refresh": "0.7.5"
|
|
163
164
|
},
|
|
@@ -169,5 +170,5 @@
|
|
|
169
170
|
"lib",
|
|
170
171
|
"typings"
|
|
171
172
|
],
|
|
172
|
-
"packageManager": "pnpm@10.
|
|
173
|
+
"packageManager": "pnpm@10.28.1"
|
|
173
174
|
}
|
package/typings/global.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export type DevtoolOption =
|
|
|
69
69
|
| 'hidden-source-map';
|
|
70
70
|
export type RulesInclude = {
|
|
71
71
|
css?: RuleSetConditionAbsolute[];
|
|
72
|
-
js?:
|
|
72
|
+
js?: RuleSetConditionAbsolute[];
|
|
73
73
|
media?: RuleSetConditionAbsolute[];
|
|
74
74
|
font?: RuleSetConditionAbsolute[];
|
|
75
75
|
wasm?: RuleSetConditionAbsolute[];
|