@moneko/core 3.1.3 → 3.1.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/docs.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- export declare const docs: {
2
- data: Record<string, string>;
3
- listener: (callback: (next: Record<string, string>) => void) => () => void;
4
- };
1
+ import ReactiveObject from './reactive-object.js';
2
+ export declare const docs: ReactiveObject<Record<string, string | undefined>>;
package/lib/docs.js CHANGED
@@ -1,2 +1,2 @@
1
- import{statSync as e}from"fs";import{dirname as t,join as r}from"path";import{watch as o}from"chokidar";import{CONFIG as n}from"./config.js";import i from"./generate-api.js";import s from"./object-listener.js";import{FRAMEWORK as p,FRAMEWORKNAME as l,createElement as a,isLibrary as c,isReact as d,isSolid as m}from"./process-env.js";import{resolveProgramPath as f}from"./utils.js";let u="@app/comment";export const docs=s({});let $={[u]:{}},g=`() => ${a}(SuspenseComp, { comp: $1 })`,b=`import { ${a}${m?",Dynamic":""} } from "${l}${m?"/web":""}";import SuspenseComp from "@app/suspense";`;// 要执行的函数
2
- function h(e,o){let s=e.replace(RegExp(`^${n.alias["@pkg"]}`),""),p=t(s).replace(/^\//,""),l=[u,p].join("/"),c=s.split("/").pop()?.replace(/\.tsx?/,".md");if(!c)return;$[u][p]||($[u][p]={});let f=r(l,c);if("deleted"===o)$[u][p][c]&&delete $[u][p][c];else{let t=i(e);$[f]=t,t?$[u][p][c]=`rr(() => import(/* webpackChunkName: '${f}' */'${f}?raw').then((res) => ({default: ${d?"() =>":""}${a}(${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;}'})})))rr`:$[u][p][c]&&delete $[u][p][c]}let h={};for(let e in $[u])Object.prototype.hasOwnProperty.call($[u],e)&&(h[e]=Object.values($[u][e]));let x={...$};delete x[u],Object.assign(docs.data,{...x,"@app/docs":`${b}export default ${JSON.stringify(h).replace(/"rr\((.+?)\)rr"/g,g)}`})}["react","solid"].includes(p)||(g="$1",b=""),c&&function(){let t=[],r=o(f("components"),{ignored:[/(^|[\\/\\])\../,/(^|[\\/\\])__tests__([\\/\\]|$)/],persistent:!0,ignoreInitial:!1});function n(t){return/\.tsx?$/.test(t)&&e(t).isFile()}r.on("add",e=>{n(e)&&(h(e,"added"),t.push(e))}),r.on("change",e=>{n(e)&&h(e,"change")}),r.on("unlink",e=>{n(e)&&(h(e,"deleted"),t.splice(t.indexOf(e),1))}),r.on("ready",()=>{t.forEach(e=>{h(e,"change")})}),process.on("SIGINT",function(){r.close()})}();
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";`;// 要执行的函数
2
+ 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/locales.d.ts CHANGED
@@ -1,10 +1,5 @@
1
- export declare const locales: {
2
- data: {
3
- name: string;
4
- data: string;
5
- };
6
- listener: (callback: (next: {
7
- name: string;
8
- data: string;
9
- }) => void) => () => void;
10
- };
1
+ import ReactiveObject from './reactive-object.js';
2
+ export declare const localesModuleName = "@app/locales";
3
+ export declare const locales: ReactiveObject<{
4
+ "@app/locales": string;
5
+ }>;
package/lib/locales.js CHANGED
@@ -1,3 +1,3 @@
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 n from"./object-listener.js";import{FRAMEWORK as s,isLibrary as c}from"./process-env.js";import{resolveProgramPath as i,tfc as g}from"./utils.js";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;'}[s];export const locales=n({name:"@app/locales",data:"export const locales = [];"});let u={};// 要执行的函数
2
- async function d(e,o){let a=t(e).replace(/\.[^.]+$/,"");if("deleted"===o)delete u[a];else{let t=await import(r`${g(e)}`);Object.assign(u,{[a]:t.default})}let l=[],n={};for(let e in u)if(Object.prototype.hasOwnProperty.call(u,e)){let t=u[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}}Object.assign(locales.data,{data:`${f[s]}
3
- 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(l)};const _res = ${JSON.stringify(n)};const resources = deepFreeze(_res);${p}`})}e(o(l.alias["@"],"./locales"))&&function(e,t){let o=[],l=a(e,{ignored:t,persistent:!0,ignoreInitial:!1});l.on("add",e=>{d(e,"added"),o.push(e)}),l.on("change",e=>{d(e,"change")}),l.on("unlink",e=>{d(e,"deleted"),o.splice(o.indexOf(e),1)}),l.on("ready",()=>{o.forEach(e=>{d(e,"change")})}),process.on("SIGINT",function(){l.close()})}(i(c?"site/locales":"src/locales"),[/^\..*/,/!\.ts$/,/\.d\.ts$/]);
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 s,isLibrary as n}from"./process-env.js";import c from"./reactive-object.js";import{resolveProgramPath as i,tfc as g}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";'},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;'}[s];export const localesModuleName="@app/locales";export const locales=new c({[localesModuleName]:"export const locales = [];"});let u={};// 要执行的函数
2
+ async function d(e,o){let a=t(e).replace(/\.[^.]+$/,"");if("deleted"===o)delete u[a];else{let t=await import(r`${g(e)}`);Object.assign(u,{[a]:t.default})}let l=[],n={};for(let e in u)if(Object.prototype.hasOwnProperty.call(u,e)){let t=u[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,`${p[s]}
3
+ 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(l)};const _res = ${JSON.stringify(n)};const resources = deepFreeze(_res);${f}`)}e(o(l.alias["@"],"./locales"))&&function(e,t){let o=[],l=a(e,{ignored:t,persistent:!0,ignoreInitial:!1});l.on("add",e=>{d(e,"added"),o.push(e)}),l.on("change",e=>{d(e,"change")}),l.on("unlink",e=>{d(e,"deleted"),o.splice(o.indexOf(e),1)}),l.on("ready",()=>{o.forEach(e=>{d(e,"change")})}),process.on("SIGINT",function(){l.close()})}(i(n?"site/locales":"src/locales"),[/^\..*/,/!\.ts$/,/\.d\.ts$/]);
@@ -0,0 +1,11 @@
1
+ /// <reference types="node" />
2
+ import EventEmitter from 'events';
3
+ declare class ReactiveObject<T extends object = Record<string, string | undefined>> extends EventEmitter {
4
+ private data;
5
+ constructor(props?: T);
6
+ setData(key: keyof T, value: T[keyof T]): void;
7
+ getData(key: keyof T): T[keyof T];
8
+ removeData(key: keyof T): void;
9
+ [Symbol.iterator](): Iterator<[keyof T, T[keyof T]]>;
10
+ }
11
+ export default ReactiveObject;
@@ -0,0 +1,2 @@
1
+ import t from"events";class e extends t{constructor(t={}){super(),this.data=t}setData(t,e){e!==this.data[t]&&(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))}// 实现迭代器接口
2
+ [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;
package/lib/routes.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import ReactiveObject from './reactive-object.js';
1
2
  type BaseRoute = {
2
3
  path: string;
3
4
  key: string;
@@ -7,25 +8,11 @@ type BaseRoute = {
7
8
  codes?: Record<string, string>;
8
9
  order?: number;
9
10
  };
10
- export declare const route: {
11
- data: {
12
- name: string;
13
- data: string;
14
- };
15
- listener: (callback: (next: {
16
- name: string;
17
- data: string;
18
- }) => void) => () => void;
19
- };
20
- export declare const example: {
21
- data: {
22
- name: string;
23
- data: Record<string, string>;
24
- };
25
- listener: (callback: (next: {
26
- name: string;
27
- data: Record<string, string>;
28
- }) => void) => () => void;
29
- };
11
+ export declare const routesModuleName = "@app/routes";
12
+ export declare const route: ReactiveObject<{
13
+ "@app/routes": string;
14
+ }>;
15
+ export declare const exampleModuleName = "@app/example";
16
+ export declare const examples: ReactiveObject<Record<string, string | undefined>>;
30
17
  export declare let routes: BaseRoute[];
31
18
  export {};
package/lib/routes.js CHANGED
@@ -1,4 +1,4 @@
1
- let e,t;import{readFileSync as r,readdirSync as o,statSync as n}from"fs";import{join as s,relative as a}from"path";import{watch as i}from"chokidar";import{load as p}from"js-yaml";import{hasCustomRouter as l}from"./config.js";import c from"./object-listener.js";import m from"./paths.js";import{FRAMEWORK as u,FRAMEWORKNAME as f,createElement as d,isLibrary as g,isReact as h,isSolid as x}from"./process-env.js";let $=/^---\n([\s\S]+?)\n---\n/,j=x?"component":"element";function O(e){return e.replace(/\$/g,":").replace(/^index\.tsx?$/,"/").replace(/^README\.mdx?$/,"/")}function b(e,t){let{regex:i,alia:l,base:c=e,outputSource:m}=t,u=o(e);return u.reduce((o,u)=>{let f=s(e,u),d=n(f);if(d.isDirectory()){let e=b(f,{...t,base:c});if(e.length>0){let t={},r={path:O(u),key:O(a(c,f))};if(m)Object.assign(t,{children:e});else{let o=e.findIndex(e=>"/"===e.path||r.path===e.path),n=e.splice(o,1)[0];e.length?Object.assign(t,!x&&n,{children:[x&&{...n,path:r.path===n.path?"/":n.path},...e].filter(Boolean)}):Object.assign(t,n)}o.push(Object.assign(t,r))}}else if(i.test(f)){let e=r(f,{encoding:"utf-8"}),t=function(e){let t=e.match($);return t&&t[1]?t[1].trim():null}(e),n=t?p(t):{},i=a(c,f),u=O(i);o.push(Object.assign({path:u.split("/").slice(-2,-1)?.join("")||"/",key:u.replace(/\/?index.tsx?$/,"/").replace(/\/?README.mdx?$/,"/").split("/").filter(Boolean).join("/"),meta:{...n}},l&&{[j]:`rr(() => import(/* webpackChunkName: '${i}' */'${s(l,i)}'))rr`},m&&{codes:function(e){let t;let r={},o=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=o.exec(e));){let[,e="jsx",o]=t,n=e.split(" ").pop()||"jsx";r[n]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(e.replace($,"").replace(/^\n+|\n+$/g,""))}))}return o},[])}export const route=c({name:"@app/routes",data:"export default []"});export const example=c({name:"@app/example",data:{}});let y=`${x?"() => ":""}${d}(SuspenseComp, { comp: $1 })`,T=`import { ${d} } from "${f}";import SuspenseComp from "@app/suspense";${h?'import prefix from "@app/prefix-router";':""}`;l&&(T+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(u)||(y="$1",T="");export let routes=[];function k(e){return`${T}const routes = [{ path: "/", children: [${x?'{ path: "/" },':""} ${e}] }];const _routes = ${l?'merge([...routes, ...customRouter], "path")':"routes"};export default ${h?"prefix(_routes)":"_routes"};`}function E(e,t,r){let o=i(e,{ignored:(e,r)=>{if(r)return!r?.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});o.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),process.on("SIGINT",function(){o.close()})}g?(// router
2
- E(m.componentsPath,/(?<!README\.mdx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=b(m.componentsPath,{regex:/README\.mdx?$/,alia:"@pkg"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,y).slice(1,-1);Object.assign(route.data,{data:k(t)})},100)}),// demos
3
- E(m.componentsPath,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t);let e={};b(m.componentsPath,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).forEach(t=>{let r=[example.data.name,t.key].filter(Boolean).join("/"),o=t.children?.[0].children?.filter(e=>e.codes)?.map(e=>({title:e.path.replace(/.md$/,""),order:0,...e.meta,codes:e.codes})).sort((e,t)=>e.order-t.order);Object.assign(e,{[r]:`export default ${JSON.stringify(o)};`})}),Object.assign(example.data,{data:e})},100)})):// router
4
- E(m.pagesPath,/(?<!index\.tsx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=b(m.pagesPath,{regex:/index\.tsx?$/,alia:"@/pages"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,y).slice(1,-1);Object.assign(route.data,{data:k(t)})},100)});
1
+ let e,t;import{readFileSync as r,readdirSync as o,statSync as s}from"fs";import{join as n,relative as p}from"path";import{watch as i}from"chokidar";import{load as a}from"js-yaml";import{hasCustomRouter as l}from"./config.js";import c from"./paths.js";import{FRAMEWORK as m,FRAMEWORKNAME as u,createElement as f,isLibrary as d,isReact as x,isSolid as h}from"./process-env.js";import g from"./reactive-object.js";let $=/^---\n([\s\S]+?)\n---\n/,j=h?"component":"element";function y(e){return e.replace(/\$/g,":").replace(/^index\.tsx?$/,"/").replace(/^README\.mdx?$/,"/")}function N(e,t){let{regex:i,alia:l,base:c=e,outputSource:m}=t,u=o(e);return u.reduce((o,u)=>{let f=n(e,u),d=s(f);if(d.isDirectory()){let e=N(f,{...t,base:c});if(e.length>0){let t={},r={path:y(u),key:y(p(c,f))};if(m)Object.assign(t,{children:e});else{let o=e.findIndex(e=>"/"===e.path||r.path===e.path),s=e.splice(o,1)[0];e.length?Object.assign(t,!h&&s,{children:[h&&{...s,path:r.path===s.path?"/":s.path},...e].filter(Boolean)}):Object.assign(t,s)}o.push(Object.assign(t,r))}}else if(i.test(f)){let e=r(f,{encoding:"utf-8"}),t=function(e){let t=e.match($);return t&&t[1]?t[1].trim():null}(e),s=t?a(t):{},i=p(c,f),u=y(i);o.push(Object.assign({path:u.split("/").slice(-2,-1)?.join("")||"/",key:u.replace(/\/?index.tsx?$/,"/").replace(/\/?README.mdx?$/,"/").split("/").filter(Boolean).join("/"),meta:{...s}},l&&{[j]:`rr(() => import(/* webpackChunkName: '${i}' */'${n(l,i)}'))rr`},m&&{codes:function(e){let t;let r={},o=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=o.exec(e));){let[,e="jsx",o]=t,s=e.split(" ").pop()||"jsx";r[s]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(e.replace($,"").replace(/^\n+|\n+$/g,""))}))}return o},[])}export const routesModuleName="@app/routes";export const route=new g({[routesModuleName]:"export default []"});export const exampleModuleName="@app/example";export const examples=new g;let T=`${h?"() => ":""}${f}(SuspenseComp, { comp: $1 })`,k=`import { ${f} } from "${u}";import SuspenseComp from "@app/suspense";${x?'import prefix from "@app/prefix-router";':""}`;l&&(k+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(m)||(T="$1",k="");export let routes=[];function D(e){return`${k}const routes = [{ path: "/", children: [${h?'{ path: "/" },':""} ${e}] }];const _routes = ${l?'merge([...routes, ...customRouter], "path")':"routes"};export default ${x?"prefix(_routes)":"_routes"};`}function E(e,t,r){let o=i(e,{ignored:(e,r)=>{if(r)return!r.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});o.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),process.on("SIGINT",function(){o.close()})}d?(// router
2
+ E(c.componentsPath,/(?<!README\.mdx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=N(c.componentsPath,{regex:/README\.mdx?$/,alia:"@pkg"}),route.setData(routesModuleName,D(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,T).slice(1,-1)))},100)}),// demos
3
+ E(c.componentsPath,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),N(c.componentsPath,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).forEach(e=>{let t=["@app/example",e.key].filter(Boolean).join("/"),r=e.children?.[0].children?.filter(e=>e.codes)?.map(e=>({title:e.path.replace(/.md$/,""),order:0,...e.meta,codes:e.codes})).sort((e,t)=>e.order-t.order)||[];examples.setData(t,`export default ${JSON.stringify(r)};`)})},100)})):// router
4
+ E(c.pagesPath,/(?<!index\.tsx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=N(c.pagesPath,{regex:/index\.tsx?$/,alia:"@/pages"}),route.setData(routesModuleName,D(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,T).slice(1,-1)))},100)});
@@ -4,6 +4,7 @@ interface VirtualModulePluginOption {
4
4
  }
5
5
  declare class VirtualModulePlugin {
6
6
  private options;
7
+ private hasTapped;
7
8
  constructor(options: VirtualModulePluginOption);
8
9
  apply(compiler: Compiler): void;
9
10
  }
@@ -1 +1 @@
1
- import t from"webpack-virtual-modules";import{docs as e}from"./docs.js";import{locales as o}from"./locales.js";import{isLibrary as a}from"./process-env.js";import{example as l,route as r}from"./routes.js";import{resolveNodeModulesPath as i}from"./utils.js";let s={};function n(t,e,o){let a=i(e),l=s[a];null!==l&&clearTimeout(l),s[a]=setTimeout(()=>{null!==l&&clearTimeout(l),s[a]=null,t.getModuleList("all")[a]!==o&&t.writeModule(a,o)},12)}export default class{constructor(t){this.options=t}apply(s){let p=new t({[i(r.data.name)]:r.data.data,[i(l.data.name)]:"export default []",[i(o.data.name)]:o.data.data});r.listener(t=>{t.data&&n(p,t.name,t.data)}),o.listener(t=>{t.data&&n(p,t.name,t.data)}),a&&(l.listener(t=>{let e=t.data;for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&e[t]&&n(p,t,e[t])}),e.listener(t=>{for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&t[e]&&n(p,e,t[e])})),p.apply(s),s.hooks.compilation.tap("VirtualModulePlugin",()=>{for(let t in this.options)if(Object.prototype.hasOwnProperty.call(this.options,t)){let e=this.options[t];"string"==typeof e?n(p,t,e):n(p,t,`export default ${JSON.stringify(e)}`)}})}}
1
+ import o from"webpack-virtual-modules";import{docs as t}from"./docs.js";import{locales as e,localesModuleName as s}from"./locales.js";import{isLibrary as p}from"./process-env.js";import{exampleModuleName as r,examples as i,route as a,routesModuleName as l}from"./routes.js";import{resolveNodeModulesPath as n}from"./utils.js";export default class{constructor(o){this.options=o,this.hasTapped=!1}apply(f){let c=new o({[n(l)]:"export default []",[n(r)]:"export default []",[n(s)]:"export const locales = [];"});function h(o,t){c.writeModule(n(o),t||"")}c.apply(f),a.on("change",h),e.on("change",h),p&&(i.on("change",h),t.on("change",h)),f.hooks.compilation.tap("VirtualModulePlugin",()=>{if(!this.hasTapped){for(let o in this.options)if(Object.prototype.hasOwnProperty.call(this.options,o)){let t=this.options[o];h(o,"string"==typeof t?t:`export default ${JSON.stringify(t)}`)}for(let o of i)h(...o);for(let o of t)h(...o);this.hasTapped=!0}})}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -1,4 +0,0 @@
1
- export default function objectListener<T extends object>(initialData: T): {
2
- data: T;
3
- listener: (callback: (next: T) => void) => () => void;
4
- };
@@ -1 +0,0 @@
1
- export default function e(e){let t=[],n=new Proxy(e,{set:(e,n,r)=>(e[n]=r,t.forEach(t=>{t(e)}),!0)});return{data:n,listener:function(e){return t.push(e),()=>{let n=t.indexOf(e);-1!==n&&t.splice(n,1)}}}}