@equinor/roma-framework 6.0.1-beta.0 → 6.0.1-beta.10
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/{_commonjsHelpers-CIHTj2Un.mjs → _commonjsHelpers-DKlypwS6.mjs} +4 -3724
- package/cypress.mjs +2 -1
- package/dev-portal/BAGVG3AX-CZ4YnljQ.mjs +37 -0
- package/dev-portal/KZB72KQG-Dk7Ih0xn.mjs +46 -0
- package/dev-portal/NITRNJ62-7tOtp9d-.mjs +12375 -0
- package/dev-portal/index-DYpA1xV-.mjs +102056 -0
- package/dev-portal/index.html +3 -2
- package/dev-portal/lib/dev-portal/AppLoader.d.ts +7 -1
- package/dev-portal/lib/dev-portal/config/AppClient.d.ts +10 -1
- package/dev-portal/lib/style-provider.d.ts +2 -1
- package/dev-portal/package.json +9 -8
- package/dev-portal/roma-framework.css +478 -0
- package/lib/dev-portal/AppLoader.d.ts +7 -1
- package/lib/dev-portal/config/AppClient.d.ts +10 -1
- package/lib/style-provider.d.ts +2 -1
- package/package.json +9 -8
- package/roma-framework.mjs +77 -10
- package/dev-portal/roma-framework.umd.js +0 -114409
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/roma-framework",
|
|
3
|
-
"version": "6.0.1-beta.
|
|
3
|
+
"version": "6.0.1-beta.10",
|
|
4
4
|
"repository": "https://github.com/equinor/tops-roma",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"private": false,
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@equinor/eds-core-react": "^
|
|
9
|
-
"@equinor/eds-icons": "^
|
|
10
|
-
"@equinor/eds-tokens": "^
|
|
8
|
+
"@equinor/eds-core-react": "^2.4.0",
|
|
9
|
+
"@equinor/eds-icons": "^1.3.0",
|
|
10
|
+
"@equinor/eds-tokens": "^2.2.0",
|
|
11
11
|
"@equinor/fusion-framework": "^8.0.0",
|
|
12
12
|
"@equinor/fusion-framework-app": "^11.0.0",
|
|
13
13
|
"@equinor/fusion-framework-module": "^6.0.0",
|
|
@@ -22,10 +22,9 @@
|
|
|
22
22
|
"@equinor/fusion-framework-react-module": "^4.0.0",
|
|
23
23
|
"@equinor/fusion-framework-react-module-http": "^11.0.0",
|
|
24
24
|
"@equinor/fusion-framework-react-router": "^1.0.2",
|
|
25
|
-
"@equinor/roma-sse-module": "
|
|
25
|
+
"@equinor/roma-sse-module": "1.0.0-beta.6",
|
|
26
26
|
"react": "^19.2.4",
|
|
27
27
|
"react-dom": "^19.2.4",
|
|
28
|
-
"react-intl": "^10.1.0",
|
|
29
28
|
"react-router-dom": "^7.13.2",
|
|
30
29
|
"rxjs": "^7.8.2",
|
|
31
30
|
"styled-components": "^6.3.11"
|
|
@@ -36,13 +35,14 @@
|
|
|
36
35
|
"@tanstack/react-query-persist-client": "^5.90.24",
|
|
37
36
|
"idb-keyval": "^6.2.2",
|
|
38
37
|
"immer": "^11.0.0",
|
|
38
|
+
"react-intl": "^10.1.0",
|
|
39
39
|
"is-mergeable-object": "^1.1.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@nx/vite": "22.5.4",
|
|
43
43
|
"@testing-library/react": "16.1.0",
|
|
44
44
|
"@vitejs/plugin-react": "^5.1.4",
|
|
45
|
-
"vite": "^7.3.
|
|
45
|
+
"vite": "^7.3.2",
|
|
46
46
|
"vite-plugin-dts": "^4.5.4"
|
|
47
47
|
},
|
|
48
48
|
"exports": {
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"types": "./lib/test-utils/roma-cypress-wrapper.d.ts",
|
|
55
55
|
"import": "./cypress.mjs",
|
|
56
56
|
"require": "./cypress.js"
|
|
57
|
-
}
|
|
57
|
+
},
|
|
58
|
+
"./css-variables.css": "./src/css-variables.css"
|
|
58
59
|
}
|
|
59
60
|
}
|
package/roma-framework.mjs
CHANGED
|
@@ -5,8 +5,9 @@ import { useState, useEffect, lazy, useRef, createContext, useContext, useMemo }
|
|
|
5
5
|
import { ModuleProvider } from "@equinor/fusion-framework-react-module";
|
|
6
6
|
import styled, { StyleSheetManager, keyframes } from "styled-components";
|
|
7
7
|
import { EdsProvider, StarProgress, Typography, Card, Button, TopBar, Chip, SideSheet, Menu, Tooltip, Icon, List } from "@equinor/eds-core-react";
|
|
8
|
-
import { E as EmptyError, o as operate, c as createOperatorSubscriber, i as innerFrom, a as identity, b as isFunction,
|
|
8
|
+
import { E as EmptyError, o as operate, c as createOperatorSubscriber, i as innerFrom, a as identity, b as isFunction, u as useParams, L as Link, B as BehaviorSubject, f as firstValueFrom, g as getDefaultExportFromCjs, d as of, e as from } from "./_commonjsHelpers-DKlypwS6.mjs";
|
|
9
9
|
import { QueryClient, QueryClientProvider, useQueryClient, useMutation, useQuery } from "@tanstack/react-query";
|
|
10
|
+
import { IntlProvider } from "react-intl";
|
|
10
11
|
import { useCurrentApp, useApps as useApps$1 } from "@equinor/fusion-framework-react/app";
|
|
11
12
|
import { App } from "@equinor/fusion-framework-module-app/app";
|
|
12
13
|
import { tokens } from "@equinor/eds-tokens";
|
|
@@ -32,14 +33,14 @@ const createExtraScopePlugin = (scope) => {
|
|
|
32
33
|
};
|
|
33
34
|
return plugin;
|
|
34
35
|
};
|
|
35
|
-
const StyleProvider = ({ scope, children }) => {
|
|
36
|
+
const StyleProvider = ({ scope, children, version: version2 }) => {
|
|
36
37
|
const stylisPlugins = [];
|
|
37
38
|
if (scope) {
|
|
38
39
|
const plugin = createExtraScopePlugin(`#${scope}`);
|
|
39
40
|
Object.defineProperty(plugin, "name", { value: `style-scope-${scope}` });
|
|
40
41
|
stylisPlugins.push(plugin);
|
|
41
42
|
}
|
|
42
|
-
return /* @__PURE__ */ jsx(StyleSheetManager, { stylisPlugins, children: /* @__PURE__ */ jsx("div", { id: scope, children }) });
|
|
43
|
+
return /* @__PURE__ */ jsx(StyleSheetManager, { stylisPlugins, children: /* @__PURE__ */ jsx("div", { id: scope, "data-roma-version": version2, children }) });
|
|
43
44
|
};
|
|
44
45
|
function lastValueFrom(source, config) {
|
|
45
46
|
return new Promise(function(resolve, reject) {
|
|
@@ -196,8 +197,9 @@ const makeComponent = (Component, args, configure2) => lazy(async () => {
|
|
|
196
197
|
source: Component
|
|
197
198
|
});
|
|
198
199
|
const queryClient = args.query ?? new QueryClient();
|
|
200
|
+
const version2 = "6.0.1-beta.10";
|
|
199
201
|
return {
|
|
200
|
-
default: () => /* @__PURE__ */ jsx(FrameworkProvider, { value: fusion, children: /* @__PURE__ */ jsx(IntlProvider, { locale: navigator.language, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(StyleProvider, { scope: `roma-${appKey}`, children: /* @__PURE__ */ jsx(
|
|
202
|
+
default: () => /* @__PURE__ */ jsx(FrameworkProvider, { value: fusion, children: /* @__PURE__ */ jsx(IntlProvider, { locale: navigator.language, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(StyleProvider, { scope: `roma-${appKey}`, version: version2, children: /* @__PURE__ */ jsx(
|
|
201
203
|
EdsEventProvider,
|
|
202
204
|
{
|
|
203
205
|
portalContainer: `roma-${appKey}`,
|
|
@@ -280,6 +282,44 @@ function getAppModule(app, framework) {
|
|
|
280
282
|
const appModuleScript = appModule.initialize();
|
|
281
283
|
return { appModule, appModuleScript };
|
|
282
284
|
}
|
|
285
|
+
async function loadCssAssets(app, container) {
|
|
286
|
+
const assets = app.metadata?.assets;
|
|
287
|
+
if (!assets || assets.length === 0)
|
|
288
|
+
return () => {
|
|
289
|
+
};
|
|
290
|
+
const cssAssets = assets.filter((url) => url.split("?")[0].endsWith(".css"));
|
|
291
|
+
const injectedStyles = [];
|
|
292
|
+
const results = await Promise.allSettled(
|
|
293
|
+
cssAssets.map(async (cssUrl) => {
|
|
294
|
+
const filename = cssUrl.split("?")[0].split("/").pop() ?? cssUrl;
|
|
295
|
+
const tag = `${app.appKey}-${filename}`;
|
|
296
|
+
if (container.querySelector(`style[data-asset="${tag}"]`)) return;
|
|
297
|
+
const response = await fetch(cssUrl);
|
|
298
|
+
if (!response.ok) {
|
|
299
|
+
console.warn(
|
|
300
|
+
`Failed to load CSS asset: ${cssUrl} (${response.status})`
|
|
301
|
+
);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const cssText = await response.text();
|
|
305
|
+
const style = document.createElement("style");
|
|
306
|
+
style.setAttribute("data-asset", tag);
|
|
307
|
+
style.textContent = `@scope { ${cssText} }`;
|
|
308
|
+
container.appendChild(style);
|
|
309
|
+
injectedStyles.push(style);
|
|
310
|
+
})
|
|
311
|
+
);
|
|
312
|
+
for (const result of results) {
|
|
313
|
+
if (result.status === "rejected") {
|
|
314
|
+
console.warn("Failed to load CSS asset:", result.reason);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return () => {
|
|
318
|
+
for (const style of injectedStyles) {
|
|
319
|
+
style.remove();
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
}
|
|
283
323
|
function AppLoader({
|
|
284
324
|
app,
|
|
285
325
|
kind,
|
|
@@ -297,15 +337,15 @@ function AppLoader({
|
|
|
297
337
|
new CustomEvent(eventName, data)
|
|
298
338
|
);
|
|
299
339
|
};
|
|
300
|
-
function renderApplication(el) {
|
|
340
|
+
async function renderApplication(el) {
|
|
301
341
|
const { appModule, appModuleScript } = getAppModule(app, framework);
|
|
302
342
|
const [basename] = window.location.pathname.match(
|
|
303
343
|
/\/?apps\/[a-z|-]+(\/)?/g
|
|
304
344
|
) ?? [""];
|
|
305
|
-
lastValueFrom(appModuleScript).then((x) => {
|
|
345
|
+
const cleanup = await lastValueFrom(appModuleScript).then((x) => {
|
|
306
346
|
const script = x.script;
|
|
307
347
|
const render = script.renderApp ?? script.default;
|
|
308
|
-
render(el, {
|
|
348
|
+
const cleanup2 = render(el, {
|
|
309
349
|
query: queryClient,
|
|
310
350
|
fusion: framework,
|
|
311
351
|
env: {
|
|
@@ -321,8 +361,9 @@ function AppLoader({
|
|
|
321
361
|
if (kind === "app") {
|
|
322
362
|
setCurrentApp(app.appKey);
|
|
323
363
|
}
|
|
364
|
+
return cleanup2;
|
|
324
365
|
});
|
|
325
|
-
return appModule;
|
|
366
|
+
return { appModule, cleanup };
|
|
326
367
|
}
|
|
327
368
|
useEffect(() => {
|
|
328
369
|
setError(null);
|
|
@@ -334,15 +375,41 @@ function AppLoader({
|
|
|
334
375
|
setLoading(true);
|
|
335
376
|
const el = document.createElement("div");
|
|
336
377
|
ref.current?.appendChild(el);
|
|
337
|
-
|
|
378
|
+
let cleanupCss = () => {
|
|
379
|
+
ref.current?.removeChild(
|
|
380
|
+
document.querySelector("[data-asset]")
|
|
381
|
+
);
|
|
382
|
+
};
|
|
383
|
+
loadCssAssets(app, ref.current).then((cleanup2) => {
|
|
384
|
+
cleanupCss = cleanup2;
|
|
385
|
+
});
|
|
386
|
+
let appModule = null;
|
|
387
|
+
let cleanup = null;
|
|
388
|
+
let disposed = false;
|
|
389
|
+
renderApplication(el).then((r) => {
|
|
390
|
+
if (disposed) {
|
|
391
|
+
queueMicrotask(() => {
|
|
392
|
+
r.cleanup();
|
|
393
|
+
r.appModule.dispose();
|
|
394
|
+
});
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
appModule = r.appModule;
|
|
398
|
+
cleanup = r.cleanup;
|
|
399
|
+
});
|
|
338
400
|
setLoading(false);
|
|
339
401
|
const currentRef = ref.current;
|
|
340
402
|
return () => {
|
|
403
|
+
disposed = true;
|
|
404
|
+
cleanupCss?.();
|
|
341
405
|
try {
|
|
342
406
|
currentRef?.removeChild(el);
|
|
343
407
|
} catch {
|
|
344
408
|
}
|
|
345
|
-
|
|
409
|
+
queueMicrotask(() => {
|
|
410
|
+
if (appModule) appModule.dispose();
|
|
411
|
+
if (cleanup) cleanup();
|
|
412
|
+
});
|
|
346
413
|
if (kind === "app") clearCurrentApp();
|
|
347
414
|
};
|
|
348
415
|
}, [app]);
|