@moneko/core 3.6.1 → 3.6.4
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/common.js +1 -1
- package/lib/docs.js +1 -1
- package/lib/done.d.ts +3 -5
- package/lib/done.js +1 -1
- package/lib/generate-api.d.ts +1 -1
- package/lib/generate-api.js +1 -1
- package/lib/locales.js +2 -2
- package/package.json +1 -1
- package/typings/global.d.ts +2 -1
package/lib/common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let e;import t from"add-asset-html-webpack-plugin";import o from"html-webpack-plugin";import r from"webpack";import s from"webpackbar";import{CONFIG as l,PUBLICPATH as a}from"./config.js";import n from"./done.js";import i from"./html-add-entry-attr.js";import p from"./html-plugin-option.js";import{moduleFederation as m}from"./module-federation.js";import c from"./module.config.js";import u,{CUSTOMCONFIG as f}from"./paths.js";import{PACKAGENAME as h,PACKAGEVERSION as d,isDev as b,isLibrary as y,isMicro as j}from"./process-env.js";import{seo as g}from"./seo.js";import{resolveNodeModulesPath as w,resolveProgramPath as k}from"./utils.js";import x from"./virtual-module-plugin.js";import C from"./virtual-modules.js";let{AutomaticPrefetchPlugin:v,DefinePlugin:$,SourceMapDevToolPlugin:O,WatchIgnorePlugin:P}=r,M=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:k(y?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${b?"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:h,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${h}`,pathinfo:b,clean:!0,publicPath:a,asyncChunks:!0,charset:!0};let D={main:w("@app/entry")};l.polyfill&&Object.assign(D,{"dom-polyfills":[`${u.corePath}/polyfills/replace-children.js`]}),l.entry&&("string"==typeof l.entry?D={main:l.entry}:Object.keys(l.entry)&&Object.assign(D,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let A=l.basename.split("/").filter(Boolean).length,B=`${Array(A).fill("..").join("/")+(A?"/":"")}404.html`,{pathSegmentsToKeep:H=A,path:K=B}=l.fixBrowserRouter||{},L=!1;l.cacheDirectory&&(L={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:`${f||"default"}-${b?"development":"production"}`,version:d});export const clientConfig={entry:D,stats:"errors-only",cache:L,infrastructureLogging:{level:"error"},target:"web",externalsPresets:l.externalsPresets,plugins:[new v,...m,l.htmlPluginOption&&new o(p),l.fixBrowserRouter&&new o({filename:K,inject:!1,templateContent:()=>`<html lang="en"><head><title>${p.title}</title><script>const pathKeep = ${H||A};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 t(M),j&&new i(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new $({"process.env":JSON.stringify(l.env)}),new P({paths:[/\.d\.ts$/]}),l.sourceMap&&new O(l.sourceMap),l.bar&&new s(l.bar),new x(C),new n({done:t=>{clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),l.done?.(t),l.seo&&g(),process.exit(0)},3e3)}}),...l.plugins].filter(e=>!!e),experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:b&&{imports:!1,entries:!1},buildHttp:l.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:l.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:c,externals:l.externals,output:outputConfig};
|
package/lib/docs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{statSync as e}from"fs";import{dirname as t,join as o}from"path";import{watch as r}from"chokidar";import{CONFIG as i}from"./config.js";import n from"./generate-api.js";import{FRAMEWORK as s,FRAMEWORKNAME as p,createElement as a,isLibrary as l,isReact as c,isSolid as d}from"./process-env.js";import m from"./reactive-object.js";import{resolveProgramPath as f}from"./utils.js";let u="@app/comment";export const docs=new m;let $={[u]:{}},g=`() => ${a}(SuspenseComp, { comp: $1 })`,b=`import { ${a}${d?",Dynamic":""} } from "${p}${d?"/web":""}";import SuspenseComp from "@app/suspense";`;function h(e,r){let s=e.replace(RegExp(`^${i.alias["@pkg"]}`),""),p=t(s).replace(/^\//,""),l=[u,p].join("/"),m=s.split("/").pop()?.replace(/\.tsx?/,".md");if(!m)return;$[u][p]||($[u][p]={});let f=o(l,m);if("deleted"===r)$[u][p][m]&&delete $[u][p][m];else{let t=n(e);$[f]=t,t?$[u][p][m]=`rr(() => import(/* webpackChunkName: '${f}' */'${f}?raw').then((res) => ({default: ${c?"() =>":""}${a}(${d?"Dynamic":"'n-md'"}, {text: res.default, ${d?"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;}'})})))rr`:$[u][p][m]&&delete $[u][p][m]}let h={};for(let e in $)if(Object.prototype.hasOwnProperty.call($,e)){let t=$[e];if(e===u)for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(h[e]=Object.values(t[e]));else docs.setData(e,t)}docs.setData("@app/docs",`${b}export default ${JSON.stringify(h).replace(/"rr\((.+?)\)rr"/g,g)}`)}["react","solid"].includes(s)||(g="$1",b=""),l&&function(){let t=[],o=r(f("components"),{ignored:[/(^|\/)\../,/(^|\/)__tests__(\/|$)/],persistent:!0,ignoreInitial:!1});function i(t){return/\.tsx?$/.test(t)&&e(t).isFile()}o.on("add",e=>{i(e)&&(h(e,"added"),t.push(e))}),o.on("change",e=>{i(e)&&h(e,"change")}),o.on("unlink",e=>{i(e)&&(h(e,"deleted"),t.splice(t.indexOf(e),1))}),o.on("ready",()=>{t.forEach(e=>{h(e,"change")})}),process.on("SIGINT",function(){o.close()})}();
|
package/lib/done.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Compiler, Stats } from 'webpack';
|
|
2
2
|
declare class DoneWebpackPlugin {
|
|
3
|
-
options
|
|
4
|
-
done?: () => void;
|
|
5
|
-
};
|
|
3
|
+
private options;
|
|
6
4
|
constructor(options: {
|
|
7
|
-
done
|
|
5
|
+
done: (stats: Stats) => void;
|
|
8
6
|
});
|
|
9
7
|
apply(compiler: Compiler): void;
|
|
10
8
|
}
|
package/lib/done.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default class{constructor(o){this.options=Object.assign({},o)}apply(o){o.hooks.done.tap("DoneWebpackPlugin",
|
|
1
|
+
export default class{constructor(o){this.options=Object.assign({},o)}apply(o){o.hooks.done.tap("DoneWebpackPlugin",o=>{this.options.done(o)})}}
|
package/lib/generate-api.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function generateApi(path: string
|
|
1
|
+
export default function generateApi(path: string): string;
|
package/lib/generate-api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{readFileSync as e}from"fs";import{dirname as t}from"path";import n from"typescript";import{CONFIG as r}from"./config.js";let{ScriptKind:l,ScriptTarget:o,SyntaxKind:i,createSourceFile:c,forEachChild:a,getLeadingCommentRanges:u,isInterfaceDeclaration:s,isQuestionToken:f,isPropertySignature:p,isFunctionTypeNode:m,isUnionTypeNode:g,isMethodSignature:$}=n,h={};function b(e){let t=u(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end),r=n.match(/\/\*\*([\s\S]*?)\*\//);if(r)return r[1].replace(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim()}return null}function d(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function y(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}](${n})`}return null}function x(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let j=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function T(e,t){if(!e)return null;let n=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if(h[e]){let n=`/${[r.basename,h[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${n})`:`[${e}](${n})`}return t?`\\color{#009688}{${e}}`:e});return t&&(n=n.replace(j,e=>`\\color{#009688}{${e}}`)),n}function B(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 k(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}export default function w(u){let j=e(u,{encoding:"utf-8"}),w=c(u,j,o.Latest,!0,l.TS),E="";return a(w,e=>{s(e)?E+=function(e){let l=e.name.text;Object.assign(h,{[e.name.text]:t(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let o=b(e),c=d(o),a=k(o),u=x(o)?.split("|")||[],s=u.includes("comment"),j=u.includes("initial"),w=u.includes("optional"),E=u.includes("version"),S=u.includes("author"),v=a?`\\color{|4||0.45}{${l}}`:l,F=(function(e){let t=[];if(e.heritageClauses){for(let r of e.heritageClauses)if(r.token===n.SyntaxKind.ExtendsKeyword)for(let e of r.types)t.push(e.getText())}return t})(e)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${T(B(e))}</n-tag>`),z=[a,v,c&&`\\color{#52c11b|1||0.9}{${c}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),K=`## ${z}`,N=e.members.filter(e=>p(e)&&e.type?.kind!==i.NeverKeyword||$(e)),q=[];if(N.length){N.forEach(e=>{let t=T(B($(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),n=b(e),r=B(e.name.getText());!r||r.startsWith("\\color")||($(e)||function(e){if(e.type){if(!g(e.type))return m(e.type);for(let t of e.type.types)if(m(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let l=e.questionToken&&f(e.questionToken);q.push([r,!w&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!s&&B(k(n)),t,!j&&B(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&B(d(n)),!S&&(y(n)||y(o))])});let e=!1,t=!1,n=!1,r=!1;q.forEach(l=>{!s&&l[2]&&(r=!0),!j&&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 i=[":-",!w&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);K+="\n";let c=i.join("|");K+=`|${c}|`,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"}(e):n.isEnumDeclaration(e)&&(E+=function(e){let l=e.name.text,o=b(e),i=k(o),c=d(o);Object.assign(h,{[e.name.text]:t(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let a=i?`\\color{|4||0.45}{${l}}`:l,u=[i,a,c&&`\\color{#52c11b|1||0.9}{${c}}`].filter(Boolean).join(" "),s=x(o)?.split("|")||[],f=s.includes("comment"),p=s.includes("version"),m=s.includes("author"),g=`## ${u}`;if(e.members.length){let t=[];e.members.forEach(e=>{let r=B(e.name.getText()),l=b(e),i=B(function(e){let t=e.initializer;return t&&n.isStringLiteral(t)?` '${t.text}'`:null}(e)),c=B(d(l)),a=B(k(l));!r||r.startsWith("\\color")||/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`),t.push([r,!f&&a,i,!p&&c,!m&&(y(l)||y(o))])});let r=!1,l=!1,i=!1;t.forEach(e=>{!f&&e[1]&&(i=!0),!p&&e[3]&&(l=!0),!m&&e[4]&&(r=!0)}),g+="\n";let c=["属性",i&&"说明","值",l&&"版本",r&&"作者"].filter(Boolean).join("|");g+=`|${c}|`;let a=[":-",i&&":-",":-",l&&":-",r&&":-"].filter(Boolean);g+="\n";let u=a.join("|");g+=`|${u}|`,t.forEach(e=>{g+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),r&&(e[4]||"-")].filter(Boolean).join("|");g+=`|${t}|`})}return g+="\n\n"}(e))}),E}
|
package/lib/locales.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
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);${u}`}export const localesModuleName="@app/locales";export const locales=new c({[localesModuleName]:d([],{})});let m={};async function z(e,o){let a=t(e).replace(/\.[^.]+$/,"");if("deleted"===o)delete m[a];else{let t=await import(r`${f(e)}`);Object.assign(m,{[a]:t.default})}let l=[],n={};for(let e in m)if(Object.prototype.hasOwnProperty.call(m,e)){let t=m[e],{language:o=a,title:r=o,icon:s,translation:c={}}=t;l.push({language:o,title:r,icon:s}),n[o]={language:o,title:r,icon:s,translation:c}}locales.setData(localesModuleName,d(l,n))}e(o(l.alias["@"],"./locales")
|
|
1
|
+
import{existsSync as e}from"fs";import{basename as t,join as o}from"path";import{watch as a}from"chokidar";import{CONFIG as l}from"./config.js";import r from"./esm.js";import{FRAMEWORK as n,isLibrary as s}from"./process-env.js";import c from"./reactive-object.js";import{empty as i,resolveProgramPath as g,tfc as f}from"./utils.js";let p={react:'import sso from "shared-store-object";',solid:'import { createEffect, createRoot, getOwner } from "solid-js";import { createStore } from "solid-js/store";'},u={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 d(e,t){return`${p[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);${u}`}export const localesModuleName="@app/locales";export const locales=new c({[localesModuleName]:d([],{})});let m={};async function z(e,o){let a=t(e).replace(/\.[^.]+$/,"");if("deleted"===o)delete m[a];else{let t=await import(r`${f(e)}`);Object.assign(m,{[a]:t.default})}let l=[],n={};for(let e in m)if(Object.prototype.hasOwnProperty.call(m,e)){let t=m[e],{language:o=a,title:r=o,icon:s,translation:c={}}=t;l.push({language:o,title:r,icon:s}),n[o]={language:o,title:r,icon:s,translation:c}}locales.setData(localesModuleName,d(l,n))}e(o(l.alias["@"],"./locales"))&&function(e,t){let o=[],l=a(e,{ignored:t,persistent:!0,ignoreInitial:!1});l.on("add",e=>{o.push(e),z(e,"added").finally(i)}),l.on("change",e=>{z(e,"change").finally(i)}),l.on("unlink",e=>{o.splice(o.indexOf(e),1),z(e,"deleted").finally(i)}),l.on("ready",()=>{o.forEach(e=>{z(e,"change").finally(i)})}),process.on("SIGINT",function(){l.close()})}(g(s?"site/locales":"src/locales"),[/^\..*/,/!\.ts$/,/\.d\.ts$/]);
|
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Options as AssetHtmlOptions } from 'add-asset-html-webpack-plugin';
|
|
|
2
2
|
import { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
|
|
3
3
|
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
4
4
|
import WebpackBar from 'webpackbar';
|
|
5
|
+
import DoneWebpackPlugin from '../lib/done';
|
|
5
6
|
import type { Options as MDXOptions } from '@mdx-js/loader';
|
|
6
7
|
import type { JsMinifyOptions, Config as SwcConfig } from '@swc/core';
|
|
7
8
|
import type { CssNanoOptionsExtended } from 'css-minimizer-webpack-plugin';
|
|
@@ -250,7 +251,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
250
251
|
}
|
|
251
252
|
| false;
|
|
252
253
|
/** 📦 打包完成 */
|
|
253
|
-
done?:
|
|
254
|
+
done?: ConstructorParameters<typeof DoneWebpackPlugin>[0];
|
|
254
255
|
mdx?: MDXOptions;
|
|
255
256
|
jsxDomExpressions?: {
|
|
256
257
|
moduleName?: string;
|