@moneko/core 3.9.17-beta.1 → 3.9.17-beta.11

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.
Files changed (128) hide show
  1. package/lib/build.common.d.mts +3 -0
  2. package/lib/build.common.mjs +1 -0
  3. package/lib/build.mjs +1 -0
  4. package/lib/build.server.d.mts +3 -0
  5. package/lib/build.server.mjs +1 -0
  6. package/lib/{common.d.ts → common.d.mts} +1 -1
  7. package/lib/common.mjs +1 -0
  8. package/lib/{config.d.ts → config.d.mts} +1 -1
  9. package/lib/config.mjs +1 -0
  10. package/lib/dev-config.d.mts +6 -0
  11. package/lib/dev-config.mjs +3 -0
  12. package/lib/dev-mock.d.mts +40 -0
  13. package/lib/dev-mock.mjs +1 -0
  14. package/lib/dev-proxy.d.mts +4 -0
  15. package/lib/dev-proxy.mjs +1 -0
  16. package/lib/dev.mjs +1 -0
  17. package/lib/has-pkg.mjs +1 -0
  18. package/lib/html-plugin-option.mjs +1 -0
  19. package/lib/index.d.mts +8 -0
  20. package/lib/index.mjs +1 -0
  21. package/lib/{info.d.ts → info.d.mts} +3 -2
  22. package/lib/info.mjs +1 -0
  23. package/lib/loader/ts-doc.d.cts +1 -1
  24. package/lib/{minify.d.ts → minify.d.mts} +1 -1
  25. package/lib/minify.mjs +1 -0
  26. package/lib/modify-vars.mjs +1 -0
  27. package/lib/module-federation.mjs +1 -0
  28. package/lib/module.config.d.mts +3 -0
  29. package/lib/module.config.mjs +1 -0
  30. package/lib/{net.d.ts → net.d.mts} +1 -1
  31. package/lib/net.mjs +1 -0
  32. package/lib/{paths.d.ts → paths.d.mts} +1 -0
  33. package/lib/{paths.js → paths.mjs} +1 -1
  34. package/lib/plugin/{external-remotes.js → external-remotes.mjs} +1 -1
  35. package/lib/plugin/override-resolve.mjs +1 -0
  36. package/lib/plugin/virtual-module.mjs +1 -0
  37. package/lib/plugins.config.mjs +1 -0
  38. package/lib/polyfills.mjs +1 -0
  39. package/lib/{process-env.d.ts → process-env.d.mts} +2 -1
  40. package/lib/process-env.mjs +1 -0
  41. package/lib/seo.mjs +1 -0
  42. package/lib/{swcrc.d.ts → swcrc.d.mts} +1 -1
  43. package/lib/swcrc.mjs +1 -0
  44. package/lib/targets.mjs +1 -0
  45. package/lib/tsloader.config.mjs +0 -0
  46. package/lib/{utils.d.ts → utils.d.mts} +2 -0
  47. package/lib/utils.mjs +2 -0
  48. package/lib/vm/coverage.mjs +1 -0
  49. package/lib/vm/{docs.d.ts → docs.d.mts} +1 -1
  50. package/lib/vm/docs.mjs +1 -0
  51. package/lib/vm/{example.d.ts → example.d.mts} +1 -1
  52. package/lib/vm/example.mjs +1 -0
  53. package/lib/vm/generate-doc.mjs +1 -0
  54. package/lib/vm/{locales.d.ts → locales.d.mts} +1 -1
  55. package/lib/vm/locales.mjs +2 -0
  56. package/lib/vm/modules.d.mts +17 -0
  57. package/lib/vm/modules.mjs +1 -0
  58. package/lib/vm/{routes.d.ts → routes.d.mts} +1 -1
  59. package/lib/vm/routes.mjs +1 -0
  60. package/package.json +25 -15
  61. package/template/index.ssr.html +25 -0
  62. package/typings/global.d.ts +10 -17
  63. package/lib/common.js +0 -1
  64. package/lib/config.js +0 -1
  65. package/lib/dev.js +0 -3
  66. package/lib/has-pkg.js +0 -1
  67. package/lib/html-plugin-option.js +0 -1
  68. package/lib/index.d.ts +0 -8
  69. package/lib/index.js +0 -1
  70. package/lib/info.js +0 -1
  71. package/lib/minify.js +0 -1
  72. package/lib/modify-vars.js +0 -1
  73. package/lib/module-federation.js +0 -1
  74. package/lib/module.config.d.ts +0 -3
  75. package/lib/module.config.js +0 -1
  76. package/lib/net.js +0 -1
  77. package/lib/plugin/override-resolve.js +0 -1
  78. package/lib/plugin/virtual-module.js +0 -1
  79. package/lib/plugins.config.js +0 -1
  80. package/lib/polyfills.js +0 -1
  81. package/lib/process-env.js +0 -1
  82. package/lib/prod.js +0 -1
  83. package/lib/seo.js +0 -1
  84. package/lib/server.js +0 -1
  85. package/lib/swcrc.js +0 -1
  86. package/lib/targets.js +0 -1
  87. package/lib/tsloader.config.d.ts +0 -8
  88. package/lib/tsloader.config.js +0 -1
  89. package/lib/utils.js +0 -2
  90. package/lib/vm/coverage.js +0 -1
  91. package/lib/vm/docs.js +0 -1
  92. package/lib/vm/example.js +0 -1
  93. package/lib/vm/generate-doc.js +0 -1
  94. package/lib/vm/locales.js +0 -2
  95. package/lib/vm/routes.js +0 -1
  96. /package/lib/{dev.d.ts → build.d.mts} +0 -0
  97. /package/lib/{prod.d.ts → dev.d.mts} +0 -0
  98. /package/lib/{has-pkg.d.ts → has-pkg.d.mts} +0 -0
  99. /package/lib/{html-plugin-option.d.ts → html-plugin-option.d.mts} +0 -0
  100. /package/lib/{modify-vars.d.ts → modify-vars.d.mts} +0 -0
  101. /package/lib/{module-federation.d.ts → module-federation.d.mts} +0 -0
  102. /package/lib/{os-tmp-dir.d.ts → os-tmp-dir.d.mts} +0 -0
  103. /package/lib/{os-tmp-dir.js → os-tmp-dir.mjs} +0 -0
  104. /package/lib/plugin/{add-entry-attribute.d.ts → add-entry-attribute.d.mts} +0 -0
  105. /package/lib/plugin/{add-entry-attribute.js → add-entry-attribute.mjs} +0 -0
  106. /package/lib/plugin/{done.d.ts → done.d.mts} +0 -0
  107. /package/lib/plugin/{done.js → done.mjs} +0 -0
  108. /package/lib/plugin/{external-remotes.d.ts → external-remotes.d.mts} +0 -0
  109. /package/lib/plugin/{lightningcss-plugin.d.ts → lightningcss-plugin.d.mts} +0 -0
  110. /package/lib/plugin/{lightningcss-plugin.js → lightningcss-plugin.mjs} +0 -0
  111. /package/lib/plugin/{override-resolve.d.ts → override-resolve.d.mts} +0 -0
  112. /package/lib/plugin/{virtual-module.d.ts → virtual-module.d.mts} +0 -0
  113. /package/lib/{plugins.config.d.ts → plugins.config.d.mts} +0 -0
  114. /package/lib/polyfills/{replace-children.js → replace-children.mjs} +0 -0
  115. /package/lib/{polyfills.d.ts → polyfills.d.mts} +0 -0
  116. /package/lib/{reactive-object.d.ts → reactive-object.d.mts} +0 -0
  117. /package/lib/{reactive-object.js → reactive-object.mjs} +0 -0
  118. /package/lib/{resolver-sync.d.ts → resolver-sync.d.mts} +0 -0
  119. /package/lib/{resolver-sync.js → resolver-sync.mjs} +0 -0
  120. /package/lib/{seo.d.ts → seo.d.mts} +0 -0
  121. /package/lib/{svg-to-data-uri.d.ts → svg-to-data-uri.d.mts} +0 -0
  122. /package/lib/{svg-to-data-uri.js → svg-to-data-uri.mjs} +0 -0
  123. /package/lib/{targets.d.ts → targets.d.mts} +0 -0
  124. /package/lib/{server.d.ts → tsloader.config.d.mts} +0 -0
  125. /package/lib/vm/{coverage.d.ts → coverage.d.mts} +0 -0
  126. /package/lib/vm/{generate-doc.d.ts → generate-doc.d.mts} +0 -0
  127. /package/lib/vm/{utils.d.ts → utils.d.mts} +0 -0
  128. /package/lib/vm/{utils.js → utils.mjs} +0 -0
@@ -0,0 +1,3 @@
1
+ import webpack from 'webpack';
2
+ declare const buildCommon: webpack.Configuration;
3
+ export default buildCommon;
@@ -0,0 +1 @@
1
+ import e from"mini-css-extract-plugin";import i from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as n}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import{commonConfig as o}from"./common.mjs";import{CONFIG as t}from"./config.mjs";import{getMinifyOption as l}from"./minify.mjs";import p from"./plugin/lightningcss-plugin.mjs";let{optimize:{MinChunkSizePlugin:s,ModuleConcatenationPlugin:u}}=m,a=r(o,{plugins:[new u,new e({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),t.splitChunk&&new s({minChunkSize:1e4}),t.bundleAnalyzer&&new n(t.bundleAnalyzer)].filter(Boolean),optimization:{splitChunks:t.splitChunk,runtimeChunk:t.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:!!t.minifier&&[new i(l(t.minifier?.type||"swc",t.minifier?.options)),new p]||[]}});export default a;
package/lib/build.mjs ADDED
@@ -0,0 +1 @@
1
+ import{removeDirAll as o}from"@moneko/mdx";import m from"webpack";import{merge as r}from"webpack-merge";import e from"webpackbar";import i from"./build.common.mjs";import s from"./build.server.mjs";import{CONFIG as t}from"./config.mjs";import n from"./module.config.mjs";import p from"./paths.mjs";import a from"./plugin/done.mjs";import{SSR as f}from"./process-env.mjs";import c from"./seo.mjs";import{compilerListener as l,log as u}from"./utils.mjs";let d=[r(i,{module:n(!1),plugins:[t.done&&new a({done:t.done}),t.bar&&new e(t.bar)].filter(Boolean)})];f&&d.push(r(i,s));let[h,j]=m(d).compilers,w=[l("client",h)];async function b(){m(d).run((o,m)=>{if(o)throw o;m&&m.stats.forEach(o=>{o.compilation.warnings.forEach(o=>u(o.message)),o.compilation.errors.forEach(o=>u(o.message))})}),await Promise.all(w),t.seo&&c()}j&&w.push(l("server",j)),await b(),process.on("exit",function(){o(p.cachePath)});
@@ -0,0 +1,3 @@
1
+ import { type Configuration } from 'webpack';
2
+ declare const serverOption: Configuration;
3
+ export default serverOption;
@@ -0,0 +1 @@
1
+ import e from"webpack-node-externals";import o from"webpackbar";import r from"./module.config.mjs";import{CUSTOMCONFIG as s}from"./paths.mjs";import{isLibrary as t}from"./process-env.mjs";import{resolveProgramPath as m}from"./utils.mjs";let a={entry:{main:m("site/ssr.tsx")},output:{path:m(`${t?"docs":"dist"}/server`),library:{type:"commonjs2",umdNamedDefine:!1},filename:"[name].cjs",chunkFilename:"[chunkhash].cjs",globalObject:"global"},cache:{type:"filesystem",name:[s,process.env.NODE_ENV,"server"].filter(Boolean).join("-")},externalsPresets:{node:!0},externals:[e({allowlist:["react","react-dom","solid-js","@app","@moneko"]})],plugins:[new o({name:"Server"})],module:r(!0),target:"node"};export default a;
@@ -1,3 +1,3 @@
1
1
  import type { Configuration } from 'webpack';
2
2
  export declare const outputConfig: Configuration['output'];
3
- export declare const clientConfig: Configuration;
3
+ export declare const commonConfig: Configuration;
package/lib/common.mjs ADDED
@@ -0,0 +1 @@
1
+ import{CONFIG as e,PUBLICPATH as t}from"./config.mjs";import o,{CUSTOMCONFIG as s}from"./paths.mjs";import r from"./plugin/override-resolve.mjs";import n from"./plugins.config.mjs";import{PACKAGENAME as a,PACKAGEVERSION as i,isDev as l,isLibrary as p}from"./process-env.mjs";import{resolveNodeModulesPath as c,resolveProgramPath as m}from"./utils.mjs";export const outputConfig={path:m(p?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${l?"name":"chunkhash"}].js`,assetModuleFilename:e=>{let t=e.filename;return t&&t.endsWith("?url")&&/(?:webworker|worker)(\.|\b).*\.(js|ts)\b/.test(t.replace("?url",""))?"worker/[name][ext]":"assets/[name][hash][ext]"},library:{name:a,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${a}`,pathinfo:l,clean:!0,publicPath:t,asyncChunks:!0,charset:!0};let u={main:[e.polyfill&&`${o.corePath}/polyfills/replace-children.js`,c("@app/entry")].filter(Boolean)};e.entry&&("string"==typeof e.entry?u={main:[e.entry]}:Object.keys(e.entry)&&(u=Object.assign(u,e.entry))),"string"==typeof u.main&&(u.main=[u.main]),e.output&&("string"==typeof e.output?outputConfig.path=e.output:Object.keys(e.output)&&Object.assign(outputConfig,e.output));let f=!1;e.cacheDirectory&&(f={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:e.cacheDirectory,memoryCacheUnaffected:!0,name:[s,process.env.NODE_ENV].filter(Boolean).join("-"),version:i});let d=Object.assign({original:e.alias["@"],override:s&&m(s)},e.overrideResolve);export const commonConfig={devtool:e.devtool,entry:u,mode:l?"development":"production",stats:"errors-only",cache:f,infrastructureLogging:{level:"error"},target:"web",externalsPresets:e.externalsPresets,plugins:n,node:{global:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:l&&{imports:!1,entries:!1},buildHttp:e.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:["...",".jsx",".ts",".tsx"],alias:e.alias,modules:[o.nodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:[e.overrideResolve&&new r(d),...e.resolvePlugins].filter(Boolean),fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},externals:e.externals,output:outputConfig};
@@ -1,3 +1,3 @@
1
- import type { ConfigType } from '.';
1
+ import type { ConfigType } from './index.mjs';
2
2
  export declare const CONFIG: ConfigType;
3
3
  export declare const PUBLICPATH: string;
package/lib/config.mjs ADDED
@@ -0,0 +1 @@
1
+ import{fileExists as e}from"@moneko/mdx";import{merge as t}from"webpack-merge";import o,{CUSTOMCONFIG as s}from"./paths.mjs";import{FRAMEWORK as i,PACKAGENAME as n,isDev as r,isLibrary as a,isMobile as l,isSolid as p,jsxImportSource as m,mainDirectory as c}from"./process-env.mjs";import{isFunction as u,log as d,readConf as h,resolveProgramPath as g}from"./utils.mjs";let f=["@moneko","neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app",".cache/http/data"],x={devtool:r?"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:{NODE_ENV:process.env.NODE_ENV},basename:"/",publicPath:"/",rem:{designSize:l?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":g(c)},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:{},cacheDirectory:o.webpackCachePath,devServer:{host:"localhost",port:3e3},htmlPluginOption:{},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{CHANGELOG:{test:/CHANGELOG\.md/,priority:-10,name:"CHANGELOG",reuseExistingChunk:!0},prismjs:{test:/(prism\.js|prism\/css\.ts)/,priority:-10,name:"vendors-prismjs",reuseExistingChunk:!0},site:{test:/site/,priority:-10,reuseExistingChunk:!0},marked:{test:/marked/,priority:-10,reuseExistingChunk:!0},"n-katex":{test:/n-katex/,priority:-10,reuseExistingChunk:!0},"n-code-live":{test:/n-code-live/,priority:-10,reuseExistingChunk:!0},"@moneko":{test:/@moneko/,priority:-10,reuseExistingChunk:!0}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:f,js:f,media:f,font:f,wasm:[]},mdx:{jsx:!1,development:r,jsxImportSource:m,providerImportSource:`@moneko/${i}/mdx`},jsxDomExpressions:{},bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${o.httpCachePath}/http.lock`,cacheLocation:`${o.httpCachePath}/data`,upgrade:!0},virtualModule:{}};p&&(x.jsxDomExpressions={moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1}),a&&(x.alias=Object.assign(x.alias,{"@pkg":o.componentsPath,[n]:o.componentsPath}));let C=x,k={},P={};if(e(o.configPath)){let e=(await h(o.configPath,"index")).default;k=u(e)?e(process):e}if(s&&e(o.customConfigPath)){let e=(await h(o.customConfigPath,s)).default;P=u(e)?e(process):e}(!1===(C=t(C,k,P)).devtool||!1===C.sourceMap)&&(C.sourceMap=!1,C.devtool=!1),C.fixBrowserRouter&&C.htmlPluginOption&&(C.htmlPluginOption.tags||(C.htmlPluginOption.tags=[]),C.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=C;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,CUSTOMCONFIG:s,log:d};
@@ -0,0 +1,6 @@
1
+ import webpack from 'webpack';
2
+ export declare const PORT: number;
3
+ export declare function devLog(err?: Error | null, stats?: webpack.Stats): void;
4
+ export declare const headers: {
5
+ 'Access-Control-Allow-Origin': string;
6
+ };
@@ -0,0 +1,3 @@
1
+ import t from"chalk";import{CONFIG as o}from"./config.mjs";import{getIPv4 as e,getPort as r}from"./net.mjs";import{log as s}from"./utils.mjs";let{yellow:i,green:n,grey:l,gray:m,bgBlue:a,bgGreenBright:c,blueBright:p,greenBright:$}=t,u=o.devServer||{},f=u.port||3e3;export const PORT=await r(f,65535,u.host);u.port=PORT;let d="/"===o.basename?"":o.basename,T=u.port!==PORT&&m(`Port ${i(f)} is in use, trying ${n(PORT)} instead.
2
+ `);function h(t){return`http://${"local"===t?u.host:e()}:${PORT}${d}`}let x=m("You application is running here:"),O=`${a(" Local ")} ${p(h("local"))}
3
+ ${c(" Network ")} ${$(h("net"))}`;export function devLog(t,o){!t&&o&&(process.stdout.write("\x1b[2J\x1b[3J\x1b[H"),s([x,"",O,"",l(`Compiled successfully in ${n(`${o.endTime-o.startTime}ms`)}`)]),T&&s(T))}export const headers={"Access-Control-Allow-Origin":"*"};
@@ -0,0 +1,40 @@
1
+ /// <reference types="multer" />
2
+ import { type NextFunction, type Request, type Response } from 'express';
3
+ export interface RequestFormData extends Request {
4
+ files: Express.Multer.File[];
5
+ }
6
+ export type ProxyFuncType = (req: RequestFormData, res: Response, next: NextFunction) => void;
7
+ export type MockConfiguration = Record<string, ProxyFuncType | Record<string, any> | null>;
8
+ export type YApiOptionBySchema = {
9
+ /** YApi host */
10
+ host: string;
11
+ /** 接口id */
12
+ id: string;
13
+ /** YApi开放接口token */
14
+ token: string;
15
+ };
16
+ type Any = any;
17
+ /**
18
+ * 通过 YApi 接口对应的响应JSON Schema生成默认的数据
19
+ * @param {YApiOptionBySchema} option Schema
20
+ * @param {T} data data
21
+ * @returns {Promise} mockData
22
+ */
23
+ export declare const yApiSchemaMock: <T extends unknown>(option: YApiOptionBySchema, data?: T | undefined) => Promise<T>;
24
+ export type YApiOption = {
25
+ /** YApi host */
26
+ host: string;
27
+ /** YApi 项目ID */
28
+ projectId: number;
29
+ /** 重写请求路径, 例如:'^/api/' */
30
+ pathRewrite: string;
31
+ };
32
+ /**
33
+ * 请求YApi高级mock接口数据
34
+ * @param {RequestFormData} req req
35
+ * @param {YApiOption} yapi YApiOption
36
+ * @returns {Promise} data
37
+ */
38
+ export declare const yApiMock: (req: RequestFormData, yapi: YApiOption) => Promise<Any>;
39
+ declare const mockMiddlewares: (directory: string) => (req: Request, res: Response, next: VoidFunction) => void;
40
+ export default mockMiddlewares;
@@ -0,0 +1 @@
1
+ import e from"http";import{watch as t}from"chokidar";import o from"express";import{mock as r}from"mock-json-schema";import{match as a}from"path-to-regexp";import{merge as n}from"webpack-merge";import{esm as s,log as i,tfc as c}from"./utils.mjs";function p(e,t,o){if(o[t]){for(let r in o[t])Object.prototype.hasOwnProperty.call(o[t],r)&&delete e[r];o[t]=null,delete o[t]}}export const yApiSchemaMock=(t,o)=>new Promise((a,s)=>{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=r(t);void 0!==o?a(n(s,o)):a(s)}}catch(e){s(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},i=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){a(e)}})});i.on("error",e=>{a(e.message)}),i.write(JSON.stringify(t.body)),i.end()});export default(e=>{let r={},n={};return t(e).on("all",async function(e,t){process.stdout.write("update mock...");let o={};switch(e){case"add":case"change":p(n,t,r),o=(await import(s`${c(t)}`)).default,r[t]=o,n=Object.assign(n,o);break;case"unlink":p(n,t,r)}i("update mock success")}),function(e,t,r){let s=`${e.method} ${e.path}`,i=Object.keys(n).filter(function(e){return RegExp(`^${e.replace(/(:\w*)[^/]/g,"((?!/).)")}*$`).test(s)});if(!n[s]&&(!i||!(i.length>0)))return r();{let c;let p=e.get("Content-Type");switch(p){case"text/plain":c=o.raw({type:"text/plain"});break;case"text/html":c=o.text({type:"text/html"});break;case"application/x-www-form-urlencoded":c=o.urlencoded({extended:!1});break;default:c=o.json()}p?.startsWith("multipart/form-data;")&&(c=o.static("./public")),c(e,t,function(){let o=n[s]||n[i[0]];if("function"==typeof o){let n=a(i[0].split(" ")[1])(e.url);n&&Object.assign(e.params,n.params),o(e,t,r)}else t.json(o)})}}});
@@ -0,0 +1,4 @@
1
+ import { type Options as ProxyConfig } from 'http-proxy-middleware';
2
+ import type { Express } from 'express';
3
+ declare const devProxy: (app: Express, proxyMap: Record<string, ProxyConfig>) => void;
4
+ export default devProxy;
@@ -0,0 +1 @@
1
+ import{createProxyMiddleware as e}from"http-proxy-middleware";export default((t,r)=>{Object.keys(r).forEach(o=>{let p=r[o],a=e(o,p);t.use(o,a)})});
package/lib/dev.mjs ADDED
@@ -0,0 +1 @@
1
+ import{directoryExists as e,removeDirAll as o}from"@moneko/mdx";import t from"cors";import i from"express";import r from"multer";import s from"webpack";import m from"webpack-dev-middleware";import l from"webpack-hot-middleware";import{merge as a}from"webpack-merge";import n from"webpackbar";import p from"./build.server.mjs";import{commonConfig as c}from"./common.mjs";import{CONFIG as d}from"./config.mjs";import{PORT as u,devLog as f,headers as h}from"./dev-config.mjs";import w from"./dev-mock.mjs";import g from"./dev-proxy.mjs";import{hasPkg as x}from"./has-pkg.mjs";import k from"./module.config.mjs";import b from"./paths.mjs";import{SSR as j,isLibrary as y,isReact as $}from"./process-env.mjs";import{compilerListener as v,resolveProgramPath as _}from"./utils.mjs";let{HotModuleReplacementPlugin:P}=s,S=x("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,D=x("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,T=$&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,B=["js","jsx","ts","tsx","json","html","vue"],I=B.join(","),E=["css","scss","sass","less","ts","tsx","js","jsx"],F=E.join(","),G=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],M=new URLSearchParams({timeout:2e3,reload:!0,quiet:!0,noInfo:!0,overlay:!1,dynamicPublicPath:!0}).toString(),O=c.output.path;j&&(O=_(`${y?"docs":"dist"}/client`));let R=a(c,{entry:{main:[`webpack-hot-middleware/client?name=client&path=//localhost:${u}/__hmr__&${M}`]},output:{path:O},module:k(!1),plugins:[new P,T&&new T,D&&new D({fix:!0,threads:!0,files:[`${d.alias["@"]}/**/*.{${I}}`,y&&`${d.alias["@pkg"]}/**/*.{${I}}`].filter(Boolean),extensions:B,exclude:G,cache:!0,lintDirtyModulesOnly:!0}),S&&new S({fix:!0,threads:!0,files:[`${d.alias["@"]}/**/*.{${F}}`,y&&`${d.alias["@pkg"]}/**/*.{${F}}`].filter(Boolean),extensions:E,exclude:G,cache:!0,lintDirtyModulesOnly:!0}),d.bar&&new n(d.bar)].filter(Boolean)}),U=[R];j&&U.push(a(c,p));let[q,L]=s(U).compilers;q.hooks.done.tap("client",e=>{f(null,e)});let N=i(),z=r(),A=m(q,{writeToDisk:!1,index:"index.html",headers:()=>h,serverSideRender:j});if(N.use(t()),N.use(A),N.use(l(q,{log:!1,path:"/__hmr__",heartbeat:2e3,ignoreUnaccepted:!1,ignoreDeclined:!0,ignoreErrored:!0})),d.proxy&&g(N,d.proxy),e(b.mockPath)){let e=w(b.mockPath);N.use(e)}let C=`${R.output.path}/index.html`;N.all("/*",z.any(),function(e,o,t){if("GET"!==e.method)return t();{let e=A.context.outputFileSystem,t=e?.readFileSync?.(C);o.end(t)}});let H=[v("client",q)];L&&(L.watch({aggregateTimeout:20,ignored:/node_modules(?![\\/]@app)/,poll:1e3,stdin:!0},f),H.push(v("server",L))),await Promise.all(H),N.listen(u,()=>{}),process.on("exit",function(){o(b.cachePath)}),process.on("SIGINT",function(){process.exit()});
@@ -0,0 +1 @@
1
+ import{fileExists as o}from"@moneko/mdx";import{resolveNodeModulesPath as m}from"./utils.mjs";export function hasPkg(r){return o(m(`${r}/package.json`))}
@@ -0,0 +1 @@
1
+ import{merge as e}from"webpack-merge";import{CONFIG as t}from"./config.mjs";import{description as i,keywords as o}from"./info.mjs";import{PACKAGENAME as m,coreName as r}from"./process-env.mjs";import{resolveProgramPath as a}from"./utils.mjs";let p=t.htmlPluginOption||{},n=p.favicon||`node_modules/${r}/template/favicon.ico`,l=p.template||`node_modules/${r}/template/index.html`,s=e({title:t.env?.PROJECTNAME||m.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{minifyJS:!0,minifyCSS:!0,collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:i,keywords:o},tags:[]},p,{template:a(l),favicon:a(n)});export default s;
@@ -0,0 +1,8 @@
1
+ export { default as paths, CUSTOMCONFIG } from './paths.mjs';
2
+ export { PACKAGENAME, PACKAGEVERSION, coreName, isDev, isLibrary, isMicro, mainDirectory, } from './process-env.mjs';
3
+ export { realResolve, resolveNodeModulesPath, resolveProgramPath, log } from './utils.mjs';
4
+ export { getIPv4, getPort } from './net.mjs';
5
+ export { default as osTmpDir } from './os-tmp-dir.mjs';
6
+ export type { MdxOptions } from '@moneko/mdx';
7
+ export type { OverrideResolverOption } from './plugin/override-resolve.mjs';
8
+ export type * from '../typings/global.js';
package/lib/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export{default as paths,CUSTOMCONFIG}from"./paths.mjs";export{PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro,mainDirectory}from"./process-env.mjs";export{realResolve,resolveNodeModulesPath,resolveProgramPath,log}from"./utils.mjs";export{getIPv4,getPort}from"./net.mjs";export{default as osTmpDir}from"./os-tmp-dir.mjs";
@@ -1,12 +1,13 @@
1
1
  declare const app: {
2
2
  name: string;
3
3
  projectName: string;
4
+ ssr: boolean;
4
5
  version: string;
5
6
  base: string;
6
- type: import("./index.js").AppType;
7
+ type: import("./index.mjs").AppType;
7
8
  routerMode: "browser" | "hash" | "memory";
8
9
  prefixCls: string | undefined;
9
- theme: import("./index.js").Theme | undefined;
10
+ theme: import("./index.mjs").Theme | undefined;
10
11
  description: any;
11
12
  author: any;
12
13
  repository: any;
package/lib/info.mjs ADDED
@@ -0,0 +1 @@
1
+ import{loadFileSync as e}from"@moneko/mdx";import{CONFIG as r}from"./config.mjs";import{APPTYPE as o,PACKAGENAME as t,PACKAGEVERSION as s,SSR as p}from"./process-env.mjs";import{resolveProgramPath as i,toUpperCaseString as m}from"./utils.mjs";let{description:n,author:a,repository:c,keywords:d}=JSON.parse(e(i("package.json"))||"{}"),f="string"==typeof a,l={name:t,projectName:m(t).replace(/-/g," "),ssr:p,version:s,base:r.basename,type:o,routerMode:r.routerMode,prefixCls:r.prefixCls,theme:r.theme,description:n,author:f?{name:a}:a,repository:f?{url:c}:c};export const description=n;export const keywords=Array.isArray(d)?d.toString():"";export default l;
@@ -1,4 +1,4 @@
1
- import type ReactiveObject from '../reactive-object.js';
1
+ import type ReactiveObject from '../reactive-object.mjs';
2
2
  import type { LoaderContext } from 'webpack';
3
3
  export default function (this: LoaderContext<{
4
4
  comment: ReactiveObject<Record<string, string>>;
@@ -1,5 +1,5 @@
1
1
  import TerserPlugin from 'terser-webpack-plugin';
2
- import type { MinifierType, SwcMinifyOptions, TerserMinifyOptions } from '.';
2
+ import type { MinifierType, SwcMinifyOptions, TerserMinifyOptions } from './index.mjs';
3
3
  type MinifyObject = {
4
4
  terser: {
5
5
  minify: typeof TerserPlugin.terserMinify;
package/lib/minify.mjs ADDED
@@ -0,0 +1 @@
1
+ import e from"terser-webpack-plugin";import{merge as o}from"webpack-merge";import{swcMinifyOption as r}from"./swcrc.mjs";export const minify={terser:{minify:e.terserMinify,terserOptions:{ecma:2015,parse:{},compress:{global_defs:{"@alert":"console.log"},drop_console:!0,drop_debugger:!0,pure_funcs:["console.log","console.warn","console.error","console.info"]},toplevel:!1,mangle:!0,module:!1,format:{comments:!1},ie8:!1,keep_classnames:void 0,keep_fnames:!1,safari10:!1},extractComments:!1},swc:{minify:e.swcMinify,terserOptions:r}};export const getMinifyOption=(e,r={})=>{let s=minify[e];return Object.assign(s,{terserOptions:o(s.terserOptions,r)})};
@@ -0,0 +1 @@
1
+ import{CONFIG as i}from"./config.mjs";import o from"./html-plugin-option.mjs";let f=i.prefixCls||"n",n={"@prefix-cls":f,"@ant-prefix":f,"@iconfont-css-prefix":`${f}-icon`,"@favicon":JSON.stringify(o.favicon)};Object.assign(n,i.modifyVars);export default n;
@@ -0,0 +1 @@
1
+ import e from"webpack";import{CONFIG as r}from"./config.mjs";import t from"./plugin/external-remotes.mjs";import{realResolve as o}from"./utils.mjs";let{NormalModuleReplacementPlugin:s,container:{ModuleFederationPlugin:a}}=e,m={},i={},l={},n=r.moduleFederation?.map(e=>{if(Array.isArray(e.remotes))for(let r=0,t=e.remotes.length;r<t;r++){let t=e.remotes[r],o=t.alias||t.name,s=t.filename||"remote_entry.js";if(l[o]=`${t.name}@${t.host}/${s}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)m[t.library[e]]=`${o}/${t.library[e]}`}if(Array.isArray(e.exposes))for(let r=0,t=e.exposes.length;r<t;r++){let t=e.exposes[r];"string"==typeof t?i[`./${t}`]=o(t):"[object Object]"===Object.prototype.toString.call(t)&&(i[`./${t.name}`]=o(t.path))}return new a({filename:"remote_entry.js",...e,remotes:l,exposes:i})});n.length&&(n.push(new t),n.push(new s(/(.*)/,e=>{m[e.request]&&(e.request=m[e.request])})));export default n;
@@ -0,0 +1,3 @@
1
+ import type { ModuleOptions } from 'webpack';
2
+ declare const _default: (ssr: boolean) => ModuleOptions;
3
+ export default _default;
@@ -0,0 +1 @@
1
+ let e;import s from"mini-css-extract-plugin";import{CONFIG as t,PUBLICPATH as o}from"./config.mjs";import{hasPkg as r}from"./has-pkg.mjs";import a from"./modify-vars.mjs";import i,{CUSTOMCONFIG as l}from"./paths.mjs";import{FRAMEWORK as n,isDev as m,isLibrary as d,isMicro as c}from"./process-env.mjs";import p from"./svg-to-data-uri.mjs";import u from"./swcrc.mjs";import{getLightningCssTargets as f}from"./targets.mjs";import{resolveNodeModulesPath as y,resolveProgramPath as g}from"./utils.mjs";import{comment as j,getCommentPath as $}from"./vm/docs.mjs";import x from"./vm/generate-doc.mjs";let v=c?o:"../",h={loader:s.loader,options:{publicPath:"/"!==v?v:"../"}},w={loader:`${i.corePath}/loader/lightningcss.cjs`,options:{sourceMap:!!t.sourceMap,analyzeDependencies:!1,targets:f(),drafts:{nesting:!0,customMedia:!0},errorRecovery:!1,unusedSymbols:[],rem:!!t.rem}};m&&(h="style-loader");let b=[...t.cssModules,`@moneko/${n}`,"neko-ui"].map(y),_=["components","example","mock","site","src","server"].map(g);function k(e){return _.concat(t.rulesInclude?.[e]?.map(y)||[])}l&&_.push(g(l)),t.overrideResolve&&t.overrideResolve.override&&_.push(t.overrideResolve.override);let M=k("css"),B=k("js"),L=k("media"),O=k("wasm"),P=k("font");r("sass")&&(e={loader:"sass-loader",options:{implementation:await import("sass"),sassOptions:{}}});let R=d&&m&&{test:/^(?![._]).*(?<!\.test)\.(tsx?)$/,include:t.alias["@pkg"],exclude:[/node_modules/,/(.+)\/__tests__\/(.+)/i],enforce:"pre",loader:`${i.corePath}/loader/ts-doc.cjs`,options:{comment:j,generateDoc:x,getCommentPath:$}};export default(s=>{let o={loader:"swc-loader",options:u(s)},r={loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,t=b.length;s<t;s++)if(e&&e?.includes(b[s]))return/(.*(?<!\.?global\.(le|c|sc|sa)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c|sc|sa)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly",exportOnlyLocals:s},importLoaders:2}},l=[h,r,w,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}}].filter(Boolean);return{noParse:[/jquery|lodash|prismjs|prism\.js/,/react\.min\.js$/,/marked\.min\.js$/],rules:[R,{oneOf:[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename:e=>{let s=e.filename;return s&&s.endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:/\.wasm$/i,type:"webassembly/async",include:O},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:L},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>p(e.toString())},include:L},{test:/\.(gif|png|jpe?g|webp)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:L},{test:/\.(webm|mp4|ogv)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:L},{test:/\.(woff2?|eot|ttf|otf)(\?.*)?$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:P},{test:/\.(sa|sc)ss$/i,use:[h,r,w,e].filter(Boolean),include:M},{test:/\.less$/i,use:l,include:M},{test:/\.css$/i,use:[h,"css-loader",w].filter(Boolean),include:M},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,o].filter(Boolean),include:B},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,{loader:`${i.corePath}/loader/mdx.cjs`,options:t.mdx}].filter(Boolean),exclude:[/node_modules/]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules].filter(e=>"object"==typeof e)}});
@@ -1,2 +1,2 @@
1
- export declare function getIPv4(): string | undefined;
1
+ export declare function getIPv4(): null;
2
2
  export declare function getPort<T = number>(start: T, end: number, host?: string): Promise<T>;
package/lib/net.mjs ADDED
@@ -0,0 +1 @@
1
+ import{createConnection as e}from"net";import{networkInterfaces as r}from"os";export function getIPv4(){let e=r(),t=null;return Object.keys(e).forEach(r=>{e[r]?.forEach(e=>{"IPv4"!==e.family||e.internal||(t=e.address)})}),t}export function getPort(r,t,o="0.0.0.0"){return new Promise(n=>{if("number"!=typeof r)n(r);else{let f=e(r,o);f.on("connect",()=>{f.destroy(),n(getPort(r+1,t,o))}),f.on("error",()=>{n(r)})}})}
@@ -22,5 +22,6 @@ declare const _default: {
22
22
  coveragePath: string;
23
23
  pagesPath: string;
24
24
  componentsPath: string;
25
+ mockPath: string;
25
26
  };
26
27
  export default _default;
@@ -1 +1 @@
1
- import e from"url";let c=JSON.parse(process.env.npm_config_argv||"{}")?.original;export const yarnArgv={};c?.forEach(e=>{let c=e.split("=");Object.assign(yarnArgv,{[c[0]]:c[1]||!0})});export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config;let o=process.cwd(),t=`${o}/node_modules`,a=`${t}/.cache/.mo`;export default{nodeModules:t,corePath:e.fileURLToPath(new URL(".",import.meta.url)),programPath:o,webpackCachePath:`${t}/.temp_cache`,cachePath:a,httpCachePath:`${t}/.cache/http`,swcCachePath:`${t}/.swc`,configPath:`${o}/config/index.ts`,customConfigPath:`${o}/config/${CUSTOMCONFIG}.ts`,coveragePath:`${o}/coverage/clover.xml`,pagesPath:`${o}/src/pages`,componentsPath:`${o}/components`};
1
+ import e from"url";let c=JSON.parse(process.env.npm_config_argv||"{}")?.original;export const yarnArgv={};c?.forEach(e=>{let c=e.split("=");Object.assign(yarnArgv,{[c[0]]:c[1]||!0})});export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config;let o=process.cwd(),t=`${o}/node_modules`,a=`${t}/.cache/.mo`;export default{nodeModules:t,corePath:e.fileURLToPath(new URL(".",import.meta.url)),programPath:o,webpackCachePath:`${t}/.temp_cache`,cachePath:a,httpCachePath:`${t}/.cache/http`,swcCachePath:`${t}/.swc`,configPath:`${o}/config/index.ts`,customConfigPath:`${o}/config/${CUSTOMCONFIG}.ts`,coveragePath:`${o}/coverage/clover.xml`,pagesPath:`${o}/src/pages`,componentsPath:`${o}/components`,mockPath:`${o}/mock`};
@@ -1 +1 @@
1
- import e from"webpack";let{sources:t}=e,r="ExternalRemotesPlugin";export default class{apply(e){e.hooks.make.tap(r,e=>{let n=[];e.hooks.buildModule.tap(r,e=>{"ExternalModule"===e.constructor.name&&"script"===e.externalType&&n.push(e)}),e.hooks.afterCodeGeneration.tap(r,function(){n.map(r=>{let n=function(e){let t=e.indexOf("@");if(t<=0||t===e.length-1)throw Error(`Invalid request "${e}"`);return[e.substring(t+1),e.substring(0,t)]}(r.request)[0],o=function(e){let t=[],r=[],n=!1,o=!1;for(let l of e)if("["===l){if(n){o=!0;break}n=!0,r.length&&(t.push(`"${r.join("")}"`),r.length=0)}else if("]"===l){if(!n){o=!0;break}n=!1,r.length&&(t.push(`${r.join("")}`),r.length=0),r.length=0}else r.push(l);if(n||o)throw Error(`Invalid template URL "${e}"`);return r.length&&t.push(`"${r.join("")}"`),t.join(" + ")}(n),l=e.codeGenerationResults.get(r,void 0).sources;l.set("javascript",new t.RawSource(l.get("javascript")?.source().replace(`"${n}"`,o)))})})})}}
1
+ import e from"webpack";let{sources:t}=e,r="ExternalRemotesPlugin";export default class{apply(e){e.hooks.make.tap(r,e=>{let n=[];e.hooks.buildModule.tap(r,e=>{"ExternalModule"===e.constructor.name&&"script"===e.externalType&&n.push(e)}),e.hooks.afterCodeGeneration.tap(r,function(){n.map(r=>{let n=function(e){let t=e.indexOf("@");if(t<=0||t===e.length-1)throw Error(`Invalid request "${e}"`);return[e.substring(t+1),e.substring(0,t)]}(r.request)[0],o=function(e){let t=[],r=[],n=!1,o=!1;for(let l of e)if("["===l){if(n){o=!0;break}n=!0,r.length&&(t.push(`"${r.join("")}"`),r.length=0)}else if("]"===l){if(!n){o=!0;break}n=!1,r.length&&(t.push(`${r.join("")}`),r.length=0),r.length=0}else r.push(l);if(n||o)throw Error(`Invalid template URL "${e}"`);return r.length&&t.push(`"${r.join("")}"`),t.join(" + ")}(n),l=e.codeGenerationResults.get(r,void 0).sources;l.set("javascript",new t.RawSource((l.get("javascript")?.source()).replace(`"${n}"`,o)))})})})}}
@@ -0,0 +1 @@
1
+ import{relative as e}from"path";import{fileExists as t}from"@moneko/mdx";import r from"../paths.mjs";let a="OverrideResolverPlugin";export default class{constructor(e){this.options=e}apply(i){let{override:o,original:s}=this.options;if(o&&s){let l=`./${e(r.programPath,s)}`,p=`./${e(r.programPath,o)}`;i.getHook("existing-file").tapAsync(a,(e,r,n)=>{let h=e.request||e.path;if(h&&h.startsWith(s)&&e.relativePath){let m=h.replace(s,o);if(t(m)){let t=e.relativePath.replace(l,p);return Object.assign(e,{path:m,relativePath:t,__innerRequest_relativePath:t,__innerRequest:t}),i.doResolve("resolved",e,`${a} 使用目标模块${o}`,r,n)}}return n()})}}}
@@ -0,0 +1 @@
1
+ import o from"webpack-virtual-modules";import{isLibrary as t}from"../process-env.mjs";import{resolveNodeModulesPath as e}from"../utils.mjs";import{comment as r,docs as m}from"../vm/docs.mjs";import{examples as p}from"../vm/example.mjs";import{locales as s}from"../vm/locales.mjs";import i from"../vm/modules.mjs";import{route as a}from"../vm/routes.mjs";export default class{constructor(o={}){this.options=o,this.hasTapped=!1}apply(l){let n=this.options,f=new o(i);function c(o,t){let r=e(o);f.writeModule(r,t||"")}f.apply(l),a.on("change",c),s.on("change",c),t&&(p.on("change",c),m.on("change",c),r.on("change",c)),l.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.hasTapped){for(let o in this.hasTapped=!0,n)if(Object.prototype.hasOwnProperty.call(n,o)){let t=n[o];c(o,"string"==typeof t?t:`export default ${JSON.stringify(t)}`)}for(let o of p)c(...o);for(let o of m)c(...o);for(let o of r)c(...o)}})}}
@@ -0,0 +1 @@
1
+ import e from"add-asset-html-webpack-plugin";import t from"html-webpack-plugin";import l from"webpack";import{CONFIG as o}from"./config.mjs";import i from"./html-plugin-option.mjs";import r from"./module-federation.mjs";import n from"./plugin/add-entry-attribute.mjs";import p from"./plugin/virtual-module.mjs";import{isMicro as a}from"./process-env.mjs";let{AutomaticPrefetchPlugin:s,DefinePlugin:m,SourceMapDevToolPlugin:c,IgnorePlugin:h,WatchIgnorePlugin:u}=l,f=o.basename.split("/").filter(Boolean).length,d=`${Array(f).fill("..").join("/")+(f?"/":"")}404.html`,{pathSegmentsToKeep:w=f,path:g=d}=o.fixBrowserRouter||{},j=o.assetHtml.map(e=>({publicPath:"",...e})),b=[new u({paths:[/\.d\.ts$/]}),...r,new p(o.virtualModule),new s,o.htmlPluginOption&&new t(i),o.fixBrowserRouter&&new t({filename:g,inject:!1,templateContent:()=>`<html lang="en"><head><title>${i.title}</title><script>const pathKeep = ${w||f};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new e(j),a&&new n({test:/main\.bundle\.js$/}),new m({"process.env":JSON.stringify(o.env)}),new h({resourceRegExp:/\/__tests__\//}),o.sourceMap&&new c(o.sourceMap),...o.plugins].filter(e=>!!e);export default b;
@@ -0,0 +1 @@
1
+ import t from"core-js-compat";import{getBrowsersTargets as r}from"./targets.mjs";export default function(){return t({targets:r(),version:"3.34"}).list}
@@ -1,4 +1,4 @@
1
- import type { AppType, Framework } from '.';
1
+ import type { AppType, Framework } from './index.mjs';
2
2
  export declare const APPTYPE: AppType;
3
3
  export declare const FRAMEWORK: Framework;
4
4
  export declare const isLibrary: boolean;
@@ -6,6 +6,7 @@ export declare const isMicro: boolean;
6
6
  export declare const isMobile: boolean;
7
7
  export declare const isReact: boolean;
8
8
  export declare const isSolid: boolean;
9
+ export declare const SSR: boolean;
9
10
  /** 项目主要文件夹 */
10
11
  export declare const mainDirectory: string;
11
12
  export declare const jsxImportSource: string;
@@ -0,0 +1 @@
1
+ import o from"./paths.mjs";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;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];export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;export const coreName="@moneko/core";export const isDev="development"===process.env.NODE_ENV;export const routeDir=isLibrary?o.componentsPath:o.pagesPath;
package/lib/seo.mjs ADDED
@@ -0,0 +1 @@
1
+ import{join as m}from"path";import{saveFileSync as o,scanRouter as t,sitemap as r}from"@moneko/mdx";import{outputConfig as e}from"./common.mjs";import{CONFIG as p}from"./config.mjs";import{isLibrary as i,routeDir as s}from"./process-env.mjs";import{resolveProgramPath as f}from"./utils.mjs";export default(()=>{let{domain:n,nojekyll:a,path:j}=p.seo||{},l=j&&f(j)||e?.path;if(!n||!l)return;let x=`https://${n}${p.basename}`;o(m(l,"CNAME"),n),o(m(l,"robots"),`Sitemap: ${x}/sitemap.txt`),o(m(l,"sitemap.txt"),r(s,x,t(s,i)).join("\n")),a&&o(m(l,".nojekyll"),"")});
@@ -1,4 +1,4 @@
1
1
  import type { JsMinifyOptions, Config as SwcConfig } from '@swc/core';
2
2
  export declare const swcMinifyOption: JsMinifyOptions;
3
- declare const _default: SwcConfig;
3
+ declare const _default: (ssr: boolean) => SwcConfig;
4
4
  export default _default;
package/lib/swcrc.mjs ADDED
@@ -0,0 +1 @@
1
+ import{merge as e}from"webpack-merge";import{CONFIG as o}from"./config.mjs";import r from"./paths.mjs";import s from"./polyfills.mjs";import{isDev as t,isReact as n,isSolid as i,jsxImportSource as l}from"./process-env.mjs";export const swcMinifyOption={compress:{top_retain:[],keep_infinity:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],toplevel:!1,drop_console:!0,drop_debugger:!0,module:!1,ecma:2015,ie8:!1,keep_classnames:void 0,keep_fnames:!1},mangle:!0};let m=function(e){for(let o=0,r=Object.keys(e),s=r.length;o<s;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{}),p={include:s(),mode:"entry",coreJs:"3.34"};export default(s=>e({module:{type:"es6",resolveFully:!0},jsc:{parser:{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0},loose:!0,target:o.polyfill?void 0:"es2017",externalHelpers:!1,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,refresh:n&&t,development:t,importSource:l},optimizer:{simplify:!1}},minify:t?void 0:swcMinifyOption,experimental:{emitAssertForImportAttributes:!0,cacheRoot:r.swcCachePath,plugins:[["swc-plugin-another-transform-imports",m],i&&["@moneko/jsx-dom-expressions",{...o.jsxDomExpressions,generate:s?"ssr":"dom",hydratable:!!s}]].filter(Boolean)}},env:o.polyfill?p:void 0,sourceMaps:!0,parseMap:!0},"function"==typeof o.swcrc?o.swcrc(t):o.swcrc||{}));
@@ -0,0 +1 @@
1
+ let r,t;import e from"browserslist";import{browserslistToTargets as s}from"lightningcss";import o from"./paths.mjs";export function getBrowsersTargets(){return r||(r=e(void 0,{path:o.programPath,env:process.env.NODE_ENV}).filter(r=>!r.endsWith(" TP"))),r}export function getLightningCssTargets(){return t||(t=s(getBrowsersTargets())),t}
File without changes
@@ -1,3 +1,4 @@
1
+ import type { Compiler } from 'webpack';
1
2
  export declare function esm(templateStrings: TemplateStringsArray, ...substitutions: unknown[]): string;
2
3
  export declare function log(msg: string | string[]): void;
3
4
  export declare function tfc(filepath: string): string;
@@ -23,4 +24,5 @@ export declare const realResolve: (url: string) => string;
23
24
  export declare function isObject(target: unknown): target is object;
24
25
  export declare function isFunction(target: unknown): target is (...args: unknown[]) => unknown;
25
26
  export declare function empty(): void;
27
+ export declare function compilerListener(name: string, compiler: Compiler): Promise<unknown>;
26
28
  export {};
package/lib/utils.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import{resolve as o}from"path";import r from"readline";import{saveFileSync as t}from"@moneko/mdx";import{transformFileSync as e}from"@swc/core";import n from"./paths.mjs";import s from"./resolver-sync.mjs";export function esm(o,...r){let t=o.raw[0];for(let e=0;e<r.length;e++)t+=r[e]+o.raw[e+1];return`data:text/javascript;base64,${Buffer.from(t).toString("base64")}`}let c={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function log(o){Array.isArray(o)?o.forEach(o=>{log(`${o}
2
+ `)}):(r.cursorTo(process.stdout,0),process.stdout.write(o))}export function tfc(o){return e(o,c).code||"{}"}export function readConf(o,r){let e=`${n.cachePath}/${r}.mjs`;return t(e,tfc(o)),import(e)}export function toUpperCaseString(o){return o?.replace(/\b\w/g,o=>o.toUpperCase()).replace(/\./g," ")}export function resolveProgramPath(r){return o(n.programPath,`./${r}`)}export const resolveNodeModulesPath=o=>`${n.nodeModules}/${o}`;export const realResolve=o=>s.resolveSync({},n.programPath,o)||o;export function isObject(o){let r=typeof o;return null!==o&&("object"==r||"function"==r)}export function isFunction(o){if(!isObject(o))return!1;let r=Object.prototype.toString.call(o);return"[object Function]"==r||"[object AsyncFunction]"==r||"[object GeneratorFunction]"==r||"[object Proxy]"==r}export function empty(){}export function compilerListener(o,r){return new Promise((t,e)=>{r.hooks.failed.tap(o,o=>{e(o)}),r.hooks.done.tap(o,r=>{r.hasErrors()||t(!0),r.compilation.warnings.forEach(r=>log([o,r.message])),r.compilation.errors.forEach(r=>log([o,r.message]))})})}
@@ -0,0 +1 @@
1
+ import{fileExists as e,loadFileSync as r}from"@moneko/mdx";import{Parser as t}from"xml2js";import{PACKAGENAME as o}from"../process-env.mjs";export default function(c){let a={},i="export default {}";if(e(c))try{let e=r(c);(0,new t({explicitArray:!1,async:!1}).parseString)(e,(e,r)=>{e||(Object.assign(a,{[o]:r.coverage.project.metrics.$}),r.coverage.project.package.forEach(e=>{Object.assign(a,{[e.$.name]:e.metrics.$})})),i=`export default ${JSON.stringify(a)}`})}catch(e){}return i}
@@ -1,4 +1,4 @@
1
- import ReactiveObject from '../reactive-object.js';
1
+ import ReactiveObject from '../reactive-object.mjs';
2
2
  export declare const docsModuleName = "@app/docs";
3
3
  export declare const docs: ReactiveObject<Record<string, string>>;
4
4
  export declare const comment: ReactiveObject<Record<string, string>>;
@@ -0,0 +1 @@
1
+ import{loadFileSync as e,scanFolder as t}from"@moneko/mdx";import o from"./generate-doc.mjs";import{CONFIG as r}from"../config.mjs";import{FRAMEWORK as n,isLibrary as a,isReact as m,isSolid as s}from"../process-env.mjs";import p from"../reactive-object.mjs";let l={react:"createElement",solid:"createComponent"}[n];export const docsModuleName="@app/docs";export const docs=new p({[docsModuleName]:"export default {}"});export const comment=new p({});export const getCommentPath=function(){let e=/^\/?(.+?)\.tsx?$/,t=r.alias["@pkg"].length;return o=>o.substring(t).replace(e,"@app/comment/$1.md")}();if(a){let a={},p=`import { ${l}${s?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[n]}${s?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${m?"() =>":""}${l}(${s?"Dynamic":"'n-md'"}, {text: res.default, ${s?"component: 'n-md', ":""}css: 'table td a {display:inline-flex;align-items:center;gap:2px;}table td a n-img{display:inline-block;overflow:hidden;border-radius:var(--border-radius);inline-size:18px;block-size:18px;}' })};}`,c=(e,t)=>{let o=e.replace(/^@app\/comment\//,"").split("/"),r=o.pop(),n=o.join("/");a[n]||(a[n]={}),t?a[n][r]&&delete a[n][r]:a[n][r]=`rr(() => ${l}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let m={};for(let e in a)Object.prototype.hasOwnProperty.call(a,e)&&(m[e]=Object.values(a[e]));docs.setData(docsModuleName,`${p}export default ${JSON.stringify(m).replace(/"rr\((.+?)\)rr"/g,"$1")}`)};comment.on("change",(e,t)=>{c(e,t?.length<0)}),t(r.alias["@pkg"]).filter(e=>/^(?![._]).*(?<!\.test)\.(tsx?)$/i.test(e)).forEach(t=>{let r=e(t);r&&comment.setData(getCommentPath(t),o(r,t))})}
@@ -1,4 +1,4 @@
1
- import ReactiveObject from '../reactive-object.js';
1
+ import ReactiveObject from '../reactive-object.mjs';
2
2
  export declare const exampleModuleName = "@app/example";
3
3
  export declare const examples: ReactiveObject<Record<string, string>>;
4
4
  export declare function generatorDemo(): void;
@@ -0,0 +1 @@
1
+ import{generateExample as e}from"@moneko/mdx";import{watchFiles as o}from"./utils.mjs";import t from"../paths.mjs";import{isDev as r,isLibrary as m}from"../process-env.mjs";import p from"../reactive-object.mjs";export const exampleModuleName="@app/example";function a(){try{return JSON.parse(e(t.componentsPath,"@app/example/"))}catch(e){return{}}}export const examples=new p(m?a():{});export function generatorDemo(){let e=a();for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&examples.setData(o,e[o])}m&&r&&o(t.componentsPath,/(?<!\/examples\/(.+)\.md)$/,generatorDemo);
@@ -0,0 +1 @@
1
+ import{dirname as e}from"path";import t from"typescript";import{CONFIG as n}from"../config.mjs";let{ScriptKind:r,ScriptTarget:l,SyntaxKind:o,createSourceFile:i,forEachChild:a,getLeadingCommentRanges:c,isInterfaceDeclaration:u,isQuestionToken:s,isPropertySignature:f,isFunctionTypeNode:p,isUnionTypeNode:m,isMethodSignature:g}=t,$={};function h(e){let t=c(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end).match(/\/\*\*([\s\S]*?)\*\//);if(n)return n[1].replace(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim()}return null}function b(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function d(e){if(!e)return null;let t=e.match(/@author (\w+)\s*(?:<([^>]+)>)?/);if(t?.length){let e=t[1].trim(),n=t[2]?.trim(),r=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(n);return n?r&&(n=`mailto:${n}`):n=`https://github.com/${e}`,`[![${e}](https://avatars.githubusercontent.com/${e}?s=64)${e}](${n})`}return null}function y(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let x=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function j(e,t){if(!e)return null;let r=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if($[e]){let r=`/${[n.basename,$[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${r})`:`[${e}](${r})`}return t?`\\color{#009688}{${e}}`:e});return t&&(r=r.replace(x,e=>`\\color{#009688}{${e}}`)),r}function T(e){return(function(e){let t;if(!e)return null;let n=[];for(;t=/\\color{([^|}]*)\|?([^|}]*)\|?([^|}]*)\|?([^}]*)}{([^}]*)}/g.exec(e);)n.push(t[0]);return e.replace(/[{}[\]()=>]|keyof|typeof|true|false/g,e=>n.some(t=>t.includes(e))?e:`\\color{#569cd6}{${e}}`)})(e)?.replace(/^\s*\|\s*|\s*\|\s*$/gm,"").replace(/\n/g,"<br/>").replace(/\*/g,"\\*").replace(/\|/g,"\\|").replace(/(['"])((?:(?!\1).)*)\1/g,"\\color{#ce9178}{$1$2$1}")}function B(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}export default function k(c,x){let k=i(x,c,l.Latest,!0,r.TS),w="";return a(k,r=>{u(r)?w+=function(r){let l=r.name.text;Object.assign($,{[r.name.text]:e(r.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let i=h(r),a=b(i),c=B(i),u=y(i)?.split("|")||[],x=u.includes("comment"),k=u.includes("initial"),w=u.includes("optional"),E=u.includes("version"),S=u.includes("author"),v=c?`\\color{|4||0.45}{${l}}`:l,F=(function(e){let n=[];if(e.heritageClauses){for(let r of e.heritageClauses)if(r.token===t.SyntaxKind.ExtendsKeyword)for(let e of r.types)n.push(e.getText())}return n})(r)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${j(T(e))}</n-tag>`),z=[c,v,a&&`\\color{#52c11b|1||0.9}{${a}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),K=`## ${z}`,N=r.members.filter(e=>f(e)&&e.type?.kind!==o.NeverKeyword||g(e)),q=[];if(N.length){N.forEach(e=>{let t=j(T(g(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),n=h(e),r=T(e.name.getText());!r||r.startsWith("\\color")||(g(e)||function(e){if(e.type){if(!m(e.type))return p(e.type);for(let t of e.type.types)if(p(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let l=e.questionToken&&s(e.questionToken);q.push([r,!w&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!x&&T(B(n)),t,!k&&T(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&T(b(n)),!S&&(d(n)||d(i))])});let e=!1,t=!1,n=!1,r=!1;q.forEach(l=>{!x&&l[2]&&(r=!0),!k&&l[4]&&(n=!0),!E&&l[5]&&(t=!0),!S&&l[6]&&(e=!0)}),K+="\n";let l=["属性",!w&&"必要",r&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");K+=`|${l}|`;let o=[":-",!w&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);K+="\n";let a=o.join("|");K+=`|${a}|`,q.forEach(l=>{K+="\n";let o=[l[0]||"-",!w&&(l[1]||"-"),r&&(l[2]||"-"),l[3]||"-",n&&(l[4]||"-"),t&&(l[5]||"-"),e&&(l[6]||"-")].filter(Boolean).join("|");K+=`|${o}|`}),K+="\n"}return K+="\n"}(r):t.isEnumDeclaration(r)&&(w+=function(r){let l=r.name.text,o=h(r),i=B(o),a=b(o);Object.assign($,{[r.name.text]:e(r.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let c=i?`\\color{|4||0.45}{${l}}`:l,u=[i,c,a&&`\\color{#52c11b|1||0.9}{${a}}`].filter(Boolean).join(" "),s=y(o)?.split("|")||[],f=s.includes("comment"),p=s.includes("version"),m=s.includes("author"),g=`## ${u}`;if(r.members.length){let e=[];r.members.forEach(n=>{let r=T(n.name.getText()),l=h(n),i=T(function(e){let n=e.initializer;return n&&t.isStringLiteral(n)?` '${n.text}'`:null}(n)),a=T(b(l)),c=T(B(l));!r||r.startsWith("\\color")||/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`),e.push([r,!f&&c,i,!p&&a,!m&&(d(l)||d(o))])});let n=!1,l=!1,i=!1;e.forEach(e=>{!f&&e[1]&&(i=!0),!p&&e[3]&&(l=!0),!m&&e[4]&&(n=!0)}),g+="\n";let a=["属性",i&&"说明","值",l&&"版本",n&&"作者"].filter(Boolean).join("|");g+=`|${a}|`;let c=[":-",i&&":-",":-",l&&":-",n&&":-"].filter(Boolean);g+="\n";let u=c.join("|");g+=`|${u}|`,e.forEach(e=>{g+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),n&&(e[4]||"-")].filter(Boolean).join("|");g+=`|${t}|`})}return g+="\n\n"}(r))}),w}
@@ -1,4 +1,4 @@
1
- import ReactiveObject from '../reactive-object.js';
1
+ import ReactiveObject from '../reactive-object.mjs';
2
2
  export declare const localesModuleName = "@app/locales";
3
3
  export declare const locales: ReactiveObject<{
4
4
  "@app/locales": string;
@@ -0,0 +1,2 @@
1
+ import{basename as e,join as t}from"path";import{directoryExists as o,scanFolder as a}from"@moneko/mdx";import{watch as l}from"chokidar";import{CONFIG as r}from"../config.mjs";import{FRAMEWORK as n,isDev as s}from"../process-env.mjs";import c from"../reactive-object.mjs";import{esm as i,tfc as g}from"../utils.mjs";let u={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;'}[n];function p(e,t){return`${u[n]}
2
+ export function interpolateString(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}`}export const localesModuleName="@app/locales";export const locales=new c({[localesModuleName]:p([],{})});let d={};async function m(t,o){let a=e(t).replace(/\.[^.]+$/,"");"deleted"===o?delete d[a]:Object.assign(d,{[a]:(await import(i`${g(t)}`)).default});let l=[],r={};for(let e in d)if(Object.prototype.hasOwnProperty.call(d,e)){let{language:t=a,title:o=t,icon:n,translation:s={}}=d[e];l.push({language:t,title:o,icon:n}),r[t]={language:t,title:o,icon:n,translation:s}}locales.setData(localesModuleName,p(l,r))}let z=t(r.alias["@"],"./locales");o(z)&&(a(z).filter(e=>!/^\..*/.test(e)&&!/!\.ts$/.test(e)&&!/\.d\.ts$/.test(e)).forEach(e=>{m(e,"added")}),s&&function(e,t){let o=l(e,{ignored:t,persistent:!0,ignoreInitial:!0});function a(){o.unwatch(e),o.close()}o.on("add",e=>{m(e,"added")}),o.on("change",e=>{m(e,"change")}),o.on("unlink",e=>{m(e,"deleted")}),o.once("ready",()=>{s||a()}),process.on("SIGINT",a)}(z,[/^\..*/,/!\.ts$/,/\.d\.ts$/]));
@@ -0,0 +1,17 @@
1
+ declare const _default: {
2
+ "node_modules/@app/info": string;
3
+ "node_modules/@app/entry": string;
4
+ "node_modules/@app/rem": string;
5
+ "node_modules/@app/fallback": string;
6
+ "node_modules/@app/coverage": string;
7
+ "node_modules/@app/merge-router": string;
8
+ "node_modules/@app/prefix-router": string;
9
+ "node_modules/@app/normalize/index.css": string;
10
+ "node_modules/@app/suspense/index.tsx": string;
11
+ "node_modules/@app/mdx-scope": string;
12
+ "node_modules/@app/routes": string;
13
+ "node_modules/@app/example": string;
14
+ "node_modules/@app/locales": string;
15
+ "node_modules/@app/docs": string;
16
+ };
17
+ export default _default;
@@ -0,0 +1 @@
1
+ import{join as m}from"path";import{getAppEntry as o,getAppFallback as r,getAppMdxScope as p,getAppMergeRouter as e,getAppNormalizeCss as t,getAppPrefixRouter as a,getAppRem as s,getAppSuspense as i}from"@moneko/mdx";import f from"./coverage.mjs";import{docs as l,docsModuleName as n}from"./docs.mjs";import{exampleModuleName as c}from"./example.mjs";import{locales as x,localesModuleName as d}from"./locales.mjs";import{route as g,routesModuleName as j}from"./routes.mjs";import{CONFIG as u}from"../config.mjs";import h from"../info.mjs";import v from"../paths.mjs";import{APPTYPE as k,FRAMEWORK as z}from"../process-env.mjs";import{resolveNodeModulesPath as D,resolveProgramPath as b}from"../utils.mjs";export default{[D("@app/info")]:`export default ${JSON.stringify(h)}`,[D("@app/entry")]:o(m(u.alias["@"],"./index.ts"),!!u.rem,!!u.normalizeCss,k,z),[D("@app/rem")]:s(u.rem?.designSize||1680),[D("@app/fallback")]:r(u.fallbackCompPath),[D("@app/coverage")]:f(v.coveragePath),[D("@app/merge-router")]:e(),[D("@app/prefix-router")]:a(),[D("@app/normalize/index.css")]:t(),[D("@app/suspense/index.tsx")]:i(k,z),[D("@app/mdx-scope")]:p(b("site/mdx-scope.ts")),[D(j)]:g.getData(j),[D(c)]:"export default []",[D(d)]:x.getData(d),[D(n)]:l.getData(n)};
@@ -1,4 +1,4 @@
1
- import ReactiveObject from '../reactive-object.js';
1
+ import ReactiveObject from '../reactive-object.mjs';
2
2
  export declare const routesModuleName = "@app/routes";
3
3
  export declare const route: ReactiveObject<{
4
4
  "@app/routes": string;
@@ -0,0 +1 @@
1
+ import{generateRouter as o}from"@moneko/mdx";import{watchFiles as e}from"./utils.mjs";import{CONFIG as t}from"../config.mjs";import{FRAMEWORK as r,isDev as m,isLibrary as s,routeDir as u}from"../process-env.mjs";import n from"../reactive-object.mjs";let i=s?"@pkg":"@/pages";export const routesModuleName="@app/routes";function p(){return o(u,`${t.alias["@"]}/router/index.ts`,r,i,s)}export const route=new n({[routesModuleName]:p()});export function generatorRouter(){route.setData(routesModuleName,p())}m&&e(u,s?/(?<!README\.mdx?)$/:/(?<!index\.tsx?)$/,generatorRouter);
package/package.json CHANGED
@@ -1,52 +1,62 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.9.17-beta.1",
3
+ "version": "3.9.17-beta.11",
4
4
  "description": "core",
5
- "main": "lib/index.js",
5
+ "main": "lib/index.mjs",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "build": "rm -rf ./lib && tsc && swc src -d lib -D",
9
- "postbuild": "npm run cjs",
10
- "cjs": "find ./lib/loader/ -type f -name \"*.js\" -execdir bash -c 'mv \"$1\" \"${1%.js}.cjs\"' _ {} \\;"
9
+ "postbuild": "npm run cjs && npm run mjs",
10
+ "cjs": "find ./lib/loader/ -type f -name \"*.js\" -execdir bash -c 'mv \"$1\" \"${1%.js}.cjs\"' _ {} \\;",
11
+ "mjs": "find ./lib/ -type f -name \"*.js\" -execdir bash -c 'mv \"$1\" \"${1%.js}.mjs\"' _ {} \\;"
11
12
  },
12
13
  "keywords": [],
13
14
  "author": "moneko",
14
15
  "license": "MIT",
15
16
  "dependencies": {
16
17
  "@moneko/mdx": "0.1.23",
17
- "@swc/core": "1.3.100",
18
+ "@swc/core": "1.3.101",
18
19
  "add-asset-html-webpack-plugin": "6.0.0",
20
+ "chokidar": "3.5.3",
19
21
  "core-js": "3.34.0",
20
22
  "core-js-compat": "3.34.0",
23
+ "cors": "2.8.5",
21
24
  "cross-env": "7.0.3",
22
25
  "css-loader": "6.8.1",
23
- "html-webpack-plugin": "5.5.4",
26
+ "express": "4.18.2",
27
+ "html-webpack-plugin": "5.6.0",
28
+ "http-proxy-middleware": "2.0.6",
24
29
  "less": "4.2.0",
25
30
  "less-loader": "11.1.3",
26
31
  "lightningcss": "1.22.1",
27
32
  "mini-css-extract-plugin": "2.7.6",
28
- "sass": "1.69.5",
29
- "sass-loader": "13.3.2",
33
+ "mock-json-schema": "1.1.1",
34
+ "multer": "1.4.5-lts.1",
35
+ "path-to-regexp": "6.2.1",
30
36
  "style-loader": "3.3.3",
31
- "style-resources-loader": "1.5.0",
32
37
  "swc-loader": "0.2.3",
33
38
  "swc-plugin-another-transform-imports": "0.2.7",
34
- "ts-import-plugin": "3.0.0",
35
- "ts-loader": "9.5.1",
36
39
  "typescript": "5.3.3",
37
40
  "webpack": "5.77.0",
38
41
  "webpack-bundle-analyzer": "4.10.1",
39
- "webpack-cli": "5.1.4",
40
- "webpack-dev-server": "4.15.1",
42
+ "webpack-dev-middleware": "6.1.1",
43
+ "webpack-hot-middleware": "2.25.4",
44
+ "webpack-merge": "5.10.0",
41
45
  "webpack-node-externals": "3.0.0",
42
46
  "webpack-virtual-modules": "0.6.1",
43
- "webpackbar": "5.0.2",
47
+ "webpackbar": "6.0.0",
44
48
  "xml2js": "0.6.2"
45
49
  },
46
50
  "devDependencies": {
47
51
  "@swc/cli": "0.1.63",
52
+ "@types/cors": "2.8.17",
53
+ "@types/express": "4.17.21",
54
+ "@types/multer": "1.4.11",
48
55
  "eslint-config-neko": "2.3.0",
49
- "stylelint-config-moneko": "1.2.1"
56
+ "eslint-webpack-plugin": "4.0.1",
57
+ "sass": "1.69.5",
58
+ "sass-loader": "13.3.2",
59
+ "stylelint-webpack-plugin": "4.1.1"
50
60
  },
51
61
  "files": [
52
62
  "lib",
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title><%= htmlWebpackPlugin.options.title %></title>
5
+ <%
6
+ var customTag="";
7
+ if (htmlWebpackPlugin.options.tags) {
8
+ htmlWebpackPlugin.options.tags.forEach(function(item){
9
+ var { tag = "script", textContent = "", ...attrs } = item;
10
+ var _attrs = "";
11
+ for (const key in attrs) {
12
+ if (attrs.hasOwnProperty(key)) {
13
+ _attrs += `${key}="${attrs[key]}" `;
14
+ }
15
+ }
16
+ customTag += `<${tag} ${_attrs}>${textContent}</${tag}>`;
17
+ });
18
+ }
19
+ %>
20
+ <%= customTag %>
21
+ </head>
22
+ <body>
23
+ <!--ssr-outlet-->
24
+ </body>
25
+ </html>
@@ -7,8 +7,8 @@ import type { MdxOptions } from '@moneko/mdx';
7
7
  import type { Config as SwcConfig, JsMinifyOptions as SwcMinifyOptions } from '@swc/core';
8
8
  import type { Options as AssetHtmlOptions } from 'add-asset-html-webpack-plugin';
9
9
  import type { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
10
+ import type { Options as ProxyConfig } from 'http-proxy-middleware';
10
11
  import type { MinifyOptions as TerserMinifyOptions } from 'terser';
11
- import type { Options } from 'ts-import-plugin';
12
12
  import type {
13
13
  Configuration,
14
14
  ExternalsPresets,
@@ -16,12 +16,6 @@ import type {
16
16
  RuleSetRule,
17
17
  WebpackPluginInstance,
18
18
  } from 'webpack';
19
- import type {
20
- Configuration as DevServerConfiguration,
21
- ProxyArray,
22
- ProxyConfigArray,
23
- ProxyConfigMap,
24
- } from 'webpack-dev-server';
25
19
 
26
20
  export type { TerserMinifyOptions, SwcMinifyOptions };
27
21
  export type WebpackBarOptions = ConstructorParameters<typeof WebpackBar>[0];
@@ -77,7 +71,7 @@ export interface Theme {
77
71
  errorColor?: string;
78
72
  warningColor?: string;
79
73
  }
80
- export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
74
+ export declare type ConfigType = {
81
75
  /** 启用 polyfill; 当设置为 `true` 时, 则根据 `browserslist` 设置自动polyfill
82
76
  * @default false
83
77
  */
@@ -86,10 +80,6 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
86
80
  * @default 'csr'
87
81
  */
88
82
  mode: 'ssr' | 'csr';
89
- /** 编译器
90
- * @default 'swc'
91
- */
92
- compiler: 'tsc' | 'swc';
93
83
  /** swc 配置项,仅当编译器为 swc 时有效 */
94
84
  swcrc?: SwcConfig | ((isDev: boolean) => SwcConfig);
95
85
  /**
@@ -158,7 +148,6 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
158
148
  * @example
159
149
  * ```js
160
150
  * const conf: Partial<ConfigType> = {
161
- * compiler: 'tsc',
162
151
  * prefixJsLoader: [
163
152
  * {
164
153
  * loader: 'babel-loader',
@@ -174,13 +163,17 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
174
163
  /** node_modules中, 需要开启 cssModules 的模块 */
175
164
  cssModules: string[];
176
165
  /** 按需引入 */
177
- importOnDemand: T extends 'tsc' ? Partial<Options>[] : SwcImportOnDemandTransform;
166
+ importOnDemand?: SwcImportOnDemandTransform;
178
167
  /** 开发服务器代理 */
179
- proxy: ProxyArray | ProxyConfigArray | ProxyConfigMap;
168
+ proxy?: Record<string, ProxyConfig>;
180
169
  /** 自定义缓存目录,为 false 时,不使用缓存 */
181
- cacheDirectory: string | false;
170
+ cacheDirectory?: string | false;
182
171
  /** 开发服务器设置 */
183
- devServer: DevServerConfiguration;
172
+ devServer?: {
173
+ headers?: Record<string, string>;
174
+ host?: string;
175
+ port?: number;
176
+ };
184
177
  /** HtmlWebpackPlugin Option */
185
178
  htmlPluginOption: HtmlWebpackOption | false;
186
179
  /** 自定义插入 html 的 js 和 css
package/lib/common.js DELETED
@@ -1 +0,0 @@
1
- import{CONFIG as e,PUBLICPATH as t}from"./config.js";import o from"./module.config.js";import s,{CUSTOMCONFIG as r}from"./paths.js";import n from"./plugin/override-resolve.js";import l from"./plugins.config.js";import{PACKAGENAME as i,PACKAGEVERSION as a,isDev as p,isLibrary as c}from"./process-env.js";import{resolveNodeModulesPath as u,resolveProgramPath as m}from"./utils.js";export const outputConfig={path:m(c?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${p?"name":"chunkhash"}].js`,assetModuleFilename:e=>{let t=e.filename;return t&&t.endsWith("?url")&&/(?:webworker|worker)(\.|\b).*\.(js|ts)\b/.test(t.replace("?url",""))?"worker/[name][ext]":"assets/[name][hash][ext]"},library:{name:i,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${i}`,pathinfo:p,clean:!0,publicPath:t,asyncChunks:!0,charset:!0};let f={main:u("@app/entry")};e.polyfill&&Object.assign(f,{"dom-polyfills":[`${s.corePath}/polyfills/replace-children.js`]}),e.entry&&("string"==typeof e.entry?f={main:e.entry}:Object.keys(e.entry)&&Object.assign(f,e.entry)),e.output&&("string"==typeof e.output?outputConfig.path=e.output:Object.keys(e.output)&&Object.assign(outputConfig,e.output));let y=!1;e.cacheDirectory&&(y=p?{type:"memory"}:{type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:e.cacheDirectory,memoryCacheUnaffected:!0,name:[r,process.env.NODE_ENV].filter(Boolean).join("-"),version:a});let d=Object.assign({original:e.alias["@"],override:r&&m(r)},e.overrideResolve);export const clientConfig={entry:f,stats:"errors-only",cache:y,infrastructureLogging:{level:"error"},target:"web",externalsPresets:e.externalsPresets,plugins:l,node:{global:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:p&&{imports:!1,entries:!1},buildHttp:e.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:["...",".jsx",".ts",".tsx"],alias:e.alias,modules:[s.nodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:[e.overrideResolve&&new n(d),...e.resolvePlugins].filter(Boolean),fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:o,externals:e.externals,output:outputConfig};
package/lib/config.js DELETED
@@ -1 +0,0 @@
1
- import{fileExists as e}from"@moneko/mdx";import{merge as t}from"webpack-merge";import o,{CUSTOMCONFIG as s}from"./paths.js";import{FRAMEWORK as i,PACKAGENAME as n,coreName as r,isDev as a,isLibrary as l,isMobile as m,isSolid as p,jsxImportSource as c,mainDirectory as u}from"./process-env.js";import{isFunction as d,log as h,readConf as f,resolveProgramPath as g}from"./utils.js";let x=["@moneko","neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app",".cache/http/data"],C={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:{NODE_ENV:process.env.NODE_ENV},basename:"/",publicPath:"/",rem:{designSize:m?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":g(u)},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:o.webpackCachePath,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`node_modules/${r}/template/index.html`,favicon:`node_modules/${r}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{CHANGELOG:{test:/CHANGELOG\.md/,priority:-10,name:"CHANGELOG",reuseExistingChunk:!0},prismjs:{test:/(prism\.js|prism\/css\.ts)/,priority:-10,name:"vendors-prismjs",reuseExistingChunk:!0},site:{test:/site/,priority:-10,reuseExistingChunk:!0},marked:{test:/marked/,priority:-10,reuseExistingChunk:!0},"n-katex":{test:/n-katex/,priority:-10,reuseExistingChunk:!0},"n-code-live":{test:/n-code-live/,priority:-10,reuseExistingChunk:!0},"@moneko":{test:/@moneko/,priority:-10,reuseExistingChunk:!0}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:x,js:x,media:x,font:x,wasm:[]},mdx:{jsx:!1,development:a,jsxImportSource:c,providerImportSource:`@moneko/${i}/mdx`},jsxDomExpressions:{},bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${o.httpCachePath}/http.lock`,cacheLocation:`${o.httpCachePath}/data`,upgrade:!0}};p&&Object.assign(C,{jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1}}),l&&(C.alias=Object.assign(C.alias,{"@pkg":o.componentsPath,[n]:o.componentsPath}));let k=C,P={},v={};if(e(o.configPath)){let e=(await f(o.configPath,"index")).default;P=d(e)?e(process):e}if(s&&e(o.customConfigPath)){let e=(await f(o.customConfigPath,s)).default;v=d(e)?e(process):e}"tsc"===(k=t(k,P,v)).compiler&&k.minifier&&void 0===k.minifier.type&&(k.minifier.type="terser"),(!1===k.devtool||!1===k.sourceMap)&&(k.sourceMap=!1,k.devtool=!1),k.fixBrowserRouter&&k.htmlPluginOption&&(k.htmlPluginOption.tags||(k.htmlPluginOption.tags=[]),k.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=k;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,CUSTOMCONFIG:s,log:h};
package/lib/dev.js DELETED
@@ -1,3 +0,0 @@
1
- import{removeDirAll as e}from"@moneko/mdx";import o from"chalk";import t from"webpack";import s from"webpack-dev-server";import{merge as r}from"webpack-merge";import i from"webpackbar";import{clientConfig as a}from"./common.js";import{CONFIG as l}from"./config.js";import{hasPkg as n}from"./has-pkg.js";import{getIPv4 as p,getPort as m}from"./net.js";import c from"./paths.js";import{isLibrary as d,isReact as u}from"./process-env.js";import{isFunction as w,log as f,resolveProgramPath as v}from"./utils.js";let{HotModuleReplacementPlugin:h,WatchIgnorePlugin:g}=t,{yellow:k,green:b,grey:$,gray:x,bgBlue:j,bgGreenBright:S,blueBright:y,greenBright:T}=o,C=n("eslint-webpack-plugin"),A=n("stylelint-webpack-plugin"),B=n("@moneko/mock"),D=A?(await import("stylelint-webpack-plugin")).default:null,E=C?(await import("eslint-webpack-plugin")).default:null,H=l.devServer.port||3e3,M=await m(H,65535,l.devServer.host),O=B&&(await import("@moneko/mock")).default,_=u&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,I=!1===l.devtool||l.devtool?l.devtool:"eval-cheap-module-source-map";l.devServer.port=M;let J="/"===l.basename,N=l.devServer.https?"https:":"http:",P=J?"":l.basename,W=l.devServer.port!==M&&x(`Port ${k(H)} is in use, trying ${b(M)} instead.
2
- `);function F(e){return`${N}//${"local"===e?l.devServer.host:p()}:${M}${P}`}let G=x("You application is running here:"),L=`${j(" Local ")} ${y(F("local"))}
3
- ${S(" Network ")} ${T(F("net"))}`,R=["js","jsx","ts","tsx","json","html","vue"],Y=R.join(","),q=["css","scss","sass","less","ts","tsx","js","jsx"],z=q.join(","),K=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],Q=[new g({paths:[/\.d\.ts$/]}),new h,_&&new _,E&&new E({fix:!0,threads:!0,files:[`${l.alias["@"]}/**/*.{${Y}}`,d&&`${l.alias["@pkg"]}/**/*.{${Y}}`].filter(Boolean),extensions:R,exclude:K,cache:!0,lintDirtyModulesOnly:!0}),D&&new D({fix:!0,threads:!0,files:[`${l.alias["@"]}/**/*.{${z}}`,d&&`${l.alias["@pkg"]}/**/*.{${z}}`].filter(Boolean),extensions:q,exclude:K,cache:!0,lintDirtyModulesOnly:!0}),l.bar&&new i(l.bar)].filter(Boolean),U={headers:{"Access-Control-Allow-Origin":"*"},compress:l.devServer.compress,host:"0.0.0.0",port:M,historyApiFallback:J||{index:P.endsWith("/")?P:`${P}/`,disableDotRule:!0},https:l.devServer.https,proxy:l.proxy,allowedHosts:l.devServer.allowedHosts,client:{reconnect:!0,progress:!1,logging:"info",overlay:!1,webSocketTransport:"ws"},webSocketServer:"ws",static:{watch:{ignored:e=>e.endsWith(".d.ts")||e.includes("/node_modules/")}},setupMiddlewares:(e,o)=>{if(!o)throw Error("devServer is not defined");return o.app&&w(O)&&O(o.app,v("mock/")),e},open:!1,hot:!0},V=t(r(a,{devtool:I,mode:"development",plugins:Q}));V.watch({aggregateTimeout:20,ignored:/node_modules(?![\\/]@app)/,poll:1e3,stdin:!0},(e,o)=>{!e&&o&&(process.stdout.write("\x1b[2J\x1b[3J\x1b[H"),f([G,"",L,"",$(`Compiled successfully in ${b(`${o.endTime-o.startTime}ms`)}`)]),o.compilation.warnings.forEach(e=>f(e.message)),o.compilation.errors.forEach(e=>f(e.message)),W&&f(W))});let X=new s(U,V);X.startCallback(e=>{e||f([G,"",L])}),X.stopCallback(o=>{o||e(c.cachePath)}),process.on("exit",function(){V.close(()=>{}),X.invalidate(),X.stop()}),process.on("SIGINT",()=>{process.exit()});
package/lib/has-pkg.js DELETED
@@ -1 +0,0 @@
1
- import{fileExists as o}from"@moneko/mdx";import{resolveNodeModulesPath as r}from"./utils.js";export function hasPkg(m){return o(r(`${m}/package.json`))}
@@ -1 +0,0 @@
1
- import{merge as e}from"webpack-merge";import{CONFIG as t}from"./config.js";import{description as i,keywords as o}from"./info.js";import{PACKAGENAME as r,coreName as m}from"./process-env.js";import{resolveProgramPath as a}from"./utils.js";let{template:p,favicon:n,...l}=Object.assign({template:`node_modules/${m}/template/index.html`,favicon:`node_modules/${m}/template/favicon.ico`},t.htmlPluginOption||{}),s=e({title:t.env?.PROJECTNAME||r.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{minifyJS:!0,minifyCSS:!0,collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},CSP:{"http-equiv":"Content-Security-Policy",content:"script-src 'self' 'unsafe-eval'"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:i,keywords:o},tags:[],template:a(p),favicon:a(n)},l);export default s;
package/lib/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export { default as paths, CUSTOMCONFIG } from './paths.js';
2
- export { PACKAGENAME, PACKAGEVERSION, coreName, isDev, isLibrary, isMicro, mainDirectory, } from './process-env.js';
3
- export { realResolve, resolveNodeModulesPath, resolveProgramPath, log } from './utils.js';
4
- export { getIPv4, getPort } from './net.js';
5
- export { default as osTmpDir } from './os-tmp-dir.js';
6
- export type { MdxOptions } from '@moneko/mdx';
7
- export type { OverrideResolverOption } from './plugin/override-resolve.js';
8
- export type * from '../typings/global.d.ts';
package/lib/index.js DELETED
@@ -1 +0,0 @@
1
- export{default as paths,CUSTOMCONFIG}from"./paths.js";export{PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro,mainDirectory}from"./process-env.js";export{realResolve,resolveNodeModulesPath,resolveProgramPath,log}from"./utils.js";export{getIPv4,getPort}from"./net.js";export{default as osTmpDir}from"./os-tmp-dir.js";
package/lib/info.js DELETED
@@ -1 +0,0 @@
1
- import{loadFileSync as e}from"@moneko/mdx";import{CONFIG as r}from"./config.js";import{APPTYPE as o,PACKAGENAME as t,PACKAGEVERSION as s}from"./process-env.js";import{resolveProgramPath as p,toUpperCaseString as i}from"./utils.js";let{description:m,author:n,repository:a,keywords:c}=JSON.parse(e(p("package.json"))||"{}"),d="string"==typeof n,f={name:t,projectName:i(t).replace(/-/g," "),version:s,base:r.basename,type:o,routerMode:r.routerMode,prefixCls:r.prefixCls,theme:r.theme,description:m,author:d?{name:n}:n,repository:d?{url:a}:a};export const description=m;export const keywords=Array.isArray(c)?c.toString():"";export default f;
package/lib/minify.js DELETED
@@ -1 +0,0 @@
1
- import e from"terser-webpack-plugin";import{merge as o}from"webpack-merge";import{swcMinifyOption as r}from"./swcrc.js";export const minify={terser:{minify:e.terserMinify,terserOptions:{ecma:2015,parse:{},compress:{global_defs:{"@alert":"console.log"},drop_console:!0,drop_debugger:!0,pure_funcs:["console.log","console.warn","console.error","console.info"]},toplevel:!1,mangle:!0,module:!1,format:{comments:!1},ie8:!1,keep_classnames:void 0,keep_fnames:!1,safari10:!1},extractComments:!1},swc:{minify:e.swcMinify,terserOptions:r}};export const getMinifyOption=(e,r={})=>{let s=minify[e];return Object.assign(s,{terserOptions:o(s.terserOptions,r)})};
@@ -1 +0,0 @@
1
- import{CONFIG as i}from"./config.js";import o from"./html-plugin-option.js";let f=i.prefixCls||"n",n={"@prefix-cls":f,"@ant-prefix":f,"@iconfont-css-prefix":`${f}-icon`,"@favicon":JSON.stringify(o.favicon)};Object.assign(n,i.modifyVars);export default n;
@@ -1 +0,0 @@
1
- import e from"webpack";import{CONFIG as r}from"./config.js";import t from"./plugin/external-remotes.js";import{realResolve as o}from"./utils.js";let{NormalModuleReplacementPlugin:s,container:{ModuleFederationPlugin:a}}=e,i={},l={},n={},m=r.moduleFederation?.map(e=>{if(Array.isArray(e.remotes))for(let r=0,t=e.remotes.length;r<t;r++){let t=e.remotes[r],o=t.alias||t.name,s=t.filename||"remote_entry.js";if(n[o]=`${t.name}@${t.host}/${s}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)i[t.library[e]]=`${o}/${t.library[e]}`}if(Array.isArray(e.exposes))for(let r=0,t=e.exposes.length;r<t;r++){let t=e.exposes[r];"string"==typeof t?l[`./${t}`]=o(t):"[object Object]"===Object.prototype.toString.call(t)&&(l[`./${t.name}`]=o(t.path))}return new a({filename:"remote_entry.js",...e,remotes:n,exposes:l})});m.length&&(m.push(new t),m.push(new s(/(.*)/,e=>{i[e.request]&&(e.request=i[e.request])})));export default m;
@@ -1,3 +0,0 @@
1
- import type { ModuleOptions } from 'webpack';
2
- declare const moduleOptions: ModuleOptions;
3
- export default moduleOptions;
@@ -1 +0,0 @@
1
- import e from"mini-css-extract-plugin";import{CONFIG as s,PUBLICPATH as t}from"./config.js";import o from"./modify-vars.js";import r,{CUSTOMCONFIG as a}from"./paths.js";import{FRAMEWORK as i,isDev as l,isLibrary as n,isMicro as d}from"./process-env.js";import m from"./svg-to-data-uri.js";import c from"./swcrc.js";import{getLightningCssTargets as p}from"./targets.js";import u from"./tsloader.config.js";import{resolveNodeModulesPath as f,resolveProgramPath as y}from"./utils.js";import{comment as g,getCommentPath as j}from"./vm/docs.js";import v from"./vm/generate-doc.js";let x=d?t:"../",$={loader:e.loader,options:{publicPath:"/"!==x?x:"../"}},h={loader:`${r.corePath}/loader/lightningcss.cjs`,options:{sourceMap:!!s.sourceMap,analyzeDependencies:!1,targets:p(),drafts:{nesting:!0,customMedia:!0},errorRecovery:!1,unusedSymbols:[],rem:!!s.rem}};l&&($="style-loader");let b=[...s.cssModules,`@moneko/${i}`,"neko-ui"].map(f),w=["components","example","mock","site","src","server"].map(y);a&&w.push(y(a)),s.overrideResolve&&s.overrideResolve.override&&w.push(s.overrideResolve.override);let _={loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,t=b.length;s<t;s++)if(e&&e?.includes(b[s]))return/(.*(?<!\.?global\.(le|c|sc|sa)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c|sc|sa)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},M=[$,_,h,{loader:"less-loader",options:{sourceMap:!!s.sourceMap,lessOptions:{modifyVars:o,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(y)}}].filter(Boolean),k="tsc"===s.compiler;function B(e){return w.concat(s.rulesInclude?.[e]?.map(f)||[])}let P=B("css"),R=B("js"),L=B("media"),O=B("wasm"),I=B("font"),J={noParse:[/jquery|lodash|prismjs|prism\.js/,/react\.min\.js$/,/marked\.min\.js$/],rules:[n&&l&&{test:/^(?![._]).*(?<!\.test)\.(tsx?)$/,include:s.alias["@pkg"],exclude:[/node_modules/,/(.+)\/__tests__\/(.+)/i],enforce:"pre",loader:`${r.corePath}/loader/ts-doc.cjs`,options:{comment:g,generateDoc:v,getCommentPath:j}},{oneOf:[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename:e=>{let s=e.filename;return s&&s.endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:/\.wasm$/i,type:"webassembly/async",include:O},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:L},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>m(e.toString())},include:L},{test:/\.(gif|png|jpe?g|webp)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:L},{test:/\.(webm|mp4|ogv)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:L},{test:/\.(woff2?|eot|ttf|otf)(\?.*)?$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:I},{test:/\.(sa|sc)ss$/i,use:[$,_,h,{loader:"sass-loader",options:{implementation:await import("sass"),sassOptions:{}}}].filter(Boolean),include:P},{test:/\.less$/i,use:M,include:P},{test:/\.css$/i,use:[$,"css-loader",h].filter(Boolean),include:P},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...s.prefixJsLoader,{loader:k?"ts-loader":"swc-loader",options:k?u:c}].filter(Boolean),include:R},{test:/\.mdx?$/i,use:[...s.prefixJsLoader,{loader:`${r.corePath}/loader/mdx.cjs`,options:s.mdx}].filter(Boolean),exclude:[/node_modules/]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...s.moduleRules].filter(e=>"object"==typeof e)};export default J;
package/lib/net.js DELETED
@@ -1 +0,0 @@
1
- import{createConnection as e}from"net";import r from"webpack-dev-server";let{internalIPSync:t}=r;export function getIPv4(){return t("v4")}export function getPort(r,t,o="0.0.0.0"){return new Promise(n=>{if("number"!=typeof r)n(r);else{let f=e(r,o);f.on("connect",()=>{f.destroy(),n(getPort(r+1,t,o))}),f.on("error",()=>{n(r)})}})}
@@ -1 +0,0 @@
1
- import{relative as e}from"path";import{fileExists as t}from"@moneko/mdx";import r from"../paths.js";let a="OverrideResolverPlugin";export default class{constructor(e){this.options=e}apply(i){let{override:o,original:s}=this.options;if(o&&s){let l=`./${e(r.programPath,s)}`,p=`./${e(r.programPath,o)}`;i.getHook("existing-file").tapAsync(a,(e,r,n)=>{let h=e.request||e.path;if(h&&h.startsWith(s)&&e.relativePath){let m=h.replace(s,o);if(t(m)){let t=e.relativePath.replace(l,p);return Object.assign(e,{path:m,relativePath:t,__innerRequest_relativePath:t,__innerRequest:t}),i.doResolve("resolved",e,`${a} 使用目标模块${o}`,r,n)}}return n()})}}}
@@ -1 +0,0 @@
1
- import{join as o}from"path";import{getAppEntry as t,getAppFallback as e,getAppMdxScope as p,getAppMergeRouter as r,getAppNormalizeCss as a,getAppPrefixRouter as s,getAppRem as i,getAppSuspense as m}from"@moneko/mdx";import n from"webpack-virtual-modules";import{CONFIG as f}from"../config.js";import l from"../info.js";import c from"../paths.js";import{APPTYPE as h,FRAMEWORK as d,isLibrary as g}from"../process-env.js";import{resolveNodeModulesPath as u,resolveProgramPath as x}from"../utils.js";import j from"../vm/coverage.js";import{comment as v,docs as y,docsModuleName as k}from"../vm/docs.js";import{exampleModuleName as b,examples as w}from"../vm/example.js";import{locales as O,localesModuleName as P}from"../vm/locales.js";import{route as z,routesModuleName as D}from"../vm/routes.js";export default class{constructor(o){this.options=o,this.hasTapped=!1}apply(S){let T=new n({[u("@app/info")]:`export default ${JSON.stringify(l)}`,[u("@app/entry")]:t(o(f.alias["@"],"./index.ts"),!!f.rem,!!f.normalizeCss,h,d),[u("@app/rem")]:i(f.rem?.designSize||1680),[u("@app/fallback")]:e(f.fallbackCompPath),[u("@app/coverage")]:j(c.coveragePath),[u("@app/merge-router")]:r(),[u("@app/prefix-router")]:s(),[u("@app/normalize/index.css")]:a(),[u("@app/suspense/index.tsx")]:m(h,d),[u("@app/mdx-scope")]:p(x("site/mdx-scope.ts")),[u(D)]:z.getData(D),[u(b)]:"export default []",[u(P)]:O.getData(P),[u(k)]:y.getData(k)});function C(o,t){let e=u(o);T.writeModule(e,t||"")}T.apply(S),z.on("change",C),O.on("change",C),g&&(w.on("change",C),y.on("change",C),v.on("change",C)),S.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.hasTapped){for(let o in this.hasTapped=!0,this.options)if(Object.prototype.hasOwnProperty.call(this.options,o)){let t=this.options[o];C(o,"string"==typeof t?t:`export default ${JSON.stringify(t)}`)}for(let o of w)C(...o);for(let o of y)C(...o);for(let o of v)C(...o)}})}}
@@ -1 +0,0 @@
1
- import e from"add-asset-html-webpack-plugin";import t from"html-webpack-plugin";import l from"webpack";import{CONFIG as o}from"./config.js";import i from"./html-plugin-option.js";import r from"./module-federation.js";import n from"./plugin/add-entry-attribute.js";import p from"./plugin/virtual-module.js";import{isMicro as a}from"./process-env.js";let{AutomaticPrefetchPlugin:s,DefinePlugin:m,SourceMapDevToolPlugin:c,IgnorePlugin:h}=l,u=o.basename.split("/").filter(Boolean).length,f=`${Array(u).fill("..").join("/")+(u?"/":"")}404.html`,{pathSegmentsToKeep:d=u,path:w=f}=o.fixBrowserRouter||{},g=o.assetHtml.map(e=>({publicPath:"",...e})),j=[...r,new p(o.virtualModule),new s,o.htmlPluginOption&&new t(i),o.fixBrowserRouter&&new t({filename:w,inject:!1,templateContent:()=>`<html lang="en"><head><title>${i.title}</title><script>const pathKeep = ${d||u};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new e(g),a&&new n({test:/main\.bundle\.js$/}),new m({"process.env":JSON.stringify(o.env)}),new h({resourceRegExp:/\/__tests__\//}),o.sourceMap&&new c(o.sourceMap),...o.plugins].filter(e=>!!e);export default j;
package/lib/polyfills.js DELETED
@@ -1 +0,0 @@
1
- import t from"core-js-compat";import{getBrowsersTargets as r}from"./targets.js";export default function(){return t({targets:r(),version:"3.34"}).list}
@@ -1 +0,0 @@
1
- import o from"./paths.js";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;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 mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;export const coreName="@moneko/core";export const isDev="development"===process.env.NODE_ENV;export const routeDir=isLibrary?o.componentsPath:o.pagesPath;
package/lib/prod.js DELETED
@@ -1 +0,0 @@
1
- import{removeDirAll as e}from"@moneko/mdx";import o from"mini-css-extract-plugin";import m from"terser-webpack-plugin";import n from"webpack";import{BundleAnalyzerPlugin as i}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import t from"webpackbar";import{clientConfig as p}from"./common.js";import{CONFIG as s}from"./config.js";import{getMinifyOption as l}from"./minify.js";import u from"./paths.js";import a from"./plugin/done.js";import c from"./plugin/lightningcss-plugin.js";import f from"./seo.js";let{optimize:{MinChunkSizePlugin:d,ModuleConcatenationPlugin:h}}=n,k=[];s.minifier&&(k.push(new m(l(s.minifier?.type||"swc",s.minifier?.options))),k.push(new c));let w={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:k};n(r(p,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",optimization:w,plugins:[new h,new o({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.splitChunk&&new d({minChunkSize:1e4}),s.bundleAnalyzer&&new i(s.bundleAnalyzer),s.bar&&new t(s.bar),new a({done:e=>{s.done?.(e),s.seo&&f()}})].filter(Boolean)})).run(e=>{if(e)throw e}),process.on("exit",function(){e(u.cachePath)});
package/lib/seo.js DELETED
@@ -1 +0,0 @@
1
- import{join as o}from"path";import{saveFileSync as t,scanRouter as m,sitemap as r}from"@moneko/mdx";import{outputConfig as e}from"./common.js";import{CONFIG as p}from"./config.js";import{isLibrary as i,routeDir as s}from"./process-env.js";import{resolveProgramPath as f}from"./utils.js";export default(()=>{let{domain:n,nojekyll:a,path:j}=p.seo||{},l=j&&f(j)||e?.path;if(!n||!l)return;let x=`https://${n}${p.basename}`;t(o(l,"CNAME"),n),t(o(l,"robots"),`Sitemap: ${x}/sitemap.txt`),t(o(l,"sitemap.txt"),r(s,x,m(s,i)).join("\n")),a&&t(o(l,".nojekyll"),"")});
package/lib/server.js DELETED
@@ -1 +0,0 @@
1
- import e from"mini-css-extract-plugin";import m from"terser-webpack-plugin";import i from"webpack";import{merge as o}from"webpack-merge";import r from"webpack-node-externals";import n from"webpackbar";import{clientConfig as t}from"./common.js";import{CONFIG as s}from"./config.js";import{getMinifyOption as p}from"./minify.js";import l from"./paths.js";import a from"./plugin/lightningcss-plugin.js";let{optimize:{ModuleConcatenationPlugin:u}}=i,c=[];s.minifier&&(c.push(new m(p(s.minifier?.type||"swc",s.minifier?.options))),c.push(new a));let f={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:c};i(o(t,{entry:{main:`${l.programPath}/site/ssr.tsx`},devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",optimization:f,externals:r,plugins:[new u,new e({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.bar&&new n(s.bar)].filter(Boolean)})).run(e=>{if(e)throw e});
package/lib/swcrc.js DELETED
@@ -1 +0,0 @@
1
- import{merge as e}from"webpack-merge";import{CONFIG as o}from"./config.js";import r from"./paths.js";import s from"./polyfills.js";import{isDev as t,isReact as n,isSolid as i,jsxImportSource as p}from"./process-env.js";export const swcMinifyOption={compress:{top_retain:[],keep_infinity:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],toplevel:!1,drop_console:!0,drop_debugger:!0,module:!1,ecma:2015,ie8:!1,keep_classnames:void 0,keep_fnames:!1},mangle:!0};let c={module:{type:"es6",resolveFully:!0},jsc:{parser:{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0},loose:!0,target:"es2017",externalHelpers:!1,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,refresh:n&&t,development:t,importSource:p},optimizer:{simplify:!1}},minify:t?void 0:swcMinifyOption,experimental:{emitAssertForImportAttributes:!0,cacheRoot:r.swcCachePath,plugins:[["swc-plugin-another-transform-imports",function(e){for(let o=0,r=Object.keys(e),s=r.length;o<s;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{})],i&&["@moneko/jsx-dom-expressions",o.jsxDomExpressions||{}]].filter(Boolean)}},sourceMaps:!0,parseMap:!0};o.polyfill&&(c.jsc.target=void 0,c.env={include:s(),mode:"entry",coreJs:"3.34"});export default e(c,"function"==typeof o.swcrc?o.swcrc(t):o.swcrc||{});
package/lib/targets.js DELETED
@@ -1 +0,0 @@
1
- let r,t;import e from"browserslist";import{browserslistToTargets as s}from"lightningcss";import o from"./paths.js";export function getBrowsersTargets(){return r||(r=e(void 0,{path:o.programPath,env:process.env.NODE_ENV}).filter(r=>!r.endsWith(" TP"))),r}export function getLightningCssTargets(){return t||(t=s(getBrowsersTargets())),t}
@@ -1,8 +0,0 @@
1
- import type { Node, SourceFile, TransformerFactory } from 'typescript';
2
- declare let tsLoaderConfig: {
3
- transpileOnly: boolean;
4
- getCustomTransformers: () => {
5
- before: (Node | TransformerFactory<SourceFile>)[];
6
- };
7
- };
8
- export default tsLoaderConfig;
@@ -1 +0,0 @@
1
- import{fileExists as r}from"@moneko/mdx";import t from"ts-import-plugin";import o from"webpack-merge";import{CONFIG as e}from"./config.js";import{isFunction as m,readConf as i,resolveProgramPath as a}from"./utils.js";let s=[];Array.isArray(e.importOnDemand)&&Object.assign(s,e.importOnDemand.map(r=>t(r)));let p=[...s],f={transpileOnly:!0,getCustomTransformers:()=>({before:p})},n=a("tsloader.config.ts");if(r(n))try{let r=(await i(n,"tsloader.config")).default;f=o(f,m(r)?r(process):r)}catch(r){}export default f;
package/lib/utils.js DELETED
@@ -1,2 +0,0 @@
1
- import{resolve as t}from"path";import o from"readline";import{saveFileSync as r}from"@moneko/mdx";import{transformFileSync as e}from"@swc/core";import n from"./paths.js";import c from"./resolver-sync.js";export function esm(t,...o){let r=t.raw[0];for(let e=0;e<o.length;e++)r+=o[e]+t.raw[e+1];return`data:text/javascript;base64,${Buffer.from(r).toString("base64")}`}let p={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function log(t){Array.isArray(t)?t.forEach(t=>{log(`${t}
2
- `)}):(o.cursorTo(process.stdout,0),process.stdout.write(t))}export function tfc(t){return e(t,p).code||"{}"}export function readConf(t,o){let e=`${n.cachePath}/${o}.mjs`;return r(e,tfc(t)),import(e)}export function toUpperCaseString(t){return t?.replace(/\b\w/g,t=>t.toUpperCase()).replace(/\./g," ")}export function resolveProgramPath(o){return t(n.programPath,`./${o}`)}export const resolveNodeModulesPath=t=>`${n.nodeModules}/${t}`;export const realResolve=t=>c.resolveSync({},n.programPath,t)||t;export function isObject(t){let o=typeof t;return null!==t&&("object"==o||"function"==o)}export function isFunction(t){if(!isObject(t))return!1;let o=Object.prototype.toString.call(t);return"[object Function]"==o||"[object AsyncFunction]"==o||"[object GeneratorFunction]"==o||"[object Proxy]"==o}export function empty(){}
@@ -1 +0,0 @@
1
- import{fileExists as e,loadFileSync as r}from"@moneko/mdx";import{Parser as t}from"xml2js";import{PACKAGENAME as o}from"../process-env.js";export default function(c){let a={},i="export default {}";if(e(c))try{let e=r(c);(0,new t({explicitArray:!1,async:!1}).parseString)(e,(e,r)=>{e||(Object.assign(a,{[o]:r.coverage.project.metrics.$}),r.coverage.project.package.forEach(e=>{Object.assign(a,{[e.$.name]:e.metrics.$})})),i=`export default ${JSON.stringify(a)}`})}catch(e){}return i}
package/lib/vm/docs.js DELETED
@@ -1 +0,0 @@
1
- import{loadFileSync as e,scanFolder as t}from"@moneko/mdx";import o from"./generate-doc.js";import{CONFIG as r}from"../config.js";import{FRAMEWORK as n,isLibrary as a,isReact as s,isSolid as p}from"../process-env.js";import m from"../reactive-object.js";let l={react:"createElement",solid:"createComponent"}[n];export const docsModuleName="@app/docs";export const docs=new m({[docsModuleName]:"export default {}"});export const comment=new m({});export const getCommentPath=function(){let e=/^\/?(.+?)\.tsx?$/,t=r.alias["@pkg"].length;return o=>o.substring(t).replace(e,"@app/comment/$1.md")}();if(a){let a={},m=`import { ${l}${p?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[n]}${p?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${s?"() =>":""}${l}(${p?"Dynamic":"'n-md'"}, {text: res.default, ${p?"component: 'n-md', ":""}css: 'table td a {display:inline-flex;align-items:center;gap:2px;}table td a n-img{display:inline-block;overflow:hidden;border-radius:var(--border-radius);inline-size:18px;block-size:18px;}' })};}`,c=(e,t)=>{let o=e.replace(/^@app\/comment\//,"").split("/"),r=o.pop(),n=o.join("/");a[n]||(a[n]={}),t?a[n][r]&&delete a[n][r]:a[n][r]=`rr(() => ${l}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let s={};for(let e in a)Object.prototype.hasOwnProperty.call(a,e)&&(s[e]=Object.values(a[e]));docs.setData(docsModuleName,`${m}export default ${JSON.stringify(s).replace(/"rr\((.+?)\)rr"/g,"$1")}`)};comment.on("change",(e,t)=>{c(e,t?.length<0)}),t(r.alias["@pkg"]).filter(e=>/^(?![._]).*(?<!\.test)\.(tsx?)$/i.test(e)).forEach(t=>{let r=e(t);r&&comment.setData(getCommentPath(t),o(r,t))})}
package/lib/vm/example.js DELETED
@@ -1 +0,0 @@
1
- import{generateExample as e}from"@moneko/mdx";import{watchFiles as o}from"./utils.js";import t from"../paths.js";import{isDev as r,isLibrary as p}from"../process-env.js";import m from"../reactive-object.js";export const exampleModuleName="@app/example";function a(){try{return JSON.parse(e(t.componentsPath,"@app/example/"))}catch(e){return{}}}export const examples=new m(p?a():{});export function generatorDemo(){let e=a();for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&examples.setData(o,e[o])}p&&r&&o(t.componentsPath,/(?<!\/examples\/(.+)\.md)$/,generatorDemo);
@@ -1 +0,0 @@
1
- import{dirname as e}from"path";import t from"typescript";import{CONFIG as n}from"../config.js";let{ScriptKind:r,ScriptTarget:l,SyntaxKind:o,createSourceFile:i,forEachChild:a,getLeadingCommentRanges:c,isInterfaceDeclaration:u,isQuestionToken:s,isPropertySignature:f,isFunctionTypeNode:p,isUnionTypeNode:m,isMethodSignature:g}=t,$={};function h(e){let t=c(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end).match(/\/\*\*([\s\S]*?)\*\//);if(n)return n[1].replace(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim()}return null}function b(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function d(e){if(!e)return null;let t=e.match(/@author (\w+)\s*(?:<([^>]+)>)?/);if(t?.length){let e=t[1].trim(),n=t[2]?.trim(),r=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(n);return n?r&&(n=`mailto:${n}`):n=`https://github.com/${e}`,`[![${e}](https://avatars.githubusercontent.com/${e}?s=64)${e}](${n})`}return null}function y(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let x=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function j(e,t){if(!e)return null;let r=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if($[e]){let r=`/${[n.basename,$[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${r})`:`[${e}](${r})`}return t?`\\color{#009688}{${e}}`:e});return t&&(r=r.replace(x,e=>`\\color{#009688}{${e}}`)),r}function T(e){return(function(e){let t;if(!e)return null;let n=[];for(;t=/\\color{([^|}]*)\|?([^|}]*)\|?([^|}]*)\|?([^}]*)}{([^}]*)}/g.exec(e);)n.push(t[0]);return e.replace(/[{}[\]()=>]|keyof|typeof|true|false/g,e=>n.some(t=>t.includes(e))?e:`\\color{#569cd6}{${e}}`)})(e)?.replace(/^\s*\|\s*|\s*\|\s*$/gm,"").replace(/\n/g,"<br/>").replace(/\*/g,"\\*").replace(/\|/g,"\\|").replace(/(['"])((?:(?!\1).)*)\1/g,"\\color{#ce9178}{$1$2$1}")}function B(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}export default function k(c,x){let k=i(x,c,l.Latest,!0,r.TS),w="";return a(k,r=>{u(r)?w+=function(r){let l=r.name.text;Object.assign($,{[r.name.text]:e(r.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let i=h(r),a=b(i),c=B(i),u=y(i)?.split("|")||[],x=u.includes("comment"),k=u.includes("initial"),w=u.includes("optional"),E=u.includes("version"),S=u.includes("author"),v=c?`\\color{|4||0.45}{${l}}`:l,F=(function(e){let n=[];if(e.heritageClauses){for(let r of e.heritageClauses)if(r.token===t.SyntaxKind.ExtendsKeyword)for(let e of r.types)n.push(e.getText())}return n})(r)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${j(T(e))}</n-tag>`),z=[c,v,a&&`\\color{#52c11b|1||0.9}{${a}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),K=`## ${z}`,N=r.members.filter(e=>f(e)&&e.type?.kind!==o.NeverKeyword||g(e)),q=[];if(N.length){N.forEach(e=>{let t=j(T(g(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),n=h(e),r=T(e.name.getText());!r||r.startsWith("\\color")||(g(e)||function(e){if(e.type){if(!m(e.type))return p(e.type);for(let t of e.type.types)if(p(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let l=e.questionToken&&s(e.questionToken);q.push([r,!w&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!x&&T(B(n)),t,!k&&T(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&T(b(n)),!S&&(d(n)||d(i))])});let e=!1,t=!1,n=!1,r=!1;q.forEach(l=>{!x&&l[2]&&(r=!0),!k&&l[4]&&(n=!0),!E&&l[5]&&(t=!0),!S&&l[6]&&(e=!0)}),K+="\n";let l=["属性",!w&&"必要",r&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");K+=`|${l}|`;let o=[":-",!w&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);K+="\n";let a=o.join("|");K+=`|${a}|`,q.forEach(l=>{K+="\n";let o=[l[0]||"-",!w&&(l[1]||"-"),r&&(l[2]||"-"),l[3]||"-",n&&(l[4]||"-"),t&&(l[5]||"-"),e&&(l[6]||"-")].filter(Boolean).join("|");K+=`|${o}|`}),K+="\n"}return K+="\n"}(r):t.isEnumDeclaration(r)&&(w+=function(r){let l=r.name.text,o=h(r),i=B(o),a=b(o);Object.assign($,{[r.name.text]:e(r.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let c=i?`\\color{|4||0.45}{${l}}`:l,u=[i,c,a&&`\\color{#52c11b|1||0.9}{${a}}`].filter(Boolean).join(" "),s=y(o)?.split("|")||[],f=s.includes("comment"),p=s.includes("version"),m=s.includes("author"),g=`## ${u}`;if(r.members.length){let e=[];r.members.forEach(n=>{let r=T(n.name.getText()),l=h(n),i=T(function(e){let n=e.initializer;return n&&t.isStringLiteral(n)?` '${n.text}'`:null}(n)),a=T(b(l)),c=T(B(l));!r||r.startsWith("\\color")||/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`),e.push([r,!f&&c,i,!p&&a,!m&&(d(l)||d(o))])});let n=!1,l=!1,i=!1;e.forEach(e=>{!f&&e[1]&&(i=!0),!p&&e[3]&&(l=!0),!m&&e[4]&&(n=!0)}),g+="\n";let a=["属性",i&&"说明","值",l&&"版本",n&&"作者"].filter(Boolean).join("|");g+=`|${a}|`;let c=[":-",i&&":-",":-",l&&":-",n&&":-"].filter(Boolean);g+="\n";let u=c.join("|");g+=`|${u}|`,e.forEach(e=>{g+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),n&&(e[4]||"-")].filter(Boolean).join("|");g+=`|${t}|`})}return g+="\n\n"}(r))}),w}
package/lib/vm/locales.js DELETED
@@ -1,2 +0,0 @@
1
- import{basename as e,join as t}from"path";import{directoryExists as o,scanFolder as a}from"@moneko/mdx";import{watch as l}from"chokidar";import{CONFIG as r}from"../config.js";import{FRAMEWORK as n,isDev as s}from"../process-env.js";import c from"../reactive-object.js";import{esm as i,tfc as g}from"../utils.js";let u={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;'}[n];function p(e,t){return`${u[n]}
2
- export function interpolateString(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}`}export const localesModuleName="@app/locales";export const locales=new c({[localesModuleName]:p([],{})});let d={};async function m(t,o){let a=e(t).replace(/\.[^.]+$/,"");"deleted"===o?delete d[a]:Object.assign(d,{[a]:(await import(i`${g(t)}`)).default});let l=[],r={};for(let e in d)if(Object.prototype.hasOwnProperty.call(d,e)){let{language:t=a,title:o=t,icon:n,translation:s={}}=d[e];l.push({language:t,title:o,icon:n}),r[t]={language:t,title:o,icon:n,translation:s}}locales.setData(localesModuleName,p(l,r))}let z=t(r.alias["@"],"./locales");o(z)&&(a(z).filter(e=>!/^\..*/.test(e)&&!/!\.ts$/.test(e)&&!/\.d\.ts$/.test(e)).forEach(e=>{m(e,"added")}),s&&function(e,t){let o=l(e,{ignored:t,persistent:!0,ignoreInitial:!0});function a(){o.unwatch(e),o.close()}o.on("add",e=>{m(e,"added")}),o.on("change",e=>{m(e,"change")}),o.on("unlink",e=>{m(e,"deleted")}),o.once("ready",()=>{s||a()}),process.on("SIGINT",a)}(z,[/^\..*/,/!\.ts$/,/\.d\.ts$/]));
package/lib/vm/routes.js DELETED
@@ -1 +0,0 @@
1
- import{generateRouter as o}from"@moneko/mdx";import{watchFiles as e}from"./utils.js";import{CONFIG as t}from"../config.js";import{FRAMEWORK as r,isDev as s,isLibrary as m,routeDir as u}from"../process-env.js";import n from"../reactive-object.js";let i=m?"@pkg":"@/pages";export const routesModuleName="@app/routes";function p(){return o(u,`${t.alias["@"]}/router/index.ts`,r,i,m)}export const route=new n({[routesModuleName]:p()});export function generatorRouter(){route.setData(routesModuleName,p())}s&&e(u,m?/(?<!README\.mdx?)$/:/(?<!index\.tsx?)$/,generatorRouter);
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes