@moneko/core 3.29.3 → 3.30.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bin/eslint.d.mts +1 -1
- package/lib/bin/eslint.mjs +1 -1
- package/lib/bin/lint-stage-git.d.mts +2 -2
- package/lib/bin/lint-stage-git.mjs +1 -1
- package/lib/common.d.mts +1 -1
- package/lib/common.mjs +1 -1
- package/lib/index.d.mts +1 -1
- package/lib/index.mjs +1 -1
- package/lib/plugin/virtual-module.d.mts +1 -1
- package/lib/plugin/virtual-module.mjs +1 -1
- package/lib/plugin/worker/eslint.d.mts +2 -0
- package/lib/plugin/worker/eslint.mjs +1 -0
- package/lib/plugins.config.d.mts +1 -1
- package/lib/plugins.config.mjs +1 -1
- package/lib/process-env.d.mts +1 -6
- package/lib/process-env.mjs +1 -1
- package/lib/utils/index.d.mts +1 -0
- package/lib/utils/index.mjs +1 -1
- package/lib/vm/info.d.mts +2 -18
- package/lib/vm/info.mjs +1 -1
- package/lib/vm/locales.mjs +2 -2
- package/lib/vm/modules.d.mts +2 -2
- package/lib/vm/modules.mjs +1 -1
- package/package.json +8 -8
package/lib/bin/eslint.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { relative } from 'node:path';
|
|
2
2
|
import { argv } from 'node:process';
|
|
3
|
+
import { ESLint } from '@moneko/eslint';
|
|
3
4
|
import { ink, print } from '@moneko/utils';
|
|
4
|
-
import { ESLint } from 'eslint';
|
|
5
5
|
import { cachePath, cwd, parseBraced } from './utils/config.mjs';
|
|
6
6
|
export default async function eslint();
|
package/lib/bin/eslint.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as e}from"node:path";import{argv as
|
|
1
|
+
import{relative as e}from"node:path";import{argv as o}from"node:process";import{ESLint as t}from"@moneko/eslint";import{ink as i,print as r}from"@moneko/utils";import{cachePath as s,cwd as a,parseBraced as c}from"./utils/config.mjs";export default async function l(){let l=i("eslint","cyan");r(`${l}: ${i("Runing...","yellow")}`,!0);let n=o[3],m=o.slice(4),f=m.includes("--fix"),u=new t({cache:!m.includes("--cache=false"),cacheLocation:`${s}/.eslintcache`,fix:f}),p=c(n).map(o=>e(a,o)),d=await u.lintFiles(p),w=await u.loadFormatter("stylish"),h=await w.format(d);f&&await t.outputFixes(d),h&&process.stdout.write(h);let $=d.some(e=>e.errorCount>0);r(`${l}: ${i(`✨ ${$?"Error":"Successfully"}!
|
|
2
2
|
`,$?"red":"green")}`,!0),$&&process.exit(1)}
|
|
@@ -2,8 +2,8 @@ import { spawnSync, type SpawnSyncReturns } from 'node:child_process';
|
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { argv } from 'node:process';
|
|
5
|
+
import { ESLint } from '@moneko/eslint';
|
|
5
6
|
import { stylelint as Stylelint } from '@moneko/stylelint';
|
|
6
|
-
import { ESLint } from 'eslint';
|
|
7
7
|
declare function parseArgs<T>(args: string[]): T;
|
|
8
8
|
type Args = {
|
|
9
9
|
fix?: boolean;
|
|
@@ -22,7 +22,7 @@ declare const cmd: {
|
|
|
22
22
|
declare const scriptRegExp: RegExp;
|
|
23
23
|
declare const vueRegExp: RegExp;
|
|
24
24
|
declare const styleRegExp: RegExp;
|
|
25
|
-
declare const child: SpawnSyncReturns<Buffer
|
|
25
|
+
declare const child: SpawnSyncReturns<Buffer>;
|
|
26
26
|
declare const lintFiles: string[];
|
|
27
27
|
export declare async function eslint();
|
|
28
28
|
declare const styleFiles: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawnSync as t}from"node:child_process";import{readFile as e}from"node:fs/promises";import{join as o}from"node:path";import{argv as i}from"node:process";import{
|
|
1
|
+
import{spawnSync as t}from"node:child_process";import{readFile as e}from"node:fs/promises";import{join as o}from"node:path";import{argv as i}from"node:process";import{ESLint as r}from"@moneko/eslint";import{stylelint as s}from"@moneko/stylelint";let n=Object.fromEntries(i.slice(2).map(function(t){let e=t.split("="),o=e[1];return void 0===o||"true"===o?o=!0:"false"===o?o=!1:/-?\d+(\.\d+)?([eE][+-]?\d+)?/.test(o)&&(o=parseFloat(o)),[e[0].replace(/^--/,""),o]})),c=n.fix,l=n.cache||!0,a=o(process.cwd(),"node_modules/.cache"),m={ci:["diff","--name-only","HEAD^","HEAD"],commit:["diff","--cached","--name-only","--diff-filter=ACMR"]},d=/.*(?<!\.d)\.(j|t|mj|mt|cj|ct)sx?$/,f=/.*(?<!\.d)\.vue$/,p=/.*(?<!\.d)\.(c|sc|sa|le)ss$/,u=t("git",m[n.mode||"ci"]||m.ci).stdout.toString().trim().split("\n");export async function eslint(){console.log("ESLint runing...");try{console.time("ESLint");let t=new r({cache:l,cacheLocation:`${a}/.eslintcache`,fix:c}),e=u.filter(t=>d.test(t)||f.test(t)),o=await t.lintFiles(e),i=await t.loadFormatter("stylish"),s=await i.format(o);c&&await r.outputFixes(o),s&&process.stdout.write(s);let n=o.some(t=>t.errorCount>0);console.timeEnd("ESLint"),n&&process.exit(1)}catch(t){console.error(t)}}let y=u.filter(t=>p.test(t)||f.test(t));export async function stylelint(){console.log("Stylelint runing..."),console.time("Stylelint");let t=await Promise.all(y.map(async t=>{let o=await e(t,{encoding:"utf-8"});return await s.lint({codeFilename:t,code:o,cache:l,cacheLocation:`${a}/.stylelintcache`,fix:c,formatter:"string"}).catch(console.log)})),o=!1;t.forEach(t=>{t&&(t.report&&process.stdout.write(t.report),t.errored&&(o=!!t.errored))}),console.timeEnd("Stylelint"),o&&process.exit(1)}
|
package/lib/common.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ import { exampleModuleName } from './vm/example.mjs';
|
|
|
8
8
|
import app from './vm/info.mjs';
|
|
9
9
|
import { CONFIG, PUBLICPATH } from './config.mjs';
|
|
10
10
|
import plugins from './plugins.config.mjs';
|
|
11
|
-
import { isDev, isLibrary, NODE_ENV,
|
|
11
|
+
import { isDev, isLibrary, NODE_ENV, packageJson } from './process-env.mjs';
|
|
12
12
|
export declare const outputConfig: Configuration['output'];
|
|
13
13
|
declare let entryMap: {
|
|
14
14
|
readonly main: string[];
|
package/lib/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extname as e,join as t,resolve as o}from"node:path";import s,{config_files as n,CUSTOMCONFIG as a}from"./commom/paths.mjs";import i from"./commom/require.mjs";import r from"./plugin/override-resolve.mjs";import{isObject as l,node_modules as m,resolveProgram as p}from"./utils/index.mjs";import{exampleModuleName as c}from"./vm/example.mjs";import u from"./vm/info.mjs";import{CONFIG as h,PUBLICPATH as d}from"./config.mjs";import f from"./plugins.config.mjs";import{isDev as g,isLibrary as b,NODE_ENV as y,
|
|
1
|
+
import{extname as e,join as t,resolve as o}from"node:path";import s,{config_files as n,CUSTOMCONFIG as a}from"./commom/paths.mjs";import i from"./commom/require.mjs";import r from"./plugin/override-resolve.mjs";import{isObject as l,node_modules as m,resolveProgram as p}from"./utils/index.mjs";import{exampleModuleName as c}from"./vm/example.mjs";import u from"./vm/info.mjs";import{CONFIG as h,PUBLICPATH as d}from"./config.mjs";import f from"./plugins.config.mjs";import{isDev as g,isLibrary as b,NODE_ENV as y,packageJson as j}from"./process-env.mjs";export const outputConfig={path:p(b?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${g?"name":"contenthash"}].js`,assetModuleFilename:t=>{let o=e(t.filename||"").substring(1);return`assets/${o}/[name][hash][ext]`},library:{name:`${u.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${j.name}`,pathinfo:g,clean:!0,publicPath:d,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"anonymous",enabledWasmLoadingTypes:["fetch"],hotUpdateChunkFilename:"[id].[fullhash].hot.js",hotUpdateMainFilename:"[runtime].[fullhash].hot.json"};let v={main:[m("@app/entry")]};if(h.polyfill&&v.main.unshift(t(s.corePath,"./polyfills/replace-children.mjs")),g&&h.refresh&&h.env.injectRemoteReactRefresh&&v.main.unshift(i.resolve("@moneko/react/lib/injectRemoteReactRefresh.js")),h.entry&&("string"==typeof h.entry?v={main:[h.entry]}:Object.keys(h.entry)&&(v=Object.assign(v,h.entry))),"string"==typeof v.main&&(v.main=[v.main]),h.output){if("string"==typeof h.output)outputConfig.path=h.output;else if(Object.keys(h.output)){let e=h.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof h.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let C={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[a,y].filter(Boolean).join("-")}`,version:`${j.version}`,buildDependencies:{config:n}};!1===h.cache?C=!1:l(h.cache)&&(C=Object.assign(C,h.cache));export const commonConfig={name:"client",target:"web",devtool:h.devtool,entry:v,mode:g?"development":"production",stats:"errors-only",cache:C,snapshot:{immutablePaths:[/node_modules\/(?!(@app|@moneko)\/)/],managedPaths:[/^@app\/.+/,/^@moneko\/.+/],buildDependencies:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:h.externalsPresets,plugins:f,node:{global:!1,__filename:!1,__dirname:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:h.lazyCompilation&&g&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(m(c))||t.startsWith(m("@app/comment"))||t.startsWith(s.pagesPath)||t.startsWith(s.componentsPath)))}},buildHttp:l(h.buildHttp)?{allowedUris:[],lockfileLocation:o(s.httpCachePath,"http.lock"),cacheLocation:o(s.httpCachePath,"data"),upgrade:!0,...h.buildHttp}:h.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:h.alias,modules:[s.nodeModules,s.pnpmNodeModules,s.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:h.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:h.externals,output:outputConfig};h.overrideResolve&&commonConfig.resolve.plugins.push(new r(Object.assign({original:h.alias["@"],override:a&&p(a)},h.overrideResolve)));
|
package/lib/index.d.mts
CHANGED
|
@@ -13,6 +13,6 @@ export { type OptimizationSplitChunksOptions, default as splitChunk } from './op
|
|
|
13
13
|
export type { HtmlMeta, HtmlPluginOption } from './plugin/html-plugin.mjs';
|
|
14
14
|
export type { OverrideResolverOption } from './plugin/override-resolve.mjs';
|
|
15
15
|
export type { VirtualModulePluginOption } from './plugin/virtual-module.mjs';
|
|
16
|
-
export { APPTYPE, coreName, FRAMEWORK, isDev, isLibrary, isMicro, mainDirectory,
|
|
16
|
+
export { APPTYPE, coreName, FRAMEWORK, isDev, isLibrary, isMicro, mainDirectory, packageJson, PACKAGENAME } from './process-env.mjs';
|
|
17
17
|
export { resolveProgram, toCamelCase } from './utils/index.mjs';
|
|
18
18
|
export type { MdxOptions } from '@moneko/mdx';
|
package/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as hasPkg}from"./commom/has-pkg.mjs";export{getIPv4,getPort}from"./commom/net.mjs";export{CUSTOMCONFIG,default as paths,routeDir,yarnArgv}from"./commom/paths.mjs";export{default as require}from"./commom/require.mjs";export{default as Rule}from"./commom/rule.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{APPTYPE,coreName,FRAMEWORK,isDev,isLibrary,isMicro,mainDirectory,PACKAGENAME
|
|
1
|
+
export{default as hasPkg}from"./commom/has-pkg.mjs";export{getIPv4,getPort}from"./commom/net.mjs";export{CUSTOMCONFIG,default as paths,routeDir,yarnArgv}from"./commom/paths.mjs";export{default as require}from"./commom/require.mjs";export{default as Rule}from"./commom/rule.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{APPTYPE,coreName,FRAMEWORK,isDev,isLibrary,isMicro,mainDirectory,packageJson,PACKAGENAME}from"./process-env.mjs";export{resolveProgram,toCamelCase}from"./utils/index.mjs";
|
|
@@ -3,7 +3,7 @@ import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
|
3
3
|
import parseModuleMeta from '../commom/parse-module-meta.mjs';
|
|
4
4
|
import paths from '../commom/paths.mjs';
|
|
5
5
|
import { isLibrary } from '../process-env.mjs';
|
|
6
|
-
import { node_modules } from '../utils/index.mjs';
|
|
6
|
+
import { node_modules, transformModule } from '../utils/index.mjs';
|
|
7
7
|
import { comment, docs } from '../vm/docs.mjs';
|
|
8
8
|
import { examples } from '../vm/example.mjs';
|
|
9
9
|
import { locales } from '../vm/locales.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"webpack-virtual-modules";import o from"../commom/parse-module-meta.mjs";import i from"../commom/paths.mjs";import{isLibrary as e}from"../process-env.mjs";import{node_modules as s}from"../utils/index.mjs";import{comment as
|
|
1
|
+
import t from"webpack-virtual-modules";import o from"../commom/parse-module-meta.mjs";import i from"../commom/paths.mjs";import{isLibrary as e}from"../process-env.mjs";import{node_modules as s,transformModule as r}from"../utils/index.mjs";import{comment as l,docs as m}from"../vm/docs.mjs";import{examples as n}from"../vm/example.mjs";import{locales as p}from"../vm/locales.mjs";import a from"../vm/modules.mjs";import{route as f}from"../vm/routes.mjs";let c={};for(let t in a)if(Object.prototype.hasOwnProperty.call(a,t)){let{file:i,pkg:e,meta:s}=o(t);c[e]=s,c[i]=r(a[t])}export class VirtualModuleWebpackPlugin{constructor(i={}){this.options={},this.init=!1,this.virtualModules=new t(c);let e={};for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)){let{file:s,pkg:l,meta:m}=o(t),n=i[t],p=n;p=s.endsWith("json")?"string"==typeof n?n:JSON.stringify(n):r(n),Object.assign(e,{[s]:p,[l]:m})}this.options=e}modify(t,o,e){let r=e||"",l=o.startsWith(i.nodeModules)?o:s(o),m=t.inputFileSystem;for(;m&&m._inputFileSystem;)m=m._inputFileSystem;let n=m?._virtualFiles?.[l];n&&n.contents===r||(this.virtualModules.writeModule(l,r),t.watching?.invalidate())}apply(t){this.virtualModules.apply(t);let o=(o,i)=>{this.modify(t,o,i)};f.on("change",o),p.on("change",o),e&&(n.on("change",o),m.on("change",o),l.on("change",o)),t.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.init){for(let t in this.init=!0,this.options)Object.prototype.hasOwnProperty.call(this.options,t)&&o(t,this.options[t]);for(let t of n)o(t[0],t[1]);for(let t of m)o(t[0],t[1]);for(let t of l)o(t[0],t[1])}})}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ESLint as e}from"@moneko/eslint";import{parentPort as a}from"worker_threads";if(!a)throw Error("This file must be run as a worker");a.on("message",async({options:t})=>{try{let o=new e({cache:t.cache,cacheLocation:t.cacheLocation,fix:t.fix}),r=t.files.map(e=>e.replace(/\\/g,"/")),i=await o.lintFiles(r),s=await o.loadFormatter("json"),c=await s.format(i);t.fix&&await e.outputFixes(i),c&&process.stdout.write(c),a.postMessage({linter:i})}catch(e){a.postMessage(e)}});
|
package/lib/plugins.config.d.mts
CHANGED
|
@@ -4,6 +4,6 @@ import { HtmlMeta, HtmlPlugin } from './plugin/html-plugin.mjs';
|
|
|
4
4
|
import moduleFederation from './plugin/module-federation.mjs';
|
|
5
5
|
import { VirtualModuleWebpackPlugin } from './plugin/virtual-module.mjs';
|
|
6
6
|
import { CONFIG } from './config.mjs';
|
|
7
|
-
import {
|
|
7
|
+
import { packageJson } from './process-env.mjs';
|
|
8
8
|
declare const plugins: WebpackPluginInstance[];
|
|
9
9
|
export default plugins;
|
package/lib/plugins.config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"webpack";import{CopyPlugin as t}from"./plugin/copy.mjs";import{HtmlPlugin as i}from"./plugin/html-plugin.mjs";import o from"./plugin/module-federation.mjs";import{VirtualModuleWebpackPlugin as
|
|
1
|
+
import e from"webpack";import{CopyPlugin as t}from"./plugin/copy.mjs";import{HtmlPlugin as i}from"./plugin/html-plugin.mjs";import o from"./plugin/module-federation.mjs";import{VirtualModuleWebpackPlugin as r}from"./plugin/virtual-module.mjs";import{CONFIG as l}from"./config.mjs";import{packageJson as n}from"./process-env.mjs";let p=[...o,new r(l.virtualModule),new t(l.copy),new e.DefinePlugin({"process.env":JSON.stringify(l.env)}),new e.IgnorePlugin({resourceRegExp:/\/(__(tests|mocks)__|test|spec|e2e)\//}),...l.plugins].filter(Boolean);if(l.htmlPluginOption){let e={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","mobile-web-app-capable":"yes",renderer:"webkit",description:n.description,keywords:Array.isArray(n.keywords)?n.keywords.toString():"","http-equiv":"refresh",viewport:"width=device-width, initial-scale=1"};l.seo&&(e.relCanonical={rel:"canonical",href:`https://${l.seo.domain}${l.basename}`}),l.htmlPluginOption.meta&&Object.assign(e,l.htmlPluginOption.meta),p.push(new i({...l.htmlPluginOption,meta:e}))}if(l.fixBrowserRouter){let e=l.basename.split("/").filter(Boolean).length,t=`${Array(e).fill("..").join("/")+(e?"/":"")}404.html`,o=l.fixBrowserRouter.pathSegmentsToKeep??e;p.push(new i({filename:l.fixBrowserRouter.path??t,inject:!1,templateContent:()=>`<html lang="en"><head><title>Redirect</title><script>const pathKeep = ${o};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>`}))}l.sourceMap&&p.push(new e.SourceMapDevToolPlugin(l.sourceMap));export default p;
|
package/lib/process-env.d.mts
CHANGED
|
@@ -17,13 +17,8 @@ export declare const jsxImportSource: string;
|
|
|
17
17
|
export declare const framework: 'react' | 'solid-js';
|
|
18
18
|
export declare const frameworkVersionStr: string;
|
|
19
19
|
export declare const frameworkVersion: number;
|
|
20
|
-
declare const
|
|
21
|
-
export declare const description: string;
|
|
22
|
-
export declare const author: string | Record<string, string>;
|
|
23
|
-
export declare const repository: string;
|
|
24
|
-
export declare const keywords: string[];
|
|
20
|
+
export declare const packageJson: Record<string, unknown>;
|
|
25
21
|
export declare const PACKAGENAME: string;
|
|
26
|
-
export declare const PACKAGEVERSION: string;
|
|
27
22
|
export declare const coreName: string;
|
|
28
23
|
export declare const isDev: boolean;
|
|
29
24
|
export declare const refresh: boolean;
|
package/lib/process-env.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{platform as o}from"node:process";import
|
|
1
|
+
import{platform as o}from"node:process";import e from"./commom/has-pkg.mjs";import r from"./commom/require.mjs";export const IS_WINDOW="win32"===o;export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const NODE_ENV=process.env.NODE_ENV;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isMobile="mobile"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const SSR="true"===process.env.SSR;export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const framework={react:"react",solid:"solid-js"}[FRAMEWORK];export const frameworkVersionStr=r(`${framework}/package.json`).version;export const frameworkVersion=parseFloat(frameworkVersionStr);export const packageJson=r(`${process.cwd()}/package.json`);delete packageJson.scripts;export const PACKAGENAME=packageJson.name;export const coreName="@moneko/core";export const isDev="development"===NODE_ENV;export const refresh=!!(isDev&&(e("solid-refresh")||e("react-refresh")));
|
package/lib/utils/index.d.mts
CHANGED
|
@@ -8,4 +8,5 @@ export declare function node_modules<T extends string>(name: T): `node_modules/$
|
|
|
8
8
|
export declare function isObject(target: unknown): target is object;
|
|
9
9
|
type AnyFunction = (...a: any[]) => any;
|
|
10
10
|
export declare function isFunction<T>(target: T): target is T & AnyFunction;
|
|
11
|
+
export declare function transformModule(obj: object | string);
|
|
11
12
|
export declare function empty();
|
package/lib/utils/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as e}from"node:path";import
|
|
1
|
+
import{resolve as e}from"node:path";import t from"../commom/paths.mjs";export function toCamelCase(e){return e.replace(/-./g,e=>e.charAt(1).toUpperCase())}export function convertToCamelCase(e){return e.toLowerCase().replace(/-(\w)/g,(e,t)=>t?t.toUpperCase():"").replace(/^./,e=>e.toUpperCase()).replace(/Ui$/,"UI")}export function resolveProgram(o){return e(t.programPath,`./${o}`)}export function node_modules(o){return e(t.nodeModules,`./${o}`)}export function isObject(e){let t=typeof e;return null!==e&&("object"===t||"function"===t)}export function isFunction(e){return["[object Function]","[object AsyncFunction]","[object GeneratorFunction]"].includes(Object.prototype.toString.call(e))}export function transformModule(e){let t="";if("string"==typeof e)t=e;else for(let[o,r]of Object.entries(e))t+=`export const ${o} = ${isFunction(r)?r:JSON.stringify(r)};`;return t}export function empty(){}
|
package/lib/vm/info.d.mts
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
import { CONFIG } from '../config.mjs';
|
|
2
|
-
import { APPTYPE,
|
|
2
|
+
import { APPTYPE, framework, frameworkVersionStr, packageJson, SSR } from '../process-env.mjs';
|
|
3
3
|
import { convertToCamelCase } from '../utils/index.mjs';
|
|
4
|
-
declare const
|
|
5
|
-
declare const app: {
|
|
6
|
-
readonly name;
|
|
7
|
-
readonly projectName;
|
|
8
|
-
readonly ssr;
|
|
9
|
-
readonly version;
|
|
10
|
-
readonly base;
|
|
11
|
-
readonly type;
|
|
12
|
-
readonly routerMode;
|
|
13
|
-
readonly prefixCls;
|
|
14
|
-
readonly theme;
|
|
15
|
-
readonly description;
|
|
16
|
-
readonly author;
|
|
17
|
-
readonly repository;
|
|
18
|
-
readonly frameworkVersion;
|
|
19
|
-
readonly framework;
|
|
20
|
-
};
|
|
4
|
+
declare const app: Record<string, unknown>;
|
|
21
5
|
export default app;
|
package/lib/vm/info.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CONFIG as e}from"../config.mjs";import{APPTYPE as r,
|
|
1
|
+
import{CONFIG as e}from"../config.mjs";import{APPTYPE as r,framework as o,frameworkVersionStr as m,packageJson as s,SSR as t}from"../process-env.mjs";import{convertToCamelCase as f}from"../utils/index.mjs";let i={...s,projectName:f(s.name),ssr:t,base:e.basename,type:r,routerMode:e.routerMode,prefixCls:e.prefixCls,theme:e.theme,frameworkVersion:m,framework:o};export default i;
|
package/lib/vm/locales.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{basename as e,join as t}from"node:path";import{directoryExists as
|
|
2
|
-
export function template(r,n){return r.replace(/\\\${\\w+}/g,function(r){var t=r.slice(2,-1);var e=n[t];return e!==void 0?e.toString():""})}function deepFreeze(o) { const p = Reflect.ownKeys(o);for (const k of p) {const v = o[k];if ((v && typeof v === "object") || typeof v === "function") {deepFreeze(v);}}return Object.freeze(o);}export const locales = ${JSON.stringify(e)};const _res = ${JSON.stringify(t)};const resources = deepFreeze(_res);${
|
|
1
|
+
import{basename as e,join as t}from"node:path";import{directoryExists as a,scanFolderSync as o}from"@moneko/utils";import{watch as l}from"chokidar";import r from"../commom/log.mjs";import n from"../commom/parse-module-meta.mjs";import c from"../commom/reactive-object.mjs";import s from"../commom/require.mjs";import i from"../commom/sigint-exit.mjs";import{CONFIG as g}from"../config.mjs";import{FRAMEWORK as m,isDev as u}from"../process-env.mjs";let p={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)||navigator.language,{translation:a,...defaultLocale}=Object.assign({title:"简体中文",language:navigator.language,translation:{}},resources[language]||resources[navigator.language]),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)||navigator.language,{translation:l,...o}=Object.assign({title:"简体中文",language:navigator.language,translation:{}},resources[a]||resources[navigator.language]),[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;'}[m];function d(e,t){return`${p[m]}
|
|
2
|
+
export function template(r,n){return r.replace(/\\\${\\w+}/g,function(r){var t=r.slice(2,-1);var e=n[t];return e!==void 0?e.toString():""})}function deepFreeze(o) { const p = Reflect.ownKeys(o);for (const k of p) {const v = o[k];if ((v && typeof v === "object") || typeof v === "function") {deepFreeze(v);}}return Object.freeze(o);}export const locales = ${JSON.stringify(e)};const _res = ${JSON.stringify(t)};const resources = deepFreeze(_res);${f}`}let b=n("@app/locales");export const localesModuleName=b.file;export const locales=new c({[localesModuleName]:d([],{}),[b.pkg]:b.meta});let j={};async function v(t,a){let o=e(t).replace(/\.[^.]+$/,"");try{"deleted"===a?delete j[o]:(delete s.cache[t],Object.assign(j,{[o]:s(t).default}));let e=[],l={};for(let t in j)if(Object.prototype.hasOwnProperty.call(j,t)){let{language:a=o,title:r=a,icon:n,translation:c={}}=j[t];e.push({language:a,title:r,icon:n}),l[a]={language:a,title:r,icon:n,translation:c}}locales.setData(localesModuleName,d(e,l)),locales.setData(b.pkg,b.meta)}catch(e){r(e)}}let z=t(g.alias["@"],"./locales");if(a(z)&&!1!==g.htmlPluginOption){let e=o(z,[".ts$"]).filter(e=>!/^\..*|\.d\.ts$/.test(e));await Promise.all(e.map(e=>v(e,"added"))),u&&function(e,t){let a=l(e,{ignored:t,persistent:!0,ignoreInitial:!0});function o(){a.unwatch(e),a.close()}a.on("add",e=>{v(e,"added")}),a.on("change",e=>{v(e,"change")}),a.on("unlink",e=>{v(e,"deleted")}),a.once("ready",()=>{u||o()}),i(o)}(z,[/^\..*/,/!\.ts$/,/\.d\.ts$/])}
|
package/lib/vm/modules.d.mts
CHANGED
|
@@ -10,7 +10,7 @@ import type { VirtualModulePluginOption } from '../plugin/virtual-module.mjs';
|
|
|
10
10
|
import { APPTYPE, FRAMEWORK } from '../process-env.mjs';
|
|
11
11
|
import createTypes from '../utils/create-types.mjs';
|
|
12
12
|
import { generateDeclaration } from '../utils/dts.mjs';
|
|
13
|
-
import { node_modules } from '../utils/index.mjs';
|
|
13
|
+
import { node_modules, transformModule } from '../utils/index.mjs';
|
|
14
14
|
import getCoverage from './coverage.mjs';
|
|
15
15
|
import { docs, docsModuleName } from './docs.mjs';
|
|
16
16
|
import info from './info.mjs';
|
|
@@ -18,7 +18,7 @@ import { locales, localesModuleName } from './locales.mjs';
|
|
|
18
18
|
import renderApp from './render-app.mjs';
|
|
19
19
|
import { route, routesModuleName } from './routes.mjs';
|
|
20
20
|
declare const mdxScope: string | false;
|
|
21
|
-
declare const normalModules: Record<string, string>;
|
|
21
|
+
declare const normalModules: Record<string, string | object>;
|
|
22
22
|
declare const appDtsPath: string;
|
|
23
23
|
declare const appDts: string[];
|
|
24
24
|
declare const vmDtsPath: string;
|
package/lib/vm/modules.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as p}from"node:path";import{getAppEntry as
|
|
1
|
+
import{join as p}from"node:path";import{getAppEntry as m,getAppFallback as o,getAppMdxScope as e,getAppMergeRouter as t,getAppNormalizeCss as r,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as i}from"@moneko/mdx";import{updateFileSync as n}from"@moneko/utils";import f from"../commom/has-pkg.mjs";import l from"../commom/paths.mjs";import d from"../commom/rule.mjs";import{CONFIG as c}from"../config.mjs";import j from"../plugin/module-federation.mjs";import{APPTYPE as x,FRAMEWORK as u}from"../process-env.mjs";import g from"../utils/create-types.mjs";import{generateDeclaration as v}from"../utils/dts.mjs";import{node_modules as h,transformModule as k}from"../utils/index.mjs";import y from"./coverage.mjs";import{docs as b,docsModuleName as z}from"./docs.mjs";import D from"./info.mjs";import{locales as C,localesModuleName as P}from"./locales.mjs";import M from"./render-app.mjs";import{route as O,routesModuleName as S}from"./routes.mjs";let q=f(p(c.alias["@"],"./mdx-scope.tsx"))||f(p(c.alias["@"],"./mdx-scope.ts")),w={"@app/env.ts":c.env,"@app/info.ts":D,"@app/render.tsx":"react"===u?M:"","@app/entry.ts":m(p(c.alias["@"],"./index.ts"),!!j.length,!!c.rem,!!c.normalizeCss,x,u),"@app/rem":a(c.rem?.designSize||1680),"@app/fallback":o(c.fallbackCompPath),"@app/coverage":y(l.coveragePath),"@app/merge-router":t(),"@app/prefix-router":s(),"@app/normalize/index.css":r(),"@app/suspense/index.tsx":i(x,u),"@app/mdx-scope.tsx":q?e(q):"export {}","@app/routes":O.getData(S),"@app/locales":C.getData(P),"@app/docs":b.getData(z)};n(h("@types/@app/index.d.ts"),["@app/env.ts","@app/info.ts","@app/entry.ts","@app/mdx-scope.tsx"].map(p=>g(p.replace(d.js,""),v(k(w[p]),p))).join("\n"));let A=h("@types/@vm/index.d.ts"),B=c.virtualModule||{};n(A,Object.keys(B).map(p=>g(p,v(k(B[p]),p))).join("\n"));export default w;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.30.0-beta.0",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -21,23 +21,24 @@
|
|
|
21
21
|
"@moneko/convert": "1.0.0",
|
|
22
22
|
"@moneko/mdx": "0.1.43",
|
|
23
23
|
"@moneko/raw-import": "0.0.3",
|
|
24
|
+
"@moneko/eslint": "1.0.1",
|
|
24
25
|
"@moneko/stylelint": "1.0.2",
|
|
25
26
|
"@moneko/transform-imports": "0.6.1",
|
|
26
27
|
"@moneko/utils": "0.1.22",
|
|
27
28
|
"@swc/core": "1.6.13",
|
|
28
29
|
"browserslist": "4.24.4",
|
|
29
30
|
"chokidar": "4.0.3",
|
|
30
|
-
"core-js": "3.
|
|
31
|
-
"core-js-compat": "3.
|
|
31
|
+
"core-js": "3.41.0",
|
|
32
|
+
"core-js-compat": "3.41.0",
|
|
32
33
|
"fastify": "4.29.0",
|
|
33
34
|
"less": "4.2.2",
|
|
34
35
|
"less-loader": "12.2.0",
|
|
35
|
-
"lightningcss": "1.29.
|
|
36
|
+
"lightningcss": "1.29.2",
|
|
36
37
|
"marked-completed": "1.2.14",
|
|
37
38
|
"mini-css-extract-plugin": "2.9.2",
|
|
38
39
|
"style-loader": "4.0.0",
|
|
39
40
|
"swc-loader": "0.2.6",
|
|
40
|
-
"typescript": "5.
|
|
41
|
+
"typescript": "5.8.2",
|
|
41
42
|
"webpack": "5.98.0",
|
|
42
43
|
"webpack-dev-middleware": "7.4.2",
|
|
43
44
|
"webpack-hot-middleware": "2.26.1",
|
|
@@ -50,10 +51,9 @@
|
|
|
50
51
|
"@types/stylis": "4.2.7",
|
|
51
52
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
52
53
|
"@types/webpack-hot-middleware": "2.25.9",
|
|
53
|
-
"babel-plugin-react-compiler": "19.0.0-beta-
|
|
54
|
-
"eslint-config-neko": "3.0.5",
|
|
54
|
+
"babel-plugin-react-compiler": "19.0.0-beta-bafa41b-20250307",
|
|
55
55
|
"sass": "1.85.1",
|
|
56
|
-
"sass-loader": "16.0.
|
|
56
|
+
"sass-loader": "16.0.5",
|
|
57
57
|
"solid-refresh": "0.7.5",
|
|
58
58
|
"stylis": "4.3.6",
|
|
59
59
|
"webpack-bundle-analyzer": "4.10.2"
|