@moneko/core 3.24.5-beta.2 → 3.24.5-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/utils/parse-module-meta.mjs +1 -1
- package/lib/vm/docs.d.mts +1 -1
- package/lib/vm/docs.mjs +1 -1
- package/lib/vm/locales.d.mts +1 -1
- package/lib/vm/locales.mjs +2 -2
- package/lib/vm/modules.mjs +1 -1
- package/lib/vm/routes.d.mts +1 -1
- package/lib/vm/routes.mjs +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e}from"path";export default function(
|
|
1
|
+
import{join as e}from"path";import n from"../paths.mjs";export default function(t,a=1){let i=t.replace(/^\/|\/$/g,""),o=i,m="index.ts",d=i.match(/(.+)\/index\.([^/]+)$/),r=i.match(/(.+)\.([^/]+)$/);return d?(o=d[1],m=`index.${d[2]}`):r&&(o=r[1],m=`index.${r[2]}`),{name:o,main:m,pkg:e(n.nodeModules,o,"package.json"),file:e(n.nodeModules,o,m),meta:`{"name":"${o}","main":"${m}","version":"0.0.${a}","description": ""}`}}
|
package/lib/vm/docs.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ReactiveObject from '../utils/reactive-object.mjs';
|
|
2
|
-
export declare const docsModuleName
|
|
2
|
+
export declare const docsModuleName: string;
|
|
3
3
|
export declare const docs: ReactiveObject<Record<string, string>>;
|
|
4
4
|
export declare const comment: ReactiveObject<Record<string, string>>;
|
|
5
5
|
export declare const getCommentPath: (file: string) => string;
|
package/lib/vm/docs.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./generate-doc.mjs";import{CONFIG as t}from"../config.mjs";import{FRAMEWORK as o,isLibrary as a,isReact as
|
|
1
|
+
import e from"./generate-doc.mjs";import{CONFIG as t}from"../config.mjs";import{FRAMEWORK as o,isLibrary as a,isReact as r,isSolid as m}from"../process-env.mjs";import n from"../utils/reactive-object.mjs";import s from"../rule.mjs";import{loadFile as l,scanFolderSync as p}from"@moneko/utils";import c from"../utils/parse-module-meta.mjs";let i={react:"createElement",solid:"createComponent"}[o],{file:f,pkg:d,meta:u}=c("@app/docs");export const docsModuleName=f;export const docs=new n({[f]:"export default {}",[d]:u});export const comment=new n({});export const getCommentPath=function(){let e=/^\/?(.+?)\.tsx?$/,o=t.alias["@pkg"]?.length;return t=>t.substring(o).replace(e,"@app/comment/$1.md")}();if(a&&!1!==t.htmlPluginOption){let a={},n=`import { ${i}${m?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[o]}${m?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${r?"() =>":""}${i}(${m?"Dynamic":"'div'"}, {${m?"innerHTML: res.default, component: 'div', class: 'n-md-box' ":"dangerouslySetInnerHTML: {__html:res.default}, className: 'n-md-box'"} })};}`,d=(e,t)=>{let o=e.replace(/^@app\/comment\//,"").split("/"),r=o.pop(),m=o.join("/");a[m]||(a[m]={}),t?a[m][r]&&delete a[m][r]:a[m][r]=`rr(() => ${i}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let l={};for(let e in a)Object.prototype.hasOwnProperty.call(a,e)&&(l[e]=Object.values(a[e]));docs.setData(f,`${n}export default ${JSON.stringify(l).replace(s.extract_func,"$1")}`)};comment.on("change",(e,t)=>{d(e,t?.length<0)});let u=p(t.alias["@pkg"],["\\.tsx?$"]).filter(e=>!/(^|\/)\.[^\\/\\.]|\.test\./i.test(e));await Promise.all(u.map(async e=>({data:await l(e),file:e}))).then(t=>{for(let o=0;o<t.length;o++){let a=t[o];if(a.data){let{file:t,pkg:o,meta:r}=c(getCommentPath(a.file));comment.setData(t,e(a.data,a.file)),comment.setData(o,r)}}})}
|
package/lib/vm/locales.d.mts
CHANGED
package/lib/vm/locales.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{basename as e,join as t}from"path";import{watch as o}from"chokidar";import{CONFIG as a}from"../config.mjs";import{FRAMEWORK as l,isDev as r}from"../process-env.mjs";import
|
|
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"path";import{watch as o}from"chokidar";import{CONFIG as a}from"../config.mjs";import{FRAMEWORK as l,isDev as r}from"../process-env.mjs";import n from"../utils/reactive-object.mjs";import s from"../utils/sigint-exit.mjs";import{directoryExists as c,scanFolderSync as i}from"@moneko/utils";import g from"../utils/require.mjs";import u from"../utils/parse-module-meta.mjs";let f={react:'import sso from "shared-store-object";',solid:'import { createEffect, createRoot, getOwner } from "solid-js";import { createStore } from "solid-js/store";'},p={react:'let storageKey="localizable.language",language=localStorage.getItem(storageKey)||"zh_CN",{translation:a,...defaultLocale}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[language]||resources.zh_CN),localizable=sso({lang:defaultLocale,t:a});export function setLang(a){let{translation:e,...l}=resources[a]||{};e&&(localizable.lang=l,localizable.t=e,localStorage.setItem(storageKey,l.language))}export default localizable;',solid:'let locale=createRoot(()=>{let e="localizable.language",a=localStorage.getItem(e)||"zh_CN",{translation:l,...o}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[a]||resources.zh_CN),[n,c]=createStore({lang:o,t:l});return createEffect(()=>{let a=resources[n.lang.language]?.translation;a&&(c("t",a),localStorage.setItem(e,n.lang.language))}),{localizable:n,setLocalizable:c,setLang:function(e){let{translation:a,...l}=resources[e]||{};a&&c("lang",l)}}},getOwner());export const setLocalizable=locale.setLocalizable;export const t=locale.localizable.t;export const lang=locale.localizable.lang;export const setLang=locale.setLang;'}[l];function m(e,t){return`${f[l]}
|
|
2
|
+
export function template(r,n){return r.replace(/\\\${\\w+}/g,function(r){var t=r.slice(2,-1);var e=n[t];return e!==void 0?e.toString():""})}function deepFreeze(o) { const p = Reflect.ownKeys(o);for (const k of p) {const v = o[k];if ((v && typeof v === "object") || typeof v === "function") {deepFreeze(v);}}return Object.freeze(o);}export const locales = ${JSON.stringify(e)};const _res = ${JSON.stringify(t)};const resources = deepFreeze(_res);${p}`}let{file:d,pkg:z,meta:b}=u("@app/locales");export const localesModuleName=d;export const locales=new n({[d]:m([],{}),[z]:b});let h={};async function j(t,o){let a=e(t).replace(/\.[^.]+$/,"");"deleted"===o?delete h[a]:(delete g.cache[t],Object.assign(h,{[a]:g(t).default}));let l=[],r={};for(let e in h)if(Object.prototype.hasOwnProperty.call(h,e)){let{language:t=a,title:o=t,icon:n,translation:s={}}=h[e];l.push({language:t,title:o,icon:n}),r[t]={language:t,title:o,icon:n,translation:s}}locales.setData(d,m(l,r)),locales.setData(z,b)}let y=t(a.alias["@"],"./locales");if(c(y)&&!1!==a.htmlPluginOption){let e=i(y,[".ts$"]).filter(e=>!/^\..*|\.d\.ts$/.test(e));await Promise.all(e.map(e=>j(e,"added"))),r&&function(e,t){let a=o(e,{ignored:t,persistent:!0,ignoreInitial:!0});function l(){a.unwatch(e),a.close()}a.on("add",e=>{j(e,"added")}),a.on("change",e=>{j(e,"change")}),a.on("unlink",e=>{j(e,"deleted")}),a.once("ready",()=>{r||l()}),s(l)}(y,[/^\..*/,/!\.ts$/,/\.d\.ts$/])}
|
package/lib/vm/modules.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as
|
|
1
|
+
import{join as t}from"path";import{getAppEntry as e,getAppFallback as p,getAppMdxScope as o,getAppMergeRouter as r,getAppNormalizeCss as m,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as i}from"@moneko/mdx";import f from"./coverage.mjs";import{docs as l,docsModuleName as n}from"./docs.mjs";import d from"./info.mjs";import{locales as u,localesModuleName as x}from"./locales.mjs";import{route as j,routesModuleName as c}from"./routes.mjs";import{CONFIG as g}from"../config.mjs";import v from"../paths.mjs";import{APPTYPE as y,FRAMEWORK as h}from"../process-env.mjs";import{node_modules as k}from"../utils/index.mjs";import{generateDeclaration as O}from"../utils/dts.mjs";import S from"../utils/has-pkg.mjs";import{updateFileSync as b}from"@moneko/utils";import z from"../plugin/module-federation.mjs";import D from"../utils/create-types.mjs";import J from"../rule.mjs";import N from"../utils/parse-module-meta.mjs";let $=S(t(g.alias["@"],"./mdx-scope.tsx"))||S(t(g.alias["@"],"./mdx-scope.ts")),C={"@app/env.ts":`export default ${JSON.stringify(g.env)}`,"@app/info.ts":`export default ${JSON.stringify(d)}`,"@app/entry.ts":e(t(g.alias["@"],"./index.ts"),!!z.length,!!g.rem,!!g.normalizeCss,y,h),"@app/rem":a(g.rem?.designSize||1680),"@app/fallback":p(g.fallbackCompPath),"@app/coverage":f(v.coveragePath),"@app/merge-router":r(),"@app/prefix-router":s(),"@app/normalize/index.css":m(),"@app/suspense/index.tsx":i(y,h),"@app/mdx-scope.tsx":$?o($):"export default {}",[c]:j.getData(c),[x]:u.getData(x),[n]:l.getData(n)};b(k("@types/@app/index.d.ts"),["@app/env.ts","@app/info.ts","@app/entry.ts","@app/mdx-scope.tsx"].map(t=>D(t.replace(J.js,""),O(C[t],t))).join("\n")),b(k("@types/@vm/index.d.ts"),Object.keys(g.virtualModule).map(t=>{let e=g.virtualModule[t],{file:p}=N(t);return D(p.replace(J.js,""),O("string"==typeof e?e:`export default ${JSON.stringify(e)}`,p))}).join("\n"));export default C;
|
package/lib/vm/routes.d.mts
CHANGED
package/lib/vm/routes.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{generateRouter as t}from"@moneko/mdx";import{watchFiles as o}from"./utils.mjs";import{CONFIG as
|
|
1
|
+
import{generateRouter as t}from"@moneko/mdx";import{watchFiles as o}from"./utils.mjs";import{CONFIG as r}from"../config.mjs";import{routeDir as e}from"../paths.mjs";import{FRAMEWORK as m,isDev as s,isLibrary as i}from"../process-env.mjs";import p from"../utils/reactive-object.mjs";import n from"../utils/parse-module-meta.mjs";let u=i?"@pkg":"@/pages",{file:a,pkg:f,meta:l}=n("@app/routes");export const routesModuleName=a;function c(){return!1===r.htmlPluginOption?"":t(e,`${r.alias["@"]}/router/index.ts`,m,u,i)}export const route=new p({[a]:c(),[f]:l});export function generatorRouter(){route.setData(a,c()),route.setData(f,l)}s&&o(e,i?/(?<!README\.mdx?)$/:/(?<!index\.tsx?)$/,generatorRouter);
|