create-bluecopa-react-app 1.0.4 → 1.0.6
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/README.md +47 -10
- package/bin/create-bluecopa-react-app.js +257 -51
- package/package.json +6 -5
- package/templates/latest/Agent.md +254 -0
- package/templates/latest/Dockerfile +22 -0
- package/templates/latest/README.md +157 -221
- package/templates/latest/app/app.css +134 -0
- package/templates/latest/app/app.tsx +46 -0
- package/templates/latest/app/components/app-sidebar.tsx +174 -0
- package/templates/latest/app/components/chart-area-interactive.tsx +290 -0
- package/templates/latest/app/components/data-table.tsx +807 -0
- package/templates/latest/app/components/nav-documents.tsx +92 -0
- package/templates/latest/app/components/nav-main.tsx +56 -0
- package/templates/latest/app/components/nav-secondary.tsx +42 -0
- package/templates/latest/app/components/nav-user.tsx +112 -0
- package/templates/latest/app/components/section-cards.tsx +102 -0
- package/templates/latest/app/components/site-header.tsx +19 -0
- package/templates/latest/app/components/ui/avatar.tsx +53 -0
- package/templates/latest/app/components/ui/badge.tsx +46 -0
- package/templates/latest/app/components/ui/breadcrumb.tsx +109 -0
- package/templates/latest/app/components/ui/button.tsx +58 -0
- package/templates/latest/app/components/ui/card.tsx +92 -0
- package/templates/latest/app/components/ui/chart.tsx +352 -0
- package/templates/latest/app/components/ui/checkbox.tsx +30 -0
- package/templates/latest/app/components/ui/drawer.tsx +139 -0
- package/templates/latest/app/components/ui/dropdown-menu.tsx +258 -0
- package/templates/latest/app/components/ui/input.tsx +21 -0
- package/templates/latest/app/components/ui/label.tsx +24 -0
- package/templates/latest/app/components/ui/select.tsx +183 -0
- package/templates/latest/app/components/ui/separator.tsx +26 -0
- package/templates/latest/app/components/ui/sheet.tsx +139 -0
- package/templates/latest/app/components/ui/sidebar.tsx +731 -0
- package/templates/latest/app/components/ui/skeleton.tsx +13 -0
- package/templates/latest/app/components/ui/sonner.tsx +23 -0
- package/templates/latest/app/components/ui/table.tsx +117 -0
- package/templates/latest/app/components/ui/tabs.tsx +66 -0
- package/templates/latest/app/components/ui/toggle-group.tsx +73 -0
- package/templates/latest/app/components/ui/toggle.tsx +47 -0
- package/templates/latest/app/components/ui/tooltip.tsx +59 -0
- package/templates/latest/app/dashboard/data.json +614 -0
- package/templates/latest/app/hooks/use-bluecopa-user.ts +37 -0
- package/templates/latest/app/hooks/use-mobile.ts +19 -0
- package/templates/latest/{src → app}/lib/utils.ts +1 -1
- package/templates/latest/app/main.tsx +12 -0
- package/templates/latest/app/routes/home.tsx +40 -0
- package/templates/latest/app/routes.tsx +15 -0
- package/templates/latest/{src → app}/single-spa.tsx +38 -28
- package/templates/latest/components.json +22 -0
- package/templates/latest/dist/assets/__federation_expose_App-DRwKKpS2.js +91 -0
- package/templates/latest/dist/assets/__federation_fn_import-CzfA7kmP.js +438 -0
- package/templates/latest/dist/assets/__federation_shared_react-Bp6HVBS4.js +16 -0
- package/templates/latest/dist/assets/__federation_shared_react-dom-BCcRGiYp.js +17 -0
- package/templates/latest/dist/assets/client-DgSav55y.js +12658 -0
- package/templates/latest/dist/assets/home-DOL6GrYV.js +54951 -0
- package/templates/latest/dist/assets/index-BzNimew1.js +69 -0
- package/templates/latest/dist/assets/index-DMFtQdNS.js +412 -0
- package/templates/latest/dist/assets/index-DdYpcDMk.js +60 -0
- package/templates/latest/dist/assets/remoteEntry.js +88 -0
- package/templates/latest/dist/assets/style-36A39bNN.css +3683 -0
- package/templates/latest/dist/avatars/shadcn.svg +6 -0
- package/templates/latest/dist/favicon.ico +0 -0
- package/templates/latest/dist/index.html +19 -0
- package/templates/latest/index.html +1 -1
- package/templates/latest/package-lock.json +1227 -3353
- package/templates/latest/package.json +47 -43
- package/templates/latest/pnpm-lock.yaml +4767 -0
- package/templates/latest/preview/index.html +32 -2
- package/templates/latest/public/avatars/shadcn.svg +6 -0
- package/templates/latest/public/favicon.ico +0 -0
- package/templates/latest/tsconfig.json +18 -11
- package/templates/latest/vite.config.ts +41 -41
- package/templates/latest/.env.example +0 -14
- package/templates/latest/.eslintrc.cjs +0 -42
- package/templates/latest/AGENT.md +0 -284
- package/templates/latest/clean.sh +0 -39
- package/templates/latest/postcss.config.cjs +0 -6
- package/templates/latest/public/bluecopa-logo.svg +0 -30
- package/templates/latest/public/favicon-32x32.png +0 -0
- package/templates/latest/public/favicon-96x96.png +0 -0
- package/templates/latest/setup.sh +0 -55
- package/templates/latest/src/App.tsx +0 -15
- package/templates/latest/src/components/layout/dashboard-header.tsx +0 -139
- package/templates/latest/src/components/layout/dashboard-layout.tsx +0 -29
- package/templates/latest/src/components/layout/sidebar.tsx +0 -54
- package/templates/latest/src/components/page/dashboard.tsx +0 -1506
- package/templates/latest/src/components/page/navbar.tsx +0 -104
- package/templates/latest/src/components/tables/data-grid.tsx +0 -439
- package/templates/latest/src/components/ui/alert.tsx +0 -59
- package/templates/latest/src/components/ui/avatar.tsx +0 -50
- package/templates/latest/src/components/ui/badge.tsx +0 -36
- package/templates/latest/src/components/ui/bluecopa-logo.tsx +0 -54
- package/templates/latest/src/components/ui/button.tsx +0 -58
- package/templates/latest/src/components/ui/card.tsx +0 -79
- package/templates/latest/src/components/ui/dropdown-menu.tsx +0 -200
- package/templates/latest/src/components/ui/input.tsx +0 -24
- package/templates/latest/src/components/ui/label.tsx +0 -23
- package/templates/latest/src/components/ui/select.tsx +0 -29
- package/templates/latest/src/hooks/use-api.ts +0 -55
- package/templates/latest/src/index.css +0 -59
- package/templates/latest/src/main.tsx +0 -13
- package/templates/latest/src/pages/Dashboard.tsx +0 -13
- package/templates/latest/src/pages/Home.tsx +0 -622
- package/templates/latest/src/providers/query-provider.tsx +0 -48
- package/templates/latest/src/types/api.ts +0 -78
- package/templates/latest/src/vite-env.d.ts +0 -11
- package/templates/latest/tailwind.config.js +0 -88
- package/templates/latest/tsconfig.app.json +0 -26
- package/templates/latest/tsconfig.node.json +0 -10
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AppSidebar } from "~/components/app-sidebar"
|
|
2
|
+
import { ChartAreaInteractive } from "~/components/chart-area-interactive"
|
|
3
|
+
import { DataTable } from "~/components/data-table"
|
|
4
|
+
import { SectionCards } from "~/components/section-cards"
|
|
5
|
+
import { SiteHeader } from "~/components/site-header"
|
|
6
|
+
import {
|
|
7
|
+
SidebarInset,
|
|
8
|
+
SidebarProvider,
|
|
9
|
+
} from "~/components/ui/sidebar"
|
|
10
|
+
|
|
11
|
+
import data from "~/dashboard/data.json"
|
|
12
|
+
|
|
13
|
+
export default function Page() {
|
|
14
|
+
return (
|
|
15
|
+
<SidebarProvider
|
|
16
|
+
style={
|
|
17
|
+
{
|
|
18
|
+
"--sidebar-width": "calc(var(--spacing) * 72)",
|
|
19
|
+
"--header-height": "calc(var(--spacing) * 12)",
|
|
20
|
+
} as React.CSSProperties
|
|
21
|
+
}
|
|
22
|
+
>
|
|
23
|
+
<AppSidebar variant="inset" />
|
|
24
|
+
<SidebarInset>
|
|
25
|
+
<SiteHeader />
|
|
26
|
+
<div className="flex flex-1 flex-col">
|
|
27
|
+
<div className="@container/main flex flex-1 flex-col gap-2">
|
|
28
|
+
<div className="flex flex-col gap-4 py-4 md:gap-6 md:py-6">
|
|
29
|
+
<SectionCards />
|
|
30
|
+
<div className="px-4 lg:px-6">
|
|
31
|
+
<ChartAreaInteractive />
|
|
32
|
+
</div>
|
|
33
|
+
<DataTable data={data} />
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</SidebarInset>
|
|
38
|
+
</SidebarProvider>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Routes, Route, Navigate } from "react-router-dom";
|
|
2
|
+
import { lazy } from "react";
|
|
3
|
+
import "./app.css";
|
|
4
|
+
|
|
5
|
+
const Home = lazy(() => import('~/routes/home'))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export default function RouteConfig() {
|
|
9
|
+
return (
|
|
10
|
+
<Routes>
|
|
11
|
+
<Route path="/" element={<Home />} />
|
|
12
|
+
<Route path="*" element={<Navigate to="/" replace />} />
|
|
13
|
+
</Routes>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { createRoot, Root } from
|
|
3
|
-
import singleSpaReact from
|
|
4
|
-
import { MemoryRouter, BrowserRouter } from
|
|
5
|
-
import App from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
3
|
+
import singleSpaReact from "single-spa-react";
|
|
4
|
+
import { MemoryRouter, BrowserRouter } from "react-router-dom";
|
|
5
|
+
import App from "./app";
|
|
6
|
+
import type { AppProps } from "single-spa";
|
|
6
7
|
|
|
7
8
|
// Single-spa lifecycle props interface
|
|
8
9
|
interface LifecycleProps {
|
|
@@ -18,15 +19,15 @@ interface LifecycleProps {
|
|
|
18
19
|
let root: Root | null = null;
|
|
19
20
|
|
|
20
21
|
// Root component wrapper that handles routing
|
|
21
|
-
const
|
|
22
|
-
basename
|
|
23
|
-
isMicroFrontend
|
|
24
|
-
}) => {
|
|
22
|
+
const MicrofrontendRoot: React.FC<{
|
|
23
|
+
basename?: string;
|
|
24
|
+
isMicroFrontend?: boolean;
|
|
25
|
+
}> = ({ basename = "/", isMicroFrontend = false }) => {
|
|
25
26
|
// Use MemoryRouter for micro-frontend to avoid conflicts with host routing
|
|
26
27
|
// Use BrowserRouter for standalone mode
|
|
27
28
|
const Router = isMicroFrontend ? MemoryRouter : BrowserRouter;
|
|
28
29
|
const routerProps = isMicroFrontend ? {} : { basename };
|
|
29
|
-
|
|
30
|
+
|
|
30
31
|
return (
|
|
31
32
|
<Router {...routerProps}>
|
|
32
33
|
<App />
|
|
@@ -38,13 +39,22 @@ const PnLExplorerRoot: React.FC<{ basename?: string; isMicroFrontend?: boolean }
|
|
|
38
39
|
const lifecycles = singleSpaReact({
|
|
39
40
|
React,
|
|
40
41
|
ReactDOMClient: { createRoot },
|
|
41
|
-
rootComponent: (props
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
rootComponent: (props: AppProps & { basename: string }) => (
|
|
43
|
+
<MicrofrontendRoot isMicroFrontend={true} basename={props.basename} />
|
|
44
|
+
),
|
|
45
|
+
errorBoundary: (err, info) => {
|
|
46
|
+
console.error("Microfrontend Single-spa Error:", err, info);
|
|
47
|
+
return <div>Something went wrong loading Microfrontend</div>;
|
|
48
|
+
},
|
|
49
|
+
renderType: "createRoot",
|
|
50
|
+
domElementGetter: () => {
|
|
51
|
+
const el = document.getElementById("single-spa-application:pnl-explorer");
|
|
52
|
+
if (!el)
|
|
53
|
+
throw new Error(
|
|
54
|
+
"Mount target #single-spa-application:pnl-explorer not found"
|
|
55
|
+
);
|
|
56
|
+
return el;
|
|
45
57
|
},
|
|
46
|
-
renderType: 'createRoot',
|
|
47
|
-
domElementGetter: () => document.getElementById('single-spa-application:pnl-explorer') || document.body
|
|
48
58
|
});
|
|
49
59
|
|
|
50
60
|
// Export the single-spa lifecycle functions
|
|
@@ -53,7 +63,7 @@ export const { mount, unmount, bootstrap } = lifecycles;
|
|
|
53
63
|
// Export a manual mount function for direct usage
|
|
54
64
|
export const manualMount = async (props: LifecycleProps) => {
|
|
55
65
|
if (!props.domElement) {
|
|
56
|
-
throw new Error(
|
|
66
|
+
throw new Error("domElement is required for mounting the application");
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
try {
|
|
@@ -65,20 +75,20 @@ export const manualMount = async (props: LifecycleProps) => {
|
|
|
65
75
|
|
|
66
76
|
// Create new root
|
|
67
77
|
root = createRoot(props.domElement);
|
|
68
|
-
|
|
78
|
+
|
|
69
79
|
// Mount the application with the provided basename as micro-frontend
|
|
70
80
|
root.render(
|
|
71
|
-
<
|
|
81
|
+
<MicrofrontendRoot
|
|
72
82
|
isMicroFrontend={true}
|
|
73
|
-
basename={props.basename ||
|
|
83
|
+
basename={props.basename || "/app/external/microfrontend"}
|
|
74
84
|
/>
|
|
75
85
|
);
|
|
76
86
|
|
|
77
|
-
console.log(
|
|
78
|
-
return
|
|
87
|
+
console.log("Microfrontend mounted successfully");
|
|
88
|
+
return;
|
|
79
89
|
} catch (error) {
|
|
80
|
-
console.error(
|
|
81
|
-
|
|
90
|
+
console.error("Failed to mount Microfrontend:", error);
|
|
91
|
+
throw error;
|
|
82
92
|
}
|
|
83
93
|
};
|
|
84
94
|
|
|
@@ -89,10 +99,10 @@ export const manualUnmount = async () => {
|
|
|
89
99
|
root.unmount();
|
|
90
100
|
root = null;
|
|
91
101
|
}
|
|
92
|
-
console.log(
|
|
102
|
+
console.log("Microfrontend unmounted successfully");
|
|
93
103
|
return Promise.resolve();
|
|
94
104
|
} catch (error) {
|
|
95
|
-
console.error(
|
|
105
|
+
console.error("Failed to unmount Microfrontend:", error);
|
|
96
106
|
return Promise.reject(error);
|
|
97
107
|
}
|
|
98
108
|
};
|
|
@@ -101,5 +111,5 @@ export const manualUnmount = async () => {
|
|
|
101
111
|
export default {
|
|
102
112
|
mount: manualMount,
|
|
103
113
|
unmount: manualUnmount,
|
|
104
|
-
bootstrap: () => Promise.resolve()
|
|
105
|
-
};
|
|
114
|
+
bootstrap: () => Promise.resolve(),
|
|
115
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
+
"style": "new-york",
|
|
4
|
+
"rsc": false,
|
|
5
|
+
"tsx": true,
|
|
6
|
+
"tailwind": {
|
|
7
|
+
"config": "",
|
|
8
|
+
"css": "app/app.css",
|
|
9
|
+
"baseColor": "gray",
|
|
10
|
+
"cssVariables": true,
|
|
11
|
+
"prefix": ""
|
|
12
|
+
},
|
|
13
|
+
"iconLibrary": "lucide",
|
|
14
|
+
"aliases": {
|
|
15
|
+
"components": "~/components",
|
|
16
|
+
"utils": "~/lib/utils",
|
|
17
|
+
"ui": "~/components/ui",
|
|
18
|
+
"lib": "~/lib",
|
|
19
|
+
"hooks": "~/hooks"
|
|
20
|
+
},
|
|
21
|
+
"registries": {}
|
|
22
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
System.register(['./__federation_fn_import-CzfA7kmP.js', './client-DgSav55y.js'], (function (exports, module) {
|
|
2
|
+
'use strict';
|
|
3
|
+
var importShared, jsxRuntimeExports, clientExports, MemoryRouter, BrowserRouter, App;
|
|
4
|
+
return {
|
|
5
|
+
setters: [module => {
|
|
6
|
+
importShared = module.importShared;
|
|
7
|
+
}, module => {
|
|
8
|
+
jsxRuntimeExports = module.j;
|
|
9
|
+
clientExports = module.c;
|
|
10
|
+
MemoryRouter = module.M;
|
|
11
|
+
BrowserRouter = module.B;
|
|
12
|
+
App = module.A;
|
|
13
|
+
}],
|
|
14
|
+
execute: (async function () {
|
|
15
|
+
|
|
16
|
+
function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o);}return n}function t(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),true).forEach((function(e){o(t,e,r[e]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e));}));}return t}function n(e){return (n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true}):e[t]=n,e}function r(e){return (r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){var n;if("function"!=typeof(n=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var n="single-spa-application:".concat(t);return function(){var e=document.getElementById(n);return e||((e=document.createElement("div")).id=n,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(r(n)));return function(){var e=n(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(r(e)));return e}}var c=null;try{c=require("react").createContext();}catch(e){}var u={React:null,ReactDOM:null,ReactDOMClient:null,rootComponent:null,loadRootComponent:null,errorBoundary:null,errorBoundaryClass:null,domElementGetter:null,parcelCanUpdate:true,suppressComponentDidCatchWarning:false,domElements:{},renderResults:{},updateResolves:{},unmountResolves:{}};function i(e){if("object"!==n(e))throw new Error("single-spa-react requires a configuration object");var o,r=t(t({},u),e);if(!r.React)throw new Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw new Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");r.renderType||(null!==(o=r.ReactDOMClient)&&void 0!==o&&o.createRoot?r.renderType="createRoot":r.renderType="render");if(!r.rootComponent&&!r.loadRootComponent)throw new Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!c&&r.React.createContext&&(c=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")");}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished);},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished);},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var a={bootstrap:s.bind(null,r),mount:p.bind(null,r),unmount:l.bind(null,r)};return r.parcelCanUpdate&&(a.update=m.bind(null,r)),a}function s(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then((function(t){e.rootComponent=t;}))}function p(e,t){return new Promise((function(n,o){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return false;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return false}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var r=y(e,t,(function(){n(this);})),c=a(e,t)(),u=function(e){var t=e.reactDom,n=e.renderType,o=e.elementToRender,r=e.domElement,a=t[n];if("function"!=typeof a)throw new Error('renderType "'.concat(n,'" did not return a function.'));switch(n){case "createRoot":case "unstable_createRoot":case "createBlockingRoot":case "unstable_createBlockingRoot":var c=a(r);return c.render(o),c;case "hydrateRoot":return a(r,o);case "hydrate":default:return a(o,r),null}}({elementToRender:r,domElement:c,reactDom:d(e),renderType:f(e)});e.domElements[t.name]=c,e.renderResults[t.name]=u;}))}function l(e,t){return new Promise((function(n){e.unmountResolves[t.name]=n;var o=e.renderResults[t.name];o&&o.unmount?o.unmount():d(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name];}))}function m(e,t){return new Promise((function(n){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(n);var o=y(e,t,null),r=e.renderResults[t.name];if(r&&r.render)r.render(o);else {var c=a(e,t)();d(e).render(o,c);}}))}function d(e){return e.ReactDOMClient||e.ReactDOM}function f(e){return "function"==typeof e.renderType?e.renderType():e.renderType}function y(e,n,o){var r=e.React.createElement(e.rootComponent,n),a=c?e.React.createElement(c.Provider,{value:n},r):r;return (e.errorBoundary||n.errorBoundary||e.errorBoundaryClass||n.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||n.errorBoundaryClass||function(e,t){function n(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},n.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")");}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},n.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t});},n}(e,n),a=e.React.createElement(e.errorBoundaryClass,n,a)),a=e.React.createElement(e.SingleSpaRoot,t(t({},n),{},{mountFinished:o,updateFinished:function(){e.updateResolves[n.name]&&(e.updateResolves[n.name].forEach((function(e){return e()})),delete e.updateResolves[n.name]);},unmountFinished:function(){e.unmountResolves[n.name]&&(e.unmountResolves[n.name](),delete e.unmountResolves[n.name]);}}),a)}
|
|
17
|
+
|
|
18
|
+
const React = await importShared('react');
|
|
19
|
+
let root = null;
|
|
20
|
+
const MicrofrontendRoot = ({ basename = "/", isMicroFrontend = false }) => {
|
|
21
|
+
const Router = isMicroFrontend ? MemoryRouter : BrowserRouter;
|
|
22
|
+
const routerProps = isMicroFrontend ? {} : { basename };
|
|
23
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Router, { ...routerProps, children: /* @__PURE__ */ jsxRuntimeExports.jsx(App, {}) });
|
|
24
|
+
};
|
|
25
|
+
const lifecycles = i({
|
|
26
|
+
React,
|
|
27
|
+
ReactDOMClient: { createRoot: clientExports.createRoot },
|
|
28
|
+
rootComponent: (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(MicrofrontendRoot, { isMicroFrontend: true, basename: props.basename }),
|
|
29
|
+
errorBoundary: (err, info) => {
|
|
30
|
+
console.error("Microfrontend Single-spa Error:", err, info);
|
|
31
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Something went wrong loading Microfrontend" });
|
|
32
|
+
},
|
|
33
|
+
renderType: "createRoot",
|
|
34
|
+
domElementGetter: () => {
|
|
35
|
+
const el = document.getElementById("single-spa-application:pnl-explorer");
|
|
36
|
+
if (!el)
|
|
37
|
+
throw new Error(
|
|
38
|
+
"Mount target #single-spa-application:pnl-explorer not found"
|
|
39
|
+
);
|
|
40
|
+
return el;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const { mount, unmount, bootstrap } = lifecycles; exports({ mount, unmount, bootstrap });
|
|
44
|
+
const manualMount = exports("manualMount", async (props) => {
|
|
45
|
+
if (!props.domElement) {
|
|
46
|
+
throw new Error("domElement is required for mounting the application");
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
if (root) {
|
|
50
|
+
root.unmount();
|
|
51
|
+
root = null;
|
|
52
|
+
}
|
|
53
|
+
root = clientExports.createRoot(props.domElement);
|
|
54
|
+
root.render(
|
|
55
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
56
|
+
MicrofrontendRoot,
|
|
57
|
+
{
|
|
58
|
+
isMicroFrontend: true,
|
|
59
|
+
basename: props.basename || "/app/external/microfrontend"
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
console.log("Microfrontend mounted successfully");
|
|
64
|
+
return;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error("Failed to mount Microfrontend:", error);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const manualUnmount = exports("manualUnmount", async () => {
|
|
71
|
+
try {
|
|
72
|
+
if (root) {
|
|
73
|
+
root.unmount();
|
|
74
|
+
root = null;
|
|
75
|
+
}
|
|
76
|
+
console.log("Microfrontend unmounted successfully");
|
|
77
|
+
return Promise.resolve();
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error("Failed to unmount Microfrontend:", error);
|
|
80
|
+
return Promise.reject(error);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const singleSpa = exports("default", {
|
|
84
|
+
mount: manualMount,
|
|
85
|
+
unmount: manualUnmount,
|
|
86
|
+
bootstrap: () => Promise.resolve()
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
})
|
|
90
|
+
};
|
|
91
|
+
}));
|