@moneko/core 3.56.0-bate.0 → 3.56.0-beta.2

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,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 n from"./commom/reactive-object.mjs";import i from"./commom/require.mjs";import m from"./commom/rule.mjs";import l from"./options/css-extract.mjs";import c from"./options/modify-vars.mjs";import p from"./options/reslove.mjs";import d 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 x from"./utils/svg-to-data-uri.mjs";import{comment as y,getCommentPath as g}from"./vm/docs.mjs";import v from"./vm/generate-doc.mjs";import{outputConfig as w}from"./common.mjs";import{CONFIG as M}from"./config.mjs";import{FRAMEWORK as P,isDev as L,isLibrary as O}from"./process-env.mjs";let _={loader:o(r.corePath,"/loader/lightning-css/loader.cjs"),options:{sourceMap:!!M.sourceMap,targets:u(),rem:!!M.rem,esModule:!0,modules:{auto(e){if(e){if(e.endsWith(".css")&&!e.endsWith("module.css"))return!1;for(let o=0,s=$.length;o<s;o++)if(e.includes($[o]))return m.css_module.test(e)}return m.node_modules_css_module.test(e)},localIdentName:"[hash]_[local]",namedExport:!0,exportLocalsConvention:"dashesOnly",exportOnlyLocals:!1,getJSON:M.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:p.lessLoader,options:{sourceMap:!!M.sourceMap,lessOptions:{modifyVars:c,javascriptEnabled:!0}}},C=new Map;function I(e){if(C.has(e))return C.get(e);try{let o,t=i.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{try{let o=i.resolve(`${e}${s}package.json`).replace(`${s}package.json`,"");C.set(e,[o])}catch{C.set(e,[f(e),f(`.pnpm/${e}`)])}return C.get(e)}}let $=[...M.cssModules,`@moneko/${P}`,"neko-ui"].map(I).flat(),b=["components","example","mock","site","src","server"].map(h);function S(e){return new Promise(o=>{o([...b,r.corePath,...M.rulesInclude?.[e]?.map(I).flat()||[]])})}a&&b.push(h(a)),M.overrideResolve&&M.overrideResolve.override&&b.push(M.overrideResolve.override);let B=await Promise.all([S("css"),S("js"),S("media"),S("wasm"),S("font")]),J=B[0],N=B[1],W=B[2],E=B[3],R=B[4];p.sassLoader&&(e={loader:p.sassLoader,options:{implementation:await import("sass"),sassOptions:{}}});let D=O&&L&&{test:m.tsdoc,include:M.alias["@pkg"],exclude:[/node_modules\/(?!(@app|@moneko)).+/,m.__tests__],enforce:"pre",loader:o(r.corePath,"/loader/ts-doc.cjs"),options:{comment:y,generateDoc:v,getCommentPath:g}},z=w.library?.type==="umd"&&!1===M.htmlPluginOption,Q=[{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/[hash][ext]":"assets/[hash][ext]"}}},{test:m.wasm,type:"webassembly/async",include:E},{test:m.txt,type:"asset/source"},{test:m.image,type:"asset",dependency:{not:["url"]},parser:{dataUrlCondition:z?()=>!0:{maxSize:4096}},generator:{filename:e=>e.filename?.toLocaleLowerCase().endsWith(".svg")?"assets/svg/[hash][ext]":"assets/images/[hash][ext]",dataUrl:(e,o)=>o.filename.toLocaleLowerCase().endsWith(".svg")?x(e.toString()):e},include:W},{test:m.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[hash][ext]"},include:W},{test:m.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[hash][ext]"},include:R}],U=M.prefixJsLoader.filter(Boolean)||[];"react"===P&&M.reactCompiler&&U.unshift({loader:o(r.corePath,"/loader/react-compiler.cjs"),options:{panicThreshold:L?void 0:"NONE",...M.reactCompiler}}),M.cssInJs&&"object"==typeof M.cssInJs.minify&&U.unshift({loader:o(r.corePath,"/loader/css-in-js-minify.cjs"),options:Object.assign({moduleName:"@moneko/css",allowFuncs:["css","injectGlobal"]},M.cssInJs.minify)});let q=new n({});q.on("change",(e,o)=>{t(e,o)});export default(s=>{let t={react:{loader:p.swcLoader,options:d(s)},solid:{loader:o(r.corePath,"/loader/solid.cjs"),options:{jsxOptions:M.jsxDomExpressions,refresh:M.refresh}}}[P];return{parser:{javascript:{commonjsMagicComments:!0,dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,importMeta:!0,importMetaContext:!0}},noParse:M.noParse,rules:[!1!==M.htmlPluginOption&&D,{oneOf:[...Q,{test:m.js,use:[...U,t].filter(Boolean),include:N,extractSourceMap:!0},{test:m.css,use:[l,_],include:J,extractSourceMap:!0},e&&{test:m.scss,use:[l,_,e],include:J,extractSourceMap:!0},{test:m.less,use:[l,_,k],include:J,extractSourceMap:!0},{test:m.markdown,use:[...U,{loader:o(r.corePath,"/loader/mdx.cjs"),options:M.mdx}].filter(Boolean),exclude:[/node_modules\/(?!(@app|@moneko)).+/],extractSourceMap:!0}].filter(Boolean)},...M.moduleRules].filter(Boolean)}});
1
+ let e;import{join as s,sep as o}from"node:path";import{saveFileSync as t}from"@moneko/utils";import r,{CUSTOMCONFIG as a}from"./commom/paths.mjs";import n from"./commom/reactive-object.mjs";import i from"./commom/require.mjs";import m 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 y from"./utils/svg-to-data-uri.mjs";import{comment as g,getCommentPath as v}from"./vm/docs.mjs";import x from"./vm/generate-doc.mjs";import{outputConfig as w}from"./common.mjs";import{CONFIG as P}from"./config.mjs";import{FRAMEWORK as L,isDev as M,isLibrary as O}from"./process-env.mjs";let _={loader:s(r.corePath,"/loader/lightning-css/loader.cjs"),options:{sourceMap:!!P.sourceMap,targets:u(),rem:!!P.rem,esModule:!0,modules:{auto(e){if(e){if(e.endsWith(".css")&&!e.endsWith("module.css"))return!1;for(let s=0,o=$.length;s<o;s++)if(e.includes($[s]))return m.css_module.test(e)}return m.node_modules_css_module.test(e)},localIdentName:"[hash]_[local]",namedExport:!0,exportLocalsConvention:"dashesOnly",exportOnlyLocals:!1,getJSON:P.cssModuleDefinition?function(e){q.setData(`${e.resourcePath}.d.ts`,`${e.exports.map(({name:e,value:s})=>`export const ${j(e)}: '${s}';`).join("\n")}
2
+ `)}:void 0},importLoaders:2}},k={loader:d.lessLoader,options:{sourceMap:!!P.sourceMap,lessOptions:{modifyVars:c,javascriptEnabled:!0}}},C=new Map;function I(e){if(C.has(e))return C.get(e);try{let s,t=i.resolve(e).split(o),r=t.lastIndexOf("node_modules");return s=-1!==r?t.slice(0,r).join(o):t.join(o),C.set(e,[s]),[s]}catch{try{let s=i.resolve(`${e}${o}package.json`).replace(`${o}package.json`,"");C.set(e,[s])}catch{C.set(e,[f(e),f(`.pnpm/${e}`)])}return C.get(e)}}let $=[...P.cssModules,`@moneko/${L}`,"neko-ui"].map(I).flat(),b=["components","example","mock","site","src","server"].map(h);function B(e){return new Promise(s=>{s([...b,r.corePath,...P.rulesInclude?.[e]?.map(I).flat()||[]])})}a&&b.push(h(a)),P.overrideResolve&&P.overrideResolve.override&&b.push(P.overrideResolve.override);let J=await Promise.all([B("css"),B("js"),B("media"),B("wasm"),B("font")]),N=J[0],W=J[1],E=J[2],R=J[3],D=J[4];d.sassLoader&&(e={loader:d.sassLoader,options:{implementation:await import("sass"),sassOptions:{}}});let S=O&&M&&{test:m.tsdoc,include:P.alias["@pkg"],exclude:[/node_modules\/(?!(@app|@moneko)).+/,m.__tests__],enforce:"pre",loader:s(r.corePath,"/loader/ts-doc.cjs"),options:{comment:g,generateDoc:x,getCommentPath:v}},z=w.library?.type==="umd"&&!1===P.htmlPluginOption,Q=[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename(e){let s=e.filename;return s&&s.toLocaleLowerCase().endsWith("wasm?url")?"wasm/[hash][ext]":"assets/[hash][ext]"}}},{test:m.wasm,type:"webassembly/async",include:R},{test:m.txt,type:"asset/source"},{test:m.image,type:"asset",dependency:{not:["url"]},parser:{dataUrlCondition:z?()=>!0:{maxSize:4096}},generator:{filename:e=>e.filename?.toLocaleLowerCase().endsWith(".svg")?"assets/svg/[hash][ext]":"assets/images/[hash][ext]",dataUrl:(e,s)=>s.filename.toLocaleLowerCase().endsWith(".svg")?y(e.toString()):e},include:E},{test:m.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[hash][ext]"},include:E},{test:m.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[hash][ext]"},include:D}],U=P.prefixJsLoader.filter(Boolean)||[];"react"===L&&P.reactCompiler&&U.unshift({loader:s(r.corePath,"/loader/react-compiler.cjs"),options:{panicThreshold:M?void 0:"NONE",...P.reactCompiler}}),P.cssInJs&&"object"==typeof P.cssInJs.minify&&U.unshift({loader:s(r.corePath,"/loader/css-in-js-minify.cjs"),options:Object.assign({moduleName:"@moneko/css",allowFuncs:["css","injectGlobal"]},P.cssInJs.minify)});let q=new n({});q.on("change",(e,s)=>{t(e,s)});export default(o=>{let t={react:{loader:d.swcLoader,options:p(o)},solid:{loader:s(r.corePath,"/loader/solid.cjs"),options:{jsxOptions:P.jsxDomExpressions,refresh:P.refresh}}}[L];return{parser:{javascript:{commonjsMagicComments:!0,dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,importMeta:!0,importMetaContext:!0}},noParse:P.noParse,rules:[!1!==P.htmlPluginOption&&S,{oneOf:[...Q,{test:m.js,use:[...U,t].filter(Boolean),include:W},{test:m.css,use:[l,_],include:N},e&&{test:m.scss,use:[l,_,e],include:N},{test:m.less,use:[l,_,k],include:N},{test:m.markdown,use:[...U,{loader:s(r.corePath,"/loader/mdx.cjs"),options:P.mdx}].filter(Boolean),exclude:[/node_modules\/(?!(@app|@moneko)).+/]}].filter(Boolean)},...P.moduleRules].filter(Boolean)}});
@@ -3,6 +3,10 @@ export interface HtmlMeta {
3
3
  [key: string]: string | undefined | HtmlMeta;
4
4
  }
5
5
  export interface HtmlPluginOption {
6
+ /**
7
+ * 公共路径, 默认使用 主配置的 publicPath
8
+ */
9
+ publicPath?: string;
6
10
  /**
7
11
  * 网站图标
8
12
  */
@@ -1 +1 @@
1
- import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import n from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}getPublicPath(t){let e=t.getAssetPath(t.outputOptions.publicPath,{hash:t.hash}),s="auto"===e?"/":e;return s.length&&!s.endsWith("/")&&(s+="/"),s}apply(o){o.hooks.compilation.tap(this.name,a=>{a.hooks.processAssets.tap({name:this.name,stage:n.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let h;if(this.options.favicon){let h=i(o.context,this.options.favicon);if(t(h)){let t=s(this.options.favicon),i=e(h);a.emitAsset(t,new n.sources.RawSource(i),{javascriptModule:!1});let o=this.getPublicPath(a);this.faviconPath=o+t}else a.warnings.push(new n.WebpackError(`Favicon file ${h} does not exist`))}if(h=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(o.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(a);h=this.injectAssets(h,t,this.options.inject)}let l="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";a.emitAsset(l,new n.sources.RawSource(h),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags();return`<!DOCTYPE html><html><head><meta charset="utf-8">${t}<title>${this.options.title}</title><link rel="icon" type="image/x-icon" href="${this.faviconPath}"></head><body><div id="root"></div></body></html>`}generateMetaTags(){if(null!==this.cachedMetaTags)return this.cachedMetaTags;if(!this.options.meta)return this.cachedMetaTags="","";let t=Object.entries(this.options.meta).map(([t,e])=>{if("string"==typeof e)return`<meta name="${t}" content="${e}">`;if(void 0===e)return"";let s=Object.entries(e).map(([t,e])=>`${t}="${e}"`).join(" ");return`<meta ${s}>`}).join("");return this.cachedMetaTags=t,t}generateCustomTags(){if(null!==this.cachedCustomTags)return this.cachedCustomTags;let t={head:"",body:""};if(!this.options.tags)return this.cachedCustomTags=t,t;let e=[],s=[];return this.options.tags.forEach(t=>{let{tag:i="script",textContent:n="",inject:o=this.options.inject,...a}=t,h=Object.entries(a).filter(([,t])=>null!=t).map(([t,e])=>!0===e?t:`${t}="${e}"`).join(" "),l=`<${i} ${h}>${n}</${i}>`;"head"===o?e.push(l):s.push(l)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]},s=this.getPublicPath(t);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(""):"",n=e.js.length?e.js.map(t=>`<script defer ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",o=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${n}${o.head}</head>${h[0]}${o.body}</body>${h[1]||""}`:`${t}${o.head}</head>${h[0]}${i}${n}${o.body}</body>${h[1]||""}`}return t}}
1
+ import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import n from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}getPublicPath(t){if("string"==typeof this.options.publicPath)return this.options.publicPath;let e=t.getAssetPath(t.outputOptions.publicPath,{hash:t.hash}),s="auto"===e?"/":e;return s.length&&!s.endsWith("/")&&(s+="/"),s}apply(o){o.hooks.compilation.tap(this.name,a=>{a.hooks.processAssets.tap({name:this.name,stage:n.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let h;if(this.options.favicon){let h=i(o.context,this.options.favicon);if(t(h)){let t=s(this.options.favicon),i=e(h);a.emitAsset(t,new n.sources.RawSource(i),{javascriptModule:!1});let o=this.getPublicPath(a);this.faviconPath=o+t}else a.warnings.push(new n.WebpackError(`Favicon file ${h} does not exist`))}if(h=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(o.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(a);h=this.injectAssets(h,t,this.options.inject)}let l="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";a.emitAsset(l,new n.sources.RawSource(h),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags();return`<!DOCTYPE html><html><head><meta charset="utf-8">${t}<title>${this.options.title}</title><link rel="icon" type="image/x-icon" href="${this.faviconPath}"></head><body><div id="root"></div></body></html>`}generateMetaTags(){if(null!==this.cachedMetaTags)return this.cachedMetaTags;if(!this.options.meta)return this.cachedMetaTags="","";let t=Object.entries(this.options.meta).map(([t,e])=>{if("string"==typeof e)return`<meta name="${t}" content="${e}">`;if(void 0===e)return"";let s=Object.entries(e).map(([t,e])=>`${t}="${e}"`).join(" ");return`<meta ${s}>`}).join("");return this.cachedMetaTags=t,t}generateCustomTags(){if(null!==this.cachedCustomTags)return this.cachedCustomTags;let t={head:"",body:""};if(!this.options.tags)return this.cachedCustomTags=t,t;let e=[],s=[];return this.options.tags.forEach(t=>{let{tag:i="script",textContent:n="",inject:o=this.options.inject,...a}=t,h=Object.entries(a).filter(([,t])=>null!=t).map(([t,e])=>!0===e?t:`${t}="${e}"`).join(" "),l=`<${i} ${h}>${n}</${i}>`;"head"===o?e.push(l):s.push(l)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]},s=this.getPublicPath(t);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(""):"",n=e.js.length?e.js.map(t=>`<script defer ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",o=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${n}${o.head}</head>${h[0]}${o.body}</body>${h[1]||""}`:`${t}${o.head}</head>${h[0]}${i}${n}${o.body}</body>${h[1]||""}`}return t}}
@@ -1 +1 @@
1
- import{parentPort as e}from"node:worker_threads";import{runBabelPluginReactCompiler as r}from"@moneko/eslint/react-compiler";e?.setMaxListeners(0),e?.on("message",({sourceCode:s,filename:t,inputSourceMap:o,options:a})=>{try{let m=r(s,t,"typescript",a);e?.postMessage([t,null,m?.code??s,m.map??o])}catch(r){e?.postMessage([t,r,s,o])}});
1
+ import{parentPort as e}from"node:worker_threads";import{runBabelPluginReactCompiler as r}from"@moneko/eslint/react-compiler";e?.setMaxListeners(0),e?.on("message",({sourceCode:s,filename:t,inputSourceMap:o,options:a})=>{try{let o=r(s,t,"typescript",a);e?.postMessage([t,null,o?.code??s,o.map])}catch(r){e?.postMessage([t,r,s,o])}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.56.0-bate.0",
3
+ "version": "3.56.0-beta.2",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",