@moneko/core 3.27.6 → 3.28.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.
@@ -1,10 +1,10 @@
1
1
  import { join } from 'node:path';
2
2
  import { argv } from 'node:process';
3
+ import { convert } from '@moneko/convert';
3
4
  import { ink, println, removeDir } from '@moneko/utils';
4
5
  import setupEnv from '../commom/setup-env.mjs';
5
6
  import { cwd, swcCachePath } from './utils/config.mjs';
6
7
  import { getSwcOption } from './utils/setup-swcrc.mjs';
7
- import convert from './convert.mjs';
8
8
  import { lesscCommonjs } from './lessc.mjs';
9
9
  import tsc from './tsc.mjs';
10
10
  declare async function build();
package/lib/bin/build.mjs CHANGED
@@ -1 +1 @@
1
- import{join as o}from"node:path";import{argv as t}from"node:process";import{ink as e,println as s,removeDir as i}from"@moneko/utils";import r from"../commom/setup-env.mjs";import{cwd as m,swcCachePath as n}from"./utils/config.mjs";import{getSwcOption as l}from"./utils/setup-swcrc.mjs";import p from"./convert.mjs";import{lesscCommonjs as c}from"./lessc.mjs";import d from"./tsc.mjs";async function u(){let u=t[3],a=t[4],f=t.slice(5);u||(s(e(`type: 无效值 ${e(u,"245")}`,"red")),process.exit(1));let j=!f.includes("no-docs"),y=!f.includes("no-lib"),b=!f.includes("no-es"),g=!f.includes("no-dts"),x=f.filter(o=>!["no-docs","no-es","no-lib"].includes(o));if(await r("production",u,a,x),"library"===u){let{CONFIG:t}=await import("../config.mjs"),e="swc"===t.dts,s=[y&&{type:"commonjs",dir:"lib",msg:"Convert to CommonJS"},b&&{type:"es6",dir:"es",msg:"Convert to ES Module"}].filter(Boolean);for(let t=0,r=s.length;t<r;t++){i(o(m,`./${s[t].dir}`));let r=l(a);"es6"===s[t].type&&(r.jsc.target="es2015"),r.jsc.experimental.emitIsolatedDts=g&&e,r.jsc.experimental.cacheRoot=n,r.module.type=s[t].type,p({outDir:s[t].dir,inputDir:"components",ignore:[/^.*\/__*__\//,/\.test\.(js|ts)x?$/,/\.DS_Store/,/\.mdx?$/,/^.*\/examples\//],options:r}),"commonjs"===s[t].type&&c(),g&&!e&&d(s[t].dir)}}("library"!==u||j&&"library"===u)&&import("../build.mjs")}export default u;
1
+ import{join as o}from"node:path";import{argv as e}from"node:process";import{convert as t}from"@moneko/convert";import{ink as s,println as i,removeDir as r}from"@moneko/utils";import m from"../commom/setup-env.mjs";import{cwd as n,swcCachePath as l}from"./utils/config.mjs";import{getSwcOption as p}from"./utils/setup-swcrc.mjs";import{lesscCommonjs as c}from"./lessc.mjs";import d from"./tsc.mjs";async function u(){let u=e[3],a=e[4],f=e.slice(5);u||(i(s(`type: 无效值 ${s(u,"245")}`,"red")),process.exit(1));let j=!f.includes("no-docs"),y=!f.includes("no-lib"),b=!f.includes("no-es"),g=!f.includes("no-dts"),x=f.filter(o=>!["no-docs","no-es","no-lib"].includes(o));if(await m("production",u,a,x),"library"===u){let{CONFIG:e}=await import("../config.mjs"),s="swc"===e.dts,i=[y&&{type:"commonjs",dir:"lib",msg:"Convert to CommonJS"},b&&{type:"es6",dir:"es",msg:"Convert to ES Module"}].filter(Boolean);for(let e=0,m=i.length;e<m;e++){r(o(n,`./${i[e].dir}`));let m=p(a);"es6"===i[e].type&&(m.jsc.target="es2015"),m.jsc.experimental.emitIsolatedDts=g&&s,m.jsc.experimental.cacheRoot=l,m.module.type=i[e].type,t({outDir:i[e].dir,inputDir:"components",ignore:[/^.*\/__*__\//,/\.test\.(js|ts)x?$/,/\.DS_Store/,/\.mdx?$/,/^.*\/examples\//],options:m}),"commonjs"===i[e].type&&c(),g&&!s&&d(i[e].dir)}}("library"!==u||j&&"library"===u)&&import("../build.mjs")}export default u;
@@ -1 +0,0 @@
1
- import e from"node:path";import{copyFile as s,ink as o,println as t,scanFolderSync as a,updateFile as l}from"@moneko/utils";import{transformFile as n}from"@swc/core";function i(s,o,t){let a=o.split(e.sep),l=""===a[0]?a[1]:a[0],n=o.replace(l,""),i=e.join(s,n);return t?i.replace(e.extname(i),t):i}let c={".ts":".js",".tsx":".js",".mts":".mjs",".cts":".cjs",".js":".js",".jsx":".js",".mjs":".mjs",".cjs":".cjs"},m={format:{comments:!1},ecma:2015,compress:{drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1,top_retain:[],keep_infinity:!0},mangle:!0};async function r({ignore:r=[],quiet:p=!0,copy:d=!0,outDir:f,outputExtension:j,inputDir:u,options:_,extensions:h=[".ts",".js",".tsx",".jsx",".mts",".mjs",".cts",".cjs"]}){let $=process.hrtime(),g={duration:0,compiled:[],copied:[],failed:[]},x=a(u,["^.*"]).map(s=>e.normalize(s)),y=[],w=[];x.forEach(s=>{!(/\.DS_Store/.test(s)||r.some(e=>e.test(s)))&&(h.includes(e.extname(s))?y.push(s):d&&w.push(s))});let S=y.map(async s=>{try{let o=j||c[e.extname(s)],{code:t,map:a,output:r}=await n(s,{..._,jsc:{externalHelpers:!1,..._.jsc,minify:{...m,..._.jsc?.minify}}}),p=i(f,s,o);if(await l(p,t),a&&await l(`${p}.map`,a),g.compiled.push(`${s} -> ${p}`),r){let o=JSON.parse(r);if(o.__swc_isolated_declarations__){let t=e.extname(s),a=i(f,s.replace(t,`.d${t}`));await l(a,o.__swc_isolated_declarations__)}}}catch(e){g.failed.push(`Error converting ${s}: ${e}`)}}).concat(w.map(async e=>{let o=i(f,e);await s(e,o)?g.copied.push(`${e} -> ${o}`):g.failed.push(`Error copying ${e} -> ${o}`)}));await Promise.all(S);let E=process.hrtime($);if(g.duration=1e3*E[0]+E[1]/1e6,p){let e={es6:"ES6",commonjs:"CommonJS",esm:"ESM",amd:"AMD",umd:"UMD",systemjs:"SystemJS",nodenext:"NodeNext"}[_.module.type];t([`${o("✨ 编译成功!🎉","82",{bold:!0})} ${o(`(${e})`,"213")}`,o(`⏱️ 总耗时:${g.duration.toFixed(3)} ms`,"117"),g.compiled.length&&o(`📄 编译文件:${g.compiled.length} 个`,"111"),g.copied.length&&o(`📋 复制文件:${g.copied.length} 个`,"226"),g.failed.length&&o(`❌ 编译失败:${g.failed.length} 个`,"203")].filter(Boolean).join("\n- "))}return g}export default r;
package/lib/common.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { extname, join, resolve } from 'node:path';
2
2
  import type { Configuration, FileCacheOptions } from 'webpack';
3
3
  import paths, { config_files, CUSTOMCONFIG } from './commom/paths.mjs';
4
+ import require from './commom/require.mjs';
4
5
  import OverrideResolverPlugin, { type OverrideResolverOption } from './plugin/override-resolve.mjs';
5
6
  import { isObject, node_modules, resolveProgram } from './utils/index.mjs';
6
7
  import { exampleModuleName } from './vm/example.mjs';
@@ -9,6 +10,8 @@ import { CONFIG, PUBLICPATH } from './config.mjs';
9
10
  import plugins from './plugins.config.mjs';
10
11
  import { isDev, isLibrary, NODE_ENV, PACKAGENAME, PACKAGEVERSION } from './process-env.mjs';
11
12
  export declare const outputConfig: Configuration['output'];
12
- declare let entryMap: Configuration['entry'];
13
+ declare let entryMap: {
14
+ readonly main: string[];
15
+ };
13
16
  declare let cacheConfig: FileCacheOptions | false;
14
17
  export declare const commonConfig: Configuration;
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 n,CUSTOMCONFIG as a}from"./commom/paths.mjs";import i from"./plugin/override-resolve.mjs";import{isObject as l,node_modules as r,resolveProgram as m}from"./utils/index.mjs";import{exampleModuleName as p}from"./vm/example.mjs";import c from"./vm/info.mjs";import{CONFIG as u,PUBLICPATH as d}from"./config.mjs";import h from"./plugins.config.mjs";import{isDev as f,isLibrary as g,NODE_ENV as b,PACKAGENAME as y,PACKAGEVERSION as j}from"./process-env.mjs";export const outputConfig={path:m(g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${f?"name":"contenthash"}].js`,assetModuleFilename:t=>{let o=e(t.filename||"").substring(1);return`assets/${o}/[name][hash][ext]`},library:{name:`${c.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${y}`,pathinfo:f,clean:!0,publicPath:d,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"anonymous",enabledWasmLoadingTypes:["fetch"],hotUpdateChunkFilename:"[id].[fullhash].hot.js",hotUpdateMainFilename:"[runtime].[fullhash].hot.json"};let v={main:[u.polyfill&&t(s.corePath,"./polyfills/replace-children.mjs"),r("@app/entry")].filter(Boolean)};u.entry&&("string"==typeof u.entry?v={main:[u.entry]}:Object.keys(u.entry)&&(v=Object.assign(v,u.entry))),"string"==typeof v.main&&(v.main=[v.main]),u.output&&("string"==typeof u.output?outputConfig.path=u.output:Object.keys(u.output)&&Object.assign(outputConfig,u.output));let C={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[a,b].filter(Boolean).join("-")}`,version:`${j}`,buildDependencies:{config:n}};!1===u.cache?C=!1:l(u.cache)&&(C=Object.assign(C,u.cache));export const commonConfig={name:"client",target:"web",devtool:u.devtool,entry:v,mode:f?"development":"production",stats:"errors-only",cache:C,snapshot:{immutablePaths:[/node_modules\/(?!(@app|@moneko)\/)/],managedPaths:[/^@app\/.+/,/^@moneko\/.+/],buildDependencies:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:u.externalsPresets,plugins:h,node:{global:!1,__filename:!1,__dirname:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:u.lazyCompilation&&f&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(r(p))||t.startsWith(r("@app/comment"))||t.startsWith(s.pagesPath)||t.startsWith(s.componentsPath)))}},buildHttp:l(u.buildHttp)?{allowedUris:[],lockfileLocation:o(s.httpCachePath,"http.lock"),cacheLocation:o(s.httpCachePath,"data"),upgrade:!0,...u.buildHttp}:u.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:u.alias,modules:[s.nodeModules,s.pnpmNodeModules,s.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:u.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:u.externals,output:outputConfig};u.overrideResolve&&commonConfig.resolve.plugins.push(new i(Object.assign({original:u.alias["@"],override:a&&m(a)},u.overrideResolve)));
1
+ import{extname as e,join as t,resolve as o}from"node:path";import s,{config_files as n,CUSTOMCONFIG as a}from"./commom/paths.mjs";import i from"./commom/require.mjs";import r from"./plugin/override-resolve.mjs";import{isObject as m,node_modules as l,resolveProgram as p}from"./utils/index.mjs";import{exampleModuleName as c}from"./vm/example.mjs";import u from"./vm/info.mjs";import{CONFIG as h,PUBLICPATH as d}from"./config.mjs";import f from"./plugins.config.mjs";import{isDev as g,isLibrary as b,NODE_ENV as j,PACKAGENAME as y,PACKAGEVERSION as v}from"./process-env.mjs";export const outputConfig={path:p(b?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${g?"name":"contenthash"}].js`,assetModuleFilename:t=>{let o=e(t.filename||"").substring(1);return`assets/${o}/[name][hash][ext]`},library:{name:`${u.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${y}`,pathinfo:g,clean:!0,publicPath:d,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"anonymous",enabledWasmLoadingTypes:["fetch"],hotUpdateChunkFilename:"[id].[fullhash].hot.js",hotUpdateMainFilename:"[runtime].[fullhash].hot.json"};let C={main:[l("@app/entry")]};h.polyfill&&C.main.unshift(t(s.corePath,"./polyfills/replace-children.mjs")),g&&h.refresh&&h.env.injectRemoteReactRefresh&&C.main.unshift(i.resolve("@moneko/react/lib/injectRemoteReactRefresh.js")),h.entry&&("string"==typeof h.entry?C={main:[h.entry]}:Object.keys(h.entry)&&(C=Object.assign(C,h.entry))),"string"==typeof C.main&&(C.main=[C.main]),h.output&&("string"==typeof h.output?outputConfig.path=h.output:Object.keys(h.output)&&Object.assign(outputConfig,h.output));let k={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[a,j].filter(Boolean).join("-")}`,version:`${v}`,buildDependencies:{config:n}};!1===h.cache?k=!1:m(h.cache)&&(k=Object.assign(k,h.cache));export const commonConfig={name:"client",target:"web",devtool:h.devtool,entry:C,mode:g?"development":"production",stats:"errors-only",cache:k,snapshot:{immutablePaths:[/node_modules\/(?!(@app|@moneko)\/)/],managedPaths:[/^@app\/.+/,/^@moneko\/.+/],buildDependencies:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:h.externalsPresets,plugins:f,node:{global:!1,__filename:!1,__dirname:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:h.lazyCompilation&&g&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(l(c))||t.startsWith(l("@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};h.overrideResolve&&commonConfig.resolve.plugins.push(new r(Object.assign({original:h.alias["@"],override:a&&p(a)},h.overrideResolve)));
package/lib/config.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import { relative } from 'node:path';
1
2
  import { fileExists } from '@moneko/utils';
2
3
  import { merge } from 'webpack-merge';
3
4
  import paths from './commom/paths.mjs';
@@ -5,9 +6,9 @@ import require from './commom/require.mjs';
5
6
  import setupEnv from './commom/setup-env.mjs';
6
7
  import jsxDomExpressions from './options/jsx-dom-expressions.mjs';
7
8
  import splitChunk from './options/split-chunk.mjs';
8
- import { isFunction, resolveProgram } from './utils/index.mjs';
9
+ import { isFunction, node_modules, resolveProgram } from './utils/index.mjs';
9
10
  import type { ConfigType } from './index.mjs';
10
- import { APPTYPE, coreName, FRAMEWORK, isDev, isLibrary, isMobile, jsxImportSource, mainDirectory, NODE_ENV, PACKAGENAME } from './process-env.mjs';
11
+ import { APPTYPE, FRAMEWORK, frameworkVersion, isDev, isLibrary, isMobile, isReact, jsxImportSource, mainDirectory, NODE_ENV, PACKAGENAME } from './process-env.mjs';
11
12
  declare const includeModule: readonly [string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string];
12
13
  export declare function getConfig(path: string): Promise<ConfigType>;
13
14
  type EnvType = {
package/lib/config.mjs CHANGED
@@ -1 +1 @@
1
- import{fileExists as e}from"@moneko/utils";import{merge as o}from"webpack-merge";import t from"./commom/paths.mjs";import n from"./commom/require.mjs";import i from"./commom/setup-env.mjs";import s from"./options/jsx-dom-expressions.mjs";import r from"./options/split-chunk.mjs";import{isFunction as l,resolveProgram as a}from"./utils/index.mjs";import{APPTYPE as m,coreName as p,FRAMEWORK as c,isDev as u,isLibrary as d,isMobile as f,jsxImportSource as h,mainDirectory as g,NODE_ENV as v,PACKAGENAME as x}from"./process-env.mjs";let C=["@app","@moneko","neko-ui",".cache/http/data","@ant-design","@antv","@antv/x6","@antv/x6-react-components","@element-plus","ant-design-vue","antd","antd-mini","antd-mobile","antd-mobile-icons","element-plus","element-ui","ng-zorro-antd","@antv","@mui","@du","ahooks","rc-queue-anim","umi","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design"];export function getConfig(o){return delete n.cache[o],new Promise(t=>{if(e(o)){let e=n(o).default;return t(l(e)?e(process):e)}return t({})})}let b=await Promise.all([i(v,m,c,[]),getConfig(t.configPath),getConfig(t.customConfigPath)]),P=b[0],w=b[1],j=b[2],k={devtool:u?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:P,basename:"/",publicPath:"/",rem:{designSize:f?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":a(g)},moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3},htmlPluginOption:{title:x.toLocaleUpperCase(),favicon:`node_modules/${p}/lib/options/favicon.ico`},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:r,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:C,js:C,media:C,font:C,wasm:[]},mdx:{jsx:!1,development:u,jsxImportSource:h,providerImportSource:`@moneko/${c}/mdx`},jsxDomExpressions:s,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69"},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==c,bundleId:"com.moneko.bid",bundles:[],stylelint:!0,eslint:!0};d&&(k.alias=Object.assign(k.alias,{"@pkg":t.componentsPath,[x]:t.componentsPath}));let y=k;(!1===(y=o(y,w,j)).devtool||!1===y.sourceMap)&&(y.sourceMap=!1,y.devtool=!1),y.fixBrowserRouter&&y.htmlPluginOption&&(y.htmlPluginOption.tags||(y.htmlPluginOption.tags=[]),y.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=y;export const PUBLICPATH=CONFIG.publicPath;
1
+ import{relative as e}from"node:path";import{fileExists as o}from"@moneko/utils";import{merge as t}from"webpack-merge";import n from"./commom/paths.mjs";import r from"./commom/require.mjs";import s from"./commom/setup-env.mjs";import i from"./options/jsx-dom-expressions.mjs";import a from"./options/split-chunk.mjs";import{isFunction as l,node_modules as m,resolveProgram as p}from"./utils/index.mjs";import{APPTYPE as c,FRAMEWORK as u,frameworkVersion as d,isDev as f,isLibrary as g,isMobile as h,isReact as x,jsxImportSource as v,mainDirectory as j,NODE_ENV as P,PACKAGENAME as C}from"./process-env.mjs";let b=["@app","@moneko","neko-ui",".cache/http/data","@ant-design","@antv","@antv/x6","@antv/x6-react-components","@element-plus","ant-design-vue","antd","antd-mini","antd-mobile","antd-mobile-icons","element-plus","element-ui","ng-zorro-antd","@antv","@mui","@du","ahooks","rc-queue-anim","umi","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design"];export function getConfig(e){return delete r.cache[e],new Promise(t=>{if(o(e)){let o=r(e).default;return t(l(o)?o(process):o)}return t({})})}let k=await Promise.all([s(P,c,u,[]),getConfig(n.configPath),getConfig(n.customConfigPath)]),w=k[0],O=k[1],y=k[2],I={devtool:f?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:w,basename:"/",publicPath:"/",rem:{designSize:h?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":p(j)},x&&d<18?{"react/package.json":m("react/package.json"),"react/jsx-runtime":m("react/jsx-runtime.js"),"react/jsx-dev-runtime":m("react/jsx-dev-runtime.js")}:{}),moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3},htmlPluginOption:{title:C.toLocaleUpperCase(),favicon:e(n.programPath,`${n.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:a,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:b,js:b,media:b,font:b,wasm:[]},mdx:{jsx:!1,development:f,jsxImportSource:v,providerImportSource:`@moneko/${u}/mdx`},jsxDomExpressions:i,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69"},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==u,bundleId:"com.moneko.bid",bundles:[],stylelint:!0,eslint:!0};g&&(I.alias=Object.assign(I.alias,{"@pkg":n.componentsPath,[C]:n.componentsPath}));let M=I;(!1===(M=t(M,O,y)).devtool||!1===M.sourceMap)&&(M.sourceMap=!1,M.devtool=!1),M.fixBrowserRouter&&M.htmlPluginOption&&(M.htmlPluginOption.tags||(M.htmlPluginOption.tags=[]),M.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=M;export const PUBLICPATH=CONFIG.publicPath;
package/lib/dev.mjs CHANGED
@@ -1 +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"@fastify/compress";import{fastifyMiddie as s}from"@fastify/middie";import{ink as l,loadFile as n,print as a,println as m,progressBar as p}from"@moneko/utils";import c from"fastify";import d from"webpack";import u from"webpack-dev-middleware";import h from"webpack-hot-middleware";import{merge as f}from"webpack-merge";import{diffObject as g}from"./commom/diff-object.mjs";import w from"./commom/has-pkg.mjs";import y,{config_files as x}from"./commom/paths.mjs";import v from"./commom/rule.mjs";import C from"./commom/sigint-exit.mjs";import{devLog as k,PORT as $}from"./dev/config.mjs";import b from"./dev/mock.mjs";import{setupProxy as j}from"./dev/proxy.mjs";import P from"./options/reslove.mjs";import S from"./plugin/stylelint.mjs";import{empty as A,resolveProgram as E}from"./utils/index.mjs";import{commonConfig as T}from"./common.mjs";import{CONFIG as I,getConfig as M,PUBLICPATH as _}from"./config.mjs";import R from"./module.config.mjs";import{isLibrary as B,isReact as H,refresh as O}from"./process-env.mjs";let q=I.eslint&&w("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,z=["js","jsx","ts","tsx","json","html","vue"],U=z.join(","),D=`${_.endsWith("/")?"":"/"}__hmr__`,G=new URLSearchParams({name:"client",path:D,dynamicPublicPath:!0,timeout:2e3,reload:!O,quiet:!0,noInfo:!0,overlay:!0,autoConnect:!0}).toString(),L=T.output.path,W=f(T,{entry:{main:[`${P.hotMiddlewareClient}?${G}`]},output:{path:L},module:R(!1),optimization:{minimize:!1,concatenateModules:!1,removeAvailableModules:!1,removeEmptyChunks:!0,providedExports:!0,usedExports:!1,sideEffects:!1,splitChunks:{chunks:"all",minChunks:1,minSize:30720,maxSize:0,maxAsyncRequests:60,maxInitialRequests:50,hidePathInfo:!1,cacheGroups:{vendors:{test:v.node_modules,priority:-10,reuseExistingChunk:!0},default:{minChunks:1,priority:-20,reuseExistingChunk:!0}}}},plugins:[new d.HotModuleReplacementPlugin,new d.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]})]});if(W.plugins||(W.plugins=[]),H){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;W.plugins.push(new e)}if(q&&W.plugins.push(new q({fix:!0,threads:!0,files:[`${I.alias["@"]}/**/*.{${U}}`,B&&`${I.alias["@pkg"]}/**/*.{${U}}`].filter(Boolean),extensions:z,exclude:["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],cache:!0,cacheLocation:`${y.lintCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:E("eslint.config.mjs"),configType:"flat"})),I.stylelint){let e="css,scss,sass,less,ts,tsx,js,jsx";W.plugins.push(new S({fix:!0,files:[r(y.programPath,`${I.alias["@"]}/**/*.{${e}}`).replace(/\\/g,"/"),B&&r(y.programPath,`${I.alias["@pkg"]}/**/*.{${e}}`).replace(/\\/g,"/")].filter(Boolean),cache:!0,cacheLocation:`${y.lintCachePath}/.stylelintcache`}))}if(I.bar){let e=I.bar,t=e.name||"Build";W.plugins.push(new d.ProgressPlugin({handler(o,r,...i){p(o||0,1,{msg:i.length?`[${r}] ${i.join(" ")}`:"",name:t,barColor:e.barColor,nameColor:e.nameColor,barBgColor:e.barBgColor,msgColor:e.msgColor}),1===o&&process.stdout.write("\r\x1b[2K")}}))}let F=d(W);F.hooks.done.tap("client-log",e=>{k(null,e)});let N={};if(I.devServer.https){let[e,t]=await Promise.all([n(I.devServer.https.key),n(I.devServer.https.cert)]);e||(m(l(`法加载私钥。请检查路径和文件是否存在,并确保路径正确:${I.devServer.https.key}`,"red")),process.exit(1)),t||(m(l(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${I.devServer.https.cert}`,"red")),process.exit(1)),N.http2=!0,N.https={key:e,cert:t}}let K=u(F,{writeToDisk:!1,index:"index.html",headers:e=>({"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization","Access-Control-Allow-Methods":"GET, POST, OPTIONS, DELETE, PATCH, PUT",...I.devServer.headers,"Access-Control-Allow-Origin":e.headers.origin||"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"}),serverSideRender:!1,lastModified:!0,publicPath:W.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),X=h(F,{log:!1,path:D,heartbeat:2e3}),J=c({logger:!1,...N});await J.register(s),J.use(K),J.use(D,X),b(J,{directory:y.mockPath}),j(J,I.proxy);let Q=`${W.output.path}/index.html`;function V(){process.exit(0)}J.get("*",async(e,t)=>{if(e.headers.accept?.includes("text/html")){let e=K.context.outputFileSystem,o=e?.readFileSync?.(Q);if(!t.sent){t.type("text/html").send(o);return}}else if(e.url?.endsWith(D)&&"text/event-stream"===e.headers.accept){e.raw.url=D,X(e.raw,t.raw,A);return}}),J.addHook("onClose",()=>{K.close(A),J.server.close(A)}),await J.register(i,{global:!0}),J.listen({port:$});let Y=await Promise.all(x.map(M)),Z=f(Y[0]||{},Y[1]||{});x.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(x.map(M)),i=f(o||{},r||{}),s=g(Z,i);1===Object.keys(s).length&&"proxy"in s?(a(l(`代理更新中...`,"yellow"),!0),await j(J,i.proxy),a(l(`代理更新完成...`,"green"),!0),I.proxy=i.proxy,Z.proxy=i.proxy,Z=i):(Z=i,m(l(`检测到工程配置${l(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e("win32"===process.platform?`netstat -ano | findstr :${$}`:`lsof -i :${$} -t`,(e,t)=>{if(e){m(l(`查找端口 ${$} 时发生错误: ${e.message}`,"red")),m(l("请尝试手动重启程序","yellow"));return}let o=t.trim().split("\n").filter(Boolean),r=ee?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){m(l(`未找到占用端口 ${$} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(r),"SIGHUP")}catch(e){m(l(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let ee="win32"===process.platform;process.on("SIGHUP",function(){J.close(A),function(){let e=t(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",V)}()}),process.on("exit",function(){J.close(A)}),C(V);
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"@fastify/compress";import{fastifyMiddie as s}from"@fastify/middie";import{ink as l,loadFile as n,print as a,println as m,progressBar as p}from"@moneko/utils";import c from"fastify";import d from"webpack";import u from"webpack-dev-middleware";import h from"webpack-hot-middleware";import{merge as f}from"webpack-merge";import{diffObject as g}from"./commom/diff-object.mjs";import w from"./commom/has-pkg.mjs";import y,{config_files as x}from"./commom/paths.mjs";import v from"./commom/rule.mjs";import C from"./commom/sigint-exit.mjs";import{devLog as k,PORT as $}from"./dev/config.mjs";import b from"./dev/mock.mjs";import{setupProxy as j}from"./dev/proxy.mjs";import P from"./options/reslove.mjs";import S from"./plugin/stylelint.mjs";import{empty as A,resolveProgram as E}from"./utils/index.mjs";import{commonConfig as T}from"./common.mjs";import{CONFIG as I,getConfig as M,PUBLICPATH as _}from"./config.mjs";import R from"./module.config.mjs";import{isLibrary as B,isReact as H,refresh as O}from"./process-env.mjs";let q=I.eslint&&w("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,z=["js","jsx","ts","tsx","json","html","vue"],U=z.join(","),D=`${_.endsWith("/")?"":"/"}__hmr__`,G=new URLSearchParams({name:"client",path:D,dynamicPublicPath:!0,timeout:2e3,reload:!O,quiet:!1,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),L=T.output.path,W=f(T,{entry:{main:[`${P.hotMiddlewareClient}?${G}`]},output:{path:L},module:R(!1),optimization:{minimize:!1,concatenateModules:!1,removeAvailableModules:!1,removeEmptyChunks:!0,providedExports:!0,usedExports:!1,sideEffects:!1,splitChunks:{chunks:"all",minChunks:1,minSize:30720,maxSize:0,maxAsyncRequests:60,maxInitialRequests:50,hidePathInfo:!1,cacheGroups:{vendors:{test:v.node_modules,priority:-10,reuseExistingChunk:!0},default:{minChunks:1,priority:-20,reuseExistingChunk:!0}}}},plugins:[new d.HotModuleReplacementPlugin,new d.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]})]});if(W.plugins||(W.plugins=[]),H){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;W.plugins.push(new e)}if(q&&W.plugins.push(new q({fix:!0,threads:!0,files:[`${I.alias["@"]}/**/*.{${U}}`,B&&`${I.alias["@pkg"]}/**/*.{${U}}`].filter(Boolean),extensions:z,exclude:["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],cache:!0,cacheLocation:`${y.lintCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:E("eslint.config.mjs"),configType:"flat"})),I.stylelint){let e="css,scss,sass,less,ts,tsx,js,jsx";W.plugins.push(new S({fix:!0,files:[r(y.programPath,`${I.alias["@"]}/**/*.{${e}}`).replace(/\\/g,"/"),B&&r(y.programPath,`${I.alias["@pkg"]}/**/*.{${e}}`).replace(/\\/g,"/")].filter(Boolean),cache:!0,cacheLocation:`${y.lintCachePath}/.stylelintcache`}))}if(I.bar){let e=I.bar,t=e.name||"Build";W.plugins.push(new d.ProgressPlugin({handler(o,r,...i){p(o||0,1,{msg:i.length?`[${r}] ${i.join(" ")}`:"",name:t,barColor:e.barColor,nameColor:e.nameColor,barBgColor:e.barBgColor,msgColor:e.msgColor}),1===o&&process.stdout.write("\r\x1b[2K")}}))}let F=d(W);F.hooks.done.tap("client-log",e=>{k(null,e)});let N={};if(I.devServer.https){let[e,t]=await Promise.all([n(I.devServer.https.key),n(I.devServer.https.cert)]);e||(m(l(`法加载私钥。请检查路径和文件是否存在,并确保路径正确:${I.devServer.https.key}`,"red")),process.exit(1)),t||(m(l(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${I.devServer.https.cert}`,"red")),process.exit(1)),N.http2=!0,N.https={key:e,cert:t}}let K=u(F,{writeToDisk:!1,index:"index.html",headers:e=>({"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization","Access-Control-Allow-Methods":"GET, POST, OPTIONS, DELETE, PATCH, PUT",...I.devServer.headers,"Access-Control-Allow-Origin":e.headers.origin||"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"}),serverSideRender:!1,lastModified:!0,publicPath:W.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),X=h(F,{log:!1,path:D,heartbeat:2e3}),J=c({logger:!1,...N});await J.register(s),J.use(K),J.use(D,X),b(J,{directory:y.mockPath}),j(J,I.proxy);let Q=`${W.output.path}/index.html`;function V(){process.exit(0)}J.get("*",async(e,t)=>{if(e.headers.accept?.includes("text/html")){let e=K.context.outputFileSystem,o=e?.readFileSync?.(Q);if(!t.sent){t.type("text/html").send(o);return}}else if(e.url?.endsWith(D)&&"text/event-stream"===e.headers.accept){e.raw.url=D,X(e.raw,t.raw,A);return}}),J.addHook("onClose",()=>{K.close(A),J.server.close(A)}),await J.register(i,{global:!0}),J.listen({port:$});let Y=await Promise.all(x.map(M)),Z=f(Y[0]||{},Y[1]||{});x.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(x.map(M)),i=f(o||{},r||{}),s=g(Z,i);1===Object.keys(s).length&&"proxy"in s?(a(l(`代理更新中...`,"yellow"),!0),await j(J,i.proxy),a(l(`代理更新完成...`,"green"),!0),I.proxy=i.proxy,Z.proxy=i.proxy,Z=i):(Z=i,m(l(`检测到工程配置${l(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e("win32"===process.platform?`netstat -ano | findstr :${$}`:`lsof -i :${$} -t`,(e,t)=>{if(e){m(l(`查找端口 ${$} 时发生错误: ${e.message}`,"red")),m(l("请尝试手动重启程序","yellow"));return}let o=t.trim().split("\n").filter(Boolean),r=ee?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){m(l(`未找到占用端口 ${$} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(r),"SIGHUP")}catch(e){m(l(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let ee="win32"===process.platform;process.on("SIGHUP",function(){J.close(A),function(){let e=t(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",V)}()}),process.on("exit",function(){J.close(A)}),C(V);
@@ -0,0 +1,13 @@
1
+ import { transformSync } from '@swc/core';
2
+ import swcrc, { SwcOption } from '../options/swcrc.mjs';
3
+ import { isDev } from '../process-env.mjs';
4
+ import info from '../vm/info.mjs';
5
+ declare const version: number;
6
+ declare const ReactDomPath: string;
7
+ declare const isHashRouter: boolean;
8
+ declare const v7Future: Record<string, boolean | undefined>;
9
+ declare const createRouter: string;
10
+ declare const code: string;
11
+ declare const swcOption: SwcOption;
12
+ declare const reactRenderApp: string;
13
+ export default reactRenderApp;
@@ -0,0 +1,41 @@
1
+ import{transformSync as e}from"@swc/core";import r from"../options/swcrc.mjs";import{isDev as t}from"../process-env.mjs";import o from"../vm/info.mjs";let a=parseFloat(o.frameworkVersion),n="hash"===o.routerMode,s=Object.assign({v7_relativeSplatPath:!1},"browser"===o.routerMode?{v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:o.ssr,v7_skipActionErrorRevalidation:!1}:{}),c=n?"createHashRouter":"createBrowserRouter",p=`import React, { StrictMode, useRef, type ReactElement } from 'react';
2
+ import Fallback from '@app/fallback';
3
+ import routes from '@app/routes';
4
+ import ReactDOM from '${a<18?"react-dom":"react-dom/client"}';
5
+ import { RouterProvider, ${c} } from 'react-router-dom';
6
+
7
+ type RenderAppProps = {
8
+ container?: HTMLElement;
9
+ basename?: string;
10
+ fallback?: ReactElement;
11
+ language?: string;
12
+ };
13
+
14
+ export function App(props: RenderAppProps) {
15
+ const v7Future = useRef(${JSON.stringify(s)});
16
+ return (
17
+ <StrictMode>
18
+ <RouterProvider
19
+ router={${c}(routes, {
20
+ basename: ${n?"/":"props.basename"},
21
+ window: window,
22
+ future: v7Future.current,
23
+ })}
24
+ future={{
25
+ /** 这使用 useTransition 而不是 useState 来更新路由器状态 */
26
+ v7_startTransition: false,
27
+ }}
28
+ fallbackElement={Fallback && <Fallback />}
29
+ />
30
+ </StrictMode>
31
+ );
32
+ }
33
+
34
+ function renderApp(props: RenderAppProps = {}) {
35
+ const { container, basename = "${o.base}", language, ...args } = props;
36
+ const _container = container?.querySelector('#root') || document.getElementById('root');
37
+ ${"micro"===o.type?"window.mainApp = { ...args, container: _container as HTMLElement };":""}
38
+ ${a<18?`ReactDOM.${t?"render":"hydrate"}(<App basename={basename} language={language} />, _container);return () => ReactDOM.unmountComponentAtNode(_container as Element);`:"const instance = ReactDOM.createRoot(_container as HTMLElement);instance.render(<App basename={basename} language={language} />);return instance.unmount;"}
39
+ }
40
+
41
+ export default renderApp;`,i=r(o.ssr);delete i.sync,delete i.parseMap;let m=e(p,i).code;console.log(m);export default m;
@@ -1,2 +1,2 @@
1
- let e;import{join as o,sep as s}from"node:path";import{saveFileSync as t}from"@moneko/utils";import r,{CUSTOMCONFIG as a}from"./commom/paths.mjs";import m from"./commom/reactive-object.mjs";import n from"./commom/require.mjs";import i from"./commom/rule.mjs";import l from"./options/css-extract.mjs";import c from"./options/modify-vars.mjs";import d from"./options/reslove.mjs";import p from"./options/swcrc.mjs";import{getLightningCssTargets as u}from"./polyfills/targets.mjs";import{node_modules as f,resolveProgram as j,toCamelCase as h}from"./utils/index.mjs";import v from"./utils/svg-to-data-uri.mjs";import{comment as g,getCommentPath as x}from"./vm/docs.mjs";import y from"./vm/generate-doc.mjs";import{CONFIG as w}from"./config.mjs";import{FRAMEWORK as L,isDev as M,isLibrary as P}from"./process-env.mjs";let _={loader:o(r.corePath,"/loader/lightning-css/loader.cjs"),options:{sourceMap:!!w.sourceMap,targets:u(),rem:!!w.rem,esModule:!0,modules:{auto(e){if(e){if(e.endsWith(".css")&&!e.endsWith("module.css"))return!1;for(let o=0,s=I.length;o<s;o++)if(e.includes(I[o]))return i.css_module.test(e)}return i.node_modules_css_module.test(e)},localIdentName:"[name][hash]_[local]",namedExport:!0,exportLocalsConvention:"dashesOnly",exportOnlyLocals:!1,getJSON:w.cssModuleDefinition?function(e){Q.setData(`${e.resourcePath}.d.ts`,`${e.exports.map(({name:e,value:o})=>`export const ${h(e)}: '${o}';`).join("\n")}
2
- `)}:void 0},importLoaders:2}},k={loader:d.lessLoader,options:{sourceMap:!!w.sourceMap,lessOptions:{modifyVars:c,javascriptEnabled:!0}}},C=new Map;function O(e){if(C.has(e))return C.get(e);try{let o;let t=n.resolve(e).split(s),r=t.lastIndexOf("node_modules");return o=-1!==r?t.slice(0,r).join(s):t.join(s),C.set(e,o),o}catch{let o=f(e);return C.set(e,o),o}}let I=[...w.cssModules,`@moneko/${L}`,"neko-ui"].map(O),b=["components","example","mock","site","src","server"].map(j);function W(e){return new Promise(o=>{o([...b,...w.rulesInclude?.[e]?.map(O)||[]])})}a&&b.push(j(a)),w.overrideResolve&&w.overrideResolve.override&&b.push(w.overrideResolve.override);let $=await Promise.all([W("css"),W("js"),W("media"),W("wasm"),W("font")]),R=$[0],B=$[1],S=$[2],z=$[3],D=$[4];d.sassLoader&&(e={loader:d.sassLoader,options:{implementation:await import("sass"),sassOptions:{}}});let E=P&&M&&{test:i.tsdoc,include:w.alias["@pkg"],exclude:[/node_modules\/(?!(@app|@moneko)).+/,i.__tests__],enforce:"pre",loader:o(r.corePath,"/loader/ts-doc.cjs"),options:{comment:g,generateDoc:y,getCommentPath:x}},J=[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename(e){let o=e.filename;return o&&o.toLocaleLowerCase().endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:i.wasm,type:"webassembly/async",include:z},{test:i.txt,type:"asset/source"},{test:i.image,type:"asset",dependency:{not:["url"]},parser:{dataUrlCondition:{maxSize:4096}},generator:{filename:e=>e.filename?.toLocaleLowerCase().endsWith(".svg")?"assets/svg/[name][ext]":"assets/images/[name][ext]",dataUrl:(e,o)=>o.filename.toLocaleLowerCase().endsWith(".svg")?v(e.toString()):e},include:S},{test:i.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:S},{test:i.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:D}],N=w.prefixJsLoader.filter(Boolean)||[];switch(L){case"react":w.reactCompiler&&N.unshift({loader:o(r.corePath,"/loader/react-compiler.cjs"),options:w.reactCompiler});break;case"solid":w.refresh=!1}let Q=new m({});Q.on("change",(e,o)=>{t(e,o)});export default(s=>{let t={loader:d.swcLoader,options:p(s)};return{parser:{javascript:{commonjsMagicComments:!0,dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,importMeta:!0,importMetaContext:!0}},noParse:w.noParse,rules:[!1!==w.htmlPluginOption&&E,{oneOf:[...J,{test:i.js,use:[...N,t],include:B},{test:i.css,use:[l,_],include:R},e&&{test:i.scss,use:[l,_,e],include:R},{test:i.less,use:[l,_,k],include:R},{test:i.markdown,use:[...N,{loader:o(r.corePath,"/loader/mdx.cjs"),options:w.mdx}],exclude:[/node_modules\/(?!(@app|@moneko)).+/]}].filter(Boolean)},...w.moduleRules].filter(Boolean)}});
1
+ let e;import{join as o,sep as s}from"node:path";import{saveFileSync as t}from"@moneko/utils";import r,{CUSTOMCONFIG as a}from"./commom/paths.mjs";import m from"./commom/reactive-object.mjs";import n from"./commom/require.mjs";import i from"./commom/rule.mjs";import l from"./options/css-extract.mjs";import c from"./options/modify-vars.mjs";import d from"./options/reslove.mjs";import p from"./options/swcrc.mjs";import{getLightningCssTargets as u}from"./polyfills/targets.mjs";import{node_modules as f,resolveProgram as h,toCamelCase as j}from"./utils/index.mjs";import v from"./utils/svg-to-data-uri.mjs";import{comment as g,getCommentPath as x}from"./vm/docs.mjs";import y from"./vm/generate-doc.mjs";import{CONFIG as w}from"./config.mjs";import{FRAMEWORK as L,isDev as P,isLibrary as M}from"./process-env.mjs";let _={loader:o(r.corePath,"/loader/lightning-css/loader.cjs"),options:{sourceMap:!!w.sourceMap,targets:u(),rem:!!w.rem,esModule:!0,modules:{auto(e){if(e){if(e.endsWith(".css")&&!e.endsWith("module.css"))return!1;for(let o=0,s=I.length;o<s;o++)if(e.includes(I[o]))return i.css_module.test(e)}return i.node_modules_css_module.test(e)},localIdentName:"[name][hash]_[local]",namedExport:!0,exportLocalsConvention:"dashesOnly",exportOnlyLocals:!1,getJSON:w.cssModuleDefinition?function(e){Q.setData(`${e.resourcePath}.d.ts`,`${e.exports.map(({name:e,value:o})=>`export const ${j(e)}: '${o}';`).join("\n")}
2
+ `)}:void 0},importLoaders:2}},k={loader:d.lessLoader,options:{sourceMap:!!w.sourceMap,lessOptions:{modifyVars:c,javascriptEnabled:!0}}},C=new Map;function O(e){if(C.has(e))return C.get(e);try{let o;let t=n.resolve(e).split(s),r=t.lastIndexOf("node_modules");return o=-1!==r?t.slice(0,r).join(s):t.join(s),C.set(e,o),o}catch{let o=f(e);return C.set(e,o),o}}let I=[...w.cssModules,`@moneko/${L}`,"neko-ui"].map(O),b=["components","example","mock","site","src","server"].map(h);function W(e){return new Promise(o=>{o([...b,r.corePath,...w.rulesInclude?.[e]?.map(O)||[]])})}a&&b.push(h(a)),w.overrideResolve&&w.overrideResolve.override&&b.push(w.overrideResolve.override);let $=await Promise.all([W("css"),W("js"),W("media"),W("wasm"),W("font")]),R=$[0],B=$[1],S=$[2],z=$[3],D=$[4];d.sassLoader&&(e={loader:d.sassLoader,options:{implementation:await import("sass"),sassOptions:{}}});let E=M&&P&&{test:i.tsdoc,include:w.alias["@pkg"],exclude:[/node_modules\/(?!(@app|@moneko)).+/,i.__tests__],enforce:"pre",loader:o(r.corePath,"/loader/ts-doc.cjs"),options:{comment:g,generateDoc:y,getCommentPath:x}},J=[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename(e){let o=e.filename;return o&&o.toLocaleLowerCase().endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:i.wasm,type:"webassembly/async",include:z},{test:i.txt,type:"asset/source"},{test:i.image,type:"asset",dependency:{not:["url"]},parser:{dataUrlCondition:{maxSize:4096}},generator:{filename:e=>e.filename?.toLocaleLowerCase().endsWith(".svg")?"assets/svg/[name][ext]":"assets/images/[name][ext]",dataUrl:(e,o)=>o.filename.toLocaleLowerCase().endsWith(".svg")?v(e.toString()):e},include:S},{test:i.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:S},{test:i.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:D}],N=w.prefixJsLoader.filter(Boolean)||[];switch(L){case"react":w.reactCompiler&&N.unshift({loader:o(r.corePath,"/loader/react-compiler.cjs"),options:w.reactCompiler});break;case"solid":w.refresh=!1}let Q=new m({});Q.on("change",(e,o)=>{t(e,o)});export default(s=>{let t={loader:d.swcLoader,options:p(s)};return{parser:{javascript:{commonjsMagicComments:!0,dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,importMeta:!0,importMetaContext:!0}},noParse:w.noParse,rules:[!1!==w.htmlPluginOption&&E,{oneOf:[...J,{test:i.js,use:[...N,t],include:B},{test:i.css,use:[l,_],include:R},e&&{test:i.scss,use:[l,_,e],include:R},{test:i.less,use:[l,_,k],include:R},{test:i.markdown,use:[...N,{loader:o(r.corePath,"/loader/mdx.cjs"),options:w.mdx}],exclude:[/node_modules\/(?!(@app|@moneko)).+/]}].filter(Boolean)},...w.moduleRules].filter(Boolean)}});
@@ -1,4 +1,6 @@
1
1
  import { CONFIG } from '../config.mjs';
2
+ import type { HtmlPluginOption } from '../plugin/html-plugin.mjs';
2
3
  declare const prefixCls: string;
4
+ declare const favicon: string;
3
5
  declare const modifyVars: Record<string, string | false | undefined>;
4
6
  export default modifyVars;
@@ -1 +1 @@
1
- import{CONFIG as i}from"../config.mjs";let f=i.prefixCls||"n",n={"@prefix-cls":f,"@ant-prefix":f,"@iconfont-css-prefix":`${f}-icon`,"@favicon":i.htmlPluginOption?.favicon};Object.assign(n,i.modifyVars);export default n;
1
+ import{CONFIG as i}from"../config.mjs";let f=i.prefixCls||"n",n=i.htmlPluginOption?.favicon||"favicon.ico",o={"@prefix-cls":f,"@ant-prefix":f,"@iconfont-css-prefix":`${f}-icon`,"@favicon":JSON.stringify(`${i.publicPath||""}${n}`)};Object.assign(o,i.modifyVars);export default o;
@@ -9,6 +9,13 @@ import reslove from './reslove.mjs';
9
9
  declare function transformConfigs(config: SwcImportOnDemandTransform);
10
10
  declare const importOnDemand: SwcImportOnDemandTransform;
11
11
  declare const env: EnvConfig;
12
+ export type SwcOption = SwcConfig & {
13
+ module?: {
14
+ resolveFully: boolean;
15
+ };
16
+ parseMap?: boolean;
17
+ sync?: boolean;
18
+ };
12
19
  declare const _dts_1: (ssr: boolean, other: {
13
20
  }) => any;
14
21
  export default _dts_1;
@@ -1 +1 @@
1
- import e from"webpack";import{CopyPlugin as t}from"./plugin/copy.mjs";import{HtmlPlugin as i}from"./plugin/html-plugin.mjs";import o from"./plugin/module-federation.mjs";import{VirtualModuleWebpackPlugin as l}from"./plugin/virtual-module.mjs";import{CONFIG as n}from"./config.mjs";import{description as r,keywords as p}from"./process-env.mjs";let a=[...o,new l(n.virtualModule),new t(n.copy),new e.DefinePlugin({"process.env":JSON.stringify(n.env)}),new e.IgnorePlugin({resourceRegExp:/\/(__(tests|mocks)__|test|spec|e2e)\//}),...n.plugins].filter(Boolean);if(n.htmlPluginOption){let e={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","mobile-web-app-capable":"yes",renderer:"webkit",description:r,keywords:Array.isArray(p)?p.toString():"","http-equiv":"refresh",viewport:"width=device-width, initial-scale=1"};n.seo&&(e.relCanonical={rel:"canonical",href:`https://${n.seo.domain}${n.basename}`}),n.htmlPluginOption.meta&&Object.assign(e,n.htmlPluginOption.meta),a.push(new i({...n.htmlPluginOption,meta:e}))}if(n.fixBrowserRouter){let e=n.basename.split("/").filter(Boolean).length,t=`${Array(e).fill("..").join("/")+(e?"/":"")}404.html`,o=n.fixBrowserRouter.pathSegmentsToKeep??e;a.push(new i({filename:n.fixBrowserRouter.path??t,inject:!1,templateContent:()=>`<html lang="en"><head><title>${n.htmlPluginOption?.title}</title><script>const pathKeep = ${o};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>`}))}n.sourceMap&&a.push(new e.SourceMapDevToolPlugin(n.sourceMap));export default a;
1
+ import e from"webpack";import{CopyPlugin as t}from"./plugin/copy.mjs";import{HtmlPlugin as i}from"./plugin/html-plugin.mjs";import o from"./plugin/module-federation.mjs";import{VirtualModuleWebpackPlugin as l}from"./plugin/virtual-module.mjs";import{CONFIG as r}from"./config.mjs";import{description as n,keywords as p}from"./process-env.mjs";let a=[...o,new l(r.virtualModule),new t(r.copy),new e.DefinePlugin({"process.env":JSON.stringify(r.env)}),new e.IgnorePlugin({resourceRegExp:/\/(__(tests|mocks)__|test|spec|e2e)\//}),...r.plugins].filter(Boolean);if(r.htmlPluginOption){let e={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","mobile-web-app-capable":"yes",renderer:"webkit",description:n,keywords:Array.isArray(p)?p.toString():"","http-equiv":"refresh",viewport:"width=device-width, initial-scale=1"};r.seo&&(e.relCanonical={rel:"canonical",href:`https://${r.seo.domain}${r.basename}`}),r.htmlPluginOption.meta&&Object.assign(e,r.htmlPluginOption.meta),a.push(new i({...r.htmlPluginOption,meta:e}))}if(r.fixBrowserRouter){let e=r.basename.split("/").filter(Boolean).length,t=`${Array(e).fill("..").join("/")+(e?"/":"")}404.html`,o=r.fixBrowserRouter.pathSegmentsToKeep??e;a.push(new i({filename:r.fixBrowserRouter.path??t,inject:!1,templateContent:()=>`<html lang="en"><head><title>Redirect</title><script>const pathKeep = ${o};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>`}))}r.sourceMap&&a.push(new e.SourceMapDevToolPlugin(r.sourceMap));export default a;
@@ -12,6 +12,9 @@ export declare const isSolid: boolean;
12
12
  export declare const SSR: boolean;
13
13
  export declare const mainDirectory: 'site' | 'src';
14
14
  export declare const jsxImportSource: string;
15
+ export declare const framework: 'react' | 'solid-js';
16
+ export declare const frameworkVersionStr: string;
17
+ export declare const frameworkVersion: number;
15
18
  declare const info: Record<string, unknown>;
16
19
  export declare const description: string;
17
20
  export declare const author: string | Record<string, string>;
@@ -1 +1 @@
1
- import o from"./commom/has-pkg.mjs";import r from"./commom/require.mjs";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const NODE_ENV=process.env.NODE_ENV;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isMobile="mobile"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const SSR="true"===process.env.SSR;export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];let e=r(`${process.cwd()}/package.json`);export const description=e.description;export const author=e.author;export const repository=e.repository;export const keywords=e.keywords;export const PACKAGENAME=e.name;export const PACKAGEVERSION=e.version;export const coreName="@moneko/core";export const isDev="development"===NODE_ENV;export const refresh=!!(isDev&&(o("solid-refresh")||o("react-refresh")));
1
+ import o from"./commom/has-pkg.mjs";import r from"./commom/require.mjs";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const NODE_ENV=process.env.NODE_ENV;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isMobile="mobile"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const SSR="true"===process.env.SSR;export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const framework={react:"react",solid:"solid-js"}[FRAMEWORK];export const frameworkVersionStr=r(`${framework}/package.json`).version;export const frameworkVersion=parseFloat(frameworkVersionStr);let e=r(`${process.cwd()}/package.json`);export const description=e.description;export const author=e.author;export const repository=e.repository;export const keywords=e.keywords;export const PACKAGENAME=e.name;export const PACKAGEVERSION=e.version;export const coreName="@moneko/core";export const isDev="development"===NODE_ENV;export const refresh=!!(isDev&&(o("solid-refresh")||o("react-refresh")));
package/lib/vm/docs.d.mts CHANGED
@@ -5,10 +5,9 @@ import paths from '../commom/paths.mjs';
5
5
  import ReactiveObject from '../commom/reactive-object.mjs';
6
6
  import Rule from '../commom/rule.mjs';
7
7
  import { CONFIG } from '../config.mjs';
8
- import { FRAMEWORK, isLibrary, isReact, isSolid } from '../process-env.mjs';
8
+ import { FRAMEWORK, framework, isLibrary, isReact, isSolid } from '../process-env.mjs';
9
9
  import generateDoc from './generate-doc.mjs';
10
10
  declare const createElement: string;
11
- declare const FRAMEWORKNAME: string;
12
11
  declare const moduleMeta: ModuleMeta;
13
12
  export declare const docsModuleName: string;
14
13
  export declare const docsModulePkgJson: string;
package/lib/vm/docs.mjs CHANGED
@@ -1 +1 @@
1
- import{relative as e,sep as t}from"node:path";import{loadFile as o,scanFolderSync as m}from"@moneko/utils";import a from"../commom/parse-module-meta.mjs";import r from"../commom/paths.mjs";import s from"../commom/reactive-object.mjs";import n from"../commom/rule.mjs";import{CONFIG as l}from"../config.mjs";import{FRAMEWORK as c,isLibrary as p,isReact as i,isSolid as d}from"../process-env.mjs";import f from"./generate-doc.mjs";let u={react:"createElement",solid:"createComponent"}[c],g=a("@app/docs");export const docsModuleName=g.file;export const docsModulePkgJson=g.pkg;export const docsModuleMeta=g.meta;export const docs=new s({[docsModuleName]:"export default {}",[docsModulePkgJson]:docsModuleMeta});export const comment=new s({});export const getCommentPath=function(){let e=/\/(.+?)\.tsx?$/,t=l.alias["@pkg"]?.length;return o=>o.substring(t).replace(/\\/g,"/").replace(e,"@app/comment/$1.md")}();if(p&&!1!==l.htmlPluginOption){let s={},p=`import { ${u}${d?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[c]}${d?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${i?"() =>":""}${u}(${d?"Dynamic":"'div'"}, {${d?"innerHTML: res.default, component: 'div', class: 'n-md-box' ":"dangerouslySetInnerHTML: {__html:res.default}, className: 'n-md-box'"} })};}`,g=(e,o)=>{if(!e.endsWith("package.json")){let m=e.replace(/@app[/\\]comment[/\\]/,"").split(t),a=m.pop(),r=m.join("/");s[r]||(s[r]={}),o?s[r][a]&&delete s[r][a]:s[r][a]=`rr(() => ${u}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let l={};for(let e in s)Object.prototype.hasOwnProperty.call(s,e)&&(l[e]=Object.values(s[e]));docs.setData(docsModuleName,`${p}export default ${JSON.stringify(l).replace(n.extract_func,"$1")}`)}};comment.on("change",(t,o)=>{g(e(r.nodeModules,t),o?.length<0)});let h=m(l.alias["@pkg"],["\\.tsx?$"]).filter(e=>!/(^|\/)\.[^\\/\\.]|\.test\./i.test(e));await Promise.all(h.map(async e=>({data:await o(e),file:e}))).then(e=>{for(let t=0;t<e.length;t++){let o=e[t];if(o.data){let{file:e,pkg:t,meta:m}=a(getCommentPath(o.file));comment.setData(e,f(o.data,o.file)),comment.setData(t,m)}}})}
1
+ import{relative as e,sep as t}from"node:path";import{loadFile as o,scanFolderSync as m}from"@moneko/utils";import a from"../commom/parse-module-meta.mjs";import n from"../commom/paths.mjs";import r from"../commom/reactive-object.mjs";import s from"../commom/rule.mjs";import{CONFIG as l}from"../config.mjs";import{FRAMEWORK as c,framework as p,isLibrary as i,isReact as d,isSolid as f}from"../process-env.mjs";import u from"./generate-doc.mjs";let g={react:"createElement",solid:"createComponent"}[c],h=a("@app/docs");export const docsModuleName=h.file;export const docsModulePkgJson=h.pkg;export const docsModuleMeta=h.meta;export const docs=new r({[docsModuleName]:"export default {}",[docsModulePkgJson]:docsModuleMeta});export const comment=new r({});export const getCommentPath=function(){let e=/\/(.+?)\.tsx?$/,t=l.alias["@pkg"]?.length;return o=>o.substring(t).replace(/\\/g,"/").replace(e,"@app/comment/$1.md")}();if(i&&!1!==l.htmlPluginOption){let r={},c=`import { ${g}${f?",Dynamic":""} } from "${p}${f?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${d?"() =>":""}${g}(${f?"Dynamic":"'div'"}, {${f?"innerHTML: res.default, component: 'div', class: 'n-md-box' ":"dangerouslySetInnerHTML: {__html:res.default}, className: 'n-md-box'"} })};}`,i=(e,o)=>{if(!e.endsWith("package.json")){let m=e.replace(/@app[/\\]comment[/\\]/,"").split(t),a=m.pop(),n=m.join("/");r[n]||(r[n]={}),o?r[n][a]&&delete r[n][a]:r[n][a]=`rr(() => ${g}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let l={};for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&(l[e]=Object.values(r[e]));docs.setData(docsModuleName,`${c}export default ${JSON.stringify(l).replace(s.extract_func,"$1")}`)}};comment.on("change",(t,o)=>{i(e(n.nodeModules,t),o?.length<0)});let h=m(l.alias["@pkg"],["\\.tsx?$"]).filter(e=>!/(^|\/)\.[^\\/\\.]|\.test\./i.test(e));await Promise.all(h.map(async e=>({data:await o(e),file:e}))).then(e=>{for(let t=0;t<e.length;t++){let o=e[t];if(o.data){let{file:e,pkg:t,meta:m}=a(getCommentPath(o.file));comment.setData(e,u(o.data,o.file)),comment.setData(t,m)}}})}
package/lib/vm/info.d.mts CHANGED
@@ -1,9 +1,6 @@
1
- import require from '../commom/require.mjs';
2
1
  import { CONFIG } from '../config.mjs';
3
- import { APPTYPE, author, description, FRAMEWORK, PACKAGENAME, PACKAGEVERSION, repository, SSR } from '../process-env.mjs';
2
+ import { APPTYPE, author, description, framework, frameworkVersionStr, PACKAGENAME, PACKAGEVERSION, repository, SSR } from '../process-env.mjs';
4
3
  import { convertToCamelCase } from '../utils/index.mjs';
5
- declare const framework: string;
6
- declare const frameworkVersion: string;
7
4
  declare const iStr: boolean;
8
5
  declare const app: {
9
6
  readonly name;
@@ -19,5 +16,6 @@ declare const app: {
19
16
  readonly author;
20
17
  readonly repository;
21
18
  readonly frameworkVersion;
19
+ readonly framework;
22
20
  };
23
21
  export default app;
package/lib/vm/info.mjs CHANGED
@@ -1 +1 @@
1
- import e from"../commom/require.mjs";import{CONFIG as r}from"../config.mjs";import{APPTYPE as o,author as s,description as m,FRAMEWORK as t,PACKAGENAME as i,PACKAGEVERSION as p,repository as a,SSR as n}from"../process-env.mjs";import{convertToCamelCase as f}from"../utils/index.mjs";let c=e(`${{react:"react",solid:"solid-js"}[t]}/package.json`).version,l="string"==typeof s,d={name:i,projectName:f(i),ssr:n,version:p,base:r.basename,type:o,routerMode:r.routerMode,prefixCls:r.prefixCls,theme:r.theme,description:m,author:l?{name:s}:s,repository:l?{url:a}:a,frameworkVersion:c};export default d;
1
+ import{CONFIG as e}from"../config.mjs";import{APPTYPE as r,author as o,description as t,framework as m,frameworkVersionStr as s,PACKAGENAME as i,PACKAGEVERSION as p,repository as a,SSR as f}from"../process-env.mjs";import{convertToCamelCase as n}from"../utils/index.mjs";let l="string"==typeof o,u={name:i,projectName:n(i),ssr:f,version:p,base:e.basename,type:r,routerMode:e.routerMode,prefixCls:e.prefixCls,theme:e.theme,description:t,author:l?{name:o}:o,repository:l?{url:a}:a,frameworkVersion:s,framework:m};export default u;
@@ -7,6 +7,7 @@ import paths from '../commom/paths.mjs';
7
7
  import Rule from '../commom/rule.mjs';
8
8
  import { CONFIG } from '../config.mjs';
9
9
  import moduleFederation from '../plugin/module-federation.mjs';
10
+ import type { VirtualModulePluginOption } from '../plugin/virtual-module.mjs';
10
11
  import { APPTYPE, FRAMEWORK } from '../process-env.mjs';
11
12
  import createTypes from '../utils/create-types.mjs';
12
13
  import { generateDeclaration } from '../utils/dts.mjs';
@@ -15,11 +16,13 @@ import getCoverage from './coverage.mjs';
15
16
  import { docs, docsModuleName } from './docs.mjs';
16
17
  import info from './info.mjs';
17
18
  import { locales, localesModuleName } from './locales.mjs';
19
+ import renderApp from './render-app.mjs';
18
20
  import { route, routesModuleName } from './routes.mjs';
19
21
  declare const mdxScope: string | false;
20
22
  declare const normalModules: Record<string, string>;
21
23
  declare const appDtsPath: string;
22
24
  declare const appDts: string[];
23
25
  declare const vmDtsPath: string;
26
+ declare const virtualModule: VirtualModulePluginOption;
24
27
  declare const customVirtualModuleDts: string[];
25
28
  export default normalModules;
@@ -1 +1 @@
1
- import{join as o}from"node:path";import{getAppEntry as m,getAppFallback as p,getAppMdxScope as t,getAppMergeRouter as e,getAppNormalizeCss as r,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as i}from"@moneko/mdx";import{updateFileSync as f}from"@moneko/utils";import n from"../commom/has-pkg.mjs";import l from"../commom/parse-module-meta.mjs";import d from"../commom/paths.mjs";import c from"../commom/rule.mjs";import{CONFIG as u}from"../config.mjs";import x from"../plugin/module-federation.mjs";import{APPTYPE as j,FRAMEWORK as g}from"../process-env.mjs";import v from"../utils/create-types.mjs";import{generateDeclaration as y}from"../utils/dts.mjs";import{node_modules as h}from"../utils/index.mjs";import k from"./coverage.mjs";import{docs as O,docsModuleName as S}from"./docs.mjs";import b from"./info.mjs";import{locales as z,localesModuleName as D}from"./locales.mjs";import{route as J,routesModuleName as N}from"./routes.mjs";let $=n(o(u.alias["@"],"./mdx-scope.tsx"))||n(o(u.alias["@"],"./mdx-scope.ts")),C={"@app/env.ts":`export default ${JSON.stringify(u.env)}`,"@app/info.ts":`export default ${JSON.stringify(b)}`,"@app/entry.ts":m(o(u.alias["@"],"./index.ts"),!!x.length,!!u.rem,!!u.normalizeCss,j,g),"@app/rem":a(u.rem?.designSize||1680),"@app/fallback":p(u.fallbackCompPath),"@app/coverage":k(d.coveragePath),"@app/merge-router":e(),"@app/prefix-router":s(),"@app/normalize/index.css":r(),"@app/suspense/index.tsx":i(j,g),"@app/mdx-scope.tsx":$?t($):"export default {}","@app/routes":J.getData(N),"@app/locales":z.getData(D),"@app/docs":O.getData(S)};f(h("@types/@app/index.d.ts"),["@app/env.ts","@app/info.ts","@app/entry.ts","@app/mdx-scope.tsx"].map(o=>v(o.replace(c.js,""),y(C[o],o))).join("\n")),f(h("@types/@vm/index.d.ts"),Object.keys(u.virtualModule).map(o=>{let m=u.virtualModule[o],{file:p}=l(o);return v(o,y("string"==typeof m?m:`export default ${JSON.stringify(m)}`,p))}).join("\n"));export default C;
1
+ import{join as m}from"node:path";import{getAppEntry as o,getAppFallback as p,getAppMdxScope as e,getAppMergeRouter as t,getAppNormalizeCss as r,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as i}from"@moneko/mdx";import{updateFileSync as n}from"@moneko/utils";import f from"../commom/has-pkg.mjs";import l from"../commom/parse-module-meta.mjs";import d from"../commom/paths.mjs";import c from"../commom/rule.mjs";import{CONFIG as x}from"../config.mjs";import u from"../plugin/module-federation.mjs";import{APPTYPE as j,FRAMEWORK as g}from"../process-env.mjs";import y from"../utils/create-types.mjs";import{generateDeclaration as v}from"../utils/dts.mjs";import{node_modules as h}from"../utils/index.mjs";import k from"./coverage.mjs";import{docs as O,docsModuleName as S}from"./docs.mjs";import b from"./info.mjs";import{locales as z,localesModuleName as D}from"./locales.mjs";import J from"./render-app.mjs";import{route as N,routesModuleName as $}from"./routes.mjs";let C=f(m(x.alias["@"],"./mdx-scope.tsx"))||f(m(x.alias["@"],"./mdx-scope.ts")),P={"@app/env.ts":`export default ${JSON.stringify(x.env)}`,"@app/info.ts":`export default ${JSON.stringify(b)}`,"@app/render.tsx":"react"===g?J:"","@app/entry.ts":o(m(x.alias["@"],"./index.ts"),!!u.length,!!x.rem,!!x.normalizeCss,j,g),"@app/rem":a(x.rem?.designSize||1680),"@app/fallback":p(x.fallbackCompPath),"@app/coverage":k(d.coveragePath),"@app/merge-router":t(),"@app/prefix-router":s(),"@app/normalize/index.css":r(),"@app/suspense/index.tsx":i(j,g),"@app/mdx-scope.tsx":C?e(C):"export default {}","@app/routes":N.getData($),"@app/locales":z.getData(D),"@app/docs":O.getData(S)};n(h("@types/@app/index.d.ts"),["@app/env.ts","@app/info.ts","@app/entry.ts","@app/mdx-scope.tsx"].map(m=>y(m.replace(c.js,""),v(P[m],m))).join("\n"));let M=h("@types/@vm/index.d.ts"),q=x.virtualModule||{};n(M,Object.keys(q).map(m=>{let o=q[m],{file:p}=l(m);return y(m,v("string"==typeof o?o:`export default ${JSON.stringify(o)}`,p))}).join("\n"));export default P;
@@ -0,0 +1,8 @@
1
+ import { CONFIG } from '../config.mjs';
2
+ import { APPTYPE, frameworkVersion, isDev, SSR } from '../process-env.mjs';
3
+ declare const ReactDomPath: string;
4
+ declare const isHashRouter: boolean;
5
+ declare const v7Future: Record<string, boolean | undefined>;
6
+ declare const createRouter: string;
7
+ declare const renderApp: string;
8
+ export default renderApp;
@@ -0,0 +1,41 @@
1
+ import{CONFIG as e}from"../config.mjs";import{APPTYPE as r,frameworkVersion as t,isDev as a,SSR as n}from"../process-env.mjs";let o="hash"===e.routerMode,s=Object.assign({v7_relativeSplatPath:!1},"browser"===e.routerMode?{v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:n,v7_skipActionErrorRevalidation:!1}:{}),c=o?"createHashRouter":"createBrowserRouter",i=`import React, { StrictMode, useRef, type ReactElement } from 'react';
2
+ import Fallback from '@app/fallback';
3
+ import routes from '@app/routes';
4
+ import ReactDOM from '${t<18?"react-dom":"react-dom/client"}';
5
+ import { RouterProvider, ${c} } from 'react-router-dom';
6
+
7
+ type RenderAppProps = {
8
+ container?: HTMLElement;
9
+ basename?: string;
10
+ fallback?: ReactElement;
11
+ language?: string;
12
+ };
13
+
14
+ export function App(props: RenderAppProps) {
15
+ const v7Future = useRef(${JSON.stringify(s)});
16
+ return (
17
+ <StrictMode>
18
+ <RouterProvider
19
+ router={${c}(routes, {
20
+ basename: ${o?"/":"props.basename"},
21
+ window: window,
22
+ future: v7Future.current,
23
+ })}
24
+ future={{
25
+ /** 这使用 useTransition 而不是 useState 来更新路由器状态 */
26
+ v7_startTransition: false,
27
+ }}
28
+ fallbackElement={Fallback && <Fallback />}
29
+ />
30
+ </StrictMode>
31
+ );
32
+ }
33
+
34
+ function renderApp(props: RenderAppProps = {}) {
35
+ const { container, basename = "${e.basename}", language, ...args } = props;
36
+ const _container = container?.querySelector('#root') || document.getElementById('root');
37
+ ${"micro"===r?"window.mainApp = { ...args, container: _container as HTMLElement };":""}
38
+ ${t<18?`ReactDOM.${a?"render":"hydrate"}(<App basename={basename} language={language} />, _container);return () => ReactDOM.unmountComponentAtNode(_container as Element);`:"const instance = ReactDOM.createRoot(_container as HTMLElement);instance.render(<App basename={basename} language={language} />);return instance.unmount;"}
39
+ }
40
+
41
+ export default renderApp;`;export default i;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.27.6",
3
+ "version": "3.28.1",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -18,7 +18,8 @@
18
18
  "@fastify/compress": "7.0.3",
19
19
  "@fastify/http-proxy": "9.5.0",
20
20
  "@fastify/middie": "8.3.3",
21
- "@moneko/mdx": "0.1.42",
21
+ "@moneko/convert": "1.0.0",
22
+ "@moneko/mdx": "0.1.43",
22
23
  "@moneko/stylelint": "1.0.2",
23
24
  "@moneko/transform-imports": "0.6.1",
24
25
  "@moneko/utils": "0.1.22",