@moneko/core 3.30.7 → 3.31.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/vm/example.d.mts +1 -2
- package/lib/vm/example.mjs +1 -1
- package/lib/vm/render-app.d.mts +0 -1
- package/lib/vm/render-app.mjs +5 -10
- package/lib/vm/routes.d.mts +1 -2
- package/lib/vm/routes.mjs +1 -1
- package/package.json +1 -1
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
|
@@ -3,7 +3,6 @@ import { APPTYPE, frameworkVersion, isDev, SSR } 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 v7Future: Record<string, boolean | undefined>;
|
|
7
6
|
declare const createRouter: string;
|
|
8
7
|
declare const renderApp: string;
|
|
9
8
|
export default renderApp;
|
package/lib/vm/render-app.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{CONFIG as e}from"../config.mjs";import{APPTYPE as r,frameworkVersion as t,isDev as
|
|
1
|
+
import{CONFIG as e}from"../config.mjs";import{APPTYPE as r,frameworkVersion as t,isDev as a}from"../process-env.mjs";let n=t<18,o="hash"===e.routerMode,c=o?"createHashRouter":"createBrowserRouter",p=`import React, { StrictMode, type ReactElement } from 'react';
|
|
2
2
|
import Fallback from '@app/fallback';
|
|
3
3
|
import routes from '@app/routes';
|
|
4
4
|
import ReactDOM from '${n?"react-dom":"react-dom/client"}';
|
|
5
|
-
|
|
5
|
+
import { RouterProvider, ${c} } from 'react-router-dom';
|
|
6
6
|
|
|
7
7
|
type RenderAppProps = {
|
|
8
8
|
container?: HTMLElement;
|
|
@@ -15,15 +15,10 @@ export function App(props: RenderAppProps) {
|
|
|
15
15
|
return (
|
|
16
16
|
<${e.strict?"StrictMode":""}>
|
|
17
17
|
<RouterProvider
|
|
18
|
-
router={${
|
|
19
|
-
basename: ${
|
|
18
|
+
router={${c}(routes, {
|
|
19
|
+
basename: ${o?"/":"props.basename"},
|
|
20
20
|
window: window,
|
|
21
|
-
future: ${JSON.stringify(c)},
|
|
22
21
|
})}
|
|
23
|
-
future={{
|
|
24
|
-
/** 这使用 useTransition 而不是 useState 来更新路由器状态 */
|
|
25
|
-
v7_startTransition: ${!n},
|
|
26
|
-
}}
|
|
27
22
|
fallbackElement={Fallback && <Fallback />}
|
|
28
23
|
/>
|
|
29
24
|
</${e.strict?"StrictMode":""}>
|
|
@@ -34,7 +29,7 @@ function renderApp(props: RenderAppProps = {}) {
|
|
|
34
29
|
const { container, basename = "${e.basename}", language, ...args } = props;
|
|
35
30
|
const _container = container?.querySelector('#root') || document.getElementById('root');
|
|
36
31
|
${"micro"===r?"window.mainApp = { ...args, container: _container as HTMLElement };":""}
|
|
37
|
-
${n?`ReactDOM.${
|
|
32
|
+
${n?`ReactDOM.${a?"render":"hydrate"}(<App basename={basename} language={language} />, _container);return () => ReactDOM.unmountComponentAtNode(_container as Element);`:"const instance = ReactDOM.createRoot(_container as HTMLElement);instance.render(<App basename={basename} language={language} />);return instance.unmount;"}
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
export default renderApp;`;export default p;
|
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);
|