@moneko/core 3.47.8 → 3.47.10

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.d.mts CHANGED
@@ -6,7 +6,7 @@ import { type OverrideResolverOption, OverrideResolverPlugin } from './plugin/ov
6
6
  import { isObject, node_modules, resolveProgram } from './utils/index.mjs';
7
7
  import { exampleModuleName } from './vm/example.mjs';
8
8
  import app from './vm/info.mjs';
9
- import { CONFIG, PUBLICPATH } from './config.mjs';
9
+ import { CONFIG } from './config.mjs';
10
10
  import plugins from './plugins.config.mjs';
11
11
  import { isCI, isDev, isLibrary, NODE_ENV, packageJson } from './process-env.mjs';
12
12
  export declare const outputConfig: Configuration['output'];
package/lib/common.mjs CHANGED
@@ -1 +1 @@
1
- import{extname as e,join as t,resolve as o}from"node:path";import s,{config_files as a,CUSTOMCONFIG as n,TMP_DIR as i}from"./commom/paths.mjs";import r from"./commom/require.mjs";import{OverrideResolverPlugin as l}from"./plugin/override-resolve.mjs";import{isObject as m,node_modules as c,resolveProgram as p}from"./utils/index.mjs";import{exampleModuleName as u}from"./vm/example.mjs";import d from"./vm/info.mjs";import{CONFIG as h,PUBLICPATH as f}from"./config.mjs";import g from"./plugins.config.mjs";import{isCI as b,isDev as y,isLibrary as j,NODE_ENV as v,packageJson as C}from"./process-env.mjs";export const outputConfig={path:p(j?"docs":"dist"),filename:"js/[name].[contenthash].bundle.js",chunkFilename:"js/[contenthash].chunk.js",assetModuleFilename:t=>{let o=e(t.filename||"").substring(1);return`assets/${o}/[hash][ext]`},library:{name:`${d.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${C.name}`,pathinfo:y,clean:!y,publicPath:f,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"]};let P={main:[c("@app/entry")]};if(h.polyfill&&P.main.unshift(t(s.corePath,"./polyfills/replace-children.mjs")),y&&h.refresh&&h.env.injectRemoteReactRefresh&&P.main.unshift(r.resolve("@moneko/react/lib/inject-react-refresh.js")),h.entry&&("string"==typeof h.entry?P={main:[h.entry]}:Object.keys(h.entry)&&(P=Object.assign(P,h.entry))),"string"==typeof P.main&&(P.main=[P.main]),h.output){if("string"==typeof h.output)outputConfig.path=h.output;else if(Object.keys(h.output)){let e=h.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof h.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let x={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[n,v].filter(Boolean).join("-")}`,version:`${C.version}`,buildDependencies:{config:a},maxMemoryGenerations:1};!1===h.cache?x=!1:m(h.cache)&&(x=Object.assign(x,h.cache)),b&&(void 0===h.cache||h.cache&&!h.cache.cacheDirectory)&&(x.cacheDirectory=o(i,C.name));export const commonConfig={name:"client",target:"web",devtool:h.devtool,entry:P,mode:y?"development":"production",stats:"errors-only",cache:x,snapshot:{immutablePaths:[s.pnpmNodeModules,s.denoNodeModules,/node_modules\/(?!(@app)\/)/],managedPaths:[s.pnpmNodeModules,s.denoNodeModules,/node_modules\/(?!(@app)\/)/],resolveBuildDependencies:{timestamp:!0,hash:!0},resolve:{timestamp:!0,hash:!0},module:{timestamp:!0,hash:!0},buildDependencies:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:h.externalsPresets,plugins:g,node:{global:!1,__filename:!1,__dirname:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:h.lazyCompilation&&y&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(c(u))||t.startsWith(c("@app/comment"))||t.startsWith(s.pagesPath)||t.startsWith(s.componentsPath)))}},buildHttp:m(h.buildHttp)?{allowedUris:[],lockfileLocation:o(s.httpCachePath,"http.lock"),cacheLocation:o(s.httpCachePath,"data"),upgrade:!0,...h.buildHttp}:h.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:h.alias,modules:[s.nodeModules,s.pnpmNodeModules,s.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:h.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:h.externals,output:outputConfig,recordsPath:h.recordsPath?t(s.programPath,h.recordsPath):t(s.webpackCachePath,"records.json")};h.overrideResolve&&commonConfig.resolve.plugins.push(new l(Object.assign({original:h.alias["@"],override:n&&p(n)},h.overrideResolve)));
1
+ import{extname as e,join as t,resolve as o}from"node:path";import s,{config_files as a,CUSTOMCONFIG as n,TMP_DIR as i}from"./commom/paths.mjs";import{OverrideResolverPlugin as r}from"./plugin/override-resolve.mjs";import{isObject as l,node_modules as m,resolveProgram as p}from"./utils/index.mjs";import{exampleModuleName as c}from"./vm/example.mjs";import u from"./vm/info.mjs";import{CONFIG as d}from"./config.mjs";import h from"./plugins.config.mjs";import{isCI as f,isDev as g,isLibrary as b,NODE_ENV as y,packageJson as j}from"./process-env.mjs";export const outputConfig={path:p(b?"docs":"dist"),filename:"js/[name].[contenthash].bundle.js",chunkFilename:"js/[contenthash].chunk.js",assetModuleFilename:t=>{let o=e(t.filename||"").substring(1);return`assets/${o}/[hash][ext]`},library:{name:`${u.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${j.name}`,pathinfo:g,clean:!g,publicPath:d.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"]};let v={main:[m("@app/entry")]};if(d.polyfill&&v.main.unshift(t(s.corePath,"./polyfills/replace-children.mjs")),d.entry&&("string"==typeof d.entry?v={main:[d.entry]}:Object.keys(d.entry)&&(v=Object.assign(v,d.entry))),"string"==typeof v.main&&(v.main=[v.main]),d.output){if("string"==typeof d.output)outputConfig.path=d.output;else if(Object.keys(d.output)){let e=d.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof d.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let C={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[n,y].filter(Boolean).join("-")}`,version:`${j.version}`,buildDependencies:{config:a},maxMemoryGenerations:1};!1===d.cache?C=!1:l(d.cache)&&(C=Object.assign(C,d.cache)),f&&(void 0===d.cache||d.cache&&!d.cache.cacheDirectory)&&(C.cacheDirectory=o(i,j.name));export const commonConfig={name:"client",target:"web",devtool:d.devtool,entry:v,mode:g?"development":"production",stats:"errors-only",cache:C,snapshot:{immutablePaths:[s.pnpmNodeModules,s.denoNodeModules,/node_modules\/(?!(@app)\/)/],managedPaths:[s.pnpmNodeModules,s.denoNodeModules,/node_modules\/(?!(@app)\/)/],resolveBuildDependencies:{timestamp:!0,hash:!0},resolve:{timestamp:!0,hash:!0},module:{timestamp:!0,hash:!0},buildDependencies:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:d.externalsPresets,plugins:h,node:{global:!1,__filename:!1,__dirname:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:d.lazyCompilation&&g&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(m(c))||t.startsWith(m("@app/comment"))||t.startsWith(s.pagesPath)||t.startsWith(s.componentsPath)))}},buildHttp:l(d.buildHttp)?{allowedUris:[],lockfileLocation:o(s.httpCachePath,"http.lock"),cacheLocation:o(s.httpCachePath,"data"),upgrade:!0,...d.buildHttp}:d.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:d.alias,modules:[s.nodeModules,s.pnpmNodeModules,s.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:d.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:d.externals,output:outputConfig,recordsPath:d.recordsPath?t(s.programPath,d.recordsPath):t(s.webpackCachePath,"records.json")};d.overrideResolve&&commonConfig.resolve.plugins.push(new r(Object.assign({original:d.alias["@"],override:n&&p(n)},d.overrideResolve)));
package/lib/config.mjs CHANGED
@@ -1 +1 @@
1
- import{join as e,relative as o}from"node:path";import t from"node:process";import{fileExists as r}from"@moneko/utils";import{merge as n}from"webpack-merge";import s from"./commom/paths.mjs";import i from"./commom/require.mjs";import a from"./commom/setup-env.mjs";import l from"./options/jsx-dom-expressions.mjs";import m from"./options/split-chunk.mjs";import{isFunction as p,node_modules as c,resolveProgram as u}from"./utils/index.mjs";import{APPTYPE as d,FRAMEWORK as f,frameworkVersion as h,isCI as g,isDev as v,isLibrary as x,isMobile as P,isReact as j,jsxImportSource as C,mainDirectory as b,NODE_ENV as k,PACKAGENAME as w}from"./process-env.mjs";let O=["@app","@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 function getConfig(e){return delete i.cache[e],new Promise(o=>{if(r(e)){let r=i(e).default;return o(p(r)?r(t):r)}return o({})})}let y=await Promise.all([a(k,d,f,[]),getConfig(s.configPath),getConfig(s.customConfigPath)]),S=y[0],M=y[1],I=y[2],z={strict:!1,devtool:v?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:"",namespace:w,moduleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]",fallbackModuleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]"},env:S,basename:"/",publicPath:"/",rem:{designSize:P?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":u(b)},j&&h<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:w.toLocaleUpperCase(),favicon:o(s.programPath,`${s.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:m,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:O,js:O,media:O,font:O,wasm:[]},mdx:{jsx:!1,development:v,jsxImportSource:C,providerImportSource:`@moneko/${f}/mdx`},jsxDomExpressions:l,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:g},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==f,bundleId:"com.moneko.bid",bundles:[],stylelint:{},eslint:{lintDirtyModulesOnly:!1},minChunkSize:1e3,compression:v,manifest:{filename:"manifest.json"}};x&&(z.alias=Object.assign(z.alias,{"@pkg":s.componentsPath,[w]:s.componentsPath}));let D=z;(!1===(D=n(D,M,I)).devtool||!1===D.sourceMap)&&(D.sourceMap=!1,D.devtool=!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.htmlPluginOption.tags.push({href:e("auto"===D.publicPath?"":D.publicPath,D.manifest.filename).replaceAll(/\\/g,"/"),tag:"link",rel:"manifest"})),"true"===t.env.CODESPACES&&(D.devServer.https=!1),!1===D.devServer.https&&"darwin"===t.platform&&(D.devServer.open=!1);export const CONFIG=D;export const PUBLICPATH=CONFIG.publicPath;
1
+ import{join as e,relative as o}from"node:path";import t from"node:process";import{fileExists as r}from"@moneko/utils";import{merge as n}from"webpack-merge";import s from"./commom/paths.mjs";import a from"./commom/require.mjs";import i from"./commom/setup-env.mjs";import l from"./options/jsx-dom-expressions.mjs";import m from"./options/split-chunk.mjs";import{isFunction as p,node_modules as c,resolveProgram as u}from"./utils/index.mjs";import{APPTYPE as d,FRAMEWORK as f,frameworkVersion as h,isCI as g,isDev as v,isLibrary as x,isMobile as P,isReact as j,jsxImportSource as C,mainDirectory as b,NODE_ENV as k,PACKAGENAME as w}from"./process-env.mjs";let O=["@app","@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 function getConfig(e){return delete a.cache[e],new Promise(o=>{if(r(e)){let r=a(e).default;return o(p(r)?r(t):r)}return o({})})}let y=await Promise.all([i(k,d,f,[]),getConfig(s.configPath),getConfig(s.customConfigPath)]),S=y[0],M=y[1],I=y[2],z={strict:!1,devtool:v?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:"",namespace:w,moduleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]",fallbackModuleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]"},env:S,basename:"/",publicPath:"/",rem:{designSize:P?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":u(b)},j&&h<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:w.toLocaleUpperCase(),favicon:o(s.programPath,`${s.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:m,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:O,js:O,media:O,font:O,wasm:[]},mdx:{jsx:!1,development:v,jsxImportSource:C,providerImportSource:`@moneko/${f}/mdx`},jsxDomExpressions:l,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:g},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==f,bundleId:"com.moneko.bid",bundles:[],stylelint:{},eslint:{lintDirtyModulesOnly:!1},minChunkSize:1e3,compression:v,manifest:{filename:"manifest.json"}};x&&(z.alias=Object.assign(z.alias,{"@pkg":s.componentsPath,[w]:s.componentsPath}));let F=z;(!1===(F=n(F,M,I)).devtool||!1===F.sourceMap)&&(F.sourceMap=!1,F.devtool=!1),F.htmlPluginOption&&(F.htmlPluginOption.tags||(F.htmlPluginOption.tags=[]),F.fixBrowserRouter&&F.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))"}),F.manifest&&F.htmlPluginOption.tags.push({href:e("auto"===F.publicPath?"":F.publicPath,F.manifest.filename).replaceAll(/\\/g,"/"),tag:"link",rel:"manifest"})),"true"===t.env.CODESPACES&&(F.devServer.https=!1),!1===F.devServer.https&&"darwin"===t.platform&&(F.devServer.open=!1);export const CONFIG=F;export const PUBLICPATH="auto"===CONFIG.publicPath?"":CONFIG.publicPath;
package/lib/dev.d.mts CHANGED
@@ -19,7 +19,7 @@ import { generateManifest } from './plugin/manifest.mjs';
19
19
  import { StylelintPlugin } from './plugin/stylelint.mjs';
20
20
  import { empty } from './utils/index.mjs';
21
21
  import { commonConfig } from './common.mjs';
22
- import { CONFIG, getConfig } from './config.mjs';
22
+ import { CONFIG, getConfig, PUBLICPATH } from './config.mjs';
23
23
  import { outputFileSystem } from './file-system.mjs';
24
24
  import type { ConfigType } from './index.mjs';
25
25
  import moduleConfig from './module.config.mjs';
package/lib/dev.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{join as r,relative as i}from"node:path";import n from"node:process";import{URL as s}from"node:url";import{ink as a,print as m,println as l,progressBar as p}from"@moneko/utils";import c from"webpack";import f from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as u}from"./commom/diff-object.mjs";import d,{config_files as g}from"./commom/paths.mjs";import w from"./commom/sigint-exit.mjs";import{devLog as y,PORT as j}from"./dev/config.mjs";import $ from"./dev/generate-progress-html.mjs";import b from"./dev/server.mjs";import v from"./options/reslove.mjs";import{ESLintPlugin as C}from"./plugin/eslint.mjs";import{generateManifest as x}from"./plugin/manifest.mjs";import{StylelintPlugin as P}from"./plugin/stylelint.mjs";import{empty as _}from"./utils/index.mjs";import{commonConfig as S}from"./common.mjs";import{CONFIG as k,getConfig as H}from"./config.mjs";import{outputFileSystem as O}from"./file-system.mjs";import T from"./module.config.mjs";import{isLibrary as B,isReact as I,refresh as q}from"./process-env.mjs";let G=!1,L="/____progress____",N={percentage:0,info:""},R="/__hmr__",U=new URLSearchParams({name:"client",path:R.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!q,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),E=h(S,{watchOptions:{stdin:!0,aggregateTimeout:300,ignored:/node_modules\/(?!(@app)\/)/},entry:{main:[`${v.hotMiddlewareClient}?${U}`]},module:T(!1),plugins:[new c.HotModuleReplacementPlugin,new c.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app)\/)/,/\.d\.ts$/]}),new c.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";G||(N.info=r,N.percentage=e,G=1===e);let i=k.bar;if(i){let t=i.name||"Build";i.quiet?n.stdout.write(`${r}
2
- `):(p(e||0,1,{msg:r,name:t,barColor:i.barColor,nameColor:i.nameColor,barBgColor:i.barBgColor,msgColor:i.msgColor}),1===e&&n.stdout.write("\r\x1b[2K"))}}})]});if(I){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;E.plugins.push(new e({overlay:!1}))}function F(e){let t=e.join(","),o=[i(d.programPath,`${k.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(i(d.programPath,`${k.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}k.eslint&&E.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:F(["js","jsx","ts","tsx","json","html","vue"]),...k.eslint})),k.stylelint&&E.plugins.push(new P({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:F(["css","scss","sass","less","ts","tsx","js","jsx"]),...k.stylelint}));let J=c(E);J.outputFileSystem=O;let M=J.watch(J.options.watchOptions,y);J.hooks.done.tap("client-log",e=>{y(null,e)});let A=`${k.publicPath}/${R}`.replace(/\/+/g,"/"),K=f(J,{log:!1,path:A,heartbeat:2e3}),W=!!k.manifest&&r("auto"===k.publicPath?"/":k.publicPath,k.manifest.filename).replaceAll(/\\/g,"/"),z=await b({port:j,root_dir:J.options.output.path,fileSystem:J.outputFileSystem,headers:k.devServer.headers,https:k.devServer.https,host:k.devServer.host,open:k.devServer.open,basename:k.basename,onRequest(e,t){let o=new s(`${k.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if("GET"===e.method){if(W&&o.pathname===W)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(x({}))),!0;if(o.pathname===L)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(N)),!0;if(!G)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end($(L,N)),!0;if(o.pathname===A&&"text/event-stream"===e.headers.accept)return K(e,t,_),!0}return!1}});function D(){n.exit(0)}z.on("close",()=>{M.close(_),K.close()});let Q=await Promise.all(g.map(H)),V=h(Q[0]||{},Q[1]||{});g.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(g.map(H)),i=h(o||{},r||{}),s=u(V,i);1===Object.keys(s).length&&"proxy"in s?(m(a(`代理更新中...`,"yellow"),!0),m(a(`代理更新完成...`,"green"),!0),k.proxy=i.proxy,V.proxy=i.proxy,V=i):(V=i,l(a(`检测到工程配置${a(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e(X?`netstat -ano | findstr :${j}`:`lsof -i :${j} -t`,(e,t)=>{if(e){l(a(`查找端口 ${j} 时发生错误: ${e.message}`,"red")),l(a("请尝试手动重启程序","yellow"));return}let o=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),r=X?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){l(a(`未找到占用端口 ${j} 的进程, 请尝试手动重启程序`,"yellow"));return}try{n.kill(Number(r),"SIGHUP")}catch(e){l(a(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let X="win32"===n.platform;n.on("SIGHUP",function(){z.close(_),function(){let e=t(n.argv[0],n.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",D)}()}),n.on("exit",function(){z.close(_)}),w(D);
1
+ import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{join as r,relative as n}from"node:path";import i from"node:process";import{URL as s}from"node:url";import{ink as a,print as m,println as l,progressBar as p}from"@moneko/utils";import c from"webpack";import f from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as u}from"./commom/diff-object.mjs";import d,{config_files as g}from"./commom/paths.mjs";import w from"./commom/sigint-exit.mjs";import{devLog as y,PORT as j}from"./dev/config.mjs";import $ from"./dev/generate-progress-html.mjs";import v from"./dev/server.mjs";import b from"./options/reslove.mjs";import{ESLintPlugin as C}from"./plugin/eslint.mjs";import{generateManifest as x}from"./plugin/manifest.mjs";import{StylelintPlugin as _}from"./plugin/stylelint.mjs";import{empty as P}from"./utils/index.mjs";import{commonConfig as S}from"./common.mjs";import{CONFIG as k,getConfig as H,PUBLICPATH as O}from"./config.mjs";import{outputFileSystem as T}from"./file-system.mjs";import B from"./module.config.mjs";import{isLibrary as I,isReact as q,refresh as G}from"./process-env.mjs";let L=!1,N="/____progress____",R={percentage:0,info:""},U="/__hmr__",E=new URLSearchParams({name:"client",path:U.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!G,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),F=h(S,{watchOptions:{stdin:!0,aggregateTimeout:300,ignored:/node_modules\/(?!(@app)\/)/},entry:{main:[`${b.hotMiddlewareClient}?${E}`]},module:B(!1),plugins:[new c.HotModuleReplacementPlugin,new c.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app)\/)/,/\.d\.ts$/]}),new c.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";L||(R.info=r,R.percentage=e,L=1===e);let n=k.bar;if(n){let t=n.name||"Build";n.quiet?i.stdout.write(`${r}
2
+ `):(p(e||0,1,{msg:r,name:t,barColor:n.barColor,nameColor:n.nameColor,barBgColor:n.barBgColor,msgColor:n.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})]});if(q){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;F.plugins.push(new e({overlay:!1}))}function J(e){let t=e.join(","),o=[n(d.programPath,`${k.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return I&&o.push(n(d.programPath,`${k.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}k.eslint&&F.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:J(["js","jsx","ts","tsx","json","html","vue"]),...k.eslint})),k.stylelint&&F.plugins.push(new _({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:J(["css","scss","sass","less","ts","tsx","js","jsx"]),...k.stylelint}));let M=c(F);M.outputFileSystem=T;let A=M.watch(M.options.watchOptions,y);M.hooks.done.tap("client-log",e=>{y(null,e)});let K=`${O}/${U}`.replace(/\/+/g,"/"),W=f(M,{log:!1,path:K,heartbeat:2e3}),z=!!k.manifest&&r(O,k.manifest.filename).replaceAll(/\\/g,"/"),D=await v({port:j,root_dir:M.options.output.path,fileSystem:M.outputFileSystem,headers:k.devServer.headers,https:k.devServer.https,host:k.devServer.host,open:k.devServer.open,basename:k.basename,onRequest(e,t){let o=new s(`${k.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if("GET"===e.method){if(z&&o.pathname===z)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(x({}))),!0;if(o.pathname===N)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(R)),!0;if(!L)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end($(N,R)),!0;if(o.pathname===K&&"text/event-stream"===e.headers.accept)return W(e,t,P),!0}return!1}});function Q(){i.exit(0)}D.on("close",()=>{A.close(P),W.close()});let V=await Promise.all(g.map(H)),X=h(V[0]||{},V[1]||{});g.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(g.map(H)),n=h(o||{},r||{}),s=u(X,n);1===Object.keys(s).length&&"proxy"in s?(m(a(`代理更新中...`,"yellow"),!0),m(a(`代理更新完成...`,"green"),!0),k.proxy=n.proxy,X.proxy=n.proxy,X=n):(X=n,l(a(`检测到工程配置${a(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e(Y?`netstat -ano | findstr :${j}`:`lsof -i :${j} -t`,(e,t)=>{if(e){l(a(`查找端口 ${j} 时发生错误: ${e.message}`,"red")),l(a("请尝试手动重启程序","yellow"));return}let o=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),r=Y?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){l(a(`未找到占用端口 ${j} 的进程, 请尝试手动重启程序`,"yellow"));return}try{i.kill(Number(r),"SIGHUP")}catch(e){l(a(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let Y="win32"===i.platform;i.on("SIGHUP",function(){D.close(P),function(){let e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",Q)}()}),i.on("exit",function(){D.close(P)}),w(Q);
@@ -1,6 +1,6 @@
1
1
  import hasPkg from '../commom/has-pkg.mjs';
2
2
  import require from '../commom/require.mjs';
3
- import { CONFIG } from '../config.mjs';
3
+ import { CONFIG, PUBLICPATH } from '../config.mjs';
4
4
  import type { HtmlPluginOption } from '../plugin/html-plugin.mjs';
5
5
  declare const prefixCls: string;
6
6
  declare const favicon: string;
@@ -1 +1 @@
1
- import o from"../commom/has-pkg.mjs";import i from"../commom/require.mjs";import{CONFIG as e}from"../config.mjs";let t=e.prefixCls||"n",r=e.htmlPluginOption?.favicon||"favicon.ico",s={"@prefix-cls":t,"@iconfont-css-prefix":`${t}-icon`,"@favicon":JSON.stringify(`${e.publicPath||""}${r}`)},m={},c=o("antd/dist/default-theme.js");c&&Object.assign(m,{...i(c)},{"@ant-prefix":t,hack:`true;@import (optional, reference) "${i.resolve("antd/lib/style/color/colorPalette.less")}";`}),Object.assign(s,m,e.modifyVars);export default s;
1
+ import o from"../commom/has-pkg.mjs";import i from"../commom/require.mjs";import{CONFIG as e,PUBLICPATH as t}from"../config.mjs";let r=e.prefixCls||"n",s=e.htmlPluginOption?.favicon||"favicon.ico",m={"@prefix-cls":r,"@iconfont-css-prefix":`${r}-icon`,"@favicon":JSON.stringify(`${t}${s}`)},n={},c=o("antd/dist/default-theme.js");c&&Object.assign(n,{...i(c)},{"@ant-prefix":r,hack:`true;@import (optional, reference) "${i.resolve("antd/lib/style/color/colorPalette.less")}";`}),Object.assign(m,n,e.modifyVars);export default m;
@@ -1 +1 @@
1
- import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import o from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}apply(n){n.hooks.compilation.tap(this.name,a=>{a.hooks.processAssets.tap({name:this.name,stage:o.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let h;if(this.options.favicon){let h=i(n.context,this.options.favicon);if(t(h)){let t=s(this.options.favicon),i=e(h);a.emitAsset(t,new o.sources.RawSource(i),{javascriptModule:!1}),this.faviconPath=(a.outputOptions.publicPath||"")+t}else a.warnings.push(new o.WebpackError(`Favicon file ${h} does not exist`))}if(h=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(n.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(a);h=this.injectAssets(h,t,this.options.inject)}let r="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";a.emitAsset(r,new o.sources.RawSource(h),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags();return`<!DOCTYPE html><html><head><meta charset="utf-8">${t}<title>${this.options.title}</title><link rel="icon" type="image/x-icon" href="${this.faviconPath}"></head><body><div id="root"></div></body></html>`}generateMetaTags(){if(null!==this.cachedMetaTags)return this.cachedMetaTags;if(!this.options.meta)return this.cachedMetaTags="","";let t=Object.entries(this.options.meta).map(([t,e])=>{if("string"==typeof e)return`<meta name="${t}" content="${e}">`;if(void 0===e)return"";let s=Object.entries(e).map(([t,e])=>`${t}="${e}"`).join(" ");return`<meta ${s}>`}).join("");return this.cachedMetaTags=t,t}generateCustomTags(){if(null!==this.cachedCustomTags)return this.cachedCustomTags;let t={head:"",body:""};if(!this.options.tags)return this.cachedCustomTags=t,t;let e=[],s=[];return this.options.tags.forEach(t=>{let{tag:i="script",textContent:o="",inject:n=this.options.inject,...a}=t,h=Object.entries(a).filter(([,t])=>null!=t).map(([t,e])=>!0===e?t:`${t}="${e}"`).join(" "),r=`<${i} ${h}>${o}</${i}>`;"head"===n?e.push(r):s.push(r)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]},s=t.outputOptions.publicPath||"";for(let i of t.entrypoints.values())for(let t of i.chunks)for(let i of t.files)i.endsWith(".js")?e.js.push(s+i):i.endsWith(".css")&&e.css.push(s+i);return e}injectAssets(t,e,s){let i=e.css.length?e.css.map(t=>`<link href="${t}" rel="stylesheet" />`).join(""):"",o=e.js.length?e.js.map(t=>`<script defer ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",n=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${o}${n.head}</head>${h[0]}${n.body}</body>${h[1]||""}`:`${t}${n.head}</head>${h[0]}${i}${o}${n.body}</body>${h[1]||""}`}return t}}
1
+ import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import o from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}apply(n){n.hooks.compilation.tap(this.name,a=>{a.hooks.processAssets.tap({name:this.name,stage:o.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let h;if(this.options.favicon){let h=i(n.context,this.options.favicon);if(t(h)){let t=s(this.options.favicon),i=e(h);a.emitAsset(t,new o.sources.RawSource(i),{javascriptModule:!1});let n=a.outputOptions.publicPath||"";this.faviconPath=("auto"===n?"":n)+t}else a.warnings.push(new o.WebpackError(`Favicon file ${h} does not exist`))}if(h=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(n.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(a);h=this.injectAssets(h,t,this.options.inject)}let l="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";a.emitAsset(l,new o.sources.RawSource(h),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags();return`<!DOCTYPE html><html><head><meta charset="utf-8">${t}<title>${this.options.title}</title><link rel="icon" type="image/x-icon" href="${this.faviconPath}"></head><body><div id="root"></div></body></html>`}generateMetaTags(){if(null!==this.cachedMetaTags)return this.cachedMetaTags;if(!this.options.meta)return this.cachedMetaTags="","";let t=Object.entries(this.options.meta).map(([t,e])=>{if("string"==typeof e)return`<meta name="${t}" content="${e}">`;if(void 0===e)return"";let s=Object.entries(e).map(([t,e])=>`${t}="${e}"`).join(" ");return`<meta ${s}>`}).join("");return this.cachedMetaTags=t,t}generateCustomTags(){if(null!==this.cachedCustomTags)return this.cachedCustomTags;let t={head:"",body:""};if(!this.options.tags)return this.cachedCustomTags=t,t;let e=[],s=[];return this.options.tags.forEach(t=>{let{tag:i="script",textContent:o="",inject:n=this.options.inject,...a}=t,h=Object.entries(a).filter(([,t])=>null!=t).map(([t,e])=>!0===e?t:`${t}="${e}"`).join(" "),l=`<${i} ${h}>${o}</${i}>`;"head"===n?e.push(l):s.push(l)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]},s=t.outputOptions.publicPath||"",i="auto"===s?"":s;for(let s of t.entrypoints.values())for(let t of s.chunks)for(let s of t.files)s.endsWith(".js")?e.js.push(i+s):s.endsWith(".css")&&e.css.push(i+s);return e}injectAssets(t,e,s){let i=e.css.length?e.css.map(t=>`<link href="${t}" rel="stylesheet" />`).join(""):"",o=e.js.length?e.js.map(t=>`<script defer ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",n=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${o}${n.head}</head>${h[0]}${n.body}</body>${h[1]||""}`:`${t}${n.head}</head>${h[0]}${i}${o}${n.body}</body>${h[1]||""}`}return t}}
@@ -5,6 +5,7 @@ declare const ReactDomPath: string;
5
5
  declare const isHashRouter: boolean;
6
6
  declare const Router: string;
7
7
  declare const StrictMode: string;
8
+ declare const remoteReactRefresh: string;
8
9
  declare const Root: string;
9
10
  declare const renderApp: string;
10
11
  export default renderApp;
@@ -1,4 +1,4 @@
1
- import{CONFIG as e}from"../config.mjs";import{APPTYPE as r,frameworkVersion as t,isDev as o}from"../process-env.mjs";let n=t<18,a="hash"===e.routerMode,c=a?"HashRouter":"BrowserRouter",p=e.strict?"StrictMode":"",s=`<${p}><${c} basename={${a?"/":"basename"}} window={window}><ErrorBoundary><App /></ErrorBoundary></${c}></${p}>`,m=`import React, { StrictMode, type ReactElement } from 'react';
1
+ import{CONFIG as e}from"../config.mjs";import{APPTYPE as r,frameworkVersion as t,isDev as o}from"../process-env.mjs";let n=t<18,a="hash"===e.routerMode,c=a?"HashRouter":"BrowserRouter",s=e.strict?"StrictMode":"",m=o&&e.refresh&&e.env.injectRemoteReactRefresh?"import '@moneko/react/lib/inject-react-refresh.js';":"",p=`<${s}><${c} basename={${a?"/":"basename"}} window={window}><ErrorBoundary><App /></ErrorBoundary></${c}></${s}>`,i=`${m}import React, { StrictMode, type ReactElement } from 'react';
2
2
  import { ErrorBoundary } from '@moneko/react';
3
3
  import routes from '@app/routes';
4
4
  import ReactDOM from '${n?"react-dom":"react-dom/client"}';
@@ -22,7 +22,7 @@ function renderApp(props: RenderAppProps = {}) {
22
22
  const { container, basename = "${e.basename}", language, ...args } = props;
23
23
  const _container = container?.querySelector('#root') || document.getElementById('root');
24
24
  ${"micro"===r?"window.mainApp = { ...args, container: _container as HTMLElement };":""}
25
- ${n?`ReactDOM.${o?"render":"hydrate"}(${s}, _container);return () => ReactDOM.unmountComponentAtNode(_container as Element);`:`const instance = ReactDOM.createRoot(_container as HTMLElement);instance.render(${s});return instance.unmount;`}
25
+ ${n?`ReactDOM.${o?"render":"hydrate"}(${p}, _container);return () => ReactDOM.unmountComponentAtNode(_container as Element);`:`const instance = ReactDOM.createRoot(_container as HTMLElement);instance.render(${p});return instance.unmount;`}
26
26
  }
27
27
 
28
- export default renderApp;`;export default m;
28
+ export default renderApp;`;export default i;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.47.8",
3
+ "version": "3.47.10",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",