@moneko/core 3.30.0-beta.1 → 3.30.0-beta.2
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/render-app.d.mts +1 -0
- package/lib/vm/render-app.mjs +9 -8
- package/package.json +1 -1
- package/typings/global.d.ts +2 -3
package/lib/vm/render-app.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CONFIG } from '../config.mjs';
|
|
2
2
|
import { APPTYPE, frameworkVersion, isDev, SSR } from '../process-env.mjs';
|
|
3
|
+
declare const legend: boolean;
|
|
3
4
|
declare const ReactDomPath: string;
|
|
4
5
|
declare const isHashRouter: boolean;
|
|
5
6
|
declare const v7Future: Record<string, boolean | undefined>;
|
package/lib/vm/render-app.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import{CONFIG as e}from"../config.mjs";import{APPTYPE as r,frameworkVersion as t,isDev as a,SSR as
|
|
1
|
+
import{CONFIG as e}from"../config.mjs";import{APPTYPE as r,frameworkVersion as t,isDev as a,SSR as o}from"../process-env.mjs";let n=t<18,s="hash"===e.routerMode,c=Object.assign({v7_relativeSplatPath:!1},"browser"===e.routerMode?{v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:o,v7_skipActionErrorRevalidation:!1}:{}),i=s?"createHashRouter":"createBrowserRouter",p=`import React, { StrictMode, useRef, type ReactElement } from 'react';
|
|
2
2
|
import Fallback from '@app/fallback';
|
|
3
3
|
import routes from '@app/routes';
|
|
4
|
-
import ReactDOM from '${
|
|
5
|
-
import {
|
|
4
|
+
import ReactDOM from '${n?"react-dom":"react-dom/client"}';
|
|
5
|
+
import { ${i} } from 'react-router';
|
|
6
|
+
import { RouterProvider } from 'react-router${n?"-dom":"/dom"}';
|
|
6
7
|
|
|
7
8
|
type RenderAppProps = {
|
|
8
9
|
container?: HTMLElement;
|
|
@@ -12,12 +13,12 @@ type RenderAppProps = {
|
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export function App(props: RenderAppProps) {
|
|
15
|
-
const v7Future = useRef(${JSON.stringify(
|
|
16
|
+
const v7Future = useRef(${JSON.stringify(c)});
|
|
16
17
|
return (
|
|
17
18
|
<StrictMode>
|
|
18
19
|
<RouterProvider
|
|
19
|
-
router={${
|
|
20
|
-
basename: ${
|
|
20
|
+
router={${i}(routes, {
|
|
21
|
+
basename: ${s?"/":"props.basename"},
|
|
21
22
|
window: window,
|
|
22
23
|
future: v7Future.current,
|
|
23
24
|
})}
|
|
@@ -35,7 +36,7 @@ function renderApp(props: RenderAppProps = {}) {
|
|
|
35
36
|
const { container, basename = "${e.basename}", language, ...args } = props;
|
|
36
37
|
const _container = container?.querySelector('#root') || document.getElementById('root');
|
|
37
38
|
${"micro"===r?"window.mainApp = { ...args, container: _container as HTMLElement };":""}
|
|
38
|
-
${
|
|
39
|
+
${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;"}
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
export default renderApp;`;export default
|
|
42
|
+
export default renderApp;`;export default p;
|
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -335,9 +335,8 @@ export declare type ConfigType = {
|
|
|
335
335
|
* // 导出 react 和 react-dom
|
|
336
336
|
* 'react',
|
|
337
337
|
* 'react-dom',
|
|
338
|
-
* // 导出 react-router
|
|
338
|
+
* // 导出 react-router
|
|
339
339
|
* 'react-router',
|
|
340
|
-
* 'react-router-dom',
|
|
341
340
|
* // 导出 Button 组件
|
|
342
341
|
* './Button': './src/components/Button'
|
|
343
342
|
* }
|
|
@@ -351,7 +350,7 @@ export declare type ConfigType = {
|
|
|
351
350
|
* name: 'demo_mf_name',
|
|
352
351
|
* host: 'http://localhost:3001/remoteEntry.js',
|
|
353
352
|
* // 引用远程模块的依赖
|
|
354
|
-
* library: ['react', 'react-dom', 'react-router'
|
|
353
|
+
* library: ['react', 'react-dom', 'react-router'],
|
|
355
354
|
* }
|
|
356
355
|
* ]
|
|
357
356
|
* }
|