@moneko/core 3.26.1 → 3.26.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 +16 -1
- package/lib/bin/build-app.mjs +1 -1
- package/lib/bin/build.d.mts +2 -1
- package/lib/bin/build.mjs +1 -1
- package/lib/bin/changelog.d.mts +1 -1
- package/lib/bin/changelog.mjs +3 -3
- package/lib/bin/eslint.d.mts +1 -1
- package/lib/bin/eslint.mjs +1 -1
- package/lib/bin/file.d.mts +0 -15
- package/lib/bin/file.mjs +1 -1
- package/lib/bin/git-hooks.d.mts +1 -1
- package/lib/bin/git-hooks.mjs +1 -1
- package/lib/bin/help.d.mts +2 -0
- package/lib/bin/help.mjs +36 -0
- package/lib/bin/index.d.mts +1 -8
- package/lib/bin/index.mjs +1 -1
- package/lib/bin/lessc.mjs +1 -1
- package/lib/bin/runlint.d.mts +1 -1
- package/lib/bin/runlint.mjs +1 -1
- package/lib/bin/start.d.mts +2 -1
- package/lib/bin/start.mjs +1 -1
- package/lib/bin/stylelint.d.mts +1 -1
- package/lib/bin/stylelint.mjs +1 -1
- package/lib/bin/utils/bundle-app.mjs +1 -1
- package/lib/bin/utils/config.d.mts +0 -1
- package/lib/bin/utils/config.mjs +1 -1
- package/lib/bin/utils/setup-swcrc.d.mts +1 -1
- package/lib/bin/utils/setup-swcrc.mjs +1 -1
- package/lib/build.mjs +1 -1
- package/lib/commom/require.mjs +1 -0
- package/lib/common.mjs +1 -1
- package/lib/config.mjs +1 -1
- package/lib/dev/mock.mjs +1 -1
- package/lib/dev/net.mjs +1 -1
- package/lib/dev.mjs +1 -1
- package/lib/index.d.mts +1 -1
- package/lib/index.mjs +1 -1
- package/lib/module.config.mjs +1 -1
- package/lib/options/modify-vars.d.mts +1 -1
- package/lib/options/modify-vars.mjs +1 -1
- package/lib/options/reslove.mjs +1 -1
- package/lib/paths.d.mts +2 -0
- package/lib/paths.mjs +1 -1
- package/lib/plugin/copy.mjs +1 -1
- package/lib/plugin/exposes-declararion.mjs +1 -1
- package/lib/plugin/lightningcss-plugin.mjs +1 -1
- package/lib/plugin/module-federation.mjs +1 -1
- package/lib/plugin/override-resolve.mjs +1 -1
- package/lib/polyfills/polyfills.mjs +1 -1
- package/lib/process-env.mjs +1 -1
- package/lib/utils/create-types.mjs +1 -1
- package/lib/utils/has-pkg.mjs +1 -1
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/parse-module-meta.mjs +1 -1
- package/lib/utils/reactive-object.d.mts +1 -1
- package/lib/utils/reactive-object.mjs +1 -1
- package/lib/utils/run.mjs +1 -1
- package/lib/utils/seo.mjs +1 -1
- package/lib/utils/vts.mjs +1 -1
- package/lib/vm/docs.mjs +1 -1
- package/lib/vm/generate-doc.mjs +1 -1
- package/lib/vm/info.mjs +1 -1
- package/lib/vm/locales.mjs +2 -2
- package/lib/vm/modules.mjs +1 -1
- package/package.json +1 -2
- package/lib/bin/version.d.mts +0 -1
- package/lib/bin/version.mjs +0 -1
- package/lib/utils/print.d.mts +0 -2
- package/lib/utils/print.mjs +0 -2
- package/lib/utils/require.mjs +0 -1
- /package/lib/{utils → commom}/require.d.mts +0 -0
package/lib/bin/build-app.d.mts
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 拷贝文件
|
|
3
|
+
* @param {String} source 源文件
|
|
4
|
+
* @param {String} target 目标文件
|
|
5
|
+
* @constructor
|
|
6
|
+
* */
|
|
7
|
+
export declare function copyFileSync(source: string, target: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* 拷贝文件夹
|
|
10
|
+
* @param {String} source 源文件夹
|
|
11
|
+
* @param {String} target 目标文件夹
|
|
12
|
+
* @param {String} sun 是否子文件夹
|
|
13
|
+
* @constructor
|
|
14
|
+
* */
|
|
15
|
+
export declare function copyFolderRecursiveSync(source: string, target: string, sun?: boolean): void;
|
|
16
|
+
export default function createApp(): Promise<void>;
|
package/lib/bin/build-app.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{argv as e}from"node:process";import{execSync as i}from"node:child_process";import{existsSync as n,statSync as o,readdirSync as s}from"node:fs";import r from"node:path";import{bundleApk as t,bundleIOS as l}from"./utils/bundle-app.mjs";import{__dirname as a}from"./file.mjs";import{corePkg as c}from"./utils/config.mjs";import{cwd as p}from"./utils/config.mjs";import{createDir as d,loadFileSync as m,saveFileSync as u,removeDir as f,saveFile as y,parseYaml as S,jsonToYaml as b,parsePlist as j,buildPlist as g,parseXml as _,buildXml as w,ink as k,print as O,println as A}from"@moneko/utils";export function copyFileSync(e,i){let n=m(e);if(null!==n){let s=i;o(i).isDirectory()&&(s=r.join(i,r.basename(e))),u(s,n)}}export function copyFolderRecursiveSync(e,i,n){let t=i;n&&(t=r.join(i,r.basename(e))),o(e).isDirectory()&&s(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(){e.slice(3).forEach(e=>{let[i,n]=e.replace(/^--/,"").split("=");process.env[`__args__${i}__`]=n});let{CONFIG:u}=await import(`${c}/lib/config.mjs`),N=u.bundleId;N||(A(k("请配置 bundleId","red")),process.exit(1)),/(^com\.)([a-zA-Z_][a-zA-Z0-9_]*[.])*([a-zA-Z_][a-zA-Z0-9_]*)$/.test(N)&&3===N.split(".").length||(A(k("软件包名不合法","red")),process.exit(1));let x=u.bundles;x&&0!==x.length||(A(k("请配置 bundles (打包类型)","red")),process.exit(1));let h=N.split(".").splice(-1,1).join(""),E=r.join(p,"/dist"),$=`flutter create -t app --org ${N} -i swift -a kotlin ${h}`,R=r.join(p,"/"+h),T=r.join(R,"assets/web/");i($,{encoding:"utf-8"}),d(T),O(k("正在注册资产...","yellow"),!0),copyFolderRecursiveSync(E,T);let V=r.join(R,"pubspec.yaml"),v=JSON.parse(await S(V)||"{}"),I=[],J=(e,i="assets/web")=>{let n=s(e);!function s(r){r!=n.length&&(o(e+"/"+n[r]).isDirectory()&&(I.push(i+"/"+n[r]+"/"),J(e+"/"+n[r],i+"/"+n[r])),s(r+1))}(0)};if(J(E),v.dependencies.webview_flutter_plus="^0.2.3",v.flutter.assets=["assets/web/",...I],y(V,await b(JSON.stringify(v))),O(k("注册资产","cyan")+": "+k("完成","cyan"),!0),x.includes("apk -release")||x.includes("apk -debug")){O(k("正在配置安卓权限...","yellow"),!0);let e=r.join(R,"android/app/src/main/AndroidManifest.xml"),i=JSON.parse(_(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"}}],y(e,w(JSON.stringify(i)));let n=r.join(R,"android/app/build.gradle"),o=m(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")),y(n,o),O(k("安卓权限配置","cyan")+": "+k("完成","cyan"),!0)}if(x.includes("ios -release")||x.includes("ios -debug")){O(k("开始配置IOS权限","yellow"),!0);let e=r.join(R,"ios/Runner/Info.plist"),i=Object.assign(JSON.parse(await j(e)),{NSAppTransportSecurity:{NSAllowsArbitraryLoads:!0},"io.flutter.embedded_views_preview":!0});y(e,await g(JSON.stringify(i))),O(k("IOS权限配置","cyan")+": "+k("完成","cyan"),!0)}y(r.join(R,"lib/main.dart"),m(r.join(a,"./conf/bootstrap"))||"");let D=r.join(p,"./bundle/");d(D),setTimeout(()=>{x.forEach(e=>{let i=e.split(" ");"apk"===i[0]&&t(R,D,i[1]),"ios"===i[0]&&l(R,D,i[1])}),f(R),n(r.join(D,"Runner"))&&f(r.join(D,"Runner")),O("✨ "+k("Done","green"),!0),process.exit(0)},1e3)}
|
package/lib/bin/build.d.mts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare function build(): Promise<void>;
|
|
2
|
+
export default build;
|
package/lib/bin/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{argv as e}from"node:process";import{spawn as o}from"node:child_process";import{join as s,relative as t}from"node:path";import i from"./utils/setup-env.mjs";import{lesscCommonjs as r}from"./lessc.mjs";import{corePkg as n,cwd as m,swcCachePath as l,runtimePath as c}from"./utils/config.mjs";import p from"./utils/setup-swcrc.mjs";import d from"../commom/require.mjs";import{__dirname as f}from"./file.mjs";import{deleteEmptyDirs as u,updateFileSync as a,removeDir as j,ink as $,println as y,scanFolderSync as _,removeFile as g}from"@moneko/utils";let b={stdio:"inherit",shell:!0};async function h(){let h=e[3],x=e[4],v=e.slice(5);h||(y($(`type: 无效值 ${$(h,"245")}`,"red")),process.exit(1));let C=!v.includes("no-docs"),w=!v.includes("no-lib"),E=!v.includes("no-es"),D=v.filter(e=>!["no-docs","no-es","no-lib"].includes(e));await i("production",h,x,D);let S=`${c} ${d.resolve(`${n}/lib/build.mjs`)}`;if("library"===h){let e=p(x),i=d.resolve("typescript/bin/tsc"),n=d.resolve("@swc/cli/bin/swc.js"),$=[w&&{type:"commonjs",dir:"lib",msg:"Convert to CommonJS"},E&&{type:"es6 -C jsc.target=es2015",dir:"es",msg:"Convert to ES Module"}].filter(Boolean),y=s(f,".types.json");$.length&&a(y,JSON.stringify({extends:t(f,s(m,"tsconfig.json")),include:[t(f,s(m,"components")),t(f,s(m,"typings"))],exclude:[t(f,s(m,"components/**/examples/*")),t(f,s(m,"components/**/__tests__/*")),t(f,s(m,"components/**/__mocks__/*"))]}));for(let t=0,p=$.length;t<p;t++){let p=s(m,`./${$[t].dir}`);j(p),o(`${c} ${n} components -d ${$[t].dir} -q --strip-leading-paths --config-file ${e} -C jsc.experimental.cacheRoot=${l} -C module.type=${$[t].type} -D --ignore "**/*.test.(js|ts)x?$"`,b).on("close",function(e){0===e&&(_(p,["README.mdx","examples","__*__"]).forEach(g),u(p),"commonjs"===$[t].type&&r())}),o(`${c} ${i} --project ${y} --outDir ${$[t].dir}`,b)}}("library"!==h||C&&"library"===h)&&o(S,b)}export default h;
|
package/lib/bin/changelog.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function changelog(): void;
|
package/lib/bin/changelog.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
${t.title}`),t.logs)Object.prototype.hasOwnProperty.call(t.logs,e)&&(
|
|
1
|
+
import{argv as t}from"node:process";import{execSync as e}from"node:child_process";import{join as o}from"node:path";import{cwd as r}from"./utils/config.mjs";import{updateFileSync as s}from"@moneko/utils";let i={feat:"✨ Features",fix:"🐛 Bug Fixes",docs:"📚 Documentation",style:"💎 Styles",refactor:"📦 Code Refactoring",perf:"🚀 Performance Improvements",test:"🚨 Tests",build:"🛠 Builds",ci:"⚙️ Continuous Integrations",chore:"♻️ Chores",revert:"🗑 Reverts"};function n(t,o){return function(t){let e=[];for(let o of t.trim().split("\n")){let[t,r,s,n,a]=o.split("|");if(a){let o=a.split(": "),l=i[o[0]];e.push({commitId:t,author:r,email:s,date:new Date(n).toLocaleString().replace(/\//g,"-"),message:l?o.slice(1).join(":"):a,type:l})}}return e}(e(`git log ${t?`${t}..`:""}${o||""} --format='%H|%an|%ae|%ad|%s'`,{encoding:"utf-8"}))}export default function a(){let i=t[3],a=["# Change log"];try{e('git show-ref --quiet --verify "refs/heads/$(git rev-parse --abbrev-ref HEAD)";');let t=e('git config --get remote.origin.url | sed "s/\\.git$//"').toString().trim(),o=function(t){let o=e("git for-each-ref --sort='v:refname' --format '%(objectname) %(refname:short) %(creatordate:iso8601)' refs/tags",{encoding:"utf-8"}),r=[],s=o.trim().split("\n");return s.forEach((e,o)=>{let[i,n,a]=e.split(" "),l=s[o-1]?.split(" ")[1],c=`## ${n}`;l&&(c=`## [${n}](${t}/compare/${l}...${n}) (${new Date(a).toLocaleDateString().replace(/\//g,"-")})`),r.push({commitId:i,tag:n,date:a,title:c,logs:{}})}),r}(t);o.forEach((e,r)=>{if(r&&n(o[r-1].tag,e.tag).forEach(e=>{if(e.type){let s=o[r].logs[e.type]||[];s.push(`- ${e.message} ([${e.commitId.substring(0,7)}](${t}/commit/${e.commitId}))`),Object.assign(o[r].logs,{[e.type]:s})}}),r===o.length-1){let s=n(e.tag);s.length&&o.push({title:"## Last",logs:{}}),s.forEach(e=>{if(e.type){let s=o[r+1].logs[e.type]||[];s.push(`- ${e.message} ([${e.commitId.substring(0,7)}](${t}/commit/${e.commitId}))`),Object.assign(o[r+1].logs,{[e.type]:s})}})}}),o.reverse().forEach(t=>{for(let e in a.push(`
|
|
2
|
+
${t.title}`),t.logs)Object.prototype.hasOwnProperty.call(t.logs,e)&&(a.push(`
|
|
3
3
|
### ${e}
|
|
4
|
-
`),t.logs[e].forEach(t=>
|
|
4
|
+
`),t.logs[e].forEach(t=>a.push(t)))})}catch{a.push("\n当前分支尚无任何提交\n")}s(o(r,i),a.join("\n"))}
|
package/lib/bin/eslint.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function eslint(): void;
|
package/lib/bin/eslint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{argv as o}from"node:process";import{join as i,relative as e}from"node:path";import{runLint as t}from"./runlint.mjs";import{cachePath as m,cwd as n,runtimePath as r}from"./utils/config.mjs";import s from"../commom/require.mjs";export default function c(){let c=o[3],l=o.slice(4),f=i(s.resolve("eslint"),"../../bin/eslint.js");t(`${r} ${f} ${e(n,c)} --config ${e(n,"eslint.config.mjs")} ${l.join(" ")} --cache --cache-location "${m}/.eslintcache"`,"eslint")}
|
package/lib/bin/file.d.mts
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
1
|
export declare const __filename: string;
|
|
2
2
|
export declare const __dirname: string;
|
|
3
|
-
/**
|
|
4
|
-
* 拷贝文件
|
|
5
|
-
* @param {String} source 源文件
|
|
6
|
-
* @param {String} target 目标文件
|
|
7
|
-
* @constructor
|
|
8
|
-
* */
|
|
9
|
-
export declare function copyFileSync(source: string, target: string): void;
|
|
10
|
-
/**
|
|
11
|
-
* 拷贝文件夹
|
|
12
|
-
* @param {String} source 源文件夹
|
|
13
|
-
* @param {String} target 目标文件夹
|
|
14
|
-
* @param {String} sun 是否子文件夹
|
|
15
|
-
* @constructor
|
|
16
|
-
* */
|
|
17
|
-
export declare function copyFolderRecursiveSync(source: string, target: string, sun?: boolean): void;
|
package/lib/bin/file.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"node:path";import o from"node:url";export const __filename=o.fileURLToPath(import.meta.url);export const __dirname=e.dirname(__filename);
|
package/lib/bin/git-hooks.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function githooks(): void;
|
package/lib/bin/git-hooks.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{argv as o}from"node:process";import{runLint as t}from"./runlint.mjs";export default function e(){let e="node_modules/.husky",i=o.slice(3).map(o=>{let t=o.split("=");return`echo "${t[1]}" > ${e}/${t[0]}`}).join(" && ");t(`git init && husky ${e} && ${i}`,"githooks",[null])}
|
package/lib/bin/help.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import{ink as e,println as $}from"@moneko/utils";export default function(){let l="react | solid | vue",r="backstage | library | site | micro | mobile";$(`
|
|
2
|
+
${e("使用方法:","white")} ${e("mo","blue")} ${e("<命令>","green")} ${e("<必选参数>","208")} ${e("[可选参数]","yellow")}
|
|
3
|
+
|
|
4
|
+
${e("命令列表:","white")}
|
|
5
|
+
${e("start","green")} ${e("<type> <framework>","208")} 启动开发服务器
|
|
6
|
+
${e("type: ","245",{bold:!0})}${e(r,"245",{italic:!0})}
|
|
7
|
+
${e("framework: ","245",{bold:!0})}${e(l,"245",{italic:!0})}
|
|
8
|
+
|
|
9
|
+
${e("build","green")} ${e("<type> <framework>","208")} 构建生产环境应用
|
|
10
|
+
${e("type: ","245",{bold:!0})}${e(r,"245")}
|
|
11
|
+
${e("framework: ","245",{bold:!0})}${e(l,"245",{italic:!0})}
|
|
12
|
+
|
|
13
|
+
${e("eslint","green")} ${e("<source_path>","208")} 执行代码规范检查
|
|
14
|
+
${e("source_path: ","245",{bold:!0})}${e("要检查的文件或目录路径","245",{italic:!0})}
|
|
15
|
+
|
|
16
|
+
${e("stylelint","green")} ${e("<source_path>","208")} 执行样式规范检查
|
|
17
|
+
${e("source_path: ","245",{bold:!0})}${e("要检查的文件或目录路径","245",{italic:!0})}
|
|
18
|
+
|
|
19
|
+
${e("githooks","green")} 配置 Git 钩子以自动化工作流
|
|
20
|
+
|
|
21
|
+
${e("buildApp","green")} 创建新的应用程序脚手架
|
|
22
|
+
|
|
23
|
+
${e("changelog","green")} ${e("<filename>","208")} 生成项目变更日志
|
|
24
|
+
${e("filename: ","245",{bold:!0})}${e("输出的文件名","245",{italic:!0})}
|
|
25
|
+
|
|
26
|
+
${e("选项:","white")}
|
|
27
|
+
${e("-v, --version","yellow")} 显示版本信息
|
|
28
|
+
${e("-h, --help","yellow")} 显示帮助信息
|
|
29
|
+
|
|
30
|
+
${e("示例:","white")}
|
|
31
|
+
${e("mo","blue")} ${e("start","green")} ${e("library react","208")} ${e("# 启动开发服务器","245")}
|
|
32
|
+
${e("mo","blue")} ${e("build","green")} ${e("library react","208")} ${e("# 构建生产版本","245")}
|
|
33
|
+
${e("mo","blue")} ${e("eslint","green")} ${e("components","208")} ${e("# 检查并修复代码","245")}
|
|
34
|
+
${e("mo","blue")} ${e("stylelint","green")} ${e("src","208")} ${e("# 检查样式文件","245")}
|
|
35
|
+
${e("mo","blue")} ${e("changelog","green")} ${e("CHANGELOG.md","208")} ${e("# 生成变更日志","245")}
|
|
36
|
+
`)}
|
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{
|
|
2
|
+
import{argv as a}from"node:process";import{ink as e,println as t}from"@moneko/utils";import{corePkg as s}from"./utils/config.mjs";import i from"../commom/require.mjs";switch(a[2]){case"-v":case"--version":t(`${e(s,"blue")}: ${i(`${s}/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()}["SIGINT","SIGTERM","SIGQUIT"].forEach(a=>process.on(a,()=>{process.exit(0)}));
|
package/lib/bin/lessc.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as
|
|
1
|
+
import{join as e}from"node:path";import{exec as o}from"node:child_process";import{runtimePath as s,corePkg as t}from"./utils/config.mjs";import i from"../commom/require.mjs";import{loadFile as r,saveFile as l,scanFolderSync as m}from"@moneko/utils";let n="";function a(t){let r=e(i.resolve("less"),"../bin/lessc");return new Promise((e,i)=>{o(`${s} ${r} --js ${n} ${t} > ${t.replace(/\.less$/g,".css")}`,function(o){if(o)return i(o);e(!0)})})}let c=/\*?\.less/g;async function f(e){let o=await r(e);o&&c.test(o)&&await l(e,o.replace(c,".css"))}export async function lesscCommonjs(){let e=m("lib",["\\.less$"]),o=(await import(`${t}/lib/options/modify-vars.mjs`)).default;for(let e in o)Object.hasOwnProperty.call(o,e)&&(n+=`--modify-var="${e}=${o[e]}" `);Promise.all(e.map(a)),e.length&&Promise.all(m("lib",["\\.js$"]).map(f))}
|
package/lib/bin/runlint.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StdioOptions } from 'child_process';
|
|
1
|
+
import { StdioOptions } from 'node:child_process';
|
|
2
2
|
export declare const runLint: (shellSrc: string, pluginName: string, stdio?: StdioOptions) => never;
|
package/lib/bin/runlint.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ink as t,print as s}from"@moneko/utils";import{spawnSync as e}from"child_process";export const runLint=(r,
|
|
1
|
+
import{ink as t,print as s}from"@moneko/utils";import{spawnSync as e}from"node:child_process";export const runLint=(o,r,i="inherit")=>{let l=t(r,"cyan");s(l+": "+t("Runing...","yellow"),!0);let n=e(o,{stdio:i,shell:!0});s(l+": "+t(`✨ ${0!==n.status?"Error":"Successfully"}!
|
|
2
2
|
`,0!==n.status?"red":"green"),!0),process.exit(n.status||0)};
|
package/lib/bin/start.d.mts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare function start(): Promise<void>;
|
|
2
|
+
export default start;
|
package/lib/bin/start.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{argv as e}from"node:process";import{spawn as o}from"node:child_process";import{ink as i,println as r}from"@moneko/utils";import{corePkg as m,runtimePath as t}from"./utils/config.mjs";import s from"./utils/setup-env.mjs";import l from"../commom/require.mjs";async function p(){let p=e[3],n=e[4],f=e.slice(5);p||(r(i("type: 无效值 "+i(p,"245"),"red")),process.exit(1));let c=f.indexOf("no-verify");-1!==c&&f.splice(c,1),await s("development",p,n,f),o(`${t} ${l.resolve(`${m}/lib/dev.mjs`)}`,{stdio:"inherit",shell:!0})}export default p;
|
package/lib/bin/stylelint.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function stylelint(): void;
|
package/lib/bin/stylelint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{argv as s}from"node:process";import{relative as t,join as e}from"node:path";import{cachePath as o,cwd as i,runtimePath as l}from"./utils/config.mjs";import{runLint as m}from"./runlint.mjs";import r from"../commom/require.mjs";export default function c(){let c=s[3],n=s.slice(4),a=e(r.resolve("stylelint"),"../../bin/stylelint.mjs");m(`${l} ${a} ${t(i,c)}/**/**/**/**/*.{less,css,scss,sass,style.ts,style.js} ${n.join(" ")} --cache --cache-location "${o}/.stylelintcache" --aei`,"stylelint")}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{join as e}from"node:path";import{renameSync as o}from"node:fs";import{execSync as n}from"node:child_process";import{bundleIpa as p,createDir as l,ink as i,print as t}from"@moneko/utils";export function bundleApk(p,a,u="-release"){t(i("正在编译 apk...","yellow"),!0),console.time("bundle apk "+u),n(`flutter build apk -${u}`),console.timeEnd("bundle apk "+u),l(a),o(e(p,`build/app/outputs/flutter-apk/app${u}.apk`),a),t("✨ "+i("Apk 编译","cyan")+": "+i("完成","cyan"),!0)}export function bundleIOS(a,u,r="-release"){t(i("正在编译 ipa...","yellow"),!0),console.time("bundle ipa "+r);let d=e(u,"Runner/Payload");n(`flutter build ios -${r} --no-codesign`),l(d),o(e(a,"build/ios/iphoneos/Runner.app"),d),p(e(u,"Runner"),u,r),console.timeEnd("bundle ipa "+r),t("✨ "+i("ipa 编译","cyan")+": "+i("完成","cyan"),!0)}
|
package/lib/bin/utils/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e,dirname as o}from"path";
|
|
1
|
+
import{join as e,dirname as o}from"node:path";let c="undefined"!=typeof Deno?"deno":"undefined"!=typeof Bun?"bun":"node",t=o(process.execPath);"win32"===process.platform&&t.includes(" ")&&(t=`"${t}"`);export const runtimePath=e(t,c);export const corePkg="@moneko/core";export const cwd=process.cwd();export const cachePath=e(cwd,"node_modules/.cache");export const swcCachePath=e(cachePath,".swc");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function setupSwcRc(framework:
|
|
1
|
+
declare function setupSwcRc(framework: string): string;
|
|
2
2
|
export default setupSwcRc;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e}from"path";import{__dirname as o}from"../file.mjs";import r from"../../
|
|
1
|
+
import{join as e}from"node:path";import{__dirname as o}from"../file.mjs";import r from"../../commom/require.mjs";import{updateFileSync as s}from"@moneko/utils";let m=e(o,".swcrc");export default function(e){let o="solid"===e;return s(m,JSON.stringify({$schema:"https://json.schemastore.org/swcrc",module:{type:"es6"},minify:!0,jsc:{minify:{mangle:!0,compress:!0,format:{comments:"some"}},parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",externalHelpers:!1,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:"react"===e,development:!1,importSource:o?"solid-js/h":void 0}},experimental:{plugins:[[r.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"]}}],o&&[r.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$"]})),m}
|
package/lib/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{analyzeBundleSize as o,completedInfo as r,ink as m,println as t,progressBar as i}from"@moneko/utils";import{relative as e}from"path";import n from"webpack";import{merge as s}from"webpack-merge";import a from"./build/common.mjs";import p from"./plugin/done.mjs";import{empty as l}from"./utils/index.mjs";import c from"./utils/seo.mjs";import{CONFIG as f}from"./config.mjs";import u from"./module.config.mjs";import d from"./paths.mjs";let h=f.bar.name||"Build",{ProgressPlugin:g}=n,w=n(s(a,{module:u(!1),plugins:[f.done&&new p({done:f.done}),!!f.bar&&new g({handler(o,r,...m){i(o||0,1,h,m.length?`[${r}] ${m.join(" ")}`:""),1===o&&process.stdout.write("\r\x1b[2K")}})].filter(Boolean)}));async function j(){let i=await new Promise((o,r)=>{w.run((m,t)=>{m&&r(m),t?o(t):r(Error("编译过程中没有生成统计信息"))})});(i.hasErrors()||i.hasWarnings())&&function(o){let{warnings:r,errors:i}=o.compilation;r.forEach(o=>{t(m(o.message,"178"))}),i.forEach(o=>{t(m(o.message,"red"))})}(i),await new Promise(n=>{i.compilation.compiler.cache.shutdown(s=>{s&&t(m(s.toString(),"red")),o(i.compilation.outputOptions.path,["\\.js$"]),r(~~((i.endTime-i.startTime)/10)/100,e(d.programPath,i.compilation.outputOptions.path)),n()})}),f.seo&&c()}process.on("exit",l),await j();
|
|
1
|
+
import{analyzeBundleSize as o,completedInfo as r,ink as m,println as t,progressBar as i}from"@moneko/utils";import{relative as e}from"node:path";import n from"webpack";import{merge as s}from"webpack-merge";import a from"./build/common.mjs";import p from"./plugin/done.mjs";import{empty as l}from"./utils/index.mjs";import c from"./utils/seo.mjs";import{CONFIG as f}from"./config.mjs";import u from"./module.config.mjs";import d from"./paths.mjs";let h=f.bar.name||"Build",{ProgressPlugin:g}=n,w=n(s(a,{module:u(!1),plugins:[f.done&&new p({done:f.done}),!!f.bar&&new g({handler(o,r,...m){i(o||0,1,h,m.length?`[${r}] ${m.join(" ")}`:""),1===o&&process.stdout.write("\r\x1b[2K")}})].filter(Boolean)}));async function j(){let i=await new Promise((o,r)=>{w.run((m,t)=>{m&&r(m),t?o(t):r(Error("编译过程中没有生成统计信息"))})});(i.hasErrors()||i.hasWarnings())&&function(o){let{warnings:r,errors:i}=o.compilation;r.forEach(o=>{t(m(o.message,"178"))}),i.forEach(o=>{t(m(o.message,"red"))})}(i),await new Promise(n=>{i.compilation.compiler.cache.shutdown(s=>{s&&t(m(s.toString(),"red")),o(i.compilation.outputOptions.path,["\\.js$"]),r(~~((i.endTime-i.startTime)/10)/100,e(d.programPath,i.compilation.outputOptions.path)),n()})}),f.seo&&c()}process.on("exit",l),await j();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import{transformFileSync as o}from"@swc/core";let t=e(import.meta.url),s={sourceMaps:!1,module:{type:"commonjs"},jsc:{parser:{syntax:"typescript"}}};function r(e,t){return e._compile(o(t,s).code,t)}t.extensions[".ts"]=r,t.extensions[".mts"]=r,t.extensions[".mjs"]=r;export default t;
|
package/lib/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CONFIG as e,PUBLICPATH as t}from"./config.mjs";import o,{CUSTOMCONFIG as a,config_files as
|
|
1
|
+
import{CONFIG as e,PUBLICPATH as t}from"./config.mjs";import o,{CUSTOMCONFIG as a,config_files as n}from"./paths.mjs";import s from"./plugin/override-resolve.mjs";import i from"./plugins.config.mjs";import{NODE_ENV as l,PACKAGENAME as r,PACKAGEVERSION as m,isDev as p,isLibrary as c}from"./process-env.mjs";import{isObject as u,node_modules as d,resolveProgram as h}from"./utils/index.mjs";import{join as f,resolve as g,extname as b}from"node:path";import{exampleModuleName as y}from"./vm/example.mjs";import j from"./vm/info.mjs";export const outputConfig={path:h(c?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${p?"name":"contenthash"}].js`,assetModuleFilename:e=>{let t=b(e.filename||"").substring(1);return`assets/${t}/[name][hash][ext]`},library:{name:`${j.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${r}`,pathinfo:p,clean:!0,publicPath:t,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"anonymous",enabledWasmLoadingTypes:["fetch"],hotUpdateChunkFilename:"[id].[fullhash].hot.js",hotUpdateMainFilename:"[runtime].[fullhash].hot.json"};let v={main:[e.polyfill&&f(o.corePath,"./polyfills/replace-children.mjs"),d("@app/entry")].filter(Boolean)};e.entry&&("string"==typeof e.entry?v={main:[e.entry]}:Object.keys(e.entry)&&(v=Object.assign(v,e.entry))),"string"==typeof v.main&&(v.main=[v.main]),e.output&&("string"==typeof e.output?outputConfig.path=e.output:Object.keys(e.output)&&Object.assign(outputConfig,e.output));let C={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:o.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[a,l].filter(Boolean).join("-")}`,version:`${m}`,buildDependencies:{config:n}};!1===e.cache?C=!1:u(e.cache)&&(C=Object.assign(C,e.cache));let k=Object.assign({original:e.alias["@"],override:a&&h(a)},e.overrideResolve);export const commonConfig={name:"client",target:"web",devtool:e.devtool,entry:v,mode:p?"development":"production",stats:"errors-only",cache:C,snapshot:{immutablePaths:[/node_modules\/(?!(@app|@moneko)\/)/],managedPaths:[/^@app\/.+/,/^@moneko\/.+/],buildDependencies:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:e.externalsPresets,plugins:i,node:{global:!1,__filename:!1,__dirname:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:e.lazyCompilation&&p&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(d(y))||t.startsWith(d("@app/comment"))||t.startsWith(o.pagesPath)||t.startsWith(o.componentsPath)))}},buildHttp:u(e.buildHttp)?{allowedUris:[],lockfileLocation:g(o.httpCachePath,"http.lock"),cacheLocation:g(o.httpCachePath,"data"),upgrade:!0,...e.buildHttp}:e.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:e.alias,modules:[o.nodeModules,o.pnpmNodeModules,o.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:[e.overrideResolve&&new s(k),...e.resolvePlugins].filter(Boolean),preferAbsolute:!0,cache:!0,fallback:{}},externals:e.externals,output:outputConfig};
|
package/lib/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import o from"./options/jsx-dom-expressions.mjs";import t from"./options/split-chunk.mjs";import n from"./paths.mjs";import{APPTYPE as s,FRAMEWORK as i,NODE_ENV as r,PACKAGENAME as l,isDev as a,isLibrary as m,isMobile as p,jsxImportSource as u,mainDirectory as c}from"./process-env.mjs";import{isFunction as d,resolveProgram as f}from"./utils/index.mjs";import h from"./utils/setup-env.mjs";import{fileExists as g}from"@moneko/utils";import x from"./
|
|
1
|
+
import{merge as e}from"webpack-merge";import o from"./options/jsx-dom-expressions.mjs";import t from"./options/split-chunk.mjs";import n from"./paths.mjs";import{APPTYPE as s,FRAMEWORK as i,NODE_ENV as r,PACKAGENAME as l,isDev as a,isLibrary as m,isMobile as p,jsxImportSource as u,mainDirectory as c}from"./process-env.mjs";import{isFunction as d,resolveProgram as f}from"./utils/index.mjs";import h from"./utils/setup-env.mjs";import{fileExists as g}from"@moneko/utils";import x from"./commom/require.mjs";let v=["@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(e){return delete x.cache[e],new Promise(o=>{if(g(e)){let t=x(e).default;return o(d(t)?t(process):t)}return o({})})}let[P,b,w]=await Promise.all([h(r,s,i),getConfig(n.configPath),getConfig(n.customConfigPath)]),C={devtool:a?"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:p?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":f(c)},moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3},htmlPluginOption:{},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:t,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:v,js:v,media:v,font:v,wasm:[]},mdx:{jsx:!1,development:a,jsxImportSource:u,providerImportSource:`@moneko/${i}/mdx`},jsxDomExpressions:o,bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==i,bundleId:"com.moneko.bid",bundles:[]};m&&(C.alias=Object.assign(C.alias,{"@pkg":n.componentsPath,[l]:n.componentsPath}));let j=C;(!1===(j=e(j,b,w)).devtool||!1===j.sourceMap)&&(j.sourceMap=!1,j.devtool=!1),j.fixBrowserRouter&&j.htmlPluginOption&&(j.htmlPluginOption.tags||(j.htmlPluginOption.tags=[]),j.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=j;export const PUBLICPATH=CONFIG.publicPath;
|
package/lib/dev/mock.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"http";import{watch as t}from"chokidar";import o from"express";import{print as r}from"@moneko/utils";import{mock as a}from"mock-json-schema";import{merge as n}from"webpack-merge";import s from"../utils/match-path.mjs";import
|
|
1
|
+
import e from"node:http";import{watch as t}from"chokidar";import o from"express";import{print as r}from"@moneko/utils";import{mock as a}from"mock-json-schema";import{merge as n}from"webpack-merge";import s from"../utils/match-path.mjs";import c from"../commom/require.mjs";import i from"../utils/log.mjs";function p(e,t,o){if(delete c.cache[t],o[t]){for(let r in o[t])Object.prototype.hasOwnProperty.call(o[t],r)&&(e[r]=null,delete e[r]);o[t]=null,delete o[t]}}export const yApiSchemaMock=(t,o)=>new Promise(r=>{e.get(`${t.host}/api/interface/get?id=${t.id}&token=${t.token}`,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{let e=JSON.parse(t);if(e?.data?.res_body_is_json_schema){let t=JSON.parse(e.data.res_body),s=a(t);void 0!==o?r(n(s,o)):r(s)}}catch(e){i(e)}})})});export const yApiMock=(t,o)=>new Promise((r,a)=>{let n=new URL(o.host),s={hostname:n.hostname,port:n.port,path:t.path.replace(new RegExp(o.pathRewrite),`/mock/${o.projectId}/`),method:t.method,headers:t.headers,query:t.query},c=e.request(s,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{r(JSON.parse(t))}catch(e){i(e)}})});c.on("error",e=>{a(e.message)}),c.write(JSON.stringify(t.body)),c.end()});export default(e=>{let a={},n={};return t(e).on("all",async function(e,t){switch(r("Updating mock...",!0),e){case"add":case"change":try{p(n,t,a);let e=c(t).default;a[t]=e,n=Object.assign(n,e)}catch{}break;case"unlink":p(n,t,a)}r("Mock update successful",!0)}),function(e,t,r){let a=`${e.method} ${e.path}`,c=Object.keys(n).filter(function(e){return RegExp(`^${e.replace(/(:\w*)[^/]/g,"((?!/).)")}*$`).test(a)});if(!n[a]&&(!c||!(c.length>0)))return r();{let i;let p=e.get("Content-Type");switch(p){case"text/plain":i=o.raw({type:"text/plain"});break;case"text/html":i=o.text({type:"text/html"});break;case"application/x-www-form-urlencoded":i=o.urlencoded({extended:!1});break;default:i=o.json()}p?.startsWith("multipart/form-data;")&&(i=o.static("./public")),i(e,t,function(){let o=n[a]||n[c[0]];if("function"==typeof o){let a=s(c[0].split(" ")[1],e.url);a&&Object.assign(e.params,a.params),o(e,t,r)}else t.json(o)})}}});
|
package/lib/dev/net.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createConnection as e}from"net";import{networkInterfaces as t}from"os";export function getIPv4(){let e=t(),
|
|
1
|
+
import{createConnection as e}from"node:net";import{networkInterfaces as t}from"node:os";export function getIPv4(){let e=t(),o=null,r=Object.keys(e);for(let t=0,n=r.length;t<n;t++){let n=e[r[t]]||[];for(let e=0,t=n.length;e<t;e++){let t=n[e];"IPv4"!==t.family||t.internal||(o=t.address)}}return o}export function getPort(t,o="0.0.0.0"){return new Promise((r,n)=>{if("number"!=typeof t)r(t);else{let l=e(t,o);l.on("connect",()=>{l.destroy(),r(getPort(t+1,o))}),l.on("error",e=>{l.destroy(e),"ECONNREFUSED"===e.code?r(t):n(e)})}})}
|
package/lib/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e;import t from"express";import o from"https";import s from"multer";import i from"webpack";import r from"webpack-dev-middleware";import l from"webpack-hot-middleware";import{merge as n}from"webpack-merge";import{commonConfig as a}from"./common.mjs";import{CONFIG as m,getConfig as c,PUBLICPATH as p}from"./config.mjs";import{PORT as d,devLog as u}from"./dev/config.mjs";import h from"./dev/mock.mjs";import f,{updateProxy as x}from"./dev/proxy.mjs";import y from"./module.config.mjs";import w,{config_files as g}from"./paths.mjs";import{isLibrary as v,isReact as k,refresh as $}from"./process-env.mjs";import C from"./utils/has-pkg.mjs";import{empty as b,resolveProgram as j}from"./utils/index.mjs";import P from"./utils/sigint-exit.mjs";import S from"./options/reslove.mjs";import{watchFile as A}from"fs";import{join as T}from"path";import{spawn as E,exec as O}from"child_process";import{directoryExists as I,ink as M,loadFile as _,println as R,progressBar as q,print as z}from"@moneko/utils";import{diffObject as B}from"./utils/diff-object.mjs";let{HotModuleReplacementPlugin:D,ProgressPlugin:G,WatchIgnorePlugin:H}=i,U=!1!==m.stylelint&&C("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,L=!1!==m.eslint&&C("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,N=k&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,F=["js","jsx","ts","tsx","json","html","vue"],W=F.join(","),K=["css","scss","sass","less","ts","tsx","js","jsx"],X=K.join(","),J=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],Q=`${p.endsWith("/")?"":"/"}__hmr__`,V=new URLSearchParams({name:"client",path:Q,dynamicPublicPath:!0,timeout:2e3,reload:!$,quiet:!0,noInfo:!0,overlay:!0,autoConnect:!0}).toString(),Y=a.output.path,Z=m.bar.name||"Build",ee=n(a,{entry:{main:[`${S.hotMiddlewareClient}?${V}`]},output:{path:Y},module:y(!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:/[\\/]node_modules[\\/]/,priority:-10,reuseExistingChunk:!0},default:{minChunks:1,priority:-20,reuseExistingChunk:!0}}}},plugins:[new D,new H({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]}),N&&new N,L&&new L({fix:!0,threads:!0,files:[`${m.alias["@"]}/**/*.{${W}}`,v&&`${m.alias["@pkg"]}/**/*.{${W}}`].filter(Boolean),extensions:F,exclude:J,cache:!0,cacheLocation:`${w.lintCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:j("eslint.config.mjs"),configType:"flat"}),U&&new U({fix:!0,threads:!0,files:[`${m.alias["@"]}/**/*.{${X}}`,v&&`${m.alias["@pkg"]}/**/*.{${X}}`].filter(Boolean),extensions:K,exclude:J,cache:!0,cacheLocation:`${w.lintCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),!!m.bar&&new G({handler(e,t,...o){q(e||0,1,Z,o.length?`[${t}] ${o.join(" ")}`:""),1===e&&process.stdout.write("\r\x1b[2K")}})].filter(Boolean)}),et=i(ee);et.hooks.done.tap("client-log",e=>{u(null,e)});let eo=t(),es=s(),ei={"Access-Control-Allow-Origin":"*","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",...m.devServer.headers},er=r(et,{writeToDisk:!1,index:"index.html",headers:e=>({...ei,"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:ee.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),el=l(et,{log:!1,path:Q,heartbeat:2e3});eo.use(t.static(T(w.programPath,"./public"))).use(er).use(Q,el),I(w.mockPath)&&eo.use(es.any(),h(w.mockPath)),m.proxy&&f(eo,m.proxy);let en=`${ee.output.path}/index.html`;if(eo.use((e,t,o)=>{if("GET"===e.method){let s=e.get("Accept");if(s?.includes("text/html")){let e=er.context.outputFileSystem,o=e?.readFileSync?.(en);t.headersSent||(t.setHeader("Content-Type","text/html"),t.send(o))}else if("text/event-stream"===s&&e.url.endsWith(Q))return e.url=Q,el(e,t,o);else return o()}else{if("OPTIONS"!==e.method)return o();t.sendStatus(200)}}),m.devServer.https){let[t,s]=await Promise.all([_(m.devServer.https.key),_(m.devServer.https.cert)]);t||(R(M(`无法加载私钥。请检查路径和文件是否存在,并确保路径正确:${m.devServer.https.key}`,"red")),process.exit(1)),s||(R(M(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${m.devServer.https.cert}`,"red")),process.exit(1)),e=o.createServer({key:t,cert:s},eo)}let ea=(e||eo).listen(d,"0.0.0.0",()=>{});function em(){process.exit(0)}let ec=await Promise.all(g.map(c)),ep=n(ec[0]||{},ec[1]||{});g.forEach(function(e){A(e,async function(){let[t,o]=await Promise.all(g.map(c)),s=n(t||{},o||{}),i=B(ep,s);1===Object.keys(i).length&&"proxy"in i?(z(M(`代理更新中...`,"yellow"),!0),x(eo,s.proxy),z(M(`代理更新完成...`,"green"),!0),m.proxy=s.proxy,ep.proxy=s.proxy,ep=s):(ep=s,R(M(`检测到工程配置${M(`[${e}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),O("win32"===process.platform?`netstat -ano | findstr :${d}`:`lsof -i :${d} -t`,(e,t)=>{if(e){R(M(`查找端口 ${d} 时发生错误: ${e.message}`,"red")),R(M("请尝试手动重启程序","yellow"));return}let o=t.trim().split("\n").filter(Boolean),s=ed?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!s){R(M(`未找到占用端口 ${d} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(s),"SIGHUP")}catch(e){R(M(`终止进程 ${s} 时发生错误: ${e.message}`,"red"))}}))})});let ed="win32"===process.platform;process.on("SIGHUP",function(){er.close(b),ea.close(b),ea.closeAllConnections(),function(){let e=E(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",em)}()}),process.on("exit",function(){er.close(b),ea.close(b),ea.closeAllConnections()}),P(em);
|
|
1
|
+
let e;import t from"express";import o from"node:https";import s from"multer";import i from"webpack";import r from"webpack-dev-middleware";import l from"webpack-hot-middleware";import{merge as n}from"webpack-merge";import{commonConfig as a}from"./common.mjs";import{CONFIG as m,getConfig as c,PUBLICPATH as p}from"./config.mjs";import{PORT as d,devLog as u}from"./dev/config.mjs";import h from"./dev/mock.mjs";import f,{updateProxy as x}from"./dev/proxy.mjs";import y from"./module.config.mjs";import w,{config_files as g}from"./paths.mjs";import{isLibrary as v,isReact as k,refresh as $}from"./process-env.mjs";import C from"./utils/has-pkg.mjs";import{empty as b,resolveProgram as j}from"./utils/index.mjs";import P from"./utils/sigint-exit.mjs";import S from"./options/reslove.mjs";import{watchFile as A}from"node:fs";import{join as T}from"node:path";import{spawn as E,exec as O}from"node:child_process";import{directoryExists as I,ink as M,loadFile as _,println as R,progressBar as q,print as z}from"@moneko/utils";import{diffObject as B}from"./utils/diff-object.mjs";let{HotModuleReplacementPlugin:D,ProgressPlugin:G,WatchIgnorePlugin:H}=i,U=!1!==m.stylelint&&C("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,L=!1!==m.eslint&&C("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,N=k&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,F=["js","jsx","ts","tsx","json","html","vue"],W=F.join(","),K=["css","scss","sass","less","ts","tsx","js","jsx"],X=K.join(","),J=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],Q=`${p.endsWith("/")?"":"/"}__hmr__`,V=new URLSearchParams({name:"client",path:Q,dynamicPublicPath:!0,timeout:2e3,reload:!$,quiet:!0,noInfo:!0,overlay:!0,autoConnect:!0}).toString(),Y=a.output.path,Z=m.bar.name||"Build",ee=n(a,{entry:{main:[`${S.hotMiddlewareClient}?${V}`]},output:{path:Y},module:y(!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:/[\\/]node_modules[\\/]/,priority:-10,reuseExistingChunk:!0},default:{minChunks:1,priority:-20,reuseExistingChunk:!0}}}},plugins:[new D,new H({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]}),N&&new N,L&&new L({fix:!0,threads:!0,files:[`${m.alias["@"]}/**/*.{${W}}`,v&&`${m.alias["@pkg"]}/**/*.{${W}}`].filter(Boolean),extensions:F,exclude:J,cache:!0,cacheLocation:`${w.lintCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:j("eslint.config.mjs"),configType:"flat"}),U&&new U({fix:!0,threads:!0,files:[`${m.alias["@"]}/**/*.{${X}}`,v&&`${m.alias["@pkg"]}/**/*.{${X}}`].filter(Boolean),extensions:K,exclude:J,cache:!0,cacheLocation:`${w.lintCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),!!m.bar&&new G({handler(e,t,...o){q(e||0,1,Z,o.length?`[${t}] ${o.join(" ")}`:""),1===e&&process.stdout.write("\r\x1b[2K")}})].filter(Boolean)}),et=i(ee);et.hooks.done.tap("client-log",e=>{u(null,e)});let eo=t(),es=s(),ei={"Access-Control-Allow-Origin":"*","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",...m.devServer.headers},er=r(et,{writeToDisk:!1,index:"index.html",headers:e=>({...ei,"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:ee.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),el=l(et,{log:!1,path:Q,heartbeat:2e3});eo.use(t.static(T(w.programPath,"./public"))).use(er).use(Q,el),I(w.mockPath)&&eo.use(es.any(),h(w.mockPath)),m.proxy&&f(eo,m.proxy);let en=`${ee.output.path}/index.html`;if(eo.use((e,t,o)=>{if("GET"===e.method){let s=e.get("Accept");if(s?.includes("text/html")){let e=er.context.outputFileSystem,o=e?.readFileSync?.(en);t.headersSent||(t.setHeader("Content-Type","text/html"),t.send(o))}else if("text/event-stream"===s&&e.url.endsWith(Q))return e.url=Q,el(e,t,o);else return o()}else{if("OPTIONS"!==e.method)return o();t.sendStatus(200)}}),m.devServer.https){let[t,s]=await Promise.all([_(m.devServer.https.key),_(m.devServer.https.cert)]);t||(R(M(`无法加载私钥。请检查路径和文件是否存在,并确保路径正确:${m.devServer.https.key}`,"red")),process.exit(1)),s||(R(M(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${m.devServer.https.cert}`,"red")),process.exit(1)),e=o.createServer({key:t,cert:s},eo)}let ea=(e||eo).listen(d,"0.0.0.0",()=>{});function em(){process.exit(0)}let ec=await Promise.all(g.map(c)),ep=n(ec[0]||{},ec[1]||{});g.forEach(function(e){A(e,async function(){let[t,o]=await Promise.all(g.map(c)),s=n(t||{},o||{}),i=B(ep,s);1===Object.keys(i).length&&"proxy"in i?(z(M(`代理更新中...`,"yellow"),!0),x(eo,s.proxy),z(M(`代理更新完成...`,"green"),!0),m.proxy=s.proxy,ep.proxy=s.proxy,ep=s):(ep=s,R(M(`检测到工程配置${M(`[${e}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),O("win32"===process.platform?`netstat -ano | findstr :${d}`:`lsof -i :${d} -t`,(e,t)=>{if(e){R(M(`查找端口 ${d} 时发生错误: ${e.message}`,"red")),R(M("请尝试手动重启程序","yellow"));return}let o=t.trim().split("\n").filter(Boolean),s=ed?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!s){R(M(`未找到占用端口 ${d} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(s),"SIGHUP")}catch(e){R(M(`终止进程 ${s} 时发生错误: ${e.message}`,"red"))}}))})});let ed="win32"===process.platform;process.on("SIGHUP",function(){er.close(b),ea.close(b),ea.closeAllConnections(),function(){let e=E(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",em)}()}),process.on("exit",function(){er.close(b),ea.close(b),ea.closeAllConnections()}),P(em);
|
package/lib/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ export { APPTYPE, FRAMEWORK, PACKAGENAME, PACKAGEVERSION, coreName, isDev, isLib
|
|
|
3
3
|
export { resolveProgram, toCamelCase } from './utils/index.mjs';
|
|
4
4
|
export { default as hasPkg } from './utils/has-pkg.mjs';
|
|
5
5
|
export { default as osTmpDir } from './utils/os-tmp-dir.mjs';
|
|
6
|
-
export { default as require } from './
|
|
6
|
+
export { default as require } from './commom/require.mjs';
|
|
7
7
|
export type { MdxOptions } from '@moneko/mdx';
|
|
8
8
|
export type { OverrideResolverOption } from './plugin/override-resolve.mjs';
|
|
9
9
|
export { type YApiOption, type YApiOptionBySchema, yApiMock, yApiSchemaMock, type RequestFormData, type ProxyFuncType, type MockConfiguration, } from './dev/mock.mjs';
|
package/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as paths,CUSTOMCONFIG,yarnArgv,routeDir}from"./paths.mjs";export{APPTYPE,FRAMEWORK,PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro,mainDirectory}from"./process-env.mjs";export{resolveProgram,toCamelCase}from"./utils/index.mjs";export{default as hasPkg}from"./utils/has-pkg.mjs";export{default as osTmpDir}from"./utils/os-tmp-dir.mjs";export{default as require}from"./
|
|
1
|
+
export{default as paths,CUSTOMCONFIG,yarnArgv,routeDir}from"./paths.mjs";export{APPTYPE,FRAMEWORK,PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro,mainDirectory}from"./process-env.mjs";export{resolveProgram,toCamelCase}from"./utils/index.mjs";export{default as hasPkg}from"./utils/has-pkg.mjs";export{default as osTmpDir}from"./utils/os-tmp-dir.mjs";export{default as require}from"./commom/require.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{getIPv4,getPort}from"./dev/net.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{default as Rule}from"./rule.mjs";
|
package/lib/module.config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e;import{CONFIG as s}from"./config.mjs";import o from"./options/modify-vars.mjs";import t from"./options/swcrc.mjs";import r,{CUSTOMCONFIG as a}from"./paths.mjs";import{getLightningCssTargets as n}from"./polyfills/targets.mjs";import{FRAMEWORK as i,isDev as m,isLibrary as l}from"./process-env.mjs";import c from"./rule.mjs";import d from"./utils/has-pkg.mjs";import{node_modules as p,resolveProgram as u,toCamelCase as f}from"./utils/index.mjs";import j from"./utils/svg-to-data-uri.mjs";import{comment as y,getCommentPath as h}from"./vm/docs.mjs";import v from"./vm/generate-doc.mjs";import g from"./options/css-extract.mjs";import{saveFileSync as x}from"@moneko/utils";import w from"./utils/reactive-object.mjs";import L from"./options/reslove.mjs";import P from"./
|
|
1
|
+
let e;import{CONFIG as s}from"./config.mjs";import o from"./options/modify-vars.mjs";import t from"./options/swcrc.mjs";import r,{CUSTOMCONFIG as a}from"./paths.mjs";import{getLightningCssTargets as n}from"./polyfills/targets.mjs";import{FRAMEWORK as i,isDev as m,isLibrary as l}from"./process-env.mjs";import c from"./rule.mjs";import d from"./utils/has-pkg.mjs";import{node_modules as p,resolveProgram as u,toCamelCase as f}from"./utils/index.mjs";import j from"./utils/svg-to-data-uri.mjs";import{comment as y,getCommentPath as h}from"./vm/docs.mjs";import v from"./vm/generate-doc.mjs";import g from"./options/css-extract.mjs";import{saveFileSync as x}from"@moneko/utils";import w from"./utils/reactive-object.mjs";import L from"./options/reslove.mjs";import P from"./commom/require.mjs";import{sep as M}from"node:path";let _={loader:`${r.corePath}/loader/lightningcss.cjs`,options:{sourceMap:!!s.sourceMap,analyzeDependencies:!1,targets:n(),drafts:{nesting:!0,customMedia:!0},errorRecovery:!1,unusedSymbols:[],rem:!!s.rem}},k={loader:L.lessLoader,options:{sourceMap:!!s.sourceMap,lessOptions:{modifyVars:o,javascriptEnabled:!0}}},C=new Map;function $(e){if(C.has(e))return C.get(e);try{let s;let o=P.resolve(e).split(M),t=o.lastIndexOf("node_modules");return s=-1!==t?o.slice(0,t).join(M):o.join(M),C.set(e,s),s}catch(o){let s=p(e);return C.set(e,s),s}}let O=[...s.cssModules,`@moneko/${i}`,"neko-ui"].map($),b=["components","example","mock","site","src","server"].map(u);function I(e){return new Promise(o=>{o([...b,...s.rulesInclude?.[e]?.map($)||[]])})}a&&b.push(u(a)),s.overrideResolve&&s.overrideResolve.override&&b.push(s.overrideResolve.override);let[R,S,z,B,D]=await Promise.all([I("css"),I("js"),I("media"),I("wasm"),I("font")]);L.sassLoader&&(e={loader:L.sassLoader,options:{implementation:await import("sass"),sassOptions:{}}});let W=l&&m&&{test:c.tsdoc,include:s.alias["@pkg"],exclude:[/node_modules\/(?!(@app|@moneko)).+/,c.__tests__],enforce:"pre",loader:`${r.corePath}/loader/ts-doc.cjs`,options:{comment:y,generateDoc:v,getCommentPath:h}},J=[{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/[name][ext]":"assets/[name][ext]"}}},{test:c.wasm,type:"webassembly/async",include:B},{test:c.txt,type:"asset/source"},{test:c.image,type:"asset",dependency:{not:["url"]},parser:{dataUrlCondition:{maxSize:4096}},generator:{filename:e=>e.filename?.toLocaleLowerCase().endsWith(".svg")?"assets/svg/[name][ext]":"assets/images/[name][ext]",dataUrl:(e,s)=>s.filename.toLocaleLowerCase().endsWith(".svg")?j(e.toString()):e},include:z},{test:c.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:z},{test:c.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:D}],N=s.prefixJsLoader.filter(Boolean)||[];switch(i){case"react":s.reactCompiler&&N.unshift({loader:`${r.corePath}/loader/react-compiler.cjs`,options:s.reactCompiler});break;case"solid":s.refresh=!1}!m&&d("@moneko/css")&&N.unshift(`${r.corePath}/loader/css-in-js-minify.cjs`);let Q=new w({});function U(e){Q.setData(`${e.resourcePath}.d.ts`,e.exports.map(({name:e,value:s})=>`export const ${f(e)}: '${s}';`).join("\n")+"\n")}Q.on("change",(e,s)=>{x(e,s)});export default(o=>{let a={loader:L.swcLoader,options:t(o)},n={loader:L.cssLoader,options:{modules:{auto:e=>{if(e){for(let s=0,o=O.length;s<o;s++)if(e.includes(O[s]))return c.css_module.test(e)}return c.node_modules_css_module.test(e)},localIdentName:"[path][name]_[local]",exportLocalsConvention:"dashesOnly",exportOnlyLocals:o,getJSON:s.cssModuleDefinition?U:void 0},importLoaders:2}};return{parser:{javascript:{commonjsMagicComments:!0,dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,importMeta:!0,importMetaContext:!0}},noParse:s.noParse,rules:[!1!==s.htmlPluginOption&&W,{oneOf:[...J,{test:c.js,use:[...N,a],include:S},{test:c.css,use:[g,L.cssLoader,_],include:R},e&&{test:c.scss,use:[g,n,_,e],include:R},{test:c.less,use:[g,n,_,k],include:R},{test:c.markdown,use:[...N,{loader:`${r.corePath}/loader/mdx.cjs`,options:s.mdx}],exclude:[/node_modules\/(?!(@app|@moneko)).+/]}].filter(Boolean)},...s.moduleRules].filter(Boolean)}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import i from"./html-plugin-option.mjs";import{CONFIG as o}from"../config.mjs";let f=o.prefixCls||"n",n={"@prefix-cls":f,"@ant-prefix":f,"@iconfont-css-prefix":`${f}-icon`,"@favicon":
|
|
1
|
+
import i from"./html-plugin-option.mjs";import{CONFIG as o}from"../config.mjs";let f=o.prefixCls||"n",n={"@prefix-cls":f,"@ant-prefix":f,"@iconfont-css-prefix":`${f}-icon`,"@favicon":i.favicon};Object.assign(n,o.modifyVars);export default n;
|
package/lib/options/reslove.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../
|
|
1
|
+
import e from"../commom/require.mjs";import s from"../utils/has-pkg.mjs";let o={styleLoader:e.resolve("style-loader"),cssLoader:e.resolve("css-loader"),sassLoader:s("sass-loader"),lessLoader:e.resolve("less-loader"),swcLoader:e.resolve("swc-loader"),transformImports:s("@moneko/transform-imports"),jsxDomExpressions:s("@moneko/jsx-dom-expressions"),hotMiddlewareClient:e.resolve("webpack-hot-middleware/client.js")};export default o;
|
package/lib/paths.d.mts
CHANGED
package/lib/paths.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"url";import{dirname as e,resolve as t}from"path";import{fileExists as
|
|
1
|
+
import o from"node:url";import{dirname as e,resolve as t}from"node:path";import{fileExists as n}from"@moneko/utils";let a=JSON.parse(process.env.npm_config_argv||'{"original":[]}').original;export const __filename=o.fileURLToPath(import.meta.url);export const __dirname=e(__filename);export const yarnArgv={};for(let o=0,e=a.length;o<e;o++){let e=a[o].split("=");Object.assign(yarnArgv,{[e[0]]:e[1]||!0})}export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config||process.env.__args__config__;let c=process.cwd(),r=t(c,"./node_modules"),s={__dirname,__filename,nodeModules:r,pnpmNodeModules:t(r,"./.pnpm/node_modules"),denoNodeModules:t(r,"./.deno"),corePath:o.fileURLToPath(new URL(".",import.meta.url)),programPath:c,webpackCachePath:t(r,"./.cache"),lintCachePath:t(r,"./.cache"),httpCachePath:t(r,"./.cache/http"),swcCachePath:t(r,"./.cache/.swc"),configPath:t(c,"./config/index.ts"),customConfigPath:t(c,`./config/${CUSTOMCONFIG}.ts`),coveragePath:t(c,"./coverage/clover.xml"),pagesPath:t(c,"./src/pages"),componentsPath:t(c,"./components"),mockPath:t(c,"./mock")};export const config_files=[n(s.configPath)&&s.configPath,n(s.customConfigPath)&&s.customConfigPath].filter(Boolean);export const routeDir="library"===process.env.APPTYPE?s.componentsPath:s.pagesPath;export default s;
|
package/lib/plugin/copy.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as e}from"path";import s from"webpack";import{loadFile as t,scanFolderSync as i}from"@moneko/utils";let l="CopyPlugin",{sources:{RawSource:o}}=s;export class CopyPlugin{constructor(s){this.cacheFiles=[],this.baseFiles=new Set(s.files?.map(s=>e(s))||[]),this.dirs=new Set(s.dirs||[])}getFiles(){let e=new Set(this.baseFiles);for(let s of this.dirs)i(s).forEach(s=>e.add(s));let s={deleted:[],files:[...e]};for(let t of new Set(this.cacheFiles))e.has(t)||s.deleted.push(t);return this.cacheFiles=s.files,s}apply(e){e.hooks.thisCompilation.tap({name:l,stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},e=>{e.hooks.processAssets.tapPromise(l,async()=>{let s=this.getFiles(),i=s.files.map(e=>t(e));(await Promise.all(i)).forEach((t,i)=>{null!==t&&e.emitAsset(s.files[i],new o(t))}),s.deleted.forEach(s=>{e.deleteAsset(s)})})})}}
|
|
1
|
+
import{resolve as e}from"node:path";import s from"webpack";import{loadFile as t,scanFolderSync as i}from"@moneko/utils";let l="CopyPlugin",{sources:{RawSource:o}}=s;export class CopyPlugin{constructor(s){this.cacheFiles=[],this.baseFiles=new Set(s.files?.map(s=>e(s))||[]),this.dirs=new Set(s.dirs||[])}getFiles(){let e=new Set(this.baseFiles);for(let s of this.dirs)i(s).forEach(s=>e.add(s));let s={deleted:[],files:[...e]};for(let t of new Set(this.cacheFiles))e.has(t)||s.deleted.push(t);return this.cacheFiles=s.files,s}apply(e){e.hooks.thisCompilation.tap({name:l,stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},e=>{e.hooks.processAssets.tapPromise(l,async()=>{let s=this.getFiles(),i=s.files.map(e=>t(e));(await Promise.all(i)).forEach((t,i)=>{null!==t&&e.emitAsset(s.files[i],new o(t))}),s.deleted.forEach(s=>{e.deleteAsset(s)})})})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"webpack";import{resolve as e,join as o}from"path";import{generateDeclaration as s}from"../utils/dts.mjs";import{loadFile as a}from"@moneko/utils";import i from"../utils/create-types.mjs";let
|
|
1
|
+
import t from"webpack";import{resolve as e,join as o}from"node:path";import{generateDeclaration as s}from"../utils/dts.mjs";import{loadFile as a}from"@moneko/utils";import i from"../utils/create-types.mjs";let n="ModuleFederationExposesDeclarationPlugin";export class ModuleFederationExposesDeclarationPlugin{constructor(t){this.option=t}apply(r){let{exposes:p}=this.option,m=Object.keys(p).map(t=>{let o=t.replace(/\.tsx?$/i,"");return{key:t,name:o,path:e(`types/${this.option.name}/${o}.d.ts`),originPath:p[t]}});r.hooks.thisCompilation.tap({name:n,stage:r.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},e=>{e.hooks.processAssets.tapPromise(n,async()=>{let n=m.map(async t=>{let e=await a(t.originPath);return null!==e?i(o(this.option.name,t.name),s(e,`${t.name}.ts`)):""}),r=await Promise.all(n);e.emitAsset("module-federation.d.ts",new t.sources.RawSource(r.join("\n")),{javascriptModule:!1})})})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Buffer as s}from"buffer";import{transform as t}from"lightningcss";import i from"webpack";import{PACKAGEVERSION as n,PACKAGENAME as o}from"../process-env.mjs";let{sources:{RawSource:e,SourceMapSource:r},ModuleFilenameHelpers:{matchObject:a}}=i,m="lightning-css-minify",p=/\.(c|le|sc|sa)ss(?:\?.*)?$/i;export class LightningCssMinifyPlugin{constructor(s={}){let{implementation:i,...n}=s;if(i&&"function"!=typeof i.transform)throw TypeError(`[LightningCssMinifyPlugin]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof i.transform}`);this.transform=i?.transform??t,this.options=n}apply(s){let t=JSON.stringify({name:o,version:n,options:this.options});s.hooks.compilation.tap(m,s=>{s.hooks.chunkHash.tap(m,(s,i)=>i.update(t)),s.hooks.processAssets.tapPromise({name:m,stage:s.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async()=>await this.transformAssets(s)),s.hooks.statsPrinter.tap(m,s=>{s.hooks.print.for("asset.info.minimized").tap(m,(s,{green:t,formatFlag:i})=>s&&t&&i?t(i("minimized")):void 0)})})}async transformAssets(t){let{options:{devtool:i}}=t.compiler,{include:n,exclude:o,test:m,sourceMap:f=!!(i&&i.includes("source-map")),...c}=this.options,l=t.getAssets().filter(s=>!s.info.minimized&&(m||p).test(s.name)&&a({include:n,exclude:o},s.name));await Promise.all(l.map(async i=>{let n;let{source:o,map:a}=i.source.sourceAndMap(),m=o.toString(),p="string"==typeof o?s.from(o):o,l=this.transform({filename:i.name,code:p,minify:!0,sourceMap:f,...c}),g=l.code.toString();n=f?new r(g,i.name,l.map?JSON.parse(l.map.toString()):{},m,a,!0):new e(g),t.updateAsset(i.name,n,{...i.info,minimized:!0})}))}}
|
|
1
|
+
import{Buffer as s}from"node:buffer";import{transform as t}from"lightningcss";import i from"webpack";import{PACKAGEVERSION as n,PACKAGENAME as o}from"../process-env.mjs";let{sources:{RawSource:e,SourceMapSource:r},ModuleFilenameHelpers:{matchObject:a}}=i,m="lightning-css-minify",p=/\.(c|le|sc|sa)ss(?:\?.*)?$/i;export class LightningCssMinifyPlugin{constructor(s={}){let{implementation:i,...n}=s;if(i&&"function"!=typeof i.transform)throw TypeError(`[LightningCssMinifyPlugin]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof i.transform}`);this.transform=i?.transform??t,this.options=n}apply(s){let t=JSON.stringify({name:o,version:n,options:this.options});s.hooks.compilation.tap(m,s=>{s.hooks.chunkHash.tap(m,(s,i)=>i.update(t)),s.hooks.processAssets.tapPromise({name:m,stage:s.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async()=>await this.transformAssets(s)),s.hooks.statsPrinter.tap(m,s=>{s.hooks.print.for("asset.info.minimized").tap(m,(s,{green:t,formatFlag:i})=>s&&t&&i?t(i("minimized")):void 0)})})}async transformAssets(t){let{options:{devtool:i}}=t.compiler,{include:n,exclude:o,test:m,sourceMap:f=!!(i&&i.includes("source-map")),...c}=this.options,l=t.getAssets().filter(s=>!s.info.minimized&&(m||p).test(s.name)&&a({include:n,exclude:o},s.name));await Promise.all(l.map(async i=>{let n;let{source:o,map:a}=i.source.sourceAndMap(),m=o.toString(),p="string"==typeof o?s.from(o):o,l=this.transform({filename:i.name,code:p,minify:!0,sourceMap:f,...c}),g=l.code.toString();n=f?new r(g,i.name,l.map?JSON.parse(l.map.toString()):{},m,a,!0):new e(g),t.updateAsset(i.name,n,{...i.info,minimized:!0})}))}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"webpack";import r from"./external-remotes.mjs";import{CONFIG as t}from"../config.mjs";import s from"../
|
|
1
|
+
import e from"webpack";import r from"./external-remotes.mjs";import{CONFIG as t}from"../config.mjs";import s from"../commom/require.mjs";import{resolveProgram as o}from"../utils/index.mjs";import{ModuleFederationExposesDeclarationPlugin as m}from"./exposes-declararion.mjs";import a from"../utils/fetch-module-federation-dts.mjs";let{NormalModuleReplacementPlugin:i,container:{ModuleFederationPlugin:n}}=e,l={},p=[],f=t.moduleFederation?.map(e=>{let r={},t={},i={};if(Array.isArray(e.remotes))for(let r=0,s=e.remotes.length;r<s;r++){let s=e.remotes[r],o=s.alias||s.name,m=s.filename||"remote_entry.js";if(t[o]=`${s.name}@${s.host}/${m}`,Array.isArray(s.library))for(let e=0,r=s.library.length;e<r;e++)l[s.library[e]]=`${o}/${s.library[e]}`;a(s.host,s.name)}if(Array.isArray(e.exposes)){for(let t=0,m=e.exposes.length;t<m;t++){let m=e.exposes[t];if("string"==typeof m){let e=m.startsWith(".");r[`./${m}`]=s.resolve(e?o(m):m),e&&(i[m]=r[`./${m}`])}else if("[object Object]"===Object.prototype.toString.call(m)){let e=m.path.startsWith(".");r[`./${m.name}`]=s.resolve(e?o(m.path):m.path),e&&(i[`./${m.name}`]=r[`./${m.name}`])}}e.exposes?.length&&p.push(new m({exposes:i,name:e.name}))}return new n({filename:"remote_entry.js",...e,remotes:t,exposes:r})});f.length>0&&(f.push(new r),f.push(new i(/(.*)/,e=>{l[e.request]&&(e.request=l[e.request])})),p.forEach(e=>f.push(e))),t.env.injectRemoteReactRefresh=Object.keys(l).includes("react-dom");export default f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as e}from"path";import t from"../paths.mjs";import{fileExists as r}from"@moneko/utils";let o="OverrideResolverPlugin";export default class{constructor(e){this.options=e}apply(a){let i=a.ensureHook("resolved"),{override:s,original:l}=this.options;if(s&&l){let p=`./${e(t.programPath,l)}`,n=`./${e(t.programPath,s)}`;a.getHook("existing-file").tapAsync(o,(e,t,h)=>{let m=e.request||e.path;if(m&&m.startsWith(l)&&e.relativePath){let u=m.replace(l,s);if(r(u)){let r=e.relativePath.replace(p,n);return Object.assign(e,{path:u,relativePath:r,__innerRequest_relativePath:r,__innerRequest:r}),a.doResolve(i,e,`${o} 使用目标模块${s}`,t,h)}}return h()})}}}
|
|
1
|
+
import{relative as e}from"node:path";import t from"../paths.mjs";import{fileExists as r}from"@moneko/utils";let o="OverrideResolverPlugin";export default class{constructor(e){this.options=e}apply(a){let i=a.ensureHook("resolved"),{override:s,original:l}=this.options;if(s&&l){let p=`./${e(t.programPath,l)}`,n=`./${e(t.programPath,s)}`;a.getHook("existing-file").tapAsync(o,(e,t,h)=>{let m=e.request||e.path;if(m&&m.startsWith(l)&&e.relativePath){let u=m.replace(l,s);if(r(u)){let r=e.relativePath.replace(p,n);return Object.assign(e,{path:u,relativePath:r,__innerRequest_relativePath:r,__innerRequest:r}),a.doResolve(i,e,`${o} 使用目标模块${s}`,t,h)}}return h()})}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"core-js-compat";import{getBrowsersTargets as o}from"./targets.mjs";import e from"../
|
|
1
|
+
import r from"core-js-compat";import{getBrowsersTargets as o}from"./targets.mjs";import e from"../commom/require.mjs";let s=e("core-js/package.json").version;export const coreJsVersion=s.substring(0,s.indexOf(".",2));export default function(){return r({targets:o(),version:coreJsVersion}).list}
|
package/lib/process-env.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"./
|
|
1
|
+
import o from"./commom/require.mjs";import e from"./utils/has-pkg.mjs";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const NODE_ENV=process.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"===process.env.SSR;export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];let{name:r,version:s,description:t,author:c,repository:i,keywords:p}=o(`${process.cwd()}/package.json`);export const PACKAGENAME=r;export const PACKAGEVERSION=s;export const coreName="@moneko/core";export const isDev="development"===NODE_ENV;export const refresh=isDev&&(e("solid-refresh")||e("react-refresh"));export{t as description,c as author,i as repository,p as keywords};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ModuleDeclarationKind as e,Project as t,SyntaxKind as r}from"ts-morph";import{resolve as o}from"path";let n=new t({useInMemoryFileSystem:!0});export default function(t,a){let
|
|
1
|
+
import{ModuleDeclarationKind as e,Project as t,SyntaxKind as r}from"ts-morph";import{resolve as o}from"node:path";let n=new t({useInMemoryFileSystem:!0});export default function(t,a){let d=[],s=o(`@types/${t}.d.ts`),i=n.createSourceFile(s,a,{overwrite:!0});i.forEachDescendant(e=>{e.getKind()===r.DeclareKeyword&&e.replaceWithText(e.isFirstNodeOnLine()?"export":"")});let l=i.getStructure().statements;return i.removeText(),i.addModule({name:`'${t}'`,declarationKind:e.Module,hasDeclareKeyword:!0,statements:l}),d.push(`// remote module: ${t}`),d.push(i.getText(!0)),d.join("\n")}
|
package/lib/utils/has-pkg.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"
|
|
1
|
+
import r from"../commom/require.mjs";export default function(e){try{return r.resolve(e)}catch(r){return!1}}
|
package/lib/utils/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as e}from"path";import t from"../paths.mjs";export function toCamelCase(e){return e.replace(/-./g,e=>e.charAt(1).toUpperCase())}export function convertToCamelCase(e){return e.toLowerCase().replace(/-(\w)/g,(e,t)=>t?t.toUpperCase():"").replace(/^./,e=>e.toUpperCase()).replace(/Ui$/,"UI")}export function resolveProgram(o){return e(t.programPath,`./${o}`)}export function node_modules(o){return e(t.nodeModules,`./${o}`)}export function isObject(e){let t=typeof e;return null!==e&&("object"===t||"function"===t)}export function isFunction(e){return["[object Function]","[object AsyncFunction]","[object GeneratorFunction]","[object Proxy]"].includes(Object.prototype.toString.call(e))}export function empty(){}
|
|
1
|
+
import{resolve as e}from"node:path";import t from"../paths.mjs";export function toCamelCase(e){return e.replace(/-./g,e=>e.charAt(1).toUpperCase())}export function convertToCamelCase(e){return e.toLowerCase().replace(/-(\w)/g,(e,t)=>t?t.toUpperCase():"").replace(/^./,e=>e.toUpperCase()).replace(/Ui$/,"UI")}export function resolveProgram(o){return e(t.programPath,`./${o}`)}export function node_modules(o){return e(t.nodeModules,`./${o}`)}export function isObject(e){let t=typeof e;return null!==e&&("object"===t||"function"===t)}export function isFunction(e){return["[object Function]","[object AsyncFunction]","[object GeneratorFunction]","[object Proxy]"].includes(Object.prototype.toString.call(e))}export function empty(){}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as e}from"path";import n from"../paths.mjs";export default function(a,
|
|
1
|
+
import{resolve as e}from"node:path";import n from"../paths.mjs";export default function(a,o=1){let t=a.replace(/^\/|\/$/g,"").replace(/\\/g,"/"),i=t,m="index.ts",d=t.match(/(.+)\/index\.([^/]+)$/),r=t.match(/(.+)\.([^/]+)$/);return d?(i=d[1],m=`index.${d[2]}`):r&&(i=r[1],m=`index.${r[2]}`),{name:i,main:m,pkg:e(n.nodeModules,i,"package.json"),file:e(n.nodeModules,i,m),meta:`{"name":"${i}","main":"${m}","version":"0.0.${o}","description": ""}`}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"events";class e extends t{constructor(t={}){super(),this.data=t}setData(t,e){this.data[t]!==e&&(this.data[t]=e,this.emit("change",t,e))}getData(t){return this.data[t]}removeData(t){Object.prototype.hasOwnProperty.call(this.data,t)&&(delete this.data[t],this.emit("change",t,null))}[Symbol.iterator](){let t=Object.keys(this.data),e=0;return{next:()=>{if(e<t.length){let a=t[e++];return{value:[a,this.data[a]],done:!1}}return{value:void 0,done:!0}}}}}export default e;
|
|
1
|
+
import t from"node:events";class e extends t{constructor(t={}){super(),this.data=t}setData(t,e){this.data[t]!==e&&(this.data[t]=e,this.emit("change",t,e))}getData(t){return this.data[t]}removeData(t){Object.prototype.hasOwnProperty.call(this.data,t)&&(delete this.data[t],this.emit("change",t,null))}[Symbol.iterator](){let t=Object.keys(this.data),e=0;return{next:()=>{if(e<t.length){let a=t[e++];return{value:[a,this.data[a]],done:!1}}return{value:void 0,done:!0}}}}}export default e;
|
package/lib/utils/run.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"vm";export default function(n,r){return e.runInThisContext(n||"",{filename:r,lineOffset:0,columnOffset:0,displayErrors:!0})}
|
|
1
|
+
import e from"node:vm";export default function(n,r){return e.runInThisContext(n||"",{filename:r,lineOffset:0,columnOffset:0,displayErrors:!0})}
|
package/lib/utils/seo.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{join as o}from"path";import{scanRouter as m,sitemap as t}from"@moneko/mdx";import{resolveProgram as r}from"./index.mjs";import{outputConfig as e}from"../common.mjs";import{CONFIG as p}from"../config.mjs";import{routeDir as i}from"../paths.mjs";import{isLibrary as s}from"../process-env.mjs";import{saveFileSync as n}from"@moneko/utils";export default(()=>{let{domain:f,jekyll:a,path:l}=p.seo||{},j=l&&r(l)||e?.path;if(!f||!j)return;let x=`https://${f}${p.basename}`;n(o(j,"CNAME"),f),n(o(j,"robots.txt"),`User-agent: *
|
|
1
|
+
import{join as o}from"node:path";import{scanRouter as m,sitemap as t}from"@moneko/mdx";import{resolveProgram as r}from"./index.mjs";import{outputConfig as e}from"../common.mjs";import{CONFIG as p}from"../config.mjs";import{routeDir as i}from"../paths.mjs";import{isLibrary as s}from"../process-env.mjs";import{saveFileSync as n}from"@moneko/utils";export default(()=>{let{domain:f,jekyll:a,path:l}=p.seo||{},j=l&&r(l)||e?.path;if(!f||!j)return;let x=`https://${f}${p.basename}`;n(o(j,"CNAME"),f),n(o(j,"robots.txt"),`User-agent: *
|
|
2
2
|
Allow: /
|
|
3
3
|
|
|
4
4
|
Sitemap: ${x}/sitemap.txt`),n(o(j,"sitemap.txt"),[x,...t(i,x,m(i,s))].join("\n")),a||n(o(j,".nojekyll"),"")});
|
package/lib/utils/vts.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{transformFileSync as e}from"@swc/core";import{Script as o,createContext as r}from"vm";import*as t from"../index.mjs";import
|
|
1
|
+
import{transformFileSync as e}from"@swc/core";import{Script as o,createContext as r}from"node:vm";import*as t from"../index.mjs";import m from"../commom/require.mjs";let s={inputSourceMap:!1,sourceMaps:!1,module:{type:"commonjs"},jsc:{target:"es2015",parser:{syntax:"typescript"},loose:!1}};export function vts(n,p){let u=e(n,s).code,i={exports:{default:null},require:e=>p?.modules[e]?p.modules[e]:"@moneko/core"===e?t:e.startsWith(".")?void 0:m(m.resolve(e))};return(r(i),new o(u,{filename:n}).runInNewContext(i),p?.namedExport)?i.exports:i.exports.default}
|
package/lib/vm/docs.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as e,sep as t}from"path";import o from"./generate-doc.mjs";import{CONFIG as r}from"../config.mjs";import{FRAMEWORK as a,isLibrary as m,isReact as n,isSolid as s}from"../process-env.mjs";import l from"../utils/reactive-object.mjs";import p from"../rule.mjs";import{loadFile as c,scanFolderSync as i}from"@moneko/utils";import d from"../utils/parse-module-meta.mjs";import f from"../paths.mjs";let u={react:"createElement",solid:"createComponent"}[a],{file:g,pkg:h,meta:$}=d("@app/docs");export const docsModuleName=g;export const docsModulePkgJson=h;export const docsModuleMeta=$;export const docs=new l({[g]:"export default {}",[h]:$});export const comment=new l({});export const getCommentPath=function(){let e=/\/(.+?)\.tsx?$/,t=r.alias["@pkg"]?.length;return o=>o.substring(t).replace(/\\/g,"/").replace(e,"@app/comment/$1.md")}();if(m&&!1!==r.htmlPluginOption){let m={},l=`import { ${u}${s?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[a]}${s?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${n?"() =>":""}${u}(${s?"Dynamic":"'div'"}, {${s?"innerHTML: res.default, component: 'div', class: 'n-md-box' ":"dangerouslySetInnerHTML: {__html:res.default}, className: 'n-md-box'"} })};}`,h=(e,o)=>{if(!e.endsWith("package.json")){let r=e.replace(/@app[/\\]comment[/\\]/,"").split(t),a=r.pop(),n=r.join("/");m[n]||(m[n]={}),o?m[n][a]&&delete m[n][a]:m[n][a]=`rr(() => ${u}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let s={};for(let e in m)Object.prototype.hasOwnProperty.call(m,e)&&(s[e]=Object.values(m[e]));docs.setData(g,`${l}export default ${JSON.stringify(s).replace(p.extract_func,"$1")}`)}};comment.on("change",(t,o)=>{h(e(f.nodeModules,t),o?.length<0)});let $=i(r.alias["@pkg"],["\\.tsx?$"]).filter(e=>!/(^|\/)\.[^\\/\\.]|\.test\./i.test(e));await Promise.all($.map(async e=>({data:await c(e),file:e}))).then(e=>{for(let t=0;t<e.length;t++){let r=e[t];if(r.data){let{file:e,pkg:t,meta:a}=d(getCommentPath(r.file));comment.setData(e,o(r.data,r.file)),comment.setData(t,a)}}})}
|
|
1
|
+
import{relative as e,sep as t}from"node:path";import o from"./generate-doc.mjs";import{CONFIG as r}from"../config.mjs";import{FRAMEWORK as a,isLibrary as m,isReact as n,isSolid as s}from"../process-env.mjs";import l from"../utils/reactive-object.mjs";import p from"../rule.mjs";import{loadFile as c,scanFolderSync as i}from"@moneko/utils";import d from"../utils/parse-module-meta.mjs";import f from"../paths.mjs";let u={react:"createElement",solid:"createComponent"}[a],{file:g,pkg:h,meta:$}=d("@app/docs");export const docsModuleName=g;export const docsModulePkgJson=h;export const docsModuleMeta=$;export const docs=new l({[g]:"export default {}",[h]:$});export const comment=new l({});export const getCommentPath=function(){let e=/\/(.+?)\.tsx?$/,t=r.alias["@pkg"]?.length;return o=>o.substring(t).replace(/\\/g,"/").replace(e,"@app/comment/$1.md")}();if(m&&!1!==r.htmlPluginOption){let m={},l=`import { ${u}${s?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[a]}${s?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${n?"() =>":""}${u}(${s?"Dynamic":"'div'"}, {${s?"innerHTML: res.default, component: 'div', class: 'n-md-box' ":"dangerouslySetInnerHTML: {__html:res.default}, className: 'n-md-box'"} })};}`,h=(e,o)=>{if(!e.endsWith("package.json")){let r=e.replace(/@app[/\\]comment[/\\]/,"").split(t),a=r.pop(),n=r.join("/");m[n]||(m[n]={}),o?m[n][a]&&delete m[n][a]:m[n][a]=`rr(() => ${u}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let s={};for(let e in m)Object.prototype.hasOwnProperty.call(m,e)&&(s[e]=Object.values(m[e]));docs.setData(g,`${l}export default ${JSON.stringify(s).replace(p.extract_func,"$1")}`)}};comment.on("change",(t,o)=>{h(e(f.nodeModules,t),o?.length<0)});let $=i(r.alias["@pkg"],["\\.tsx?$"]).filter(e=>!/(^|\/)\.[^\\/\\.]|\.test\./i.test(e));await Promise.all($.map(async e=>({data:await c(e),file:e}))).then(e=>{for(let t=0;t<e.length;t++){let r=e[t];if(r.data){let{file:e,pkg:t,meta:a}=d(getCommentPath(r.file));comment.setData(e,o(r.data,r.file)),comment.setData(t,a)}}})}
|
package/lib/vm/generate-doc.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dirname as e}from"path";import t from"typescript";import{CONFIG as n}from"../config.mjs";import l from"../options/md-to-html.mjs";let{ScriptKind:r,ScriptTarget:o,SyntaxKind:i,createSourceFile:a,forEachChild:c,getLeadingCommentRanges:s,isInterfaceDeclaration:u,isQuestionToken:f,isPropertySignature:m,isFunctionTypeNode:p,isUnionTypeNode:g,isMethodSignature:$}=t,d={};function b(e){let t=s(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.slice(t[0].pos,t[0].end).match(/\/\*\*([\s\S]*?)\*\//);if(n)return n[1].replaceAll(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim()}}function h(e){if(!e)return;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():void 0}function y(e){if(!e)return;let t=e.match(/@author (\w+)\s*(?:<([^>]+)>)?/);if(t&&t.length>0){let e=t[1].trim(),n=t[2]?.trim(),l=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(n);return n?l&&(n=`mailto:${n}`):n=`https://github.com/${e}`,`[${e}](${n})`}}function x(e){if(!e)return;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():void 0}let A=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function j(e,t){if(!e)return;let l=e.replaceAll(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if(d[e]){let l=`/${[n.basename,d[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${l})`:`[${e}](${l})`}return t?`\\color{#009688}{${e}}`:e});return t&&(l=l.replaceAll(A,e=>`\\color{#009688}{${e}}`)),l}function k(e){if(e)return(function(e){let t;if(!e)return;let n=[];for(;t=/\\color{([^|}]*)\|?([^|}]*)\|?([^|}]*)\|?([^}]*)}{([^}]*)}/g.exec(e);)n.push(t[0]);return e.replaceAll(/[{}[\]()=>]|keyof|typeof|true|false/g,e=>n.some(t=>t.includes(e))?e:`\\color{#569cd6}{${e}}`)})(e)?.replaceAll(/^\s*\|\s*|\s*\|\s*$/gm,"").replaceAll(/\n/g,"<br/>").replaceAll(/\*/g,"\\*").replaceAll(/\|/g,"\\|").replaceAll(/(['"])((?:(?!\1).)*)\1/g,"\\color{#ce9178}{$1$2$1}")}function v(e){if(e)return e.replaceAll(/@example\s*([\s\S]*?)(?=@[a-zA-Z]|\n*$)/g,"").replaceAll(/^@[a-z].+/gm,"").replaceAll(/(\n\s+)+/g,"<br />").replaceAll(/\n/g,"<br />").replaceAll(/(<br \/>)$/g,"")}export default function S(s,A){let S=a(A,s,o.Latest,!0,r.TS),w="";return c(S,l=>{u(l)?w+=function(l){let r=l.name.text;Object.assign(d,{[l.name.text]:e(l.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let o=b(l),a=h(o),c=v(o),s=x(o)?.split("|")||[],u=s.includes("comment"),A=s.includes("initial"),S=s.includes("optional"),w=s.includes("version"),T=s.includes("author"),B=c?`\\color{|4||0.45}{${r}}`:r,z=(function(e){let n=[];if(e.heritageClauses){for(let l of e.heritageClauses)if(l.token===t.SyntaxKind.ExtendsKeyword)for(let e of l.types)n.push(e.getText())}return n})(l)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${j(k(e))}</n-tag>`),F=[c,B,a&&`\\color{#52c11b|1||0.9}{${a}}`,z.length>0&&`<sub>\`extends\`</sub> ${z.join(" ")}`].filter(Boolean).join(" "),N=`## ${F}`,Z=l.members.filter(e=>m(e)&&e.type?.kind!==i.NeverKeyword||$(e)),K=[];if(Z.length>0){for(let e=0,t=Z.length;e<t;e++){let t=Z[e],n=j(k($(t)?`(${t.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${t.type?.getText()||"any"}`:t.type?.getText()||"any"),!0),l=b(t),r=k(t.name.getText());!r||r.startsWith("\\color")||($(t)||function(e){if(e.type){if(!g(e.type))return p(e.type);for(let t of e.type.types)if(p(t))return!0}return!1}(t)||n?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let i=t.questionToken&&f(t.questionToken);K.push([r,!S&&`\\color{${i?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${i?"✘":"✔"}}`,!u&&k(v(l)),n,!A&&k(function(e){if(!e)return;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():void 0}(l)),!w&&k(h(l)),!T&&(y(l)||y(o)),function(e){if(!e)return;let t=e.match(/@example\s*([\s\S]*?)(?=@[a-zA-Z]|\n*$)/);return t?t[1].trim():void 0}(l)])}let e=!1,t=!1,n=!1,l=!1;for(let r=0,o=K.length;r<o;r++){let o=K[r];!u&&o[2]&&(l=!0),!A&&o[4]&&(n=!0),!w&&o[5]&&(t=!0),!T&&o[6]&&(e=!0)}N+="\n";let r=["属性",!S&&"必要",l&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");N+=`|${r}|`;let i=[":-",!S&&":-",l&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);N+="\n";let a=i.join("|");N+=`|${a}|`;for(let r=0,o=K.length;r<o;r++){let o=K[r];N+="\n";let i=[(o[7]?`<n-popover arrow="true" trigger="click" content=${JSON.stringify(`<n-md css=.n-md-body{margin-bottom:0;padding:0.5rem;background-color:transparent;backdrop-filter:none;box-shadow:none;}>${o[7]}</n-md>`)}><n-button size="small" type="primary" circle="true" style="margin-right:8px;">?</n-button></n-popover>`:"")+(o[0]||"-"),!S&&(o[1]||"-"),l&&(o[2]||"-"),o[3]||"-",n&&(o[4]||"-"),t&&(o[5]||"-"),e&&(o[6]||"-")].filter(Boolean).join("|");N+=`|${i}|`}N+="\n"}return N+"\n"}(l):t.isEnumDeclaration(l)&&(w+=function(l){let r=l.name.text,o=b(l),i=v(o),a=h(o);Object.assign(d,{[l.name.text]:e(l.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let c=i?`\\color{|4||0.45}{${r}}`:r,s=[i,c,a&&`\\color{#52c11b|1||0.9}{${a}}`].filter(Boolean).join(" "),u=x(o)?.split("|")||[],f=u.includes("comment"),m=u.includes("version"),p=u.includes("author"),g=`## ${s}`;if(l.members.length>0){let e=[];for(let n=0,r=l.members.length;n<r;n++){let r=l.members[n],i=k(r.name.getText()),a=b(r),c=k(function(e){let n=e.initializer;if(n&&t.isStringLiteral(n))return` '${n.text}'`}(r)),s=k(h(a)),u=k(v(a));!i||i.startsWith("\\color")||/^["'](.+)["']$/.test(i)||(i=`\\color{#4c81db}{${i}}`),e.push([i,!f&&u,c,!m&&s,!p&&(y(a)||y(o))])}let n=!1,r=!1,i=!1;for(let t=0,l=e.length;t<l;t++){let l=e[t];!f&&l[1]&&(i=!0),!m&&l[3]&&(r=!0),!p&&l[4]&&(n=!0)}g+="\n";let a=["属性",i&&"说明","值",r&&"版本",n&&"作者"].filter(Boolean).join("|");g+=`|${a}|`;let c=[":-",i&&":-",":-",r&&":-",n&&":-"].filter(Boolean);g+="\n";let s=c.join("|");g+=`|${s}|`;for(let t=0,l=e.length;t<l;t++){let l=e[t];g+="\n";let o=[l[0]||"-",i&&(l[1]||"-"),l[2]||"-",r&&(l[3]||"-"),n&&(l[4]||"-")].filter(Boolean).join("|");g+=`|${o}|`}}return g+"\n\n"}(l))}),l(w)}
|
|
1
|
+
import{dirname as e}from"node:path";import t from"typescript";import{CONFIG as n}from"../config.mjs";import l from"../options/md-to-html.mjs";let{ScriptKind:r,ScriptTarget:o,SyntaxKind:i,createSourceFile:a,forEachChild:c,getLeadingCommentRanges:s,isInterfaceDeclaration:u,isQuestionToken:f,isPropertySignature:m,isFunctionTypeNode:p,isUnionTypeNode:g,isMethodSignature:$}=t,d={};function b(e){let t=s(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.slice(t[0].pos,t[0].end).match(/\/\*\*([\s\S]*?)\*\//);if(n)return n[1].replaceAll(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim()}}function h(e){if(!e)return;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():void 0}function y(e){if(!e)return;let t=e.match(/@author (\w+)\s*(?:<([^>]+)>)?/);if(t&&t.length>0){let e=t[1].trim(),n=t[2]?.trim(),l=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(n);return n?l&&(n=`mailto:${n}`):n=`https://github.com/${e}`,`[${e}](${n})`}}function x(e){if(!e)return;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():void 0}let A=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function j(e,t){if(!e)return;let l=e.replaceAll(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if(d[e]){let l=`/${[n.basename,d[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${l})`:`[${e}](${l})`}return t?`\\color{#009688}{${e}}`:e});return t&&(l=l.replaceAll(A,e=>`\\color{#009688}{${e}}`)),l}function k(e){if(e)return(function(e){let t;if(!e)return;let n=[];for(;t=/\\color{([^|}]*)\|?([^|}]*)\|?([^|}]*)\|?([^}]*)}{([^}]*)}/g.exec(e);)n.push(t[0]);return e.replaceAll(/[{}[\]()=>]|keyof|typeof|true|false/g,e=>n.some(t=>t.includes(e))?e:`\\color{#569cd6}{${e}}`)})(e)?.replaceAll(/^\s*\|\s*|\s*\|\s*$/gm,"").replaceAll(/\n/g,"<br/>").replaceAll(/\*/g,"\\*").replaceAll(/\|/g,"\\|").replaceAll(/(['"])((?:(?!\1).)*)\1/g,"\\color{#ce9178}{$1$2$1}")}function v(e){if(e)return e.replaceAll(/@example\s*([\s\S]*?)(?=@[a-zA-Z]|\n*$)/g,"").replaceAll(/^@[a-z].+/gm,"").replaceAll(/(\n\s+)+/g,"<br />").replaceAll(/\n/g,"<br />").replaceAll(/(<br \/>)$/g,"")}export default function S(s,A){let S=a(A,s,o.Latest,!0,r.TS),w="";return c(S,l=>{u(l)?w+=function(l){let r=l.name.text;Object.assign(d,{[l.name.text]:e(l.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let o=b(l),a=h(o),c=v(o),s=x(o)?.split("|")||[],u=s.includes("comment"),A=s.includes("initial"),S=s.includes("optional"),w=s.includes("version"),T=s.includes("author"),B=c?`\\color{|4||0.45}{${r}}`:r,z=(function(e){let n=[];if(e.heritageClauses){for(let l of e.heritageClauses)if(l.token===t.SyntaxKind.ExtendsKeyword)for(let e of l.types)n.push(e.getText())}return n})(l)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${j(k(e))}</n-tag>`),F=[c,B,a&&`\\color{#52c11b|1||0.9}{${a}}`,z.length>0&&`<sub>\`extends\`</sub> ${z.join(" ")}`].filter(Boolean).join(" "),N=`## ${F}`,Z=l.members.filter(e=>m(e)&&e.type?.kind!==i.NeverKeyword||$(e)),K=[];if(Z.length>0){for(let e=0,t=Z.length;e<t;e++){let t=Z[e],n=j(k($(t)?`(${t.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${t.type?.getText()||"any"}`:t.type?.getText()||"any"),!0),l=b(t),r=k(t.name.getText());!r||r.startsWith("\\color")||($(t)||function(e){if(e.type){if(!g(e.type))return p(e.type);for(let t of e.type.types)if(p(t))return!0}return!1}(t)||n?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let i=t.questionToken&&f(t.questionToken);K.push([r,!S&&`\\color{${i?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${i?"✘":"✔"}}`,!u&&k(v(l)),n,!A&&k(function(e){if(!e)return;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():void 0}(l)),!w&&k(h(l)),!T&&(y(l)||y(o)),function(e){if(!e)return;let t=e.match(/@example\s*([\s\S]*?)(?=@[a-zA-Z]|\n*$)/);return t?t[1].trim():void 0}(l)])}let e=!1,t=!1,n=!1,l=!1;for(let r=0,o=K.length;r<o;r++){let o=K[r];!u&&o[2]&&(l=!0),!A&&o[4]&&(n=!0),!w&&o[5]&&(t=!0),!T&&o[6]&&(e=!0)}N+="\n";let r=["属性",!S&&"必要",l&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");N+=`|${r}|`;let i=[":-",!S&&":-",l&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);N+="\n";let a=i.join("|");N+=`|${a}|`;for(let r=0,o=K.length;r<o;r++){let o=K[r];N+="\n";let i=[(o[7]?`<n-popover arrow="true" trigger="click" content=${JSON.stringify(`<n-md css=.n-md-body{margin-bottom:0;padding:0.5rem;background-color:transparent;backdrop-filter:none;box-shadow:none;}>${o[7]}</n-md>`)}><n-button size="small" type="primary" circle="true" style="margin-right:8px;">?</n-button></n-popover>`:"")+(o[0]||"-"),!S&&(o[1]||"-"),l&&(o[2]||"-"),o[3]||"-",n&&(o[4]||"-"),t&&(o[5]||"-"),e&&(o[6]||"-")].filter(Boolean).join("|");N+=`|${i}|`}N+="\n"}return N+"\n"}(l):t.isEnumDeclaration(l)&&(w+=function(l){let r=l.name.text,o=b(l),i=v(o),a=h(o);Object.assign(d,{[l.name.text]:e(l.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let c=i?`\\color{|4||0.45}{${r}}`:r,s=[i,c,a&&`\\color{#52c11b|1||0.9}{${a}}`].filter(Boolean).join(" "),u=x(o)?.split("|")||[],f=u.includes("comment"),m=u.includes("version"),p=u.includes("author"),g=`## ${s}`;if(l.members.length>0){let e=[];for(let n=0,r=l.members.length;n<r;n++){let r=l.members[n],i=k(r.name.getText()),a=b(r),c=k(function(e){let n=e.initializer;if(n&&t.isStringLiteral(n))return` '${n.text}'`}(r)),s=k(h(a)),u=k(v(a));!i||i.startsWith("\\color")||/^["'](.+)["']$/.test(i)||(i=`\\color{#4c81db}{${i}}`),e.push([i,!f&&u,c,!m&&s,!p&&(y(a)||y(o))])}let n=!1,r=!1,i=!1;for(let t=0,l=e.length;t<l;t++){let l=e[t];!f&&l[1]&&(i=!0),!m&&l[3]&&(r=!0),!p&&l[4]&&(n=!0)}g+="\n";let a=["属性",i&&"说明","值",r&&"版本",n&&"作者"].filter(Boolean).join("|");g+=`|${a}|`;let c=[":-",i&&":-",":-",r&&":-",n&&":-"].filter(Boolean);g+="\n";let s=c.join("|");g+=`|${s}|`;for(let t=0,l=e.length;t<l;t++){let l=e[t];g+="\n";let o=[l[0]||"-",i&&(l[1]||"-"),l[2]||"-",r&&(l[3]||"-"),n&&(l[4]||"-")].filter(Boolean).join("|");g+=`|${o}|`}}return g+"\n\n"}(l))}),l(w)}
|
package/lib/vm/info.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CONFIG as e}from"../config.mjs";import{description as r,author as o,repository as s,APPTYPE as
|
|
1
|
+
import{CONFIG as e}from"../config.mjs";import{description as r,author as o,repository as s,APPTYPE as m,PACKAGENAME as t,PACKAGEVERSION as i,SSR as p,FRAMEWORK as a}from"../process-env.mjs";import{convertToCamelCase as n}from"../utils/index.mjs";import f from"../commom/require.mjs";let c=f(`${{react:"react",solid:"solid-js"}[a]}/package.json`).version,l="string"==typeof o,d={name:t,projectName:n(t),ssr:p,version:i,base:e.basename,type:m,routerMode:e.routerMode,prefixCls:e.prefixCls,theme:e.theme,description:r,author:l?{name:o}:o,repository:l?{url:s}:s,frameworkVersion:c};export default d;
|
package/lib/vm/locales.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{basename as e,join as t}from"path";import{watch as o}from"chokidar";import{CONFIG as a}from"../config.mjs";import{FRAMEWORK as l,isDev as r}from"../process-env.mjs";import n from"../utils/reactive-object.mjs";import s from"../utils/sigint-exit.mjs";import{directoryExists as c,scanFolderSync as i}from"@moneko/utils";import g from"../
|
|
2
|
-
export function template(r,n){return r.replace(/\\\${\\w+}/g,function(r){var t=r.slice(2,-1);var e=n[t];return e!==void 0?e.toString():""})}function deepFreeze(o) { const p = Reflect.ownKeys(o);for (const k of p) {const v = o[k];if ((v && typeof v === "object") || typeof v === "function") {deepFreeze(v);}}return Object.freeze(o);}export const locales = ${JSON.stringify(e)};const _res = ${JSON.stringify(t)};const resources = deepFreeze(_res);${
|
|
1
|
+
import{basename as e,join as t}from"node:path";import{watch as o}from"chokidar";import{CONFIG as a}from"../config.mjs";import{FRAMEWORK as l,isDev as r}from"../process-env.mjs";import n from"../utils/reactive-object.mjs";import s from"../utils/sigint-exit.mjs";import{directoryExists as c,scanFolderSync as i}from"@moneko/utils";import g from"../commom/require.mjs";import u from"../utils/parse-module-meta.mjs";let m={react:'import sso from "shared-store-object";',solid:'import { createEffect, createRoot, getOwner } from "solid-js";import { createStore } from "solid-js/store";'},f={react:'let storageKey="localizable.language",language=localStorage.getItem(storageKey)||"zh_CN",{translation:a,...defaultLocale}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[language]||resources.zh_CN),localizable=sso({lang:defaultLocale,t:a});export function setLang(a){let{translation:e,...l}=resources[a]||{};e&&(localizable.lang=l,localizable.t=e,localStorage.setItem(storageKey,l.language))}export default localizable;',solid:'let locale=createRoot(()=>{let e="localizable.language",a=localStorage.getItem(e)||"zh_CN",{translation:l,...o}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[a]||resources.zh_CN),[n,c]=createStore({lang:o,t:l});return createEffect(()=>{let a=resources[n.lang.language]?.translation;a&&(c("t",a),localStorage.setItem(e,n.lang.language))}),{localizable:n,setLocalizable:c,setLang:function(e){let{translation:a,...l}=resources[e]||{};a&&c("lang",l)}}},getOwner());export const setLocalizable=locale.setLocalizable;export const t=locale.localizable.t;export const lang=locale.localizable.lang;export const setLang=locale.setLang;'}[l];function p(e,t){return`${m[l]}
|
|
2
|
+
export function template(r,n){return r.replace(/\\\${\\w+}/g,function(r){var t=r.slice(2,-1);var e=n[t];return e!==void 0?e.toString():""})}function deepFreeze(o) { const p = Reflect.ownKeys(o);for (const k of p) {const v = o[k];if ((v && typeof v === "object") || typeof v === "function") {deepFreeze(v);}}return Object.freeze(o);}export const locales = ${JSON.stringify(e)};const _res = ${JSON.stringify(t)};const resources = deepFreeze(_res);${f}`}let{file:d,pkg:z,meta:b}=u("@app/locales");export const localesModuleName=d;export const locales=new n({[d]:p([],{}),[z]:b});let h={};async function j(t,o){let a=e(t).replace(/\.[^.]+$/,"");try{"deleted"===o?delete h[a]:(delete g.cache[t],Object.assign(h,{[a]:g(t).default}));let e=[],l={};for(let t in h)if(Object.prototype.hasOwnProperty.call(h,t)){let{language:o=a,title:r=o,icon:n,translation:s={}}=h[t];e.push({language:o,title:r,icon:n}),l[o]={language:o,title:r,icon:n,translation:s}}locales.setData(d,p(e,l)),locales.setData(z,b)}catch{}}let y=t(a.alias["@"],"./locales");if(c(y)&&!1!==a.htmlPluginOption){let e=i(y,[".ts$"]).filter(e=>!/^\..*|\.d\.ts$/.test(e));await Promise.all(e.map(e=>j(e,"added"))),r&&function(e,t){let a=o(e,{ignored:t,persistent:!0,ignoreInitial:!0});function l(){a.unwatch(e),a.close()}a.on("add",e=>{j(e,"added")}),a.on("change",e=>{j(e,"change")}),a.on("unlink",e=>{j(e,"deleted")}),a.once("ready",()=>{r||l()}),s(l)}(y,[/^\..*/,/!\.ts$/,/\.d\.ts$/])}
|
package/lib/vm/modules.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as t}from"path";import{getAppEntry as p,getAppFallback as e,getAppMdxScope as o,getAppMergeRouter as r,getAppNormalizeCss as m,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as i}from"@moneko/mdx";import l from"./coverage.mjs";import{docs as f,docsModuleName as n}from"./docs.mjs";import d from"./info.mjs";import{locales as u,localesModuleName as x}from"./locales.mjs";import{route as c,routesModuleName as j}from"./routes.mjs";import{CONFIG as g}from"../config.mjs";import v from"../paths.mjs";import{APPTYPE as y,FRAMEWORK as h}from"../process-env.mjs";import{node_modules as k}from"../utils/index.mjs";import{generateDeclaration as O}from"../utils/dts.mjs";import S from"../utils/has-pkg.mjs";import{updateFileSync as b}from"@moneko/utils";import z from"../plugin/module-federation.mjs";import D from"../utils/create-types.mjs";import J from"../rule.mjs";import N from"../utils/parse-module-meta.mjs";let $=S(t(g.alias["@"],"./mdx-scope.tsx"))||S(t(g.alias["@"],"./mdx-scope.ts")),C={"@app/env.ts":`export default ${JSON.stringify(g.env)}`,"@app/info.ts":`export default ${JSON.stringify(d)}`,"@app/entry.ts":p(t(g.alias["@"],"./index.ts"),!!z.length,!!g.rem,!!g.normalizeCss,y,h),"@app/rem":a(g.rem?.designSize||1680),"@app/fallback":e(g.fallbackCompPath),"@app/coverage":l(v.coveragePath),"@app/merge-router":r(),"@app/prefix-router":s(),"@app/normalize/index.css":m(),"@app/suspense/index.tsx":i(y,h),"@app/mdx-scope.tsx":$?o($):"export default {}","@app/routes":c.getData(j),"@app/locales":u.getData(x),"@app/docs":f.getData(n)};b(k("@types/@app/index.d.ts"),["@app/env.ts","@app/info.ts","@app/entry.ts","@app/mdx-scope.tsx"].map(t=>D(t.replace(J.js,""),O(C[t],t))).join("\n")),b(k("@types/@vm/index.d.ts"),Object.keys(g.virtualModule).map(t=>{let p=g.virtualModule[t],{file:e}=N(t);return D(t,O("string"==typeof p?p:`export default ${JSON.stringify(p)}`,e))}).join("\n"));export default C;
|
|
1
|
+
import{join as t}from"node:path";import{getAppEntry as p,getAppFallback as e,getAppMdxScope as o,getAppMergeRouter as r,getAppNormalizeCss as m,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as i}from"@moneko/mdx";import l from"./coverage.mjs";import{docs as f,docsModuleName as n}from"./docs.mjs";import d from"./info.mjs";import{locales as u,localesModuleName as x}from"./locales.mjs";import{route as c,routesModuleName as j}from"./routes.mjs";import{CONFIG as g}from"../config.mjs";import v from"../paths.mjs";import{APPTYPE as y,FRAMEWORK as h}from"../process-env.mjs";import{node_modules as k}from"../utils/index.mjs";import{generateDeclaration as O}from"../utils/dts.mjs";import S from"../utils/has-pkg.mjs";import{updateFileSync as b}from"@moneko/utils";import z from"../plugin/module-federation.mjs";import D from"../utils/create-types.mjs";import J from"../rule.mjs";import N from"../utils/parse-module-meta.mjs";let $=S(t(g.alias["@"],"./mdx-scope.tsx"))||S(t(g.alias["@"],"./mdx-scope.ts")),C={"@app/env.ts":`export default ${JSON.stringify(g.env)}`,"@app/info.ts":`export default ${JSON.stringify(d)}`,"@app/entry.ts":p(t(g.alias["@"],"./index.ts"),!!z.length,!!g.rem,!!g.normalizeCss,y,h),"@app/rem":a(g.rem?.designSize||1680),"@app/fallback":e(g.fallbackCompPath),"@app/coverage":l(v.coveragePath),"@app/merge-router":r(),"@app/prefix-router":s(),"@app/normalize/index.css":m(),"@app/suspense/index.tsx":i(y,h),"@app/mdx-scope.tsx":$?o($):"export default {}","@app/routes":c.getData(j),"@app/locales":u.getData(x),"@app/docs":f.getData(n)};b(k("@types/@app/index.d.ts"),["@app/env.ts","@app/info.ts","@app/entry.ts","@app/mdx-scope.tsx"].map(t=>D(t.replace(J.js,""),O(C[t],t))).join("\n")),b(k("@types/@vm/index.d.ts"),Object.keys(g.virtualModule).map(t=>{let p=g.virtualModule[t],{file:e}=N(t);return D(t,O("string"==typeof p?p:`export default ${JSON.stringify(p)}`,e))}).join("\n"));export default C;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.26.
|
|
3
|
+
"version": "3.26.3",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"@typescript/vfs": "1.6.0",
|
|
26
26
|
"browserslist": "4.24.2",
|
|
27
27
|
"chokidar": "4.0.1",
|
|
28
|
-
"commander": "12.1.0",
|
|
29
28
|
"core-js": "3.39.0",
|
|
30
29
|
"core-js-compat": "3.39.0",
|
|
31
30
|
"css-loader": "7.1.2",
|
package/lib/bin/version.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/bin/version.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{program as o}from"commander";import{coreVersion as m}from"./utils/config.mjs";o.version(m,"-v, --version");
|
package/lib/utils/print.d.mts
DELETED
package/lib/utils/print.mjs
DELETED
package/lib/utils/require.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as e}from"module";import{transformFileSync as o}from"@swc/core";let t=e(import.meta.url),s={sourceMaps:!1,module:{type:"commonjs"},jsc:{parser:{syntax:"typescript"}}};function r(e,t){return e._compile(o(t,s).code,t)}t.extensions[".ts"]=r,t.extensions[".mts"]=r,t.extensions[".mjs"]=r;export default t;
|
|
File without changes
|