@moneko/core 3.9.17-beta.19 → 3.9.17-beta.20
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/reactive-object.mjs +1 -1
- package/lib/utils/run.d.mts +2 -0
- package/lib/utils/run.mjs +1 -0
- package/lib/vm/docs.mjs +1 -1
- package/lib/vm/locales.mjs +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"events";class e extends t{constructor(t={}){super(),this.data=t}setData(t,e){
|
|
1
|
+
import t from"events";class e extends t{constructor(t={}){super(),this.data=t}setData(t,e){this.data[t]=e,this.emit("change",t,e)}getData(t){return this.data[t]}removeData(t){Object.prototype.hasOwnProperty.call(this.data,t)&&(delete this.data[t],this.emit("change",t,null))}[Symbol.iterator](){let t=Object.keys(this.data),e=0;return{next:()=>{if(e<t.length){let a=t[e++];return{value:[a,this.data[a]],done:!1}}return{value:void 0,done:!0}}}}}export default e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"vm";export default function(n,r){return e.runInThisContext(n||"",{filename:r,lineOffset:0,columnOffset:0,displayErrors:!0})}
|
package/lib/vm/docs.mjs
CHANGED
|
@@ -1 +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 s,isSolid as m}from"../process-env.mjs";import p from"../utils/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}${m?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[n]}${m?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${s?"() =>":""}${l}(${m?"Dynamic":"'n-md'"}, {text: res.default, ${m?"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,`${p}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
|
|
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 s,isSolid as m}from"../process-env.mjs";import p from"../utils/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}${m?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[n]}${m?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${s?"() =>":""}${l}(${m?"Dynamic":"'n-md'"}, {text: res.default, ${m?"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,`${p}export default ${JSON.stringify(s).replace(/"rr\((.+?)\)rr"/g,"$1")}`)};comment.on("change",(e,t)=>{c(e,t?.length<0)}),t(r.alias["@pkg"],["\\.tsx?$"]).filter(e=>!/(^|\/)\.[^\\/\\.]|\.test\./i.test(e)).forEach(t=>{let r=e(t);r&&comment.setData(getCommentPath(t),o(r,t))})}
|
package/lib/vm/locales.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
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"../utils/esm.mjs";import i from"../utils/reactive-object.mjs";import g from"../utils/tfc.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 i({[localesModuleName]:p([],{})});let m={};async function d(t,o){let a=e(t).replace(/\.[^.]+$/,"");"deleted"===o?delete m[a]:Object.assign(m,{[a]:(await import(c`${g(t)}`)).default});let l=[],r={};for(let e in m)if(Object.prototype.hasOwnProperty.call(m,e)){let{language:t=a,title:o=t,icon:n,translation:s={}}=m[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)
|
|
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 i({[localesModuleName]:p([],{})});let m={};async function d(t,o){let a=e(t).replace(/\.[^.]+$/,"");"deleted"===o?delete m[a]:Object.assign(m,{[a]:(await import(c`${g(t)}`)).default});let l=[],r={};for(let e in m)if(Object.prototype.hasOwnProperty.call(m,e)){let{language:t=a,title:o=t,icon:n,translation:s={}}=m[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");if(o(z)){let e=a(z,[".ts$"]).filter(e=>!/^\..*|\.d\.ts$/.test(e));await Promise.all(e.map(e=>d(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=>{d(e,"added")}),o.on("change",e=>{d(e,"change")}),o.on("unlink",e=>{d(e,"deleted")}),o.once("ready",()=>{s||a()}),process.on("SIGINT",a)}(z,[/^\..*/,/!\.ts$/,/\.d\.ts$/])}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.9.17-beta.
|
|
3
|
+
"version": "3.9.17-beta.20",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"author": "moneko",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@moneko/mdx": "0.1.
|
|
17
|
+
"@moneko/mdx": "0.1.25",
|
|
18
18
|
"@swc/core": "1.3.101",
|
|
19
19
|
"add-asset-html-webpack-plugin": "6.0.0",
|
|
20
20
|
"chokidar": "3.5.3",
|