@moneko/core 3.30.0-beta.2 → 3.30.0-beta.3
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.mjs +5 -6
- package/package.json +1 -1
package/lib/vm/render-app.mjs
CHANGED
|
@@ -1,9 +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 o,SSR as a}from"../process-env.mjs";let n=t<18,s="hash"===e.routerMode,i=Object.assign({v7_relativeSplatPath:!1},"browser"===e.routerMode?{v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:a,v7_skipActionErrorRevalidation:!1}:{}),c=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
4
|
import ReactDOM from '${n?"react-dom":"react-dom/client"}';
|
|
5
|
-
import { ${
|
|
6
|
-
import { RouterProvider } from 'react-router${n?"-dom":"/dom"}';
|
|
5
|
+
${n?`import { RouterProvider, ${c} } from 'react-router-dom';`:`import { ${c} } from 'react-router';import { RouterProvider } from 'react-router/dom';`}
|
|
7
6
|
|
|
8
7
|
type RenderAppProps = {
|
|
9
8
|
container?: HTMLElement;
|
|
@@ -13,11 +12,11 @@ type RenderAppProps = {
|
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
export function App(props: RenderAppProps) {
|
|
16
|
-
const v7Future = useRef(${JSON.stringify(
|
|
15
|
+
const v7Future = useRef(${JSON.stringify(i)});
|
|
17
16
|
return (
|
|
18
17
|
<StrictMode>
|
|
19
18
|
<RouterProvider
|
|
20
|
-
router={${
|
|
19
|
+
router={${c}(routes, {
|
|
21
20
|
basename: ${s?"/":"props.basename"},
|
|
22
21
|
window: window,
|
|
23
22
|
future: v7Future.current,
|
|
@@ -36,7 +35,7 @@ function renderApp(props: RenderAppProps = {}) {
|
|
|
36
35
|
const { container, basename = "${e.basename}", language, ...args } = props;
|
|
37
36
|
const _container = container?.querySelector('#root') || document.getElementById('root');
|
|
38
37
|
${"micro"===r?"window.mainApp = { ...args, container: _container as HTMLElement };":""}
|
|
39
|
-
${n?`ReactDOM.${
|
|
38
|
+
${n?`ReactDOM.${o?"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;"}
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
export default renderApp;`;export default p;
|