@moneko/core 3.27.4 → 3.27.6-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/build.mjs +1 -1
- package/lib/common.d.mts +5 -2
- package/lib/common.mjs +1 -1
- package/lib/dev.d.mts +0 -2
- package/lib/dev.mjs +1 -1
- package/lib/loader/lightning-css/loader.cjs +1 -1
- package/lib/loader/lightning-css/runtime/get-url.cjs +1 -1
- package/lib/loader/lightning-css/runtime/get-url.d.cts +5 -1
- package/lib/plugin/html-plugin.mjs +1 -1
- package/lib/vm/info.d.mts +2 -1
- package/lib/vm/info.mjs +1 -1
- package/lib/vm/modules.d.mts +2 -0
- package/lib/vm/modules.mjs +1 -1
- package/package.json +2 -2
- package/typings/global.d.ts +2 -2
package/lib/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as o}from"node:path";import{analyzeBundleSize as
|
|
1
|
+
import{relative as o}from"node:path";import{analyzeBundleSize as r,completedInfo as m,ink as i,println as t,progressBar as e}from"@moneko/utils";import n from"webpack";import{merge as s}from"webpack-merge";import a from"./build/common.mjs";import p from"./commom/paths.mjs";import l from"./plugin/done.mjs";import{empty as u}from"./utils/index.mjs";import c from"./utils/seo.mjs";import{CONFIG as g}from"./config.mjs";import f from"./module.config.mjs";let d=s(a,{module:f(!1),plugins:[]});if(g.done&&d.plugins.push(new l({done:g.done})),g.bar){let o=g.bar,r=o.name||"Build";d.plugins.push(new n.ProgressPlugin({handler(m,i,...t){e(m||0,1,{msg:t.length?`[${i}] ${t.join(" ")}`:"",name:r,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===m&&process.stdout.write("\r\x1b[2K")}}))}let h=n(d);async function w(){let e=await new Promise((o,r)=>{h.run((m,i)=>{m&&r(m),i?o(i):r(Error("编译过程中没有生成统计信息"))})});(e.hasErrors()||e.hasWarnings())&&function(o){let{warnings:r,errors:m}=o.compilation;r.forEach(o=>{t(i(o.message,"178"))}),m.forEach(o=>{t(i(o.message,"red"))})}(e),await new Promise(n=>{e.compilation.compiler.cache.shutdown(s=>{s&&t(i(s.toString(),"red")),r(e.compilation.outputOptions.path,["\\.js$"]),m(~~((e.endTime-e.startTime)/10)/100,o(p.programPath,e.compilation.outputOptions.path)),n()})}),g.seo&&c()}process.on("exit",u),await w();
|
package/lib/common.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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
|
|
4
|
+
import require from './commom/require.mjs';
|
|
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';
|
|
7
8
|
import app from './vm/info.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:
|
|
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
|
|
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/dev.d.mts
CHANGED
|
@@ -34,8 +34,6 @@ declare const hmrPath: string;
|
|
|
34
34
|
declare const clientParams: ClientOptions;
|
|
35
35
|
declare const hotParams: string;
|
|
36
36
|
declare const path: string | undefined;
|
|
37
|
-
declare const bar: ConfigType['bar'];
|
|
38
|
-
declare const bar_name: string;
|
|
39
37
|
declare const clientOption: webpack.Configuration;
|
|
40
38
|
declare const compilers: webpack.Compiler;
|
|
41
39
|
interface FastifyOptions {
|
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
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return u}});const t=require("lightningcss"),r=(e=require("../../commom/log.mjs"))&&e.__esModule?e:{default:e},
|
|
1
|
+
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return u}});const t=require("lightningcss"),r=(e=require("../../commom/log.mjs"))&&e.__esModule?e:{default:e},s=require("./codegen.cjs"),i=require("./utils.cjs");function o(e,t){return JSON.stringify(e.utils.contextify(e.context||e.rootContext,t))}const l=new TextEncoder,n={Declaration:{custom(e){if("content"===e.name&&1===e.value.length){let t=e.value[0];if("token"===t.type&&"string"===t.value.type)return[{property:e.name,raw:JSON.stringify(t.value.value.replace(/[\u4e00-\u9faF]/g,function(e){return`\\${e.charCodeAt(0).toString(16)}`}))}]}}}};async function u(e,u){let _=this.async();this.cacheable&&this.cacheable();let{implementation:a,visitor:p,rem:c,...f}=this.getOptions(),m=!!f.modules?.auto?.(this.resourcePath);if(m&&void 0===f.modules.namedExport&&(f.modules.namedExport=!0),a&&"function"!=typeof a.transform){_(TypeError(`[lightning-loader]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof a.transform}`));return}let d=[],h=[],R=[],S=[],g=[];f.modules?.exportOnlyLocals!==!0&&h.unshift({type:"api_import",importName:"___CSS_LOADER_API_IMPORT___",url:o(this,require.resolve("./runtime/api.cjs"))});let y=a?.transform?a.transform:t.transform,L=new Map,O=new Map,E=new Map,v=function(e,t,r,s,o,l){let n=new Map,u=!1,_=new Map,a=new Map,p=-1,c=-1;return{Rule:{import(s){let o;if(e.importFilter&&!e.importFilter(s.value.url,s.value.media))return s;let u=s.value.url;c++,l.set(c,u),u=`__MO_LIGHTNINGCSS_LOADER_IMPORT_URL_REPLACE_${c}__`;let _=s.value.media.mediaQueries.length?JSON.stringify(s.value.media.mediaQueries):void 0,a=(0,i.isUrlRequestable)(u);if(a){let e=u.split("!");e.length>1&&(u=e.pop(),o=e.join("!"))}if(!a)return t.push({url:u,media:_}),{type:"ignored",value:""};let p=o?`${o}!${u}`:u,f=n.get(p);if(!f){f=`___CSS_LOADER_AT_RULE_IMPORT_${n.size}___`,n.set(p,f);let t=e.urlHandler(p);r.push({type:"rule_import",importName:f,url:t})}return t.push({importName:f,media:_}),{type:"ignored",value:""}}},Url:t=>(function(t){let l,n=t.url;if(!e.urlFilter(n)||(0,i.isDataUrl)(n))return t;p++,o.set(p,n);let[,c,f]=(n=`__MO_LIGHTNINGCSS_LOADER_URL_REPLACE_${p}__`).split(/(\?)?#/,3),m=n.split("!");m.length>1&&(n=m.pop(),l=m.join("!"));let d=c?"?":"";d+=f?`#${f}`:"",u||(r.push({type:"get_url_import",importName:"___CSS_LOADER_GET_URL_IMPORT___",url:JSON.stringify(require.resolve("./runtime/get-url.cjs")),index:-1}),u=!0);let h=l?`${l}!${n}`:n,R=_.get(h);R||(R=`___CSS_LOADER_URL_IMPORT_${_.size}___`,_.set(h,R),r.push({type:"url",importName:R,url:JSON.stringify(h),index:p}));let S=JSON.stringify({newUrl:h,hash:d,needQuotes:!1}),g=a.get(S);return g||(g=`___CSS_LOADER_URL_REPLACEMENT_${a.size}___`,a.set(S,g),s.push({replacementName:g,importName:R,hash:d,needQuotes:!1})),{loc:t.loc,url:g}})(t)}}({urlHandler:e=>o(this,(0,i.getPreRequester)(this)(f.importLoaders??0)+e),urlFilter:(0,i.getFilter)(f.url,this.resourcePath),importFilter:(0,i.getFilter)(f.import,this.resourcePath),context:this.context},S,h,g,L,E),C=function({apis:e,imports:t,replacements:r,replacedUrls:s,urlHandler:i}){let o=-1,l=-1;return{Declaration:{composes(n){if("unparsed"===n.property)return;let u=n.value.from;if(u?.type!=="file")return;let _=u.value;if(!_)return;o++,s.set(o,_),_=`__MO_LIGHTNINGCSS_LOADER_ICSS_URL_REPLACE_${o}__`;let a=`___CSS_LOADER_ICSS_IMPORT_${t.length}___`;t.push({type:"icss_import",importName:a,icss:!0,url:i(_),index:o}),e.push({importName:a,dedupe:!0,index:o});let p=[];for(let e of n.value.names){l++;let t=`___CSS_LOADER_ICSS_IMPORT_${o}_REPLACEMENT_${l}___`;r.push({replacementName:t,importName:a,localName:e}),p.push(t)}return{property:"composes",value:{loc:n.value.loc,names:p,from:u}}}}}}({apis:S,imports:R,replacements:g,replacedUrls:O,urlHandler:e=>o(this,(0,i.getPreRequester)(this)(f.importLoaders)+e)});try{c&&!n.Length&&(n.Length=function(e){if("px"===e.unit)return{unit:"rem",value:e.value/16}});let{code:t,map:r,exports:o}=y({filename:this.resourcePath,code:l.encode(e),minify:!0,visitor:{...n,...v,...C,...p},cssModules:!!m&&{pattern:f.modules.localIdentName},sourceMap:this.sourceMap,inputSourceMap:this.sourceMap&&u?JSON.stringify(u):void 0,analyzeDependencies:!1,drafts:{customMedia:!0},include:1,errorRecovery:!1,unusedSymbols:[],...f}),a=t.toString();if(o){for(let e in o)if(Object.prototype.hasOwnProperty.call(o,e)){let t=o[e],r=t.name;for(let e of t.composes)r+=` ${e.name}`;d.push({name:e,value:r})}f.modules.getJSON?.({resourcePath:this.resourcePath,exports:d})}if(0!==L.size){let e=this.getResolve({conditionNames:["asset"],mainFields:["asset"],mainFiles:[],extensions:[]});for(let[t,r]of L.entries()){let[s]=r.split(/(\?)?#/,3),o=(0,i.requestify)(s,this.rootContext),l=await (0,i.resolveRequests)(e,this.context,[...new Set([o,r])]);for(let e of h)e.url=e.url.replace(`__MO_LIGHTNINGCSS_LOADER_URL_REPLACE_${t}__`,l??r)}}if(0!==E.size){let e=this.getResolve({conditionNames:["style"],extensions:[".css"],mainFields:["css","style","main","..."],mainFiles:["index","..."],restrictions:[/\.css$/i]});for(let[t,r]of E.entries()){let[s]=r.split(/(\?)?#/,3),o=(0,i.requestify)(s,this.rootContext),l=await (0,i.resolveRequests)(e,this.context,[...new Set([o,r])]);for(let e of h)e.url=e.url.replace(`__MO_LIGHTNINGCSS_LOADER_IMPORT_URL_REPLACE_${t}__`,l??r)}}if(0!==O.size){let e=this.getResolve({conditionNames:["style"],extensions:[],mainFields:["css","style","main","..."],mainFiles:["index","..."]});for(let[t,r]of O.entries()){let[s]=r.split(/(\?)?#/,3),o=(0,i.requestify)(s,this.rootContext),l=await (0,i.resolveRequests)(e,this.context,[...new Set([r,o])]);for(let e of R)e.url=e.url.replace(`__MO_LIGHTNINGCSS_LOADER_ICSS_URL_REPLACE_${t}__`,l??r)}}h.push(...R);let M=(0,s.getImportCode)(h,f),N=(0,s.getModuleCode)({css:a,map:r},S,g,f,this),x=(0,s.getExportCode)(d,g,f),P=`${M}${N}${x}`;_(null,P,r&&JSON.parse(r.toString()))}catch(e){_(e),(0,r.default)(e)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";module.exports=function(a
|
|
1
|
+
"use strict";module.exports=function(e,a){return(a||(a={}),"string"!=typeof(e=e&&e.__esModule?e.default:e))?"Buffer"===e.type&&e.data?`data:${function(e){let a=(function(e,a=0){return e.slice(a,16).map(e=>e.toString(16).padStart(2,"0")).join("")})(e,0).toLowerCase();for(let[e,f]of Object.entries({"0001000000":"font/ttf","4f54544f":"font/otf","774f4646":"font/woff","774f4632":"font/woff2","89504e470d0a1a0a":"image/png",ffd8ffe0:"image/jpeg",ffd8ffdb:"image/jpeg",ffd8ffee:"image/jpeg",ffd8ffe000104a4649460001:"image/jpeg","ffd8ffe1????457869660000":"image/jpeg","0000000c4a584c200d0a870a":"image/jxl","474946383761":"image/gif","474946383961":"image/gif","49492a00":"image/tif","49492b00":"image/tif","4d4d002a":"image/tiff","4d4d002b":"image/tiff","52494646????????57454250":"image/webp","424d":"image/bmp","00000100":"image/x-icon","69636e73":"image/x-icns","6674797068656963":"image/heic","667479706d":"image/heic",ff4fff51:"image/jp2","0000000c6a5020200d0a870a":"image/jp2","667479704d534e56":"video/mp4","6674797069736f6d":"video/mp4","1a45dfa3":"video/webm","52494646????????41564920":"video/avi","000001ba":"video/mpeg","000001b3":"video/mpeg","464c56":"video/x-flv",494433:"audio/mpeg","4f676753":"audio/ogg","52494646????????57415645":"audio/wav","664c6143":"audio/flac","4d546864":"audio/midi","3026b2758e66cf11a6d900aa0062ce6c":"application/x-ms-asf"}))if(a.startsWith(e))return f;return"unknown"}(e.data)};base64,${btoa(Array.from(e.data,e=>String.fromCharCode(e)).join(""))}`:e:(/^['"].*['"]$/.test(e)&&(e=e.slice(1,-1)),a.hash&&(e+=a.hash),/["'() \t\n]/.test(e)||a.needQuotes)?'"'.concat(e.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):e};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
type Url = {
|
|
2
2
|
__esModule?: boolean;
|
|
3
3
|
default: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
data?: number[];
|
|
4
6
|
};
|
|
5
|
-
declare function
|
|
7
|
+
declare function uint8ArrayToBase64(numberArray: number[]);
|
|
8
|
+
declare function numberArrayToHex(buffer: number[], start?: number);
|
|
9
|
+
declare function getMimeType(buffer: number[]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import
|
|
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\.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(),e=this.generateCustomTags();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}">${e.head}</head><body><div id="root"></div>${e.body}</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}}
|
package/lib/vm/info.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import require from '../commom/require.mjs';
|
|
|
2
2
|
import { CONFIG } from '../config.mjs';
|
|
3
3
|
import { APPTYPE, author, description, FRAMEWORK, PACKAGENAME, PACKAGEVERSION, repository, SSR } from '../process-env.mjs';
|
|
4
4
|
import { convertToCamelCase } from '../utils/index.mjs';
|
|
5
|
-
declare const framework:
|
|
5
|
+
declare const framework: 'react' | 'solid-js';
|
|
6
6
|
declare const frameworkVersion: string;
|
|
7
7
|
declare const iStr: boolean;
|
|
8
8
|
declare const app: {
|
|
@@ -19,5 +19,6 @@ declare const app: {
|
|
|
19
19
|
readonly author;
|
|
20
20
|
readonly repository;
|
|
21
21
|
readonly frameworkVersion;
|
|
22
|
+
readonly ReactDomEntry: string | undefined;
|
|
22
23
|
};
|
|
23
24
|
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
|
|
1
|
+
import e from"../commom/require.mjs";import{CONFIG as r}from"../config.mjs";import{APPTYPE as o,author as t,description as m,FRAMEWORK as s,PACKAGENAME as i,PACKAGEVERSION as a,repository as n,SSR as c}from"../process-env.mjs";import{convertToCamelCase as p}from"../utils/index.mjs";let l={react:"react",solid:"solid-js"}[s],d=e(`${l}/package.json`).version,f="string"==typeof t,j={name:i,projectName:p(i),ssr:c,version:a,base:r.basename,type:o,routerMode:r.routerMode,prefixCls:r.prefixCls,theme:r.theme,description:m,author:f?{name:t}:t,repository:f?{url:n}:n,frameworkVersion:d,ReactDomEntry:void 0};if("react"===l){let e=parseFloat(d);j.ReactDomEntry=e<18?"react-dom":"react-dom/client"}else delete j.ReactDomEntry;export default j;
|
package/lib/vm/modules.d.mts
CHANGED
|
@@ -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';
|
|
@@ -21,5 +22,6 @@ declare const normalModules: Record<string, string>;
|
|
|
21
22
|
declare const appDtsPath: string;
|
|
22
23
|
declare const appDts: string[];
|
|
23
24
|
declare const vmDtsPath: string;
|
|
25
|
+
declare const virtualModule: VirtualModulePluginOption;
|
|
24
26
|
declare const customVirtualModuleDts: string[];
|
|
25
27
|
export default normalModules;
|
package/lib/vm/modules.mjs
CHANGED
|
@@ -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
|
|
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 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{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=>y(o.replace(c.js,""),v(C[o],o))).join("\n"));let P=h("@types/@vm/index.d.ts"),M=u.virtualModule||{};f(P,Object.keys(M).map(o=>{let m=M[o],{file:p}=l(o);return y(o,v("string"==typeof m?m:`export default ${JSON.stringify(m)}`,p))}).join("\n"));export default C;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.27.
|
|
3
|
+
"version": "3.27.6-beta.0",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
50
50
|
"@types/webpack-hot-middleware": "2.25.9",
|
|
51
51
|
"eslint-config-neko": "3.0.3",
|
|
52
|
-
"sass": "1.83.
|
|
52
|
+
"sass": "1.83.1",
|
|
53
53
|
"sass-loader": "16.0.4",
|
|
54
54
|
"solid-refresh": "0.7.5",
|
|
55
55
|
"stylis": "4.3.4",
|
package/typings/global.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ import type {
|
|
|
20
20
|
OverrideResolverOption,
|
|
21
21
|
ProxyConfig,
|
|
22
22
|
VirtualModulePluginOption,
|
|
23
|
-
} from '../lib/index';
|
|
23
|
+
} from '../lib/index.mjs';
|
|
24
24
|
import type { CopyPluginOption } from '../lib/plugin/copy.mjs';
|
|
25
|
-
import type { DonePluginOption } from '../lib/plugin/done';
|
|
25
|
+
import type { DonePluginOption } from '../lib/plugin/done.mjs';
|
|
26
26
|
|
|
27
27
|
import type { BundleAnalyzerOption } from './bundle-analyzer.d';
|
|
28
28
|
|