@moneko/core 3.30.7 → 3.32.0
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/dev.d.mts +0 -4
- package/lib/vm/example.d.mts +1 -2
- package/lib/vm/example.mjs +1 -1
- package/lib/vm/render-app.d.mts +4 -3
- package/lib/vm/render-app.mjs +12 -22
- package/lib/vm/routes.d.mts +1 -2
- package/lib/vm/routes.mjs +1 -1
- package/package.json +1 -1
package/lib/dev.d.mts
CHANGED
|
@@ -51,9 +51,5 @@ declare const _prev: ConfigType[];
|
|
|
51
51
|
declare let prev: ConfigType;
|
|
52
52
|
declare function watchConfig(filepath: string);
|
|
53
53
|
declare function restart();
|
|
54
|
-
interface Command {
|
|
55
|
-
command: string;
|
|
56
|
-
args: string[];
|
|
57
|
-
}
|
|
58
54
|
declare const isWindow: boolean;
|
|
59
55
|
declare function killPort(port: number);
|
package/lib/vm/example.d.mts
CHANGED
|
@@ -4,10 +4,9 @@ import paths from '../commom/paths.mjs';
|
|
|
4
4
|
import ReactiveObject from '../commom/reactive-object.mjs';
|
|
5
5
|
import Rule from '../commom/rule.mjs';
|
|
6
6
|
import { CONFIG } from '../config.mjs';
|
|
7
|
-
import {
|
|
7
|
+
import { isDev, isLibrary } from '../process-env.mjs';
|
|
8
8
|
import { watchFiles } from './utils.mjs';
|
|
9
9
|
export declare const exampleModuleName: string;
|
|
10
|
-
declare const legend: boolean;
|
|
11
10
|
declare function getExample();
|
|
12
11
|
export declare const examples: ReactiveObject<Record<string, string>>;
|
|
13
12
|
export declare function generatorExample();
|
package/lib/vm/example.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{generateExample as e}from"@moneko/mdx";import o from"../commom/parse-module-meta.mjs";import t from"../commom/paths.mjs";import m from"../commom/reactive-object.mjs";import r from"../commom/rule.mjs";import{CONFIG as p}from"../config.mjs";import{
|
|
1
|
+
import{generateExample as e}from"@moneko/mdx";import o from"../commom/parse-module-meta.mjs";import t from"../commom/paths.mjs";import m from"../commom/reactive-object.mjs";import r from"../commom/rule.mjs";import{CONFIG as p}from"../config.mjs";import{isDev as a,isLibrary as l}from"../process-env.mjs";import{watchFiles as n}from"./utils.mjs";export const exampleModuleName="@app/example";function s(){if(!l||!1===p.htmlPluginOption)return{};let m=JSON.parse(e(t.componentsPath,`${exampleModuleName}/`,"6")),a={};for(let e in m)Object.prototype.hasOwnProperty.call(m,e)&&Object.assign(a,{[e]:`rr(() => import('${e}'))rr`});let n={...m,[exampleModuleName]:`export default ${JSON.stringify(a).replace(r.extract_func,"$1")}`},s={};for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e)){let{file:t,pkg:m,meta:r}=o(e);s[m]=r,s[t]=n[e]}return s}export const examples=new m(s());export function generatorExample(){let e=s();for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&examples.setData(o,e[o])}l&&a&&!1!==p.htmlPluginOption&&n(t.componentsPath,/(?<!\/examples\/(.+)\.md)$/,generatorExample);
|
package/lib/vm/render-app.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CONFIG } from '../config.mjs';
|
|
2
|
-
import { APPTYPE, frameworkVersion, isDev
|
|
2
|
+
import { APPTYPE, frameworkVersion, isDev } from '../process-env.mjs';
|
|
3
3
|
declare const legend: boolean;
|
|
4
4
|
declare const ReactDomPath: string;
|
|
5
5
|
declare const isHashRouter: boolean;
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
6
|
+
declare const Router: string;
|
|
7
|
+
declare const StrictMode: string;
|
|
8
|
+
declare const Root: string;
|
|
8
9
|
declare const renderApp: string;
|
|
9
10
|
export default renderApp;
|
package/lib/vm/render-app.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import{CONFIG as e}from"../config.mjs";import{APPTYPE as
|
|
2
|
-
|
|
1
|
+
import{CONFIG as e}from"../config.mjs";import{APPTYPE as t,frameworkVersion as r,isDev as o}from"../process-env.mjs";let n=r<18,a="hash"===e.routerMode,c=a?"HashRouter":"BrowserRouter",p=e.strict?"StrictMode":"",s=`<${p}>
|
|
2
|
+
<${c} basename={${a?"/":"basename"}} window={window}>
|
|
3
|
+
<App />
|
|
4
|
+
</${c}>
|
|
5
|
+
</${p}>`,m=`import React, { StrictMode, type ReactElement } from 'react';
|
|
3
6
|
import routes from '@app/routes';
|
|
4
7
|
import ReactDOM from '${n?"react-dom":"react-dom/client"}';
|
|
5
|
-
|
|
8
|
+
import { ${c}, useRoutes } from 'react-router-dom';
|
|
6
9
|
|
|
7
10
|
type RenderAppProps = {
|
|
8
11
|
container?: HTMLElement;
|
|
@@ -12,29 +15,16 @@ type RenderAppProps = {
|
|
|
12
15
|
};
|
|
13
16
|
|
|
14
17
|
export function App(props: RenderAppProps) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
router={${s}(routes, {
|
|
19
|
-
basename: ${i?"/":"props.basename"},
|
|
20
|
-
window: window,
|
|
21
|
-
future: ${JSON.stringify(c)},
|
|
22
|
-
})}
|
|
23
|
-
future={{
|
|
24
|
-
/** 这使用 useTransition 而不是 useState 来更新路由器状态 */
|
|
25
|
-
v7_startTransition: ${!n},
|
|
26
|
-
}}
|
|
27
|
-
fallbackElement={Fallback && <Fallback />}
|
|
28
|
-
/>
|
|
29
|
-
</${e.strict?"StrictMode":""}>
|
|
30
|
-
);
|
|
18
|
+
const router = useRoutes(routes);
|
|
19
|
+
|
|
20
|
+
return router;
|
|
31
21
|
}
|
|
32
22
|
|
|
33
23
|
function renderApp(props: RenderAppProps = {}) {
|
|
34
24
|
const { container, basename = "${e.basename}", language, ...args } = props;
|
|
35
25
|
const _container = container?.querySelector('#root') || document.getElementById('root');
|
|
36
|
-
${"micro"===
|
|
37
|
-
${n?`ReactDOM.${o?"render":"hydrate"}(
|
|
26
|
+
${"micro"===t?"window.mainApp = { ...args, container: _container as HTMLElement };":""}
|
|
27
|
+
${n?`ReactDOM.${o?"render":"hydrate"}(${s}, _container);return () => ReactDOM.unmountComponentAtNode(_container as Element);`:`const instance = ReactDOM.createRoot(_container as HTMLElement);instance.render(${s});return instance.unmount;`}
|
|
38
28
|
}
|
|
39
29
|
|
|
40
|
-
export default renderApp;`;export default
|
|
30
|
+
export default renderApp;`;export default m;
|
package/lib/vm/routes.d.mts
CHANGED
|
@@ -3,14 +3,13 @@ import parseModuleMeta, { type ModuleMeta } from '../commom/parse-module-meta.mj
|
|
|
3
3
|
import { routeDir } from '../commom/paths.mjs';
|
|
4
4
|
import ReactiveObject from '../commom/reactive-object.mjs';
|
|
5
5
|
import { CONFIG } from '../config.mjs';
|
|
6
|
-
import { FRAMEWORK,
|
|
6
|
+
import { FRAMEWORK, isDev, isLibrary } from '../process-env.mjs';
|
|
7
7
|
import { watchFiles } from './utils.mjs';
|
|
8
8
|
declare const routerAlia: '@pkg' | '@/pages';
|
|
9
9
|
declare const moduleMeta: ModuleMeta;
|
|
10
10
|
export declare const routesModuleName: string;
|
|
11
11
|
export declare const routesModulePkgJson: string;
|
|
12
12
|
export declare const routesModuleMeta: string;
|
|
13
|
-
declare const legend: boolean;
|
|
14
13
|
declare function getRouter();
|
|
15
14
|
export declare const route: ReactiveObject<{
|
|
16
15
|
[x: string]: string;
|
package/lib/vm/routes.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{generateRouter as o}from"@moneko/mdx";import e from"../commom/parse-module-meta.mjs";import{routeDir as t}from"../commom/paths.mjs";import r from"../commom/reactive-object.mjs";import{CONFIG as m}from"../config.mjs";import{FRAMEWORK as s,
|
|
1
|
+
import{generateRouter as o}from"@moneko/mdx";import e from"../commom/parse-module-meta.mjs";import{routeDir as t}from"../commom/paths.mjs";import r from"../commom/reactive-object.mjs";import{CONFIG as m}from"../config.mjs";import{FRAMEWORK as s,isDev as u,isLibrary as n}from"../process-env.mjs";import{watchFiles as p}from"./utils.mjs";let a=n?"@pkg":"@/pages",i=e("@app/routes");export const routesModuleName=i.file;export const routesModulePkgJson=i.pkg;export const routesModuleMeta=i.meta;function l(){return!1===m.htmlPluginOption?"":o(t,`${m.alias["@"]}/router/index.ts`,s,a,n,"6")}export const route=new r({[routesModuleName]:l(),[routesModulePkgJson]:routesModuleMeta});export function generatorRouter(){route.setData(routesModuleName,l())}u&&p(t,n?/(?<!README\.mdx?)$/:/(?<!index\.tsx?)$/,generatorRouter);
|