@moneko/core 3.42.2-beta.1 → 3.42.2-beta.3
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-app.d.mts +1 -1
- package/lib/bin/build-app.mjs +1 -1
- package/lib/bin/build.d.mts +1 -1
- package/lib/bin/build.mjs +1 -1
- package/lib/bin/eslint.d.mts +1 -1
- package/lib/bin/eslint.mjs +2 -2
- package/lib/bin/git-hooks.d.mts +1 -1
- package/lib/bin/git-hooks.mjs +2 -2
- package/lib/bin/index.d.mts +1 -1
- package/lib/bin/index.mjs +1 -1
- package/lib/bin/pure-lint.d.mts +1 -1
- package/lib/bin/pure-lint.mjs +1 -1
- package/lib/bin/start.d.mts +1 -1
- package/lib/bin/start.mjs +1 -1
- package/lib/bin/stylelint.d.mts +1 -1
- package/lib/bin/stylelint.mjs +2 -2
- package/lib/bin/tsc.d.mts +1 -0
- package/lib/bin/tsc.mjs +1 -1
- package/lib/bin/utils/config.d.mts +1 -0
- package/lib/bin/utils/config.mjs +1 -1
- package/lib/build/server.d.mts +1 -0
- package/lib/build/server.mjs +1 -1
- package/lib/build.d.mts +1 -0
- package/lib/build.mjs +2 -2
- package/lib/commom/is-ci-environment.d.mts +1 -0
- package/lib/commom/is-ci-environment.mjs +1 -1
- package/lib/commom/log.d.mts +2 -1
- package/lib/commom/log.mjs +4 -4
- package/lib/commom/mime.mjs +1 -1
- package/lib/commom/paths.d.mts +1 -0
- package/lib/commom/paths.mjs +1 -1
- package/lib/commom/setup-env.d.mts +1 -0
- package/lib/commom/setup-env.mjs +1 -1
- package/lib/commom/sigint-exit.d.mts +1 -0
- package/lib/commom/sigint-exit.mjs +1 -1
- package/lib/config.d.mts +1 -0
- package/lib/config.mjs +1 -1
- package/lib/dev/generate-progress-html.d.mts +6 -0
- package/lib/dev/generate-progress-html.mjs +1 -0
- package/lib/dev/get-cert.d.mts +5 -0
- package/lib/dev/get-cert.mjs +1 -0
- package/lib/dev.d.mts +9 -23
- package/lib/dev.mjs +2 -2
- package/lib/http-server.d.mts +27 -0
- package/lib/http-server.mjs +1 -0
- package/lib/polyfills/targets.d.mts +1 -0
- package/lib/polyfills/targets.mjs +1 -1
- package/lib/process-env.d.mts +1 -1
- package/lib/process-env.mjs +1 -1
- package/package.json +1 -3
package/lib/bin/build-app.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
2
|
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { argv } from 'node:process';
|
|
4
|
+
import { argv, env, exit } from 'node:process';
|
|
5
5
|
import { buildPlist, buildXml, createDir, ink, jsonToYaml, loadFileSync, parsePlist, parseXml, parseYaml, print, println, removeDir, saveFile, saveFileSync } from '@moneko/utils';
|
|
6
6
|
import { bundleApk, bundleIOS } from './utils/bundle-app.mjs';
|
|
7
7
|
import { cwd } from './utils/config.mjs';
|
package/lib/bin/build-app.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{execSync as e}from"node:child_process";import{existsSync as i,readdirSync as n,statSync as o}from"node:fs";import
|
|
1
|
+
import{execSync as e}from"node:child_process";import{existsSync as i,readdirSync as n,statSync as o}from"node:fs";import r from"node:path";import{argv as s,env as t,exit as l}from"node:process";import{buildPlist as a,buildXml as d,createDir as c,ink as p,jsonToYaml as m,loadFileSync as u,parsePlist as f,parseXml as y,parseYaml as S,print as $,println as b,removeDir as j,saveFile as _,saveFileSync as g}from"@moneko/utils";import{bundleApk as w,bundleIOS as k}from"./utils/bundle-app.mjs";import{cwd as O}from"./utils/config.mjs";import{__dirname as A}from"./file.mjs";export function copyFileSync(e,i){let n=u(e);if(null!==n){let s=i;o(i).isDirectory()&&(s=r.join(i,r.basename(e))),g(s,n)}}export function copyFolderRecursiveSync(e,i,s){let t=i;s&&(t=r.join(i,r.basename(e))),o(e).isDirectory()&&n(e).forEach(function(i){let n=r.join(e,i);o(n).isDirectory()?copyFolderRecursiveSync(n,t,!0):copyFileSync(n,t)})}export default async function N(){s.slice(3).forEach(e=>{let[i,n]=e.replace(/^--/,"").split("=");t[`__args__${i}__`]=n});let{CONFIG:g}=await import("../config.mjs"),N=g.bundleId;N||(b(p("请配置 bundleId","red")),l(1)),/(^com\.)([a-zA-Z_][a-zA-Z0-9_]*[.])*([a-zA-Z_][a-zA-Z0-9_]*)$/.test(N)&&3===N.split(".").length||(b(p("软件包名不合法","red")),l(1));let h=g.bundles;h&&0!==h.length||(b(p("请配置 bundles (打包类型)","red")),l(1));let E=N.split(".").splice(-1,1).join(""),R=r.join(O,"/dist"),T=`flutter create -t app --org ${N} -i swift -a kotlin ${E}`,V=r.join(O,`/${E}`),v=r.join(V,"assets/web/");e(T,{encoding:"utf-8"}),c(v),$(p("正在注册资产...","yellow"),!0),copyFolderRecursiveSync(R,v);let x=r.join(V,"pubspec.yaml"),I=JSON.parse(await S(x)||"{}"),J=[],D=(e,i="assets/web")=>{let r=n(e);!function n(s){s!=r.length&&(o(`${e}/${r[s]}`).isDirectory()&&(J.push(`${i}/${r[s]}/`),D(`${e}/${r[s]}`,`${i}/${r[s]}`)),n(s+1))}(0)};if(D(R),I.dependencies.webview_flutter_plus="^0.2.3",I.flutter.assets=["assets/web/",...J],_(x,await m(JSON.stringify(I))),$(`${p("注册资产","cyan")}: ${p("完成","cyan")}`,!0),h.includes("apk -release")||h.includes("apk -debug")){$(p("正在配置安卓权限...","yellow"),!0);let e=r.join(V,"android/app/src/main/AndroidManifest.xml"),i=JSON.parse(y(e));i.manifest.application.$["android:usesCleartextTraffic"]="true",i.manifest["uses-permission"]=[{$:{"android:name":"android.permission.INTERNET"}},{$:{"android:name":"android.permission.ACCESS_NETWORK_STATE"}},{$:{"android:name":"android.permission.WAKE_LOCK"}}],_(e,d(JSON.stringify(i)));let n=r.join(V,"android/app/build.gradle"),o=u(n)||"",s="minSdkVersion flutter.minSdkVersion";if(o?.includes(s))o=o.replace(s,"minSdkVersion 20");else{let e=o.indexOf("minSdkVersion "),i=o.substring(e,e+16);o=o.replace(i,"minSdkVersion 20")}let t="compileSdkVersion flutter.compileSdkVersion";o.includes(t)&&(o=o.replace(t,"compileSdkVersion 32")),_(n,o),$(`${p("安卓权限配置","cyan")}: ${p("完成","cyan")}`,!0)}if(h.includes("ios -release")||h.includes("ios -debug")){$(p("开始配置IOS权限","yellow"),!0);let e=r.join(V,"ios/Runner/Info.plist"),i=Object.assign(JSON.parse(await f(e)),{NSAppTransportSecurity:{NSAllowsArbitraryLoads:!0},"io.flutter.embedded_views_preview":!0});_(e,await a(JSON.stringify(i))),$(`${p("IOS权限配置","cyan")}: ${p("完成","cyan")}`,!0)}_(r.join(V,"lib/main.dart"),u(r.join(A,"./conf/bootstrap"))||"");let F=r.join(O,"./bundle/");c(F),setTimeout(()=>{h.forEach(e=>{let i=e.split(" ");"apk"===i[0]&&w(V,F,i[1]),"ios"===i[0]&&k(V,F,i[1])}),j(V),i(r.join(F,"Runner"))&&j(r.join(F,"Runner")),$(`✨ ${p("Done","green")}`,!0),l(0)},1e3)}
|
package/lib/bin/build.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
-
import { argv } from 'node:process';
|
|
2
|
+
import { argv, exit } from 'node:process';
|
|
3
3
|
import { convert } from '@moneko/convert';
|
|
4
4
|
import { ink, println, removeDir } from '@moneko/utils';
|
|
5
5
|
import setupEnv from '../commom/setup-env.mjs';
|
package/lib/bin/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as o}from"node:path";import{argv as t}from"node:process";import{convert as
|
|
1
|
+
import{join as o}from"node:path";import{argv as t,exit as e}from"node:process";import{convert as r}from"@moneko/convert";import{ink as s,println as i,removeDir as m}from"@moneko/utils";import n from"../commom/setup-env.mjs";import{cwd as c,swcCachePath as l}from"./utils/config.mjs";import{getSwcOption as p}from"./utils/setup-swcrc.mjs";import{lesscCommonjs as d}from"./lessc.mjs";import a from"./tsc.mjs";async function f(){let f=t[3],u=t[4],j=t.slice(5);f||(i(s(`type: 无效值 ${s(f,"245")}`,"red")),e(1));let y=!j.includes("no-docs"),g=!j.includes("no-lib"),b=!j.includes("no-es"),x=!j.includes("no-dts"),w=j.filter(o=>!["no-docs","no-es","no-lib"].includes(o));if(await n("production",f,u,w),"library"===f){let{CONFIG:t}=await import("../config.mjs"),e="swc"===t.dts,s=[g&&{type:"commonjs",dir:"lib",msg:"Convert to CommonJS"},b&&{type:"es6",dir:"es",msg:"Convert to ES Module"}].filter(Boolean);for(let t=0,i=s.length;t<i;t++){m(o(c,`./${s[t].dir}`));let i=p(u);"es6"===s[t].type&&(i.jsc.target="es2015"),i.jsc.experimental.emitIsolatedDts=x&&e,i.jsc.experimental.cacheRoot=l,i.module.type=s[t].type,r({outDir:s[t].dir,inputDir:"components",ignore:[/^.*\/__*__\//,/\.test\.(js|ts)x?$/,/\.DS_Store/,/\.mdx?$/,/^.*\/examples\//,/\.d\.(cj|mj|j|t|ct|mt)sx?$/],options:i}),"commonjs"===s[t].type&&d(),x&&!e&&a(s[t].dir)}}if("library"!==f||y&&"library"===f)try{await import("../build.mjs")}catch(o){i(s(Error(o).message,"red")),e(1)}}export default f;
|
package/lib/bin/eslint.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { relative } from 'node:path';
|
|
2
|
-
import { argv } from 'node:process';
|
|
2
|
+
import { argv, exit, stdout } from 'node:process';
|
|
3
3
|
import { ESLint } from '@moneko/eslint';
|
|
4
4
|
import { ink, print } from '@moneko/utils';
|
|
5
5
|
import { cachePath, cwd, parseBraced } from './utils/config.mjs';
|
package/lib/bin/eslint.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as e}from"node:path";import{argv as o}from"node:process";import{ESLint as
|
|
2
|
-
|
|
1
|
+
import{relative as e}from"node:path";import{argv as o,exit as t,stdout as i}from"node:process";import{ESLint as r}from"@moneko/eslint";import{ink as a,print as l}from"@moneko/utils";import{cachePath as n,cwd as s,parseBraced as c}from"./utils/config.mjs";export default async function m(){let m=a("eslint","cyan");l(`${m}: ${a("Runing...","yellow")}`,!0);let f=o[3],u=o.slice(4),p=u.includes("--fix"),d=new r({cache:!u.includes("--cache=false"),cacheLocation:`${n}/.eslintcache`,fix:p}),w=c(f).map(o=>e(s,o)),h=await d.lintFiles(w),$=await d.loadFormatter("stylish"),y=await $.format(h);p&&await r.outputFixes(h),y&&i.write(y);let x=h.some(e=>e.errorCount>0);l(`${m}: ${a(`✨ ${x?"Error":"Successfully"}!
|
|
2
|
+
`,x?"red":"green")}`,!0),x&&t(1)}
|
package/lib/bin/git-hooks.d.mts
CHANGED
package/lib/bin/git-hooks.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{spawn as o}from"node:child_process";import{argv as e}from"node:process";import{ink as
|
|
2
|
-
`,o?"red":"green");i(`${
|
|
1
|
+
import{spawn as o}from"node:child_process";import{argv as e,exit as l}from"node:process";import{ink as n,print as i}from"@moneko/utils";import t from"husky";export default function s(){let s=n("Git init","cyan"),r=o=>n(`✨ ${o?"Error":"Successfully"}!
|
|
2
|
+
`,o?"red":"green");i(`${s}: ${n("Runing...","yellow")}`,!0),o("git init && git config core.ignorecase false",{stdio:[null],shell:!0}).on("close",function(c){i(`${s}: ${r(0!==c)}`,!0);let u=n("Git hooks","cyan");i(`${u}: ${n("Runing...","yellow")}`,!0);let $="node_modules/.husky";t($);let f=e.slice(3).map(o=>{let e=o.split("=");return`echo ${e[1]} > ${$}/${e[0]}`}).join(" && ");o(`${f}`,{stdio:[null],shell:!0}).on("close",function(o){i(`${u}: ${r(0!==o)}`,!0),l(o)})})}
|
package/lib/bin/index.d.mts
CHANGED
package/lib/bin/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{argv as a}from"node:process";import{ink as
|
|
2
|
+
import{argv as a,exit as t}from"node:process";import{ink as e,println as i}from"@moneko/utils";import s from"../commom/require.mjs";import o from"../commom/sigint-exit.mjs";import{corePkg as m}from"./utils/config.mjs";switch(a[2]){case"-v":case"--version":i(`${e(m,"blue")}: ${s(`${m}/package.json`).version}`,!0);break;case"start":(await import("./start.mjs")).default();break;case"build":(await import("./build.mjs")).default();break;case"eslint":(await import("./eslint.mjs")).default();break;case"stylelint":(await import("./stylelint.mjs")).default();break;case"githooks":(await import("./git-hooks.mjs")).default();break;case"buildApp":(await import("./build-app.mjs")).default();break;case"changelog":(await import("./changelog.mjs")).default();break;default:(await import("./help.mjs")).default()}o(()=>{t(0)});
|
package/lib/bin/pure-lint.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawnSync, type SpawnSyncReturns } from 'node:child_process';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { argv } from 'node:process';
|
|
4
|
+
import { argv, cwd as _cwd, exit, stdout } from 'node:process';
|
|
5
5
|
import { ESLint } from '@moneko/eslint';
|
|
6
6
|
import { LinterResult, stylelint as Stylelint } from '@moneko/stylelint';
|
|
7
7
|
import { ink, loadFile, println } from '@moneko/utils';
|
package/lib/bin/pure-lint.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{spawnSync as t}from"node:child_process";import{join as e}from"node:path";import{argv as o}from"node:process";import{ESLint as
|
|
2
|
+
import{spawnSync as t}from"node:child_process";import{join as e}from"node:path";import{argv as o,cwd as i,exit as r,stdout as n}from"node:process";import{ESLint as l}from"@moneko/eslint";import{stylelint as a}from"@moneko/stylelint";import{ink as m,loadFile as c,println as s}from"@moneko/utils";import f from"../commom/log.mjs";import d from"../commom/parse-args.mjs";import p from"../commom/timer.mjs";let y=d(o.slice(2)),h=y.fix,u=y.cache||!0,w=e(i(),"node_modules/.cache"),g={ci:["diff","--name-only","HEAD^","HEAD"],commit:["diff","--cached","--name-only","--diff-filter=ACMR"]},S=/.*(?<!\.d)\.(j|t|mj|mt|cj|ct)sx?$/,$=/.*(?<!\.d)\.vue$/,E=/.*(?<!\.d)\.(c|sc|sa|le)ss$/,j=t("git",g[y.mode||"ci"]||g.ci).stdout.toString().trim().split("\n");async function L(){let t=m("ESLint","cyan");s(`${t}: ${m("runing...","yellow")}`,!0);try{p.start("ESLint");let t=j.filter(t=>S.test(t)||$.test(t));if(0===t.length){p.end("ESLint");return}let e=new l({cache:u,cacheLocation:`${w}/.eslintcache`,fix:h}),o=await e.lintFiles(t),i=await e.loadFormatter("stylish"),a=await i.format(o);h&&await l.outputFixes(o),a&&n.write(a);let m=o.some(t=>t.errorCount>0);p.end("ESLint"),m&&r(1)}catch(t){f(Error(t))}}let k=j.filter(t=>E.test(t)||$.test(t));async function x(){let t=m("Stylelint","cyan");if(s(`${t}: ${m("runing...","yellow")}`,!0),p.start("Stylelint"),0===k.length){p.end("Stylelint");return}let e=await Promise.all(k.map(async t=>{let e=await c(t);return await a.lint({codeFilename:t,code:e,cache:u,cacheLocation:`${w}/.stylelintcache`,fix:h,formatter:"string"}).catch(f)})),o=!1;e.forEach(t=>{t&&(t.report&&n.write(t.report),t.errored&&(o=!!t.errored))}),p.end("Stylelint"),o&&r(1)}await Promise.all([L(),x()]);
|
package/lib/bin/start.d.mts
CHANGED
package/lib/bin/start.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{argv as e}from"node:process";import{ink as
|
|
1
|
+
import{argv as e,exit as o}from"node:process";import{ink as t,println as r}from"@moneko/utils";import m from"../commom/setup-env.mjs";async function i(){let i=e[3],s=e[4],p=e.slice(5);i||(r(t(`type: 无效值 ${t(i,"245")}`,"red")),o(1));let n=p.indexOf("no-verify");-1!==n&&p.splice(n,1),await m("development",i,s,p);try{await import("../dev.mjs")}catch(e){r(t(Error(e).message,"red")),o(1)}}export default i;
|
package/lib/bin/stylelint.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { relative } from 'node:path';
|
|
2
|
-
import { argv } from 'node:process';
|
|
2
|
+
import { argv, exit, stdout } from 'node:process';
|
|
3
3
|
import { stylelint } from '@moneko/stylelint';
|
|
4
4
|
import { ink, print } from '@moneko/utils';
|
|
5
5
|
import { cachePath, cwd, parseBraced } from './utils/config.mjs';
|
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{stylelint as
|
|
2
|
-
`,
|
|
1
|
+
import{relative as e}from"node:path";import{argv as s,exit as t,stdout as r}from"node:process";import{stylelint as o}from"@moneko/stylelint";import{ink as i,print as l}from"@moneko/utils";import{cachePath as c,cwd as n,parseBraced as a}from"./utils/config.mjs";async function m(){let m=i("stylelint","cyan");l(`${m}: ${i("Runing...","yellow")}`,!0);let f=s[3],p=s.slice(4),u=p.includes("--fix"),d=await o.lint({files:a(f).map(s=>e(n,`${s}/**/*.{css,scss,sass,less,ts,tsx,js,jsx}`).replace(/\\/g,"/")),fix:u,cache:!p.includes("--cache=false"),cacheLocation:`${c}/.stylelintcache`,formatter:"string"}),y=d.errored;d.report&&r.write(d.report),l(`${m}: ${i(`✨ ${y?"Error":"Successfully"}!
|
|
2
|
+
`,y?"red":"green")}`,!0),y&&t(1)}export default m;
|
package/lib/bin/tsc.d.mts
CHANGED
package/lib/bin/tsc.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e}from"node:path";import t from"typescript";import{cwd as
|
|
1
|
+
import{join as e}from"node:path";import{stdout as t}from"node:process";import o from"typescript";import{cwd as i}from"./utils/config.mjs";async function n(n){return new Promise(s=>{let r=o.parseJsonConfigFileContent({extends:e(i,"tsconfig.json"),compilerOptions:{outDir:n,typeRoots:["node_modules/@types/","node_modules/.pnpm/node_modules/@types/"],declaration:!0,emitDeclarationOnly:!0,skipLibCheck:!0,skipDefaultLibCheck:!0,noEmitOnError:!1},include:[e(i,"components"),e(i,"typings")],exclude:[e(i,"components/**/examples/*"),e(i,"components/**/__tests__/*"),e(i,"components/**/__mocks__/*")]},o.sys,i);r.options.incremental&&(r.options.tsBuildInfoFile=r.options.tsBuildInfoFile??e(n,".tsbuildinfo"));let l=o.createProgram(r.fileNames,r.options),m=l.emit();o.getPreEmitDiagnostics(l).concat(m.diagnostics).forEach(e=>{if(t.write("\n"),e.file){let{line:i,character:n}=e.file.getLineAndCharacterOfPosition(e.start),s=o.flattenDiagnosticMessageText(e.messageText,"\n");t.write(`${e.file.fileName} (${i+1},${n+1}): ${s}`)}else t.write(o.flattenDiagnosticMessageText(e.messageText,"\n"))}),s(!0)})}export default n;
|
package/lib/bin/utils/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dirname as e,join as o}from"node:path";let
|
|
1
|
+
import{dirname as e,join as o}from"node:path";import{cwd as t,execPath as n,platform as c}from"node:process";let r="undefined"!=typeof Deno?"deno":"undefined"!=typeof Bun?"bun":"node",s=e(n);"win32"===c&&s.includes(" ")&&(s=`"${s}"`);export const runtimePath=o(s,r);export const corePkg="@moneko/core";export const cwd=t();export const cachePath=o(cwd,"node_modules/.cache");export const swcCachePath=o(cachePath,".swc");export function parseBraced(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1).split(","):[e]}
|
package/lib/build/server.d.mts
CHANGED
package/lib/build/server.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{env as e}from"node:process";import{CUSTOMCONFIG as m}from"../commom/paths.mjs";import o from"../module.config.mjs";import{isLibrary as s}from"../process-env.mjs";import{resolveProgram as r}from"../utils/index.mjs";let t={name:"server",target:"node",dependencies:["client"],entry:{main:r("site/ssr.tsx")},output:{path:r(`${s?"docs":"dist"}/server`),library:{type:"commonjs2",umdNamedDefine:!1},filename:"[name].cjs",chunkFilename:"[chunkhash].cjs",globalObject:"global"},cache:{type:"filesystem",name:[m,e.NODE_ENV,"server"].filter(Boolean).join("-")},externalsPresets:{node:!0},externals:[],module:o(!0)};export default t;
|
package/lib/build.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { relative } from 'node:path';
|
|
2
|
+
import process from 'node:process';
|
|
2
3
|
import { analyzeBundleSize, completedInfo, ink, println, progressBar } from '@moneko/utils';
|
|
3
4
|
import webpack, { type Compiler, type Configuration, type Stats } from 'webpack';
|
|
4
5
|
import { merge } from 'webpack-merge';
|
package/lib/build.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as o}from"node:path";import{analyzeBundleSize as
|
|
2
|
-
`):(
|
|
1
|
+
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as m,completedInfo as t,ink as i,println as e,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/paths.mjs";import u from"./plugin/done.mjs";import{empty as g}from"./utils/index.mjs";import c from"./utils/seo.mjs";import{CONFIG as f}from"./config.mjs";import d from"./module.config.mjs";let h=a(p,{module:d(!1),plugins:[]});if(f.done&&h.plugins.push(new u({done:f.done})),f.bar){let o=f.bar,m=o.name||"Build";h.plugins.push(new s.ProgressPlugin({handler(t,i,...e){let s=e.length?`[${i}] ${e.join(" ")}`:" ";o.quiet?r.stdout.write(`${s}
|
|
2
|
+
`):(n(t||0,1,{msg:s,name:m,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===t&&r.stdout.write("\r\x1b[2K"))}}))}let w=s(h);async function b(){let r=await new Promise((o,r)=>{w.run((m,t)=>{m&&r(m),t?o(t):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:m}=o.compilation;r.forEach(o=>{e(i(o.message,"178"))}),m.forEach(o=>{e(i(o.message,"red"))})}(r),await new Promise(n=>{r.compilation.compiler.cache.shutdown(s=>{s&&e(i(s.toString(),"red")),m(r.compilation.outputOptions.path,["\\.js$"]),t(~~((r.endTime-r.startTime)/10)/100,o(l.programPath,r.compilation.outputOptions.path)),n()})}),f.seo&&c()}r.on("exit",g),await b();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function(){if(
|
|
1
|
+
import{env as I}from"node:process";export default function(){if(I.DOCKER_BUILD_ID||I.DOCKER_APP_NAME||"true"===I.CI||"1"===I.CI)return!0;let E=["CI","CONTINUOUS_INTEGRATION","BUILD_NUMBER","RUN_ID","GITHUB_ACTIONS","GITLAB_CI","TRAVIS","CIRCLECI","JENKINS_URL","TF_BUILD","APPVEYOR","BITBUCKET_BUILD_NUMBER","CODEBUILD_BUILD_ID","TEAMCITY_VERSION","BAMBOO_BUILDKEY","BUILDKITE","DRONE","SEMAPHORE","NETLIFY","VERCEL","NOW_BUILDER","HEROKU_TEST_RUN_ID","CODEBUILD_BUILD_ID","HUDSON_URL","TASK_ID","GO_PIPELINE_NAME","CI_NAME","CI_WORKER_ID"].some(E=>void 0!==I[E]&&""!==I[E]),_="true"===I.NETLIFY||"true"===I.VERCEL||"production"===I.NODE_ENV&&!!I.HEROKU_APP_ID||"codeship"===I.CI_NAME||"true"===I.BUDDY||"true"===I.SCRUTINIZER||void 0!==I.CF_BUILD_ID;return E||_}
|
package/lib/commom/log.d.mts
CHANGED
package/lib/commom/log.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
${a.stack||""}`:String(a)).split("\n"),
|
|
3
|
-
${
|
|
4
|
-
`;
|
|
1
|
+
import{hrtime as t}from"node:process";import{appendToFileSync as e}from"@moneko/utils";let r=new Date,n=t();async function a(a){let o=function(){let e=t(n),a=e[0],o=e[1],g=new Date(r.getTime()+1e3*a+Math.floor(o/1e6)),i=g.getFullYear(),$=String(g.getMonth()+1).padStart(2,"0"),s=String(g.getDate()).padStart(2,"0"),S=String(g.getHours()).padStart(2,"0"),l=String(g.getMinutes()).padStart(2,"0"),p=String(g.getSeconds()).padStart(2,"0"),d=String(Math.floor(o%1e6/1e3)).padStart(3,"0"),u=String(o%1e3).padStart(3,"0");return`${i}-${$}-${s} ${S}:${l}:${p}.${d}${u}`}(),g=(a instanceof Error?`${a.message}
|
|
2
|
+
${a.stack||""}`:String(a)).split("\n"),i=`[${o}] ${g[0]}`,$=" ".repeat(`[${o}] `.length),s=g.slice(1).map(t=>`${$}${t}`).join("\n"),S=`${i}${s?`
|
|
3
|
+
${s}`:""}
|
|
4
|
+
`;e(`logs/${o.substring(0,16)}.log`,S)}export default a;
|
package/lib/commom/mime.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default{".html":"text/html",".js":"application/javascript",".css":"text/css",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".json":"application/json",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".eot":"font/eot",".otf":"font/otf",".wasm":"application/wasm",".mp4":"video/mp4",".mp3":"audio/mpeg",".wav":"audio/wav",".ogg":"audio/ogg",".webm":"video/webm",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".zip":"application/zip",".rar":"application/x-rar-compressed",".tar":"application/x-tar",".gz":"application/gzip",".bz2":"application/x-bzip2",".7z":"application/x-7z-compressed",".iso":"application/x-iso9660-image",".dmg":"application/x-apple-diskimage",".pkg":"application/vnd.apple.installer+xml",".deb":"application/vnd.debian.binary-package",".rpm":"application/x-rpm",".exe":"application/x-msdownload",".msi":"application/x-msdownload",".cab":"application/vnd.ms-cab-compressed",".app":"application/x-apple-applescript",".sh":"application/x-sh",".bash":"application/x-sh",".bat":"application/x-msdownload",".cmd":"application/x-msdownload",".com":"application/x-msdownload",".hta":"application/hta",".jar":"application/java-archive",".mjs":"text/javascript"};
|
|
1
|
+
export default{".html":"text/html; charset=utf-8",".js":"application/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".json":"application/json",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".eot":"font/eot",".otf":"font/otf",".wasm":"application/wasm",".mp4":"video/mp4",".mp3":"audio/mpeg",".wav":"audio/wav",".ogg":"audio/ogg",".webm":"video/webm",".txt":"text/plain; charset=utf-8",".xml":"application/xml",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".zip":"application/zip",".rar":"application/x-rar-compressed",".tar":"application/x-tar",".gz":"application/gzip",".bz2":"application/x-bzip2",".7z":"application/x-7z-compressed",".iso":"application/x-iso9660-image",".dmg":"application/x-apple-diskimage",".pkg":"application/vnd.apple.installer+xml",".deb":"application/vnd.debian.binary-package",".rpm":"application/x-rpm",".exe":"application/x-msdownload",".msi":"application/x-msdownload",".cab":"application/vnd.ms-cab-compressed",".app":"application/x-apple-applescript",".sh":"application/x-sh",".bash":"application/x-sh",".bat":"application/x-msdownload",".cmd":"application/x-msdownload",".com":"application/x-msdownload",".hta":"application/hta",".jar":"application/java-archive",".mjs":"text/javascript; charset=utf-8"};
|
package/lib/commom/paths.d.mts
CHANGED
package/lib/commom/paths.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{tmpdir as o}from"node:os";import{resolve as e}from"node:path";import t from"node:url";import{fileExists as
|
|
1
|
+
import{tmpdir as o}from"node:os";import{resolve as e}from"node:path";import{cwd as t,env as n}from"node:process";import a from"node:url";import{fileExists as c}from"@moneko/utils";let r=JSON.parse(n.npm_config_argv||'{"original":[]}').original;export const __dirname=a.fileURLToPath(new URL("..",import.meta.url));export const yarnArgv={};for(let o=0,e=r.length;o<e;o++){let e=r[o].split("=");Object.assign(yarnArgv,{[e[0]]:e[1]||!0})}export const CUSTOMCONFIG=n.npm_config_config||yarnArgv.config||n.__args__config__;let i=t(),s=e(i,"node_modules");export const TMP_DIR=e(o(),"@moneko");let p={nodeModules:s,pnpmNodeModules:e(s,".pnpm/node_modules"),denoNodeModules:e(s,".deno"),corePath:__dirname,programPath:i,CA_DIR:e(TMP_DIR,".ca"),webpackCachePath:e(s,".cache"),lintCachePath:e(s,".cache"),httpCachePath:e(s,".cache/http"),swcCachePath:e(s,".cache/.swc"),configPath:e(i,"config/index.ts"),customConfigPath:e(i,`config/${CUSTOMCONFIG}.ts`),coveragePath:e(i,"coverage/clover.xml"),pagesPath:e(i,"src/pages"),componentsPath:e(i,"components"),mockPath:e(i,"mock")};export const config_files=[c(p.configPath)&&p.configPath,c(p.customConfigPath)&&p.customConfigPath].filter(Boolean);export const routeDir="library"===n.APPTYPE?p.componentsPath:p.pagesPath;export default p;
|
package/lib/commom/setup-env.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{env as e}from"node:process";import{loadFile as t}from"@moneko/utils";async function r(r,i,n,o){let s=[".env",".env/.env",`.env/.${"production"===r?"prod":"dev"}.env`],a={NODE_ENV:r,APPTYPE:i,FRAMEWORK:n};return o.forEach(e=>{let[t,r]=e.replace(/^--/,"").split("=");Object.assign(a,{[`__args__${t}__`]:r||!0})}),(await Promise.all(s.map(t))).forEach(e=>{e&&Object.assign(a,e.split("\n").reduce((e,t)=>{if(!t||t.trim().startsWith("#"))return e;let[r,...i]=t.split("=");if(!r)return e;let n=i.join("=").trim();return e[r.trim()]=n.replace(/^["']|["']$/g,""),e},{}))}),Object.keys(a).forEach(t=>{let r=a[t];e[t]!==r&&(e[t]=a[t])}),a}export default r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function(
|
|
1
|
+
import o from"node:process";export default function(n){o.on("SIGINT",n),o.on("SIGTERM",n),o.on("SIGQUIT",n)}
|
package/lib/config.d.mts
CHANGED
package/lib/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as e}from"node:path";import{fileExists as
|
|
1
|
+
import{relative as e}from"node:path";import o from"node:process";import{fileExists as t}from"@moneko/utils";import{merge as r}from"webpack-merge";import s from"./commom/paths.mjs";import n from"./commom/require.mjs";import i from"./commom/setup-env.mjs";import a from"./options/jsx-dom-expressions.mjs";import l from"./options/split-chunk.mjs";import{isFunction as m,node_modules as p,resolveProgram as c}from"./utils/index.mjs";import{APPTYPE as u,FRAMEWORK as d,frameworkVersion as f,isCI as h,isDev as g,isLibrary as v,isMobile as x,isReact as j,jsxImportSource as C,mainDirectory as P,NODE_ENV as b,PACKAGENAME as k}from"./process-env.mjs";let w=["@app","@moneko","neko-ui",".cache/http/data","@element-plus","ant-design-vue","element-plus","element-ui","ng-zorro-antd","@mui","@du","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design","monaco-editor"];export function getConfig(e){return delete n.cache[e],new Promise(r=>{if(t(e)){let t=n(e).default;return r(m(t)?t(o):t)}return r({})})}let O=await Promise.all([i(b,u,d,[]),getConfig(s.configPath),getConfig(s.customConfigPath)]),y=O[0],S=O[1],M=O[2],I={strict:!1,devtool:g?"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:y,basename:"/",publicPath:"/",rem:{designSize:x?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":c(P)},j&&f<18?{"react/package.json":p("react/package.json"),"react/jsx-runtime":p("react/jsx-runtime.js"),"react/jsx-dev-runtime":p("react/jsx-dev-runtime.js")}:{}),moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3},htmlPluginOption:{title:k.toLocaleUpperCase(),favicon:e(s.programPath,`${s.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:l,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:w,js:w,media:w,font:w,wasm:[]},mdx:{jsx:!1,development:g,jsxImportSource:C,providerImportSource:`@moneko/${d}/mdx`},jsxDomExpressions:a,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:h},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==d,bundleId:"com.moneko.bid",bundles:[],stylelint:{},eslint:{lintDirtyModulesOnly:!1}};v&&(I.alias=Object.assign(I.alias,{"@pkg":s.componentsPath,[k]:s.componentsPath}));let z=I;(!1===(z=r(z,S,M)).devtool||!1===z.sourceMap)&&(z.sourceMap=!1,z.devtool=!1),z.fixBrowserRouter&&z.htmlPluginOption&&(z.htmlPluginOption.tags||(z.htmlPluginOption.tags=[]),z.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))"})),"true"===o.env.CODESPACES&&(z.devServer.https=!1),!1===z.devServer.https&&(z.devServer.open=!1);export const CONFIG=z;export const PUBLICPATH=CONFIG.publicPath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function(e,t){let r=Math.floor(100*t.percentage);return`<!DOCTYPE html><html><head><title>Building...</title><link rel="image/x-icon" href="/favicon.ico"><style>html{ display:flex; justify-content:center; align-items:center; block-size:100vb;}.progress-container{ position:relative; overflow:hidden; margin:1rem auto; border:0.0625rem solid #ccc; border-radius:0.625rem; inline-size:18.75rem; block-size:1.25rem;}.progress-bar{ block-size:100%; background:#4caf50; inline-size:0%; transition:inline-size 0.5s ease;}#progress-text{ position:absolute; margin:auto; font-size:0.875rem; font-family:sans-serif; font-weight:600; text-align:center; color:#fff; text-shadow:0 0 0.0625rem black; inset-inline:0; inset-block:0; line-height:1.25rem;}#progress-info{ font-size:small; font-family:sans-serif; font-weight:100; text-align:center; opacity:0.5; margin-block-start:0.625rem;}</style></head><body><div class="progress-container"><div class="progress-bar"></div><div id="progress-text">${r}%</div></div><div id="progress-info">${t.info}</div><script>function checkProgress() {fetch('${e}').then(r => r.json()) .then(data => {const percentage = Math.floor(data.percentage * 100);document.querySelector('.progress-bar').style.width = percentage + '%';document.getElementById('progress-text').textContent = percentage + '%';document.getElementById('progress-info').textContent = data.info;if (percentage === 100) {window.location.reload();} else {setTimeout(checkProgress, 500);}});}checkProgress();</script></body></html>`}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ink as e,loadFile as t,println as r}from"@moneko/utils";import{setupCert as o}from"../commom/ca.mjs";import{CONFIG as s}from"../config.mjs";async function v(){if("object"==typeof s.devServer.https&&"key"in s.devServer.https){let o=await Promise.all([t(s.devServer.https.key),t(s.devServer.https.cert)]);return o[0]||(r(e(`法加载私钥。请检查路径和文件是否存在,并确保路径正确:${s.devServer.https.key}`,"red")),process.exit(1)),o[1]||(r(e(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${s.devServer.https.cert}`,"red")),process.exit(1)),{key:o[0],cert:o[1]}}return o(s.devServer.host,!0===s.devServer.https||"object"==typeof s.devServer.https&&s.devServer.https.install)}export default v;
|
package/lib/dev.d.mts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { exec, spawn } from 'node:child_process';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
2
|
+
import { watchFile } from 'node:fs';
|
|
3
|
+
import { relative } from 'node:path';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
import { ink, print, println, progressBar } from '@moneko/utils';
|
|
6
6
|
import webpack, { type Compiler, type OutputFileSystem, type Watching, type WebpackPluginInstance } from 'webpack';
|
|
7
7
|
import webpackHotMiddleware, { type ClientOptions } from 'webpack-hot-middleware';
|
|
8
8
|
import { merge } from 'webpack-merge';
|
|
9
|
-
import { setupCert } from './commom/ca.mjs';
|
|
10
9
|
import { diffObject } from './commom/diff-object.mjs';
|
|
11
|
-
import mime from './commom/mime.mjs';
|
|
12
|
-
import open from './commom/open.mjs';
|
|
13
10
|
import paths, { config_files } from './commom/paths.mjs';
|
|
14
11
|
import sigintExit from './commom/sigint-exit.mjs';
|
|
15
|
-
import { devLog,
|
|
16
|
-
import
|
|
17
|
-
import
|
|
12
|
+
import { devLog, PORT } from './dev/config.mjs';
|
|
13
|
+
import generateProgressHtml, { CompliationProcess } from './dev/generate-progress-html.mjs';
|
|
14
|
+
import getCert from './dev/get-cert.mjs';
|
|
18
15
|
import reslove from './options/reslove.mjs';
|
|
19
16
|
import ESLintPlugin from './plugin/eslint.mjs';
|
|
20
17
|
import StylelintPlugin from './plugin/stylelint.mjs';
|
|
@@ -22,6 +19,7 @@ import { empty } from './utils/index.mjs';
|
|
|
22
19
|
import { commonConfig } from './common.mjs';
|
|
23
20
|
import { CONFIG, getConfig, PUBLICPATH } from './config.mjs';
|
|
24
21
|
import { outputFileSystem } from './file-system.mjs';
|
|
22
|
+
import server, { type FileSystem, type Server } from './http-server.mjs';
|
|
25
23
|
import type { ConfigType } from './index.mjs';
|
|
26
24
|
import moduleConfig from './module.config.mjs';
|
|
27
25
|
import { isLibrary, isReact, refresh } from './process-env.mjs';
|
|
@@ -32,10 +30,6 @@ declare const hotParams: string;
|
|
|
32
30
|
declare const clientOption: webpack.Configuration;
|
|
33
31
|
declare function getLintFiles(exts: string[]);
|
|
34
32
|
declare let isInitialBuildDone: boolean;
|
|
35
|
-
type CompliationProcess = {
|
|
36
|
-
percentage: number;
|
|
37
|
-
info: string;
|
|
38
|
-
};
|
|
39
33
|
declare const progressApi: string;
|
|
40
34
|
declare const compilationProgress: CompliationProcess;
|
|
41
35
|
declare const compiler: Compiler;
|
|
@@ -48,16 +42,8 @@ interface FastifyOptions {
|
|
|
48
42
|
};
|
|
49
43
|
}
|
|
50
44
|
declare const fastifyOptions: FastifyOptions;
|
|
51
|
-
declare async function getCert();
|
|
52
45
|
declare const hotMiddleware: ReturnType<typeof webpackHotMiddleware>;
|
|
53
|
-
declare const app:
|
|
54
|
-
declare const normalHeaders: Record<string, string>;
|
|
55
|
-
declare function generateProgressHtml(progress: CompliationProcess);
|
|
56
|
-
type FileSystem = OutputFileSystem & {
|
|
57
|
-
existsSync: typeof existsSync;
|
|
58
|
-
createReadStream: typeof createReadStream;
|
|
59
|
-
};
|
|
60
|
-
declare function replyStream(req: FastifyRequest, reply: FastifyReply, filePath: string);
|
|
46
|
+
declare const app: Server;
|
|
61
47
|
declare function exit();
|
|
62
48
|
declare const _prev: ConfigType[];
|
|
63
49
|
declare let prev: ConfigType;
|
package/lib/dev.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{
|
|
2
|
-
`):(m(o||0,1,{msg:
|
|
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"node:process";import{ink as n,print as s,println as l,progressBar as m}from"@moneko/utils";import a from"webpack";import p from"webpack-hot-middleware";import{merge as c}from"webpack-merge";import{diffObject as f}from"./commom/diff-object.mjs";import h,{config_files as u}from"./commom/paths.mjs";import d from"./commom/sigint-exit.mjs";import{devLog as g,PORT as w}from"./dev/config.mjs";import y from"./dev/generate-progress-html.mjs";import j from"./dev/get-cert.mjs";import $ from"./options/reslove.mjs";import b from"./plugin/eslint.mjs";import x from"./plugin/stylelint.mjs";import{empty as v}from"./utils/index.mjs";import{commonConfig as C}from"./common.mjs";import{CONFIG as _,getConfig as P,PUBLICPATH as k}from"./config.mjs";import{outputFileSystem as S}from"./file-system.mjs";import H from"./http-server.mjs";import B from"./module.config.mjs";import{isLibrary as I,isReact as L,refresh as O}from"./process-env.mjs";let R=`${k.endsWith("/")?"":"/"}__hmr__`,U=new URLSearchParams({name:"client",path:R,dynamicPublicPath:!0,timeout:2e3,reload:!O,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),q=c(C,{watchOptions:{stdin:!0,ignored:/node_modules\/(?!(@app|@moneko)).+/},entry:{main:[`${$.hotMiddlewareClient}?${U}`]},module:B(!1),plugins:[new a.HotModuleReplacementPlugin,new a.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]})]});if(q.plugins||(q.plugins=[]),L){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;q.plugins.push(new e({overlay:!1}))}function E(e){let t=e.join(","),o=[r(h.programPath,`${_.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return I&&o.push(r(h.programPath,`${_.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}_.eslint&&q.plugins.push(new b({fix:!0,cache:!0,cacheLocation:`${h.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:E(["js","jsx","ts","tsx","json","html","vue"]),..._.eslint})),_.stylelint&&q.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${h.lintCachePath}/.stylelintcache`,files:E(["css","scss","sass","less","ts","tsx","js","jsx"]),..._.stylelint}));let G=!1,T="/____progress____",F={percentage:0,info:""};if(_.bar){let e=_.bar,t=e.name||"Build";q.plugins.push(new a.ProgressPlugin({handler(o,r,...n){let s=n.length?`[${r}] ${n.join(" ")}`:" ";G||(F.info=s,F.percentage=o,G=1===o),e.quiet?i.stdout.write(`${s}
|
|
2
|
+
`):(m(o||0,1,{msg:s,name:t,barColor:e.barColor,nameColor:e.nameColor,barBgColor:e.barBgColor,msgColor:e.msgColor}),1===o&&i.stdout.write("\r\x1b[2K"))}}))}let M=a(q);M.outputFileSystem=S;let N=M.watch(M.options.watchOptions,g);M.hooks.done.tap("client-log",e=>{g(null,e)});let W={};_.devServer.https&&(W.http2=!0,W.https=await j());let J=p(M,{log:!1,path:R,heartbeat:2e3}),K=await H({port:w,root_dir:M.options.output.path,fileSystem:M.outputFileSystem,onRequest(e,t){let o=new URL(`${_.devServer.https?"https":"http"}://localhost:${w}${e.url}`);if("GET"===e.method){if(o.pathname===T){t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(F));return}if(!G){t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(y(T,F));return}if(o.pathname===`/${R}`.replace("//","/")&&"text/event-stream"===e.headers.accept){e.url=R,J(e,t,()=>{if(t.writableEnded)return});return}}}});function z(){i.exit(0)}K.on("close",()=>{N.close(v)});let A=await Promise.all(u.map(P)),D=c(A[0]||{},A[1]||{});u.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(u.map(P)),m=c(o||{},r||{}),a=f(D,m);1===Object.keys(a).length&&"proxy"in a?(s(n(`代理更新中...`,"yellow"),!0),s(n(`代理更新完成...`,"green"),!0),_.proxy=m.proxy,D.proxy=m.proxy,D=m):(D=m,l(n(`检测到工程配置${n(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e(Q?`netstat -ano | findstr :${w}`:`lsof -i :${w} -t`,(e,t)=>{if(e){l(n(`查找端口 ${w} 时发生错误: ${e.message}`,"red")),l(n("请尝试手动重启程序","yellow"));return}let o=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),r=Q?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){l(n(`未找到占用端口 ${w} 的进程, 请尝试手动重启程序`,"yellow"));return}try{i.kill(Number(r),"SIGHUP")}catch(e){l(n(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let Q="win32"===i.platform;i.on("SIGHUP",function(){K.close(v),function(){let e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",z)}()}),i.on("exit",function(){K.close(v)}),d(z);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { createReadStream, existsSync } from 'node:fs';
|
|
2
|
+
import { createServer, type IncomingMessage, Server as HttpServer, type ServerResponse } from 'node:http';
|
|
3
|
+
import { createServer as createHttpsServer, Server as HttpsServer } from 'node:https';
|
|
4
|
+
import { extname, sep } from 'node:path';
|
|
5
|
+
import type { OutputFileSystem } from 'webpack';
|
|
6
|
+
import mime from './commom/mime.mjs';
|
|
7
|
+
import { getServerAddress } from './dev/config.mjs';
|
|
8
|
+
import getCert from './dev/get-cert.mjs';
|
|
9
|
+
import { CONFIG } from './config.mjs';
|
|
10
|
+
export type FileSystem = OutputFileSystem & {
|
|
11
|
+
existsSync: typeof existsSync;
|
|
12
|
+
createReadStream: typeof createReadStream;
|
|
13
|
+
};
|
|
14
|
+
declare const normalHeaders: Record<string, string>;
|
|
15
|
+
type HttpServerResponse = ServerResponse<IncomingMessage> & {
|
|
16
|
+
req: IncomingMessage;
|
|
17
|
+
};
|
|
18
|
+
declare function replyStream(req: IncomingMessage, res: HttpServerResponse, filePath: string, fs: FileSystem);
|
|
19
|
+
interface ServerOption {
|
|
20
|
+
port: number;
|
|
21
|
+
root_dir: string;
|
|
22
|
+
fileSystem: FileSystem;
|
|
23
|
+
onRequest(req: IncomingMessage, res: HttpServerResponse): void;
|
|
24
|
+
}
|
|
25
|
+
export type Server = HttpServer | HttpsServer;
|
|
26
|
+
declare async function server(option: ServerOption);
|
|
27
|
+
export default server;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createServer as e}from"node:http";import{createServer as t}from"node:https";import{extname as o,sep as r}from"node:path";import n from"./commom/mime.mjs";import{getServerAddress as i}from"./dev/config.mjs";import s from"./dev/get-cert.mjs";import{CONFIG as a}from"./config.mjs";let d={"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","Access-Control-Allow-Origin":"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0",...a.devServer.headers||{}};async function c(c){function l(e,t){if(c.onRequest(e,t),"GET"===e.method){let i=decodeURIComponent(`${c.root_dir}${r}${"/"===e.url?"index.html":e.url}`);c.fileSystem.existsSync(i)&&function(e,t,r,i){t.setHeaders(new Headers(d)),e.headers.origin&&t.setHeader("Access-Control-Allow-Origin",e.headers.origin);let s=e.headers["accept-encoding"],a=s?.includes("br"),c=`${r}.${a?"br":"gz"}`,l=i.existsSync(c);l&&t.setHeader("Content-Encoding",a?"br":"gzip");let m=i.createReadStream(l?c:r,{autoClose:!0});m.on("open",()=>{t.writeHead(200,{"Content-Type":n[o(r)||"application/octet-stream"]})}),m?.on("error",e=>{switch(m.destroy(),e.code){case"ENOENT":t.writeHead(301,{Location:"/index.html"}),t.end();break;case"EACCES":t.writeHead(403,{"Content-Type":"text/plain"}),t.end(`Forbidden: ${e.message}`);break;default:t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`Internal Server Error: ${e.message}`)}}),m.pipe(t)}(e,t,i,c.fileSystem)}}let m=a.devServer.https?t(await s(),l):e(l);return m.listen(c.port,()=>{a.devServer.open&&open(i("local"))}),m}export default c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let r,t;import e from"browserslist";import{browserslistToTargets as s}from"lightningcss";import
|
|
1
|
+
let r,t;import{env as o}from"node:process";import e from"browserslist";import{browserslistToTargets as s}from"lightningcss";import i from"../commom/paths.mjs";export function getBrowsersTargets(){return r||(r=e(void 0,{path:i.programPath,env:o.NODE_ENV}).filter(r=>!r.endsWith(" TP"))),r}export function getLightningCssTargets(){return t||(t=s(getBrowsersTargets())),t}
|
package/lib/process-env.d.mts
CHANGED
package/lib/process-env.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"node:process";import r from"./commom/has-pkg.mjs";import e from"./commom/is-ci-environment.mjs";import t from"./commom/require.mjs";export const IS_WINDOW="win32"===o.platform;export const APPTYPE=o.env.APPTYPE;export const FRAMEWORK=o.env.FRAMEWORK;export const NODE_ENV=o.env.NODE_ENV;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isMobile="mobile"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const SSR="true"===o.env.SSR;export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const framework={react:"react",solid:"solid-js"}[FRAMEWORK];export const frameworkVersionStr=framework?t(`${framework}/package.json`).version:19;export const frameworkVersion=parseFloat(frameworkVersionStr);export const packageJson=t(`${o.cwd()}/package.json`);delete packageJson.scripts;export const PACKAGENAME=packageJson.name;export const coreName="@moneko/core";export const isDev="development"===NODE_ENV;export const refresh=!!(isDev&&(r("solid-refresh")||r("react-refresh")));export const isCI=e();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.42.2-beta.
|
|
3
|
+
"version": "3.42.2-beta.3",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -106,7 +106,6 @@
|
|
|
106
106
|
"homepage": "https://monako97.github.io/neko-ui/@moneko/config",
|
|
107
107
|
"license": "MIT",
|
|
108
108
|
"dependencies": {
|
|
109
|
-
"@fastify/http-proxy": "9.5.0",
|
|
110
109
|
"@moneko/convert": "1.0.1",
|
|
111
110
|
"@moneko/eslint": "1.5.0",
|
|
112
111
|
"@moneko/mdx": "0.1.44",
|
|
@@ -119,7 +118,6 @@
|
|
|
119
118
|
"chokidar": "4.0.3",
|
|
120
119
|
"core-js": "3.41.0",
|
|
121
120
|
"core-js-compat": "3.41.0",
|
|
122
|
-
"fastify": "4.29.0",
|
|
123
121
|
"husky": "9.1.7",
|
|
124
122
|
"less": "4.3.0",
|
|
125
123
|
"less-loader": "12.2.0",
|