@moneko/core 3.26.13 → 3.27.0-beta.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.
- package/lib/bin/build.d.mts +1 -1
- package/lib/bin/build.mjs +1 -1
- package/lib/bin/convert.d.mts +32 -10
- package/lib/bin/convert.mjs +1 -1
- package/lib/bin/index.d.mts +0 -0
- package/lib/bin/index.mjs +0 -0
- package/lib/bin/stylelint.d.mts +3 -2
- package/lib/bin/stylelint.mjs +2 -2
- package/lib/bin/utils/setup-swcrc.mjs +1 -1
- package/lib/config.mjs +1 -1
- package/lib/dev.d.mts +1 -3
- package/lib/dev.mjs +1 -1
- package/lib/plugin/stylelint.d.mts +23 -0
- package/lib/plugin/stylelint.mjs +1 -0
- package/lib/plugin/virtual-module.d.mts +1 -1
- package/lib/plugin/virtual-module.mjs +1 -1
- package/lib/plugin/worker/stylelint.d.mts +2 -0
- package/lib/plugin/worker/stylelint.mjs +1 -0
- package/package.json +3 -4
- package/typings/global.d.ts +9 -1
package/lib/bin/build.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
import { argv } from 'node:process';
|
|
3
|
-
import {
|
|
3
|
+
import { ink, println, removeDir } from '@moneko/utils';
|
|
4
4
|
import setupEnv from '../commom/setup-env.mjs';
|
|
5
5
|
import { cwd, swcCachePath } from './utils/config.mjs';
|
|
6
6
|
import { getSwcOption } from './utils/setup-swcrc.mjs';
|
package/lib/bin/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as o}from"node:path";import{argv as
|
|
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;
|
package/lib/bin/convert.d.mts
CHANGED
|
@@ -1,14 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { copyFile, ink, println, scanFolderSync, updateFile } from '@moneko/utils';
|
|
3
|
+
import { JsMinifyOptions, type Options, type Output, transformFile } from '@swc/core';
|
|
4
|
+
declare function getOutfilePath(outDir: string, file: string, outFileExtension?: string);
|
|
5
|
+
interface ConvertOptions {
|
|
4
6
|
outDir: string;
|
|
5
|
-
|
|
7
|
+
inputDir: string;
|
|
8
|
+
options: Options;
|
|
9
|
+
ignore?: RegExp[];
|
|
6
10
|
extensions?: string[];
|
|
7
|
-
|
|
8
|
-
outFileExtension?: string;
|
|
11
|
+
copy?: boolean;
|
|
9
12
|
quiet?: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
outputExtension?: string;
|
|
14
|
+
}
|
|
15
|
+
interface ConvertResult {
|
|
16
|
+
duration: number;
|
|
17
|
+
compiled: string[];
|
|
18
|
+
copied: string[];
|
|
19
|
+
failed: string[];
|
|
20
|
+
}
|
|
21
|
+
interface ConvertOutput extends Output {
|
|
22
|
+
output?: string;
|
|
23
|
+
}
|
|
24
|
+
declare const normalizeExtension: Record<string, string>;
|
|
25
|
+
declare const jscMinify: JsMinifyOptions;
|
|
26
|
+
declare async function convert({ ignore = [], quiet = true, copy = true, outDir, outputExtension, inputDir, options, extensions = [
|
|
27
|
+
'.ts',
|
|
28
|
+
'.js',
|
|
29
|
+
'.tsx',
|
|
30
|
+
'.jsx',
|
|
31
|
+
'.mts',
|
|
32
|
+
'.mjs',
|
|
33
|
+
'.cts',
|
|
34
|
+
'.cjs'
|
|
35
|
+
] }: ConvertOptions);
|
|
14
36
|
export default convert;
|
package/lib/bin/convert.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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/bin/index.d.mts
CHANGED
|
File without changes
|
package/lib/bin/index.mjs
CHANGED
|
File without changes
|
package/lib/bin/stylelint.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { relative } from 'node:path';
|
|
2
2
|
import { argv } from 'node:process';
|
|
3
|
+
import { stylelint } from '@moneko/stylelint';
|
|
3
4
|
import { ink, print } from '@moneko/utils';
|
|
4
|
-
import stylelints from 'stylelint';
|
|
5
5
|
import { cachePath, cwd, parseBraced } from './utils/config.mjs';
|
|
6
|
-
|
|
6
|
+
declare async function run();
|
|
7
|
+
export default run;
|
package/lib/bin/stylelint.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as e}from"node:path";import{argv as s}from"node:process";import{
|
|
2
|
-
`,u?"red":"green")}`,!0),u&&process.exit(1)}
|
|
1
|
+
import{relative as e}from"node:path";import{argv as s}from"node:process";import{stylelint as t}from"@moneko/stylelint";import{ink as o,print as r}from"@moneko/utils";import{cachePath as i,cwd as c,parseBraced as l}from"./utils/config.mjs";async function n(){let n=o("stylelint","cyan");r(`${n}: ${o("Runing...","yellow")}`,!0);let a=s[3],m=s.slice(4),f=m.includes("--fix"),p=await t.lint({files:l(a).map(s=>e(c,`${s}/**/*.{css,scss,sass,less,ts,tsx,js,jsx}`).replace(/\\/g,"/")),fix:f,cache:!m.includes("--cache=false"),cacheLocation:`${i}/.stylelintcache`,formatter:"string"}),u=p.errored;p.report&&process.stdout.write(p.report),r(`${n}: ${o(`✨ ${u?"Error":"Successfully"}!
|
|
2
|
+
`,u?"red":"green")}`,!0),u&&process.exit(1)}export default n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../../commom/require.mjs";export function getSwcOption(o){let r="solid"===o;return{module:{type:"es6"},minify:!0,jsc:{minify:{
|
|
1
|
+
import e from"../../commom/require.mjs";export function getSwcOption(o){let r="solid"===o;return{module:{type:"es6"},minify:!0,jsc:{minify:{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},parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:"react"===o,development:!1,importSource:r?"solid-js/h":void 0}},experimental:{plugins:[[e.resolve("@moneko/transform-imports"),{"@moneko/common":{transform:"@moneko/common/lib/${member}"},lodash:{transform:"lodash/${member}"},"@ant-design/icons":{transform:"es/icons/${member}"},antd:{transform:"es/${member}",memberTransformers:["dashed_case"]},"neko-ui":{transform:"es/${member}",memberTransformers:["dashed_case"]}}],r&&[e.resolve("@moneko/jsx-dom-expressions"),{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1}]].filter(Boolean)}},sourceMaps:!0,exclude:["__tests__/","examples/","\\.d\\.ts$"]}}
|
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
|
|
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;
|
package/lib/dev.d.mts
CHANGED
|
@@ -18,6 +18,7 @@ import { devLog, PORT } from './dev/config.mjs';
|
|
|
18
18
|
import setupMock from './dev/mock.mjs';
|
|
19
19
|
import { type ProxyConfig, setupProxy } from './dev/proxy.mjs';
|
|
20
20
|
import reslove from './options/reslove.mjs';
|
|
21
|
+
import StylelintPlugin from './plugin/stylelint.mjs';
|
|
21
22
|
import { empty, resolveProgram } from './utils/index.mjs';
|
|
22
23
|
import { commonConfig } from './common.mjs';
|
|
23
24
|
import { CONFIG, getConfig, PUBLICPATH } from './config.mjs';
|
|
@@ -25,11 +26,8 @@ import type { ConfigType } from './index.mjs';
|
|
|
25
26
|
import moduleConfig from './module.config.mjs';
|
|
26
27
|
import { isLibrary, isReact, refresh } from './process-env.mjs';
|
|
27
28
|
type WebpackPlugin = new(opt?: object) => WebpackPluginInstance;
|
|
28
|
-
declare const StylelintPlugin: WebpackPlugin;
|
|
29
29
|
declare const ESLintPlugin: WebpackPlugin;
|
|
30
|
-
declare const ReactRefresh: WebpackPlugin;
|
|
31
30
|
declare const eslintExts: string[], eslintExtStr: string;
|
|
32
|
-
declare const stylelintExts: string[], stylelintExtStr: string;
|
|
33
31
|
declare const lintExclude: string[];
|
|
34
32
|
declare const hmrPath: string;
|
|
35
33
|
declare const clientParams: ClientOptions;
|
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 r from"@fastify/compress";import{fastifyMiddie as
|
|
1
|
+
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import r from"@fastify/compress";import{fastifyMiddie as s}from"@fastify/middie";import{ink as i,loadFile as l,print as n,println as a,progressBar as m}from"@moneko/utils";import p from"fastify";import c from"webpack";import d from"webpack-dev-middleware";import u from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as f}from"./commom/diff-object.mjs";import g from"./commom/has-pkg.mjs";import w,{config_files as y}from"./commom/paths.mjs";import x from"./commom/rule.mjs";import v from"./commom/sigint-exit.mjs";import{devLog as C,PORT as k}from"./dev/config.mjs";import $ from"./dev/mock.mjs";import{setupProxy as b}from"./dev/proxy.mjs";import j from"./options/reslove.mjs";import P from"./plugin/stylelint.mjs";import{empty as S,resolveProgram as A}from"./utils/index.mjs";import{commonConfig as E}from"./common.mjs";import{CONFIG as T,getConfig as I,PUBLICPATH as M}from"./config.mjs";import _ from"./module.config.mjs";import{isLibrary as R,isReact as B,refresh as H}from"./process-env.mjs";let O=T.eslint&&g("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,q=["js","jsx","ts","tsx","json","html","vue"],z=q.join(","),U=`${M.endsWith("/")?"":"/"}__hmr__`,D=new URLSearchParams({name:"client",path:U,dynamicPublicPath:!0,timeout:2e3,reload:!H,quiet:!0,noInfo:!0,overlay:!0,autoConnect:!0}).toString(),G=E.output.path,L=T.bar,W=L.name||"Build",F=h(E,{entry:{main:[`${j.hotMiddlewareClient}?${D}`]},output:{path:G},module:_(!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:x.node_modules,priority:-10,reuseExistingChunk:!0},default:{minChunks:1,priority:-20,reuseExistingChunk:!0}}}},plugins:[new c.HotModuleReplacementPlugin,new c.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]})]});if(F.plugins||(F.plugins=[]),B){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;F.plugins.push(new e)}if(O&&F.plugins.push(new O({fix:!0,threads:!0,files:[`${T.alias["@"]}/**/*.{${z}}`,R&&`${T.alias["@pkg"]}/**/*.{${z}}`].filter(Boolean),extensions:q,exclude:["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],cache:!0,cacheLocation:`${w.lintCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:A("eslint.config.mjs"),configType:"flat"})),T.stylelint){let e="css,scss,sass,less,ts,tsx,js,jsx";F.plugins.push(new P({fix:!0,files:[`${T.alias["@"]}/**/*.{${e}}`,R&&`${T.alias["@pkg"]}/**/*.{${e}}`].filter(Boolean),cache:!0,cacheLocation:`${w.lintCachePath}/.stylelintcache`}))}T.bar&&F.plugins.push(new c.ProgressPlugin({handler(e,t,...o){m(e||0,1,{msg:o.length?`[${t}] ${o.join(" ")}`:"",name:W,barColor:L.barColor,nameColor:L.nameColor,barBgColor:L.barBgColor,msgColor:L.msgColor}),1===e&&process.stdout.write("\r\x1b[2K")}}));let N=c(F);N.hooks.done.tap("client-log",e=>{C(null,e)});let K={};if(T.devServer.https){let[e,t]=await Promise.all([l(T.devServer.https.key),l(T.devServer.https.cert)]);e||(a(i(`法加载私钥。请检查路径和文件是否存在,并确保路径正确:${T.devServer.https.key}`,"red")),process.exit(1)),t||(a(i(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${T.devServer.https.cert}`,"red")),process.exit(1)),K.http2=!0,K.https={key:e,cert:t}}let X=d(N,{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",...T.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:F.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),J=u(N,{log:!1,path:U,heartbeat:2e3}),Q=p({logger:!1,...K});await Q.register(s),Q.use(X),Q.use(U,J),$(Q,{directory:w.mockPath}),b(Q,T.proxy);let V=`${F.output.path}/index.html`;function Y(){process.exit(0)}Q.get("*",async(e,t)=>{if(e.headers.accept?.includes("text/html")){let e=X.context.outputFileSystem,o=e?.readFileSync?.(V);if(!t.sent){t.type("text/html").send(o);return}}else if(e.url?.endsWith(U)&&"text/event-stream"===e.headers.accept){e.raw.url=U,J(e.raw,t.raw,S);return}}),Q.addHook("onClose",()=>{X.close(S),Q.server.close(S)}),await Q.register(r,{global:!0}),Q.listen({port:k});let Z=await Promise.all(y.map(I)),ee=h(Z[0]||{},Z[1]||{});y.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(y.map(I)),s=h(o||{},r||{}),l=f(ee,s);1===Object.keys(l).length&&"proxy"in l?(n(i(`代理更新中...`,"yellow"),!0),await b(Q,s.proxy),n(i(`代理更新完成...`,"green"),!0),T.proxy=s.proxy,ee.proxy=s.proxy,ee=s):(ee=s,a(i(`检测到工程配置${i(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e("win32"===process.platform?`netstat -ano | findstr :${k}`:`lsof -i :${k} -t`,(e,t)=>{if(e){a(i(`查找端口 ${k} 时发生错误: ${e.message}`,"red")),a(i("请尝试手动重启程序","yellow"));return}let o=t.trim().split("\n").filter(Boolean),r=et?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){a(i(`未找到占用端口 ${k} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(r),"SIGHUP")}catch(e){a(i(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let et="win32"===process.platform;process.on("SIGHUP",function(){Q.close(S),function(){let e=t(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",Y)}()}),process.on("exit",function(){Q.close(S)}),v(Y);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { type LinterOptions, type LinterResult, type LintResult, stylelint, type Warning } from '@moneko/stylelint';
|
|
3
|
+
import webpack, { type Compilation, type Compiler } from 'webpack';
|
|
4
|
+
import { Worker } from 'worker_threads';
|
|
5
|
+
declare class StylelintError extends webpack.WebpackError {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
interface StylelintPluginOptions extends LinterOptions {
|
|
9
|
+
threads?: number;
|
|
10
|
+
files: string[];
|
|
11
|
+
exclude?: string[];
|
|
12
|
+
}
|
|
13
|
+
declare class StylelintPlugin {
|
|
14
|
+
private name: string;
|
|
15
|
+
private worker: Worker;
|
|
16
|
+
private options: StylelintPluginOptions;
|
|
17
|
+
constructor(options: StylelintPluginOptions = {
|
|
18
|
+
files: []
|
|
19
|
+
});
|
|
20
|
+
apply(compiler: Compiler): void;
|
|
21
|
+
private report(linter: LinterResult, compilation: Compilation);
|
|
22
|
+
}
|
|
23
|
+
export default StylelintPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fileURLToPath as r}from"node:url";import{stylelint as t}from"@moneko/stylelint";import e from"webpack";import{Worker as s}from"worker_threads";class n extends e.WebpackError{constructor(r){super(`[Stylelint] ${r.replace(/[^\r\n]*(\r?\n)*$/,"")}`),this.name="StylelintError",this.stack=""}}export default class{constructor(t={files:[]}){this.name="StylelintPlugin",this.options=t,this.worker=new s(r(new URL("./worker/stylelint.mjs",import.meta.url)))}apply(r){r.hooks.thisCompilation.tap(this.name,r=>{this.worker.postMessage({options:this.options}),this.worker.once("message",t=>{let e=JSON.parse(t);this.report(e,r)})}),r.hooks.shutdown.tap(this.name,()=>{this.worker.terminate()})}report(r,e){let s=[],o=[];r.results.forEach(r=>{if(!r.ignored&&(r.errored||r.parseErrors.length||r.invalidOptionWarnings.length||r.deprecations.length)){let t=[],e=[];r.warnings.forEach(r=>{"error"===r.severity?t.push(r):"warning"===r.severity&&e.push(r)}),t.length>0&&s.push({...r,warnings:t}),e.length>0&&o.push({...r,warnings:e})}}),t.formatters.string.then(t=>{o.length&&e.warnings.push(new n(t(o,r))),s.length&&e.errors.push(new n(t(s,r)))})}}
|
|
@@ -15,7 +15,7 @@ export interface VirtualModulePluginOption {
|
|
|
15
15
|
}
|
|
16
16
|
declare const PLUGIN_NAME: string;
|
|
17
17
|
export declare class VirtualModuleWebpackPlugin {
|
|
18
|
-
private virtualModules:
|
|
18
|
+
private virtualModules: VirtualModulesPlugin;
|
|
19
19
|
private options: Record<string, string>;
|
|
20
20
|
private init: boolean;
|
|
21
21
|
constructor(options: VirtualModulePluginOption = {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"webpack-virtual-modules";import o from"../commom/parse-module-meta.mjs";import i from"../commom/paths.mjs";import{isLibrary as e}from"../process-env.mjs";import{node_modules as s}from"../utils/index.mjs";import{comment as r,docs as l}from"../vm/docs.mjs";import{examples as m}from"../vm/example.mjs";import{locales as n}from"../vm/locales.mjs";import p from"../vm/modules.mjs";import{route as a}from"../vm/routes.mjs";let f={};for(let t in p)if(Object.prototype.hasOwnProperty.call(p,t)){let{file:i,pkg:e,meta:s}=o(t);f[e]=s,f[i]=p[t]}export class VirtualModuleWebpackPlugin{constructor(i={}){this.
|
|
1
|
+
import t from"webpack-virtual-modules";import o from"../commom/parse-module-meta.mjs";import i from"../commom/paths.mjs";import{isLibrary as e}from"../process-env.mjs";import{node_modules as s}from"../utils/index.mjs";import{comment as r,docs as l}from"../vm/docs.mjs";import{examples as m}from"../vm/example.mjs";import{locales as n}from"../vm/locales.mjs";import p from"../vm/modules.mjs";import{route as a}from"../vm/routes.mjs";let f={};for(let t in p)if(Object.prototype.hasOwnProperty.call(p,t)){let{file:i,pkg:e,meta:s}=o(t);f[e]=s,f[i]=p[t]}export class VirtualModuleWebpackPlugin{constructor(i={}){this.options={},this.init=!1,this.virtualModules=new t(f);let e={};for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)){let{file:s,pkg:r,meta:l}=o(t),m=i[t],n=m;n=s.endsWith("json")?"string"==typeof m?m:JSON.stringify(m):"string"==typeof m?m:`export default ${JSON.stringify(m)}`,Object.assign(e,{[s]:n,[r]:l})}this.options=e}modify(t,o,e){let r=e||"",l=o.startsWith(i.nodeModules)?o:s(o),m=t.inputFileSystem;for(;m&&m._inputFileSystem;)m=m._inputFileSystem;let n=m?._virtualFiles?.[l];n&&n.contents===r||(this.virtualModules.writeModule(l,r),t.watching?.invalidate())}apply(t){this.virtualModules.apply(t);let o=(o,i)=>{this.modify(t,o,i)};a.on("change",o),n.on("change",o),e&&(m.on("change",o),l.on("change",o),r.on("change",o)),t.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.init){for(let t in this.init=!0,this.options)Object.prototype.hasOwnProperty.call(this.options,t)&&o(t,this.options[t]);for(let t of m)o(t[0],t[1]);for(let t of l)o(t[0],t[1]);for(let t of r)o(t[0],t[1])}})}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{stylelint as e}from"@moneko/stylelint";import{parentPort as t}from"worker_threads";if(!t)throw Error("This file must be run as a worker");t.on("message",async({options:i})=>{try{let a=await e.lint({cache:i.cache,cacheLocation:i.cacheLocation,fix:i.fix,files:i.files,quietDeprecationWarnings:i.quietDeprecationWarnings,quiet:i.quiet});delete a.output,t.postMessage(JSON.stringify(a))}catch(e){t.postMessage(e)}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.27.0-beta.1",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"@fastify/http-proxy": "9.5.0",
|
|
21
21
|
"@fastify/middie": "8.3.3",
|
|
22
22
|
"@moneko/mdx": "0.1.42",
|
|
23
|
+
"@moneko/stylelint": "1.0.1",
|
|
23
24
|
"@moneko/transform-imports": "0.6.1",
|
|
24
|
-
"@moneko/utils": "0.1.
|
|
25
|
-
"@swc/cli": "0.5.2",
|
|
25
|
+
"@moneko/utils": "0.1.22",
|
|
26
26
|
"@swc/core": "1.6.13",
|
|
27
27
|
"browserslist": "4.24.3",
|
|
28
28
|
"chokidar": "4.0.2",
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"sass": "1.83.0",
|
|
53
53
|
"sass-loader": "16.0.4",
|
|
54
54
|
"solid-refresh": "0.7.5",
|
|
55
|
-
"stylelint": "16.11.0",
|
|
56
55
|
"webpack-bundle-analyzer": "4.10.2"
|
|
57
56
|
},
|
|
58
57
|
"files": [
|
package/typings/global.d.ts
CHANGED
|
@@ -420,7 +420,15 @@ export declare type ConfigType = {
|
|
|
420
420
|
* @description 用于配置 SolidJS JSX 语法中 DOM 表达式的处理方式
|
|
421
421
|
*/
|
|
422
422
|
jsxDomExpressions?: JsxDomExpressions;
|
|
423
|
-
bar?:
|
|
423
|
+
bar?:
|
|
424
|
+
| {
|
|
425
|
+
name?: string;
|
|
426
|
+
barColor?: string;
|
|
427
|
+
nameColor?: string;
|
|
428
|
+
barBgColor?: string;
|
|
429
|
+
msgColor?: string;
|
|
430
|
+
}
|
|
431
|
+
| false;
|
|
424
432
|
/** 虚拟模块
|
|
425
433
|
* @example
|
|
426
434
|
* const conf = {
|