@moneko/core 4.0.2 → 4.0.4
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-dev.mjs +2 -2
- package/lib/build.mjs +2 -2
- package/lib/dev/config.mjs +2 -2
- package/lib/dev/mock.mjs +1 -1
- package/lib/loader/lightning-css.cjs +1 -1
- package/package.json +1 -1
package/lib/build-dev.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as t,completedInfo as
|
|
2
|
-
`):(
|
|
1
|
+
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as t,completedInfo as e,ink as m,println as i,progressBar as n}from"@moneko/utils";import a from"webpack";import s from"./commom/log.mjs";import l from"./commom/paths.mjs";import{empty as p}from"./utils/index.mjs";import{CONFIG as c}from"./config.mjs";import{createDevelopmentConfiguration as g}from"./create-development-configuration.mjs";let u=await g({});if(c.bar){let o=c.bar,t=o.name||"Build";u.plugins.push(new a.ProgressPlugin({handler(e,m,...i){let a=i.length?`[${m}] ${i.join(" ")}`:" ";o.quiet?r.stdout.write(`${a}
|
|
2
|
+
`):(n(e||0,1,{msg:a,name:t,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===e&&r.stdout.write("\r\x1b[2K"))}}))}let d=a(u);async function f(){let r=await new Promise((o,r)=>{d?.run((t,e)=>{t&&r(t),e?o(e):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:t}=o.compilation,e=[];r.forEach(o=>{o.message.includes("Conflicting order between css ./node_modules/.pnpm/monaco-editor")?e.push(o.message):i(m(o.message,"178"))}),e.length&&s(e.join("\n")),t.forEach(o=>{i(m(o.message,"red"))})}(r),await new Promise(n=>{r.compilation.compiler.cache.shutdown(a=>{a&&i(m(a.toString(),"red")),t(r.compilation.outputOptions.path,["\\.js$"]),e(~~((r.endTime-r.startTime)/10)/100,o(l.programPath,r.compilation.outputOptions.path)),n()})})}r.on("exit",p),await f();
|
package/lib/build.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as m,completedInfo as
|
|
2
|
-
`):(n(
|
|
1
|
+
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as m,completedInfo as e,ink as t,println as i,progressBar as n}from"@moneko/utils";import s from"webpack";import{merge as a}from"webpack-merge";import p from"./build/common.mjs";import l from"./commom/log.mjs";import u from"./commom/paths.mjs";import{DonePlugin as g}from"./plugin/done.mjs";import{empty as c}from"./utils/index.mjs";import d from"./utils/seo.mjs";import{CONFIG as f}from"./config.mjs";import h from"./module.config.mjs";let w=a(p,{module:h(!1),plugins:[]});if(f.done&&w.plugins.push(new g({done:f.done})),f.bar){let o=f.bar,m=o.name||"Build";w.plugins.push(new s.ProgressPlugin({handler(e,t,...i){let s=i.length?`[${t}] ${i.join(" ")}`:" ";o.quiet?r.stdout.write(`${s}
|
|
2
|
+
`):(n(e||0,1,{msg:s,name:m,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===e&&r.stdout.write("\r\x1b[2K"))}}))}let b=s(w);if(!b)throw Error("无法创建编译器");async function j(){let r=await new Promise((o,r)=>{b?.run((m,e)=>{m&&r(m),e?o(e):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:m}=o.compilation,e=[];r.forEach(o=>{o.message.includes("Conflicting order between css ./node_modules/.pnpm/monaco-editor")?e.push(o.message):i(t(o.message,"178"))}),e.length&&l(e.join("\n")),m.forEach(o=>{i(t(o.message,"red"))})}(r),await new Promise(n=>{r.compilation.compiler.cache.shutdown(s=>{s&&i(t(s.toString(),"red")),m(r.compilation.outputOptions.path,["\\.js$"]),e(~~((r.endTime-r.startTime)/10)/100,o(u.programPath,r.compilation.outputOptions.path)),n()})}),f.seo&&d()}r.on("exit",c),await j();
|
package/lib/dev/config.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ink as e,println as
|
|
2
|
-
`,"245");export function getServerAddress(e){return`${
|
|
1
|
+
import{ink as e,println as o,termClear as r}from"@moneko/utils";import{hostHelp as t}from"../commom/host.mjs";import m from"../commom/log.mjs";import{getIPv4 as s,getPort as n}from"../commom/net.mjs";import i from"../commom/print-log.mjs";import{CONFIG as l}from"../config.mjs";let a=l.devServer.port||3e3;export const PORT=await n(a);l.devServer.port=PORT;let p="/"===l.basename?"":l.basename,c=a!==PORT&&e(`Port ${e(`${a}`,"yellow")} is in use, trying ${e(`${PORT}`,"green")} instead.
|
|
2
|
+
`,"245");export function getServerAddress(e){return`${l.devServer.https?"https":"http"}://${"local"===e?l.devServer.host:s()}:${PORT}${p}`}let d=e("You application is running here:","245");export function devLog(s,n){r(3);let a=(n?.endTime??0)-(n?.startTime??0);if(o(d,!0),o("",!0),i("Local",getServerAddress("local"),{timestamp:!1,labelBackgroundColor:"blue",labelLen:9}),i("Network",getServerAddress("net"),{timestamp:!1,labelBackgroundColor:"29"}),o("",!0),o(e(`Compiled successfully in ${e(`${a}ms`,"green")}`,"245"),!0),o("",!0),c&&o(c),t(l.devServer.host),n){let e=[];n.compilation.warnings.forEach(r=>{r.message.includes("Conflicting order between css ./node_modules/.pnpm/monaco-editor")?e.push(r.message):o(r.message)}),n.compilation.errors.forEach(e=>{o(e.message)}),e.length&&m(e.join("\n"))}s&&o(s.message)}
|
package/lib/dev/mock.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{watch as e}from"node:fs";import t from"node:http";import{join as r}from"node:path";import{StringDecoder as o}from"node:string_decoder";import{URL as n}from"node:url";import{directoryExists as a,ink as i,print as c,scanFolderSync as s}from"@moneko/utils";import{merge as m}from"webpack-merge";import d from"../commom/log.mjs";import l from"../commom/match-path.mjs";import p from"../commom/paths.mjs";import
|
|
1
|
+
import{watch as e}from"node:fs";import t from"node:http";import{join as r}from"node:path";import{StringDecoder as o}from"node:string_decoder";import{URL as n}from"node:url";import{directoryExists as a,ink as i,print as c,scanFolderSync as s}from"@moneko/utils";import{merge as m}from"webpack-merge";import d from"../commom/log.mjs";import l from"../commom/match-path.mjs";import p from"../commom/paths.mjs";import u,{METHOD_COLOR as f}from"../commom/print-log.mjs";import h from"../commom/require.mjs";import g from"../commom/sigint-exit.mjs";import{jsonSchema as y}from"./json-schema.mjs";function b(e){return!["GET","HEAD","OPTIONS"].includes(e.method?.toUpperCase()||"")}export function cacheBody(e){if(!e._bodyCached&&b(e)&&!e.readableEnded){e._bodyCached=!0;try{let t=[],r=e.on.bind(e),o=e.emit.bind(e),n=!1;e.on=function(e,o){return"data"!==e||n||(n=!0,r("data",e=>{t.push(e)})),r(e,o)};let a=!1;e.emit=function(r,...n){return"end"===r&&!a&&(a=!0,t.length>0&&(e._dataChunks=t)),o.call(this,r,...n)}}catch(e){d(e)}}}function k(e,t){try{let r=Buffer.concat(e);if(t.includes("application/json")){let e=new o("utf-8").write(r);return JSON.parse(e)}if(t.includes("application/octet-stream")||t.startsWith("image/"));else if(t.includes("text/"))return r.toString("utf-8");else if(t.includes("application/x-www-form-urlencoded"))return Object.fromEntries(new URLSearchParams(r.toString("utf8")));return r}catch(e){return d(e),null}}async function j(e){return new Promise(t=>{if(!b(e))return void t(null);let r=e.headers["content-type"]||"",o=e.headers["content-length"],n=e.headers["transfer-encoding"],a=[];void 0!==e._dataChunks?t(k(e._dataChunks,r)):o||n?(e.on("data",e=>{a.push(e)}),e.on("end",()=>{t(k(a,r))}),e.on("error",e=>{t(null),d(e)})):t(null)})}export const yApiSchemaMock=(e,r)=>new Promise(o=>{t.get(`${e.host}/api/interface/get?id=${e.id}&token=${e.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=y(t);void 0!==r?o(m(n,r)):o(n)}}catch(e){d(e)}})})});export const yApiMock=(e,r)=>new Promise((o,a)=>{let i=new n(r.host),c={hostname:i.hostname,port:i.port,path:e.url?.replace(new RegExp(r.pathRewrite),`/mock/${r.projectId}/`),method:e.method,headers:e.headers,query:Object.fromEntries(i.searchParams)},s=t.request(c,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{o(JSON.parse(t))}catch(e){d(e)}})});s.on("error",e=>{a(e.message)}),s.write(JSON.stringify(e.body)),s.end()});let w=()=>{if(!a(p.mockPath)){O={};return}let e={},t=s(p.mockPath,["\\.(t|j)s$"]);c(i("Updating mock...","245"),!0),t.forEach(t=>{try{Object.assign(e,h(t).default)}catch(e){d(e)}}),c(i("Mock update successful","245"),!0),O=e},O={};w();export function containMockUrl(e){return Object.keys(O).find(t=>RegExp(`^${t.replace(/(:\w*)[^/]/g,"((?!/).)")}*$`).test(e))}export default(()=>{if(!a(p.mockPath))return;let t=e(p.mockPath,(e,t)=>{if(t){let e=r(p.mockPath,t);delete h.cache[e]}w()});return g(()=>{t.close()}),(e,t)=>{if(t.writableEnded)return t;let r=new n(`http://localhost:3000${e.url}`),o=e.method||"GET",a=`${o} ${r.pathname}`,i=containMockUrl(a)||a,c=O[i];if(c){if(u(o,r.pathname,{note:"MOCK",labelAlign:"center",labelLen:8,labelForegroundColor:f[o].fg,labelBackgroundColor:f[o].bg}),t.send=e=>t.end("string"==typeof e?e:JSON.stringify(e)),t.writeHead(200,{"Content-Type":e.headers["content-type"]}),"function"==typeof c){let o=l(i.split(" ")[1],r.pathname);r.searchParams&&Object.assign(e,{query:Object.fromEntries(r.searchParams)}),o&&Object.assign(e,{params:o.params}),e.body=j(e);try{c(e,t)}catch(e){d(e)}return!0}return t.end("string"==typeof c?c:JSON.stringify(c)),!0}return!1}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return
|
|
1
|
+
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return i}});let t=require("lightningcss"),r=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e},n=new TextEncoder,a={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 i(e,i){let u=this.async();this.cacheable&&this.cacheable();let{visitor:o,rem:s,...c}=this.getOptions();try{s&&!a.Length&&(a.Length=function(e){if("px"===e.unit)return{unit:"rem",value:e.value/16}});let r=(0,t.transform)({filename:this.resourcePath,code:n.encode(e),minify:!0,visitor:{...a,...o},cssModules:!1,sourceMap:this.sourceMap,inputSourceMap:this.sourceMap&&i?JSON.stringify(i):void 0,analyzeDependencies:!1,drafts:{customMedia:!0},include:1,errorRecovery:!1,unusedSymbols:[],...c});u(null,r.code,r.map&&JSON.parse(r.map.toString()))}catch(e){u(e),(0,r.default)(e)}}
|