@moneko/core 3.9.17-beta.17 → 3.9.17-beta.19

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 +1 @@
1
- import e from"mini-css-extract-plugin";import i from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as n}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import{commonConfig as o}from"../common.mjs";import{CONFIG as t}from"../config.mjs";import{getMinifyOption as l}from"../options/js-minify.mjs";import p from"../plugin/lightningcss-plugin.mjs";let{optimize:{MinChunkSizePlugin:s,ModuleConcatenationPlugin:u}}=m,a=r(o,{plugins:[new u,new e({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),t.splitChunk&&new s({minChunkSize:1e4}),t.bundleAnalyzer&&new n(t.bundleAnalyzer)].filter(Boolean),optimization:{splitChunks:t.splitChunk,runtimeChunk:t.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:!!t.minifier&&[new i(l(t.minifier?.type||"swc",t.minifier?.options)),new p]||[]}});export default a;
1
+ import e from"mini-css-extract-plugin";import i from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as n}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import{commonConfig as o}from"../common.mjs";import{CONFIG as t}from"../config.mjs";import{getMinifyOption as l}from"../options/js-minify.mjs";import{LightningCssMinifyPlugin as p}from"../plugin/lightningcss-plugin.mjs";let{optimize:{MinChunkSizePlugin:s,ModuleConcatenationPlugin:u}}=m,a=r(o,{plugins:[new u,new e({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),t.splitChunk&&new s({minChunkSize:1e4}),t.bundleAnalyzer&&new n(t.bundleAnalyzer)].filter(Boolean),optimization:{splitChunks:t.splitChunk,runtimeChunk:t.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:t.minifier&&[new i(l(t.minifier.type,t.minifier.options)),new p]||[]}});export default a;
package/lib/dev/mock.mjs CHANGED
@@ -1 +1 @@
1
- import e from"http";import{watch as t}from"chokidar";import o from"express";import{mock as r}from"mock-json-schema";import{match as a}from"path-to-regexp";import{merge as s}from"webpack-merge";import n from"../utils/esm.mjs";import i from"../utils/log.mjs";import p from"../utils/tfc.mjs";function c(e,t,o){if(o[t]){for(let r in o[t])Object.prototype.hasOwnProperty.call(o[t],r)&&delete e[r];o[t]=null,delete o[t]}}export const yApiSchemaMock=(t,o)=>new Promise((a,n)=>{e.get(`${t.host}/api/interface/get?id=${t.id}&token=${t.token}`,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{let e=JSON.parse(t);if(e?.data?.res_body_is_json_schema){let t=JSON.parse(e.data.res_body),n=r(t);void 0!==o?a(s(n,o)):a(n)}}catch(e){n(e)}})})});export const yApiMock=(t,o)=>new Promise((r,a)=>{let s=new URL(o.host),n={hostname:s.hostname,port:s.port,path:t.path.replace(new RegExp(o.pathRewrite),`/mock/${o.projectId}/`),method:t.method,headers:t.headers,query:t.query},i=e.request(n,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{r(JSON.parse(t))}catch(e){a(e)}})});i.on("error",e=>{a(e.message)}),i.write(JSON.stringify(t.body)),i.end()});export default(e=>{let r={},s={};return t(e).on("all",async function(e,t){process.stdout.write("update mock...");let o={};switch(e){case"add":case"change":c(s,t,r),o=(await import(n`${p(t)}`)).default,r[t]=o,s=Object.assign(s,o);break;case"unlink":c(s,t,r)}i("update mock success")}),function(e,t,r){let n=`${e.method} ${e.path}`,i=Object.keys(s).filter(function(e){return RegExp(`^${e.replace(/(:\w*)[^/]/g,"((?!/).)")}*$`).test(n)});if(!s[n]&&(!i||!(i.length>0)))return r();{let p;let c=e.get("Content-Type");switch(c){case"text/plain":p=o.raw({type:"text/plain"});break;case"text/html":p=o.text({type:"text/html"});break;case"application/x-www-form-urlencoded":p=o.urlencoded({extended:!1});break;default:p=o.json()}c?.startsWith("multipart/form-data;")&&(p=o.static("./public")),p(e,t,function(){let o=s[n]||s[i[0]];if("function"==typeof o){let s=a(i[0].split(" ")[1])(e.url);s&&Object.assign(e.params,s.params),o(e,t,r)}else t.json(o)})}}});
1
+ import t from"http";import{watch as e}from"chokidar";import o from"express";import{mock as r}from"mock-json-schema";import{merge as a}from"webpack-merge";import s from"../utils/esm.mjs";import n from"../utils/log.mjs";import i from"../utils/match-path.mjs";import c from"../utils/tfc.mjs";function p(t,e,o){if(o[e]){for(let r in o[e])Object.prototype.hasOwnProperty.call(o[e],r)&&delete t[r];o[e]=null,delete o[e]}}export const yApiSchemaMock=(e,o)=>new Promise((s,n)=>{t.get(`${e.host}/api/interface/get?id=${e.id}&token=${e.token}`,t=>{t.setEncoding("utf8");let e="";t.on("data",t=>{e+=t}),t.on("end",()=>{try{let t=JSON.parse(e);if(t?.data?.res_body_is_json_schema){let e=JSON.parse(t.data.res_body),n=r(e);void 0!==o?s(a(n,o)):s(n)}}catch(t){n(t)}})})});export const yApiMock=(e,o)=>new Promise((r,a)=>{let s=new URL(o.host),n={hostname:s.hostname,port:s.port,path:e.path.replace(new RegExp(o.pathRewrite),`/mock/${o.projectId}/`),method:e.method,headers:e.headers,query:e.query},i=t.request(n,t=>{t.setEncoding("utf8");let e="";t.on("data",t=>{e+=t}),t.on("end",()=>{try{r(JSON.parse(e))}catch(t){a(t)}})});i.on("error",t=>{a(t.message)}),i.write(JSON.stringify(e.body)),i.end()});export default(t=>{let r={},a={};return e(t).on("all",async function(t,e){process.stdout.write("update mock...");let o={};switch(t){case"add":case"change":p(a,e,r),o=(await import(s`${c(e)}`)).default,r[e]=o,a=Object.assign(a,o);break;case"unlink":p(a,e,r)}n("update mock success")}),function(t,e,r){let s=`${t.method} ${t.path}`,n=Object.keys(a).filter(function(t){return RegExp(`^${t.replace(/(:\w*)[^/]/g,"((?!/).)")}*$`).test(s)});if(!a[s]&&(!n||!(n.length>0)))return r();{let c;let p=t.get("Content-Type");switch(p){case"text/plain":c=o.raw({type:"text/plain"});break;case"text/html":c=o.text({type:"text/html"});break;case"application/x-www-form-urlencoded":c=o.urlencoded({extended:!1});break;default:c=o.json()}p?.startsWith("multipart/form-data;")&&(c=o.static("./public")),c(t,e,function(){let o=a[s]||a[n[0]];if("function"==typeof o){let a=i(n[0].split(" ")[1],t.url);a&&Object.assign(t.params,a.params),o(t,e,r)}else e.json(o)})}}});
package/lib/dev.mjs CHANGED
@@ -1 +1 @@
1
- import{directoryExists as e,removeDirAll as t}from"@moneko/mdx";import o from"cors";import i from"express";import r from"multer";import m from"webpack";import s from"webpack-dev-middleware";import l from"webpack-hot-middleware";import{merge as a}from"webpack-merge";import n from"webpackbar";import p from"./build/server.mjs";import{commonConfig as c}from"./common.mjs";import{CONFIG as d}from"./config.mjs";import{PORT as u,devLog as f,headers as h}from"./dev/config.mjs";import w from"./dev/mock.mjs";import g from"./dev/proxy.mjs";import x from"./module.config.mjs";import j from"./paths.mjs";import{SSR as k,isLibrary as b,isReact as y}from"./process-env.mjs";import v from"./rule.mjs";import $ from"./utils/compiler-listener.mjs";import _ from"./utils/has-pkg.mjs";import{resolveProgramPath as P}from"./utils/index.mjs";let S=_("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,D=_("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,T=y&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,B=["js","jsx","ts","tsx","json","html","vue"],I=B.join(","),E=["css","scss","sass","less","ts","tsx","js","jsx"],F=E.join(","),G=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],M=new URLSearchParams({timeout:2e3,reload:!0,quiet:!0,noInfo:!0,overlay:!0,dynamicPublicPath:!0}).toString(),O=c.output.path;k&&(O=P(`${b?"docs":"dist"}/client`));let R=a(c,{entry:{main:[`webpack-hot-middleware/client?name=client&path=//localhost:${u}/__hmr__&${M}`]},output:{path:O},module:x(!1),plugins:[T&&new T,D&&new D({fix:!0,threads:!0,files:[`${d.alias["@"]}/**/*.{${I}}`,b&&`${d.alias["@pkg"]}/**/*.{${I}}`].filter(Boolean),extensions:B,exclude:G,cache:!0,lintDirtyModulesOnly:!0}),S&&new S({fix:!0,threads:!0,files:[`${d.alias["@"]}/**/*.{${F}}`,b&&`${d.alias["@pkg"]}/**/*.{${F}}`].filter(Boolean),extensions:E,exclude:G,cache:!0,lintDirtyModulesOnly:!0}),d.bar&&new n(d.bar)].filter(Boolean)}),U=[R];k&&U.push(a(c,p));let[q,L]=m(U).compilers;q.hooks.done.tap("client",e=>{f(null,e)});let N=i(),z=r(),A=s(q,{writeToDisk:!1,index:"index.html",headers:()=>h,serverSideRender:k});if(N.use(o()),N.use(A),N.use(l(q,{log:!1,path:"/__hmr__",heartbeat:2e3,ignoreUnaccepted:!1,ignoreDeclined:!0,ignoreErrored:!0})),d.proxy&&g(N,d.proxy),e(j.mockPath)){let e=w(j.mockPath);N.use(e)}let C=`${R.output.path}/index.html`;N.all("/*",z.any(),function(e,t,o){if("GET"!==e.method)return o();{let e=A.context.outputFileSystem,o=e?.readFileSync?.(C);t.end(o)}});let H=[$("client",q)];L&&(L.watch({aggregateTimeout:20,ignored:v.dev_watch_ignored,poll:1e3,stdin:!0},f),H.push($("server",L))),await Promise.all(H),N.listen(u,()=>{}),process.on("exit",function(){t(j.cachePath)}),process.on("SIGINT",function(){process.exit()});
1
+ import{directoryExists as e,removeDirAll as t}from"@moneko/mdx";import o from"express";import i from"multer";import r from"webpack";import m from"webpack-dev-middleware";import s from"webpack-hot-middleware";import{merge as l}from"webpack-merge";import a from"webpackbar";import n from"./build/server.mjs";import{commonConfig as p}from"./common.mjs";import{CONFIG as c}from"./config.mjs";import{PORT as d,devLog as u,headers as f}from"./dev/config.mjs";import h from"./dev/mock.mjs";import w from"./dev/proxy.mjs";import g from"./module.config.mjs";import x from"./paths.mjs";import{SSR as j,isLibrary as k,isReact as b}from"./process-env.mjs";import y from"./rule.mjs";import v from"./utils/compiler-listener.mjs";import $ from"./utils/has-pkg.mjs";import{resolveProgramPath as _}from"./utils/index.mjs";let{HotModuleReplacementPlugin:P}=r,S=$("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,D=$("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,T=b&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,B=["js","jsx","ts","tsx","json","html","vue"],I=B.join(","),E=["css","scss","sass","less","ts","tsx","js","jsx"],F=E.join(","),G=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],M=new URLSearchParams({timeout:2e3,reload:!0,quiet:!0,noInfo:!0,overlay:!0,dynamicPublicPath:!0}).toString(),O=p.output.path;j&&(O=_(`${k?"docs":"dist"}/client`));let R=l(p,{entry:{main:[`webpack-hot-middleware/client?name=client&path=//localhost:${d}/__hmr__&${M}`]},output:{path:O},module:g(!1),plugins:[new P,T&&new T,D&&new D({fix:!0,threads:!0,files:[`${c.alias["@"]}/**/*.{${I}}`,k&&`${c.alias["@pkg"]}/**/*.{${I}}`].filter(Boolean),extensions:B,exclude:G,cache:!0,lintDirtyModulesOnly:!0}),S&&new S({fix:!0,threads:!0,files:[`${c.alias["@"]}/**/*.{${F}}`,k&&`${c.alias["@pkg"]}/**/*.{${F}}`].filter(Boolean),extensions:E,exclude:G,cache:!0,lintDirtyModulesOnly:!0}),c.bar&&new a(c.bar)].filter(Boolean)}),U=[R];j&&U.push(l(p,n));let[q,L]=r(U).compilers;q.hooks.done.tap("client",e=>{u(null,e)});let N=o(),z=i(),A=m(q,{writeToDisk:!1,index:"index.html",headers:()=>f,serverSideRender:j});if(N.use(A),N.use(s(q,{log:!1,path:"/__hmr__",heartbeat:2e3,ignoreUnaccepted:!1,ignoreDeclined:!0,ignoreErrored:!0})),c.proxy&&w(N,c.proxy),e(x.mockPath)){let e=h(x.mockPath);N.use(e)}let C=`${R.output.path}/index.html`;N.all("/*",z.any(),function(e,t,o){if("GET"!==e.method)return o();{let e=A.context.outputFileSystem,o=e?.readFileSync?.(C);t.end(o)}});let H=[v("client",q)];L&&(L.watch({aggregateTimeout:20,ignored:y.dev_watch_ignored,poll:1e3,stdin:!0},u),H.push(v("server",L))),await Promise.all(H),N.listen(d,()=>{}),process.on("exit",function(){t(x.cachePath)}),process.on("SIGINT",function(){process.exit()});
@@ -12,7 +12,7 @@ type MinifyObject = {
12
12
  };
13
13
  };
14
14
  export declare const minify: MinifyObject;
15
- export declare const getMinifyOption: (type: MinifierType, options?: SwcMinifyOptions | TerserMinifyOptions) => ({
15
+ export declare const getMinifyOption: (type?: MinifierType, options?: SwcMinifyOptions | TerserMinifyOptions) => ({
16
16
  minify: typeof TerserPlugin.terserMinify;
17
17
  terserOptions: TerserMinifyOptions;
18
18
  extractComments?: boolean | undefined;
@@ -1 +1 @@
1
- import e from"terser-webpack-plugin";import{merge as o}from"webpack-merge";import{swcMinifyOption as r}from"./swcrc.mjs";export const minify={terser:{minify:e.terserMinify,terserOptions:{ecma:2015,parse:{},compress:{global_defs:{"@alert":"console.log"},drop_console:!0,drop_debugger:!0,pure_funcs:["console.log","console.warn","console.error","console.info"]},toplevel:!1,mangle:!0,module:!1,format:{comments:!1},ie8:!1,keep_classnames:void 0,keep_fnames:!1,safari10:!1},extractComments:!1},swc:{minify:e.swcMinify,terserOptions:r}};export const getMinifyOption=(e,r={})=>{let s=minify[e];return Object.assign(s,{terserOptions:o(s.terserOptions,r)})};
1
+ import e from"terser-webpack-plugin";import{merge as o}from"webpack-merge";import{swcMinifyOption as r}from"./swcrc.mjs";export const minify={terser:{minify:e.terserMinify,terserOptions:{ecma:2015,parse:{},compress:{global_defs:{"@alert":"console.log"},drop_console:!0,drop_debugger:!0,pure_funcs:["console.log","console.warn","console.error","console.info"]},toplevel:!1,mangle:!0,module:!1,format:{comments:!1},ie8:!1,keep_classnames:void 0,keep_fnames:!1,safari10:!1},extractComments:!1},swc:{minify:e.swcMinify,terserOptions:r}};export const getMinifyOption=(e="swc",r={})=>{let s=minify[e];return Object.assign(s,{terserOptions:o(s.terserOptions,r)})};
@@ -4,7 +4,7 @@ import type { Compiler } from 'webpack';
4
4
  * ```javascript
5
5
  * // 假设输出 main chunk 为 main.[hash].chunk.js。
6
6
  * // 提示:输出 chunk 的名称规范化可以在 output.filename 中配置
7
- * new AddEntryAttributeWebpackPlugin((src => {
7
+ * new AddEntryAttributePlugin((src => {
8
8
  * return !!(src.match(/main\.(.*)\.bundle.js$/) || src.match('main.bundle.js'));
9
9
  * })),
10
10
  * ```
@@ -1 +1 @@
1
- export class AddEntryAttributePlugin{constructor(t){this.test=t.test}apply(t){t.hooks.compilation.tap("AddEntryAttributeWebpackPlugin",s=>{t.options.plugins.filter(t=>t?.constructor.name==="HtmlWebpackPlugin").forEach(t=>{t.getHooks(s).alterAssetTagGroups.tap("AddEntryAttributeWebpackPlugin",t=>(t.headTags.forEach(t=>{"script"===t.tagName&&t.attributes.src&&this.test.test(t.attributes.src)&&(t.attributes.entry=!0)}),t))})})}}
1
+ let t="AddEntryAttributePlugin";export class AddEntryAttributePlugin{constructor(t){this.test=t.test}apply(s){s.hooks.compilation.tap(t,r=>{s.options.plugins.filter(t=>t?.constructor.name==="HtmlWebpackPlugin").forEach(s=>{s.getHooks(r).alterAssetTagGroups.tap(t,t=>(t.headTags.forEach(t=>{"script"===t.tagName&&t.attributes.src&&this.test.test(t.attributes.src)&&(t.attributes.entry=!0)}),t))})})}}
@@ -10,11 +10,11 @@ interface MinifyPluginOpts {
10
10
  exclude?: Filter | Filter[];
11
11
  targets?: Targets;
12
12
  }
13
- declare class LightningCssMinifyPlugin {
13
+ export declare class LightningCssMinifyPlugin {
14
14
  private readonly options;
15
15
  private readonly transform;
16
16
  constructor(opts?: MinifyPluginOpts);
17
17
  apply(compiler: Compiler): void;
18
18
  private transformAssets;
19
19
  }
20
- export default LightningCssMinifyPlugin;
20
+ export {};
@@ -1 +1 @@
1
- import{Buffer as s}from"buffer";import{loadFileSync as t}from"@moneko/mdx";import{transform as o}from"lightningcss";import i from"webpack";let{sources:{RawSource:n,SourceMapSource:e},ModuleFilenameHelpers:{matchObject:r}}=i,a="lightning-css-minify",m=/\.css(?:\?.*)?$/i,{name:p,version:f}=JSON.parse(t(`${process.cwd()}/package.json`)||"{}");export default class{constructor(s={}){let{implementation:t,...i}=s;if(t&&"function"!=typeof t.transform)throw TypeError(`[LightningCssMinifyPlugin]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof t.transform}`);this.transform=t?.transform??o,this.options=i}apply(s){let t=JSON.stringify({name:p,version:f,options:this.options});s.hooks.compilation.tap(a,s=>{s.hooks.chunkHash.tap(a,(s,o)=>o.update(t)),s.hooks.processAssets.tapPromise({name:a,stage:s.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async()=>await this.transformAssets(s)),s.hooks.statsPrinter.tap(a,s=>{s.hooks.print.for("asset.info.minimized").tap(a,(s,{green:t,formatFlag:o})=>s&&t&&o?t(o("minimized")):void 0)})})}async transformAssets(t){let{options:{devtool:o}}=t.compiler,{include:i,exclude:a,test:p,sourceMap:f=!!(o&&o.includes("source-map")),...c}=this.options,l=t.getAssets().filter(s=>!s.info.minimized&&(p||m).test(s.name)&&r({include:i,exclude:a},s.name));await Promise.all(l.map(async o=>{let i;let{source:r,map:a}=o.source.sourceAndMap(),m=r.toString(),p="string"==typeof r?s.from(r):r,l=this.transform({filename:o.name,code:p,minify:!0,sourceMap:f,...c}),h=l.code.toString();i=f?new e(h,o.name,JSON.parse(l.map.toString()),m,a,!0):new n(h),t.updateAsset(o.name,i,{...o.info,minimized:!0})}))}}
1
+ import{Buffer as s}from"buffer";import{loadFileSync as t}from"@moneko/mdx";import{transform as i}from"lightningcss";import o from"webpack";let{sources:{RawSource:n,SourceMapSource:e},ModuleFilenameHelpers:{matchObject:r}}=o,a="lightning-css-minify",m=/\.css(?:\?.*)?$/i,{name:p,version:f}=JSON.parse(t(`${process.cwd()}/package.json`)||"{}");export class LightningCssMinifyPlugin{constructor(s={}){let{implementation:t,...o}=s;if(t&&"function"!=typeof t.transform)throw TypeError(`[LightningCssMinifyPlugin]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof t.transform}`);this.transform=t?.transform??i,this.options=o}apply(s){let t=JSON.stringify({name:p,version:f,options:this.options});s.hooks.compilation.tap(a,s=>{s.hooks.chunkHash.tap(a,(s,i)=>i.update(t)),s.hooks.processAssets.tapPromise({name:a,stage:s.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async()=>await this.transformAssets(s)),s.hooks.statsPrinter.tap(a,s=>{s.hooks.print.for("asset.info.minimized").tap(a,(s,{green:t,formatFlag:i})=>s&&t&&i?t(i("minimized")):void 0)})})}async transformAssets(t){let{options:{devtool:i}}=t.compiler,{include:o,exclude:a,test:p,sourceMap:f=!!(i&&i.includes("source-map")),...c}=this.options,l=t.getAssets().filter(s=>!s.info.minimized&&(p||m).test(s.name)&&r({include:o,exclude:a},s.name));await Promise.all(l.map(async i=>{let o;let{source:r,map:a}=i.source.sourceAndMap(),m=r.toString(),p="string"==typeof r?s.from(r):r,l=this.transform({filename:i.name,code:p,minify:!0,sourceMap:f,...c}),g=l.code.toString();o=f?new e(g,i.name,JSON.parse(l.map.toString()),m,a,!0):new n(g),t.updateAsset(i.name,o,{...i.info,minimized:!0})}))}}
@@ -1 +1 @@
1
- import e from"add-asset-html-webpack-plugin";import t from"html-webpack-plugin";import l from"webpack";import{CONFIG as o}from"./config.mjs";import i from"./options/html-plugin-option.mjs";import{AddEntryAttributePlugin as n}from"./plugin/add-entry-attribute.mjs";import p from"./plugin/module-federation.mjs";import{VirtualModuleWebpackPlugin as r}from"./plugin/virtual-module.mjs";import{isDev as a,isMicro as s}from"./process-env.mjs";let{DefinePlugin:m,SourceMapDevToolPlugin:c,IgnorePlugin:h,WatchIgnorePlugin:u,HotModuleReplacementPlugin:f}=l,d=o.basename.split("/").filter(Boolean).length,w=`${Array(d).fill("..").join("/")+(d?"/":"")}404.html`,{pathSegmentsToKeep:g=d,path:j=w}=o.fixBrowserRouter||{},b=o.assetHtml.map(e=>({publicPath:"",...e})),v=[a&&new f,new u({paths:[/\.d\.ts$/]}),...p,new r(o.virtualModule),o.htmlPluginOption&&new t(i),o.fixBrowserRouter&&new t({filename:j,inject:!1,templateContent:()=>`<html lang="en"><head><title>${i.title}</title><script>const pathKeep = ${g||d};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new e(b),s&&new n({test:/main\.bundle\.js$/}),new m({"process.env":JSON.stringify(o.env)}),new h({resourceRegExp:/\/__tests__\//}),o.sourceMap&&new c(o.sourceMap),...o.plugins].filter(e=>!!e);export default v;
1
+ import e from"add-asset-html-webpack-plugin";import t from"html-webpack-plugin";import l from"webpack";import{CONFIG as o}from"./config.mjs";import i from"./options/html-plugin-option.mjs";import{AddEntryAttributePlugin as p}from"./plugin/add-entry-attribute.mjs";import r from"./plugin/module-federation.mjs";import{VirtualModuleWebpackPlugin as n}from"./plugin/virtual-module.mjs";import{isMicro as a}from"./process-env.mjs";let{DefinePlugin:s,SourceMapDevToolPlugin:m,IgnorePlugin:c,WatchIgnorePlugin:h}=l,u=o.basename.split("/").filter(Boolean).length,f=`${Array(u).fill("..").join("/")+(u?"/":"")}404.html`,{pathSegmentsToKeep:d=u,path:w=f}=o.fixBrowserRouter||{},g=o.assetHtml.map(e=>({publicPath:"",...e})),j=[new h({paths:[/\.d\.ts$/]}),...r,new n(o.virtualModule),o.htmlPluginOption&&new t(i),o.fixBrowserRouter&&new t({filename:w,inject:!1,templateContent:()=>`<html lang="en"><head><title>${i.title}</title><script>const pathKeep = ${d||u};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new e(g),a&&new p({test:/main\.bundle\.js$/}),new s({"process.env":JSON.stringify(o.env)}),new c({resourceRegExp:/\/__tests__\//}),o.sourceMap&&new m(o.sourceMap),...o.plugins].filter(e=>!!e);export default j;
@@ -0,0 +1,22 @@
1
+ type MatchPath = {
2
+ path: string;
3
+ params: Record<string, unknown>;
4
+ };
5
+ /**
6
+ * RESTful 风格api
7
+ * @param {String} pattern pattern
8
+ * @param {String} path paths
9
+ * @example
10
+ * const pattern = '/users/:id';
11
+ * const pathToMatch = '/users/123';
12
+ * const result = matchPath(pattern, pathToMatch);
13
+ * if (result) {
14
+ * console.log('Match found:', result);
15
+ * console.log('Params:', result.params);
16
+ * } else {
17
+ * console.log('No match found.');
18
+ * }
19
+ * @returns {MatchPath|null} MatchPath
20
+ */
21
+ declare function matchPath(pattern: string, path: string): MatchPath | null;
22
+ export default matchPath;
@@ -0,0 +1 @@
1
+ export default function(t,l){let e=t.split("/"),n=l.split("/");if(e.length!==n.length)return null;let r={};for(let t=0;t<e.length;t++){let l=e[t],i=n[t];if(l.startsWith(":"))r[l.slice(1)]=i;else if(l!==i)return null}return{path:l,params:r}}
package/lib/vm/docs.mjs CHANGED
@@ -1 +1 @@
1
- import{loadFileSync as e,scanFolder as t}from"@moneko/mdx";import o from"./generate-doc.mjs";import{CONFIG as r}from"../config.mjs";import{FRAMEWORK as n,isLibrary as a,isReact as s,isSolid as m}from"../process-env.mjs";import p from"../utils/reactive-object.mjs";let l={react:"createElement",solid:"createComponent"}[n];export const docsModuleName="@app/docs";export const docs=new p({[docsModuleName]:"export default {}"});export const comment=new p({});export const getCommentPath=function(){let e=/^\/?(.+?)\.tsx?$/,t=r.alias["@pkg"].length;return o=>o.substring(t).replace(e,"@app/comment/$1.md")}();if(a){let a={},p=`import { ${l}${m?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[n]}${m?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${s?"() =>":""}${l}(${m?"Dynamic":"'n-md'"}, {text: res.default, ${m?"component: 'n-md', ":""}css: 'table td a {display:inline-flex;align-items:center;gap:2px;}table td a n-img{display:inline-block;overflow:hidden;border-radius:var(--border-radius);inline-size:18px;block-size:18px;}' })};}`,c=(e,t)=>{let o=e.replace(/^@app\/comment\//,"").split("/"),r=o.pop(),n=o.join("/");a[n]||(a[n]={}),t?a[n][r]&&delete a[n][r]:a[n][r]=`rr(() => ${l}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let s={};for(let e in a)Object.prototype.hasOwnProperty.call(a,e)&&(s[e]=Object.values(a[e]));docs.setData(docsModuleName,`${p}export default ${JSON.stringify(s).replace(/"rr\((.+?)\)rr"/g,"$1")}`)};comment.on("change",(e,t)=>{c(e,t?.length<0)}),t(r.alias["@pkg"]).filter(e=>/^(?![._]).*(?<!\.test)\.(tsx?)$/i.test(e)).forEach(t=>{let r=e(t);r&&comment.setData(getCommentPath(t),o(r,t))})}
1
+ import{loadFileSync as e,scanFolder as t}from"@moneko/mdx";import o from"./generate-doc.mjs";import{CONFIG as r}from"../config.mjs";import{FRAMEWORK as n,isLibrary as a,isReact as s,isSolid as m}from"../process-env.mjs";import p from"../utils/reactive-object.mjs";let l={react:"createElement",solid:"createComponent"}[n];export const docsModuleName="@app/docs";export const docs=new p({[docsModuleName]:"export default {}"});export const comment=new p({});export const getCommentPath=function(){let e=/^\/?(.+?)\.tsx?$/,t=r.alias["@pkg"]?.length;return o=>o.substring(t).replace(e,"@app/comment/$1.md")}();if(a){let a={},p=`import { ${l}${m?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[n]}${m?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${s?"() =>":""}${l}(${m?"Dynamic":"'n-md'"}, {text: res.default, ${m?"component: 'n-md', ":""}css: 'table td a {display:inline-flex;align-items:center;gap:2px;}table td a n-img{display:inline-block;overflow:hidden;border-radius:var(--border-radius);inline-size:18px;block-size:18px;}' })};}`,c=(e,t)=>{let o=e.replace(/^@app\/comment\//,"").split("/"),r=o.pop(),n=o.join("/");a[n]||(a[n]={}),t?a[n][r]&&delete a[n][r]:a[n][r]=`rr(() => ${l}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let s={};for(let e in a)Object.prototype.hasOwnProperty.call(a,e)&&(s[e]=Object.values(a[e]));docs.setData(docsModuleName,`${p}export default ${JSON.stringify(s).replace(/"rr\((.+?)\)rr"/g,"$1")}`)};comment.on("change",(e,t)=>{c(e,t?.length<0)}),t(r.alias["@pkg"]).filter(e=>/^(?![._]).*(?<!\.test)\.(tsx?)$/i.test(e)).forEach(t=>{let r=e(t);r&&comment.setData(getCommentPath(t),o(r,t))})}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.9.17-beta.17",
3
+ "version": "3.9.17-beta.19",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -20,7 +20,6 @@
20
20
  "chokidar": "3.5.3",
21
21
  "core-js": "3.34.0",
22
22
  "core-js-compat": "3.34.0",
23
- "cors": "2.8.5",
24
23
  "cross-env": "7.0.3",
25
24
  "css-loader": "6.8.1",
26
25
  "express": "4.18.2",
@@ -32,7 +31,6 @@
32
31
  "mini-css-extract-plugin": "2.7.6",
33
32
  "mock-json-schema": "1.1.1",
34
33
  "multer": "1.4.5-lts.1",
35
- "path-to-regexp": "6.2.1",
36
34
  "style-loader": "3.3.3",
37
35
  "swc-loader": "0.2.3",
38
36
  "swc-plugin-another-transform-imports": "0.2.7",
@@ -49,14 +47,11 @@
49
47
  },
50
48
  "devDependencies": {
51
49
  "@swc/cli": "0.1.63",
52
- "@types/cors": "2.8.17",
53
50
  "@types/express": "4.17.21",
54
51
  "@types/multer": "1.4.11",
55
52
  "eslint-config-neko": "2.3.0",
56
- "eslint-webpack-plugin": "4.0.1",
57
53
  "sass": "1.69.5",
58
- "sass-loader": "13.3.2",
59
- "stylelint-webpack-plugin": "4.1.1"
54
+ "sass-loader": "13.3.2"
60
55
  },
61
56
  "files": [
62
57
  "lib",