@moneko/core 3.0.0-beta.93 → 3.0.0-beta.95
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/routes.d.ts +2 -0
- package/lib/routes.js +1 -1
- package/lib/virtual-modules.js +1 -1
- package/package.json +1 -1
package/lib/routes.d.ts
CHANGED
|
@@ -9,5 +9,7 @@ type BaseRoute = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const exampleModule = "@app/example";
|
|
11
11
|
export declare const routesModule = "@app/routes";
|
|
12
|
+
export declare let exampleModuleValue: string;
|
|
13
|
+
export declare let routesModuleValue: string;
|
|
12
14
|
export declare let routes: BaseRoute[];
|
|
13
15
|
export {};
|
package/lib/routes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e,t;import{readFileSync as
|
|
1
|
+
let e,t;import{readFileSync as o,readdirSync as r,statSync as l}from"fs";import{join as s,relative as n}from"path";import{watch as i}from"chokidar";import{load as u}from"js-yaml";import{APPTYPE as p,DEV as a,FRAMEWORK as m,PROGRAMPATH as c}from"./process-env.js";import{resolveNodeModulesPath as d}from"./utils.js";import{vm as f}from"./virtual-module-plugin.js";let x=/^---\n([\s\S]+?)\n---\n/;function g(e,t){let{regex:i,alia:p,base:a=e,outputSource:m}=t,c=r(e);return c.reduce((r,c)=>{let d=s(e,c),f=l(d);if(f.isDirectory()){let e=g(d,{...t,base:a});if(e.length>0){let t={},o={path:c,key:n(a,d)};if(m)Object.assign(t,{children:e});else{let r=e.splice(0,1)[0];e.length?Object.assign(t,{children:[{...r,path:"/",key:o.key},...e]}):Object.assign(t,r)}r.push(Object.assign(t,o))}}else if(i.test(d)){let e=o(d,{encoding:"utf-8"}),t=function(e){let t=e.match(x);return t&&t[1]?t[1].trim():null}(e),l=t?u(t):{},i=n(a,d);r.push(Object.assign({path:c,key:i,meta:{...l}},p&&{component:`rr(() => import(/* webpackChunkName: '${i}' */'${s(p,i)}'))rr`},m&&{codes:function(e){let t;let o={},r=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=r.exec(e));){let[,e="jsx",r]=t,l=e.split(" ").pop()||"jsx";o[l]=r.trim()}return Object.keys(o).length?o:{jsx:e}}(e.replace(x,"").replace(/^\n+|\n+$/g,""))}))}return r},[])}let h=s(c,"./components");export const exampleModule="@app/example";export const routesModule="@app/routes";export let exampleModuleValue="export default []";export let routesModuleValue="export default []";export let routes=[];function $(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e);let t={react:"createElement","solid-js":"createComponent"}[m],o=`() => ${t}(SuspenseComp, { comp: $1 })`,r=`import { ${t} } from "${m}";import { SuspenseComp } from "@moneko/${m}";`;["react","solid-js"].includes(m)||(o="$1",r=""),routes=g(h,{regex:/README\.mdx?$/,alia:"@pkg"});let l=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,o);routesModuleValue=`${r}export default ${l}`,f?.writeModule(d(routesModule),routesModuleValue)},100)}function j(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),g(h,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).forEach(e=>{let t=[exampleModule,e.key].filter(Boolean).join("/"),o=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);exampleModuleValue=`export default ${JSON.stringify(o)};`,f?.writeModule(d(t),exampleModuleValue)})},100)}function M(e,t,o){let r=i(e,{ignored:(e,o)=>{if(o)return!o?.isDirectory()&&t.test(e)},persistent:!0});r.on("add",()=>{o()}).on("change",()=>{o()}).on("unlink",()=>{o()}),process.on("SIGINT",function(){r.close()})}"library"===p&&(a?(M(h,/(?<!README\.mdx?)$/,$),M(h,/(?<!\/examples\/(.+)\.md)$/,j)):($(),j()));
|
package/lib/virtual-modules.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as o,constants as p}from"fs";import{join as
|
|
1
|
+
import{accessSync as o,constants as p}from"fs";import{join as a}from"path";import t from"./app.js";import{CONFIG as r}from"./common.js";import{coverage as e}from"./coverage.js";import{APPTYPE as m,PROGRAMPATH as l}from"./process-env.js";import{exampleModule as s,exampleModuleValue as c,routesModule as f,routesModuleValue as i}from"./routes.js";let b={...r.virtualModule,"@app":t,"@app/fallback":"export default null",[f]:i};if(r.fallbackCompPath&&Object.assign(b,{"@app/fallback":`import Fallback from "${r.fallbackCompPath}";export default Fallback;`}),"library"===m){let t={};try{let r=a(l,"./site/mdx-scope.ts");o(r,p.R_OK),t='import scope from "@/mdx-scope";export default scope;'}catch(o){t={}}Object.assign(b,{"@app/coverage":e,"@app/mdx-scope":t,[s]:c})}export default b;
|