@equinor/fusion-framework-vite-plugin-spa 4.0.1 → 4.0.4
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/CHANGELOG.md +21 -0
- package/dist/esm/html/bootstrap.js +2 -7
- package/dist/esm/html/bootstrap.js.map +1 -1
- package/dist/esm/html/create-portal-entry-point.js +20 -0
- package/dist/esm/html/create-portal-entry-point.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/html/bootstrap.js +38 -31
- package/dist/html/bootstrap.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/html/create-portal-entry-point.d.ts +7 -0
- package/dist/types/html/index.html.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/src/html/bootstrap.ts +4 -5
- package/src/html/create-portal-entry-point.ts +20 -0
- package/src/version.ts +1 -1
- package/tests/create-portal-entry-point.test.ts +36 -0
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the portal template entrypoint URL used by the SPA bootstrap loader.
|
|
3
|
+
*
|
|
4
|
+
* @param segments - Ordered URL/path segments such as proxy prefix, asset path, and template entry.
|
|
5
|
+
* @returns A normalized entrypoint string with single slashes between segments.
|
|
6
|
+
*/
|
|
7
|
+
export declare const createPortalEntryPoint: (...segments: Array<string | undefined | null>) => string;
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
* @constant
|
|
16
16
|
* @type {string}
|
|
17
17
|
*/
|
|
18
|
-
export declare const html = "\n <!DOCTYPE html>\n <html>\n <head>\n <title>%FUSION_SPA_TITLE%</title>\n <meta name=\"mode\" content=\"%MODE%\">\n <meta name=\"fusion-spa-plugin-version\" content=\"4.0.
|
|
18
|
+
export declare const html = "\n <!DOCTYPE html>\n <html>\n <head>\n <title>%FUSION_SPA_TITLE%</title>\n <meta name=\"mode\" content=\"%MODE%\">\n <meta name=\"fusion-spa-plugin-version\" content=\"4.0.4\">\n <link rel=\"stylesheet\" href=\"https://cdn.eds.equinor.com/font/equinor-font.css\" />\n <script type=\"module\" src=\"%FUSION_SPA_BOOTSTRAP%\"></script>\n <script>\n // Set AG Grid license key globally if provided\n window.FUSION_AG_GRID_KEY = '%FUSION_SPA_AG_GRID_KEY%';\n \n // suppress console error for custom elements already defined. \n // WebComponents should be added by the portal, but not removed from application\n const _customElementsDefine = window.customElements.define;\n window.customElements.define = (name, cl, conf) => {\n if (!customElements.get(name)) {\n _customElementsDefine.call(window.customElements, name, cl, conf);\n }\n };\n </script>\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n font-family: 'EquinorFont', sans-serif;\n }\n </style>\n </head>\n <body></body>\n </html>\n";
|
|
19
19
|
export default html;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.0.
|
|
1
|
+
export declare const version = "4.0.4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-vite-plugin-spa",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Vite plugin for SPA development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@equinor/fusion-framework-module": "6.0.0",
|
|
41
|
-
"@equinor/fusion-framework-module-http": "8.0.0",
|
|
42
|
-
"@equinor/fusion-framework-module-msal": "8.0.1",
|
|
43
41
|
"@equinor/fusion-framework-module-service-discovery": "10.0.0",
|
|
44
|
-
"@equinor/fusion-framework-module-telemetry": "5.0.
|
|
42
|
+
"@equinor/fusion-framework-module-telemetry": "5.0.1",
|
|
43
|
+
"@equinor/fusion-framework-module-http": "8.0.0",
|
|
44
|
+
"@equinor/fusion-framework-module-msal": "8.0.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@rollup/plugin-commonjs": "^29.0.0",
|
package/src/html/bootstrap.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from '@equinor/fusion-framework-module-telemetry';
|
|
15
15
|
import { ConsoleAdapter } from '@equinor/fusion-framework-module-telemetry/console-adapter';
|
|
16
16
|
|
|
17
|
+
import { createPortalEntryPoint } from './create-portal-entry-point.js';
|
|
17
18
|
import { registerServiceWorker } from './register-service-worker.js';
|
|
18
19
|
|
|
19
20
|
import { version } from '../version.js';
|
|
@@ -163,13 +164,11 @@ enableTelemetry(configurator, {
|
|
|
163
164
|
document.body.innerHTML = '';
|
|
164
165
|
document.body.appendChild(el);
|
|
165
166
|
|
|
166
|
-
const portalEntryPoint =
|
|
167
|
-
portalProxy ? '/portal-proxy' :
|
|
167
|
+
const portalEntryPoint = createPortalEntryPoint(
|
|
168
|
+
portalProxy ? '/portal-proxy' : undefined,
|
|
168
169
|
portal_manifest.build.assetPath,
|
|
169
170
|
portal_manifest.build.templateEntry,
|
|
170
|
-
|
|
171
|
-
.filter(Boolean)
|
|
172
|
-
.join('/');
|
|
171
|
+
);
|
|
173
172
|
|
|
174
173
|
// @todo: should test if the entrypoint is external or internal
|
|
175
174
|
// @todo: add proper return type
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the portal template entrypoint URL used by the SPA bootstrap loader.
|
|
3
|
+
*
|
|
4
|
+
* @param segments - Ordered URL/path segments such as proxy prefix, asset path, and template entry.
|
|
5
|
+
* @returns A normalized entrypoint string with single slashes between segments.
|
|
6
|
+
*/
|
|
7
|
+
export const createPortalEntryPoint = (...segments: Array<string | undefined | null>): string => {
|
|
8
|
+
const normalized = segments
|
|
9
|
+
.filter((segment): segment is string => segment !== undefined && segment !== null)
|
|
10
|
+
.map((segment) => segment.trim())
|
|
11
|
+
.filter(Boolean)
|
|
12
|
+
.map((segment, index) => {
|
|
13
|
+
if (index === 0) {
|
|
14
|
+
return segment.replace(/\/+$/g, '');
|
|
15
|
+
}
|
|
16
|
+
return segment.replace(/^\/+|\/+$/g, '');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return normalized.join('/');
|
|
20
|
+
};
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '4.0.
|
|
2
|
+
export const version = '4.0.4';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { createPortalEntryPoint } from '../src/html/create-portal-entry-point';
|
|
4
|
+
|
|
5
|
+
describe('createPortalEntryPoint', () => {
|
|
6
|
+
it('should avoid double slashes when proxy prefix and asset path both include slash boundaries', () => {
|
|
7
|
+
const result = createPortalEntryPoint(
|
|
8
|
+
'/portal-proxy',
|
|
9
|
+
'/bundles/templates/app-portal@2.0.1/dist',
|
|
10
|
+
'index.mjs?import',
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
expect(result).toBe('/portal-proxy/bundles/templates/app-portal@2.0.1/dist/index.mjs?import');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should normalize trailing and leading slashes across all segments', () => {
|
|
17
|
+
const result = createPortalEntryPoint(
|
|
18
|
+
'/portal-proxy/',
|
|
19
|
+
'/bundles/templates/app-portal@2.0.1/dist/',
|
|
20
|
+
'/index.mjs?import',
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
expect(result).toBe('/portal-proxy/bundles/templates/app-portal@2.0.1/dist/index.mjs?import');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should preserve absolute origin when asset path points to an external URL', () => {
|
|
27
|
+
const result = createPortalEntryPoint(
|
|
28
|
+
'https://cdn.example.com/bundles/templates/app-portal@2.0.1/dist/',
|
|
29
|
+
'/index.mjs?import',
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
expect(result).toBe(
|
|
33
|
+
'https://cdn.example.com/bundles/templates/app-portal@2.0.1/dist/index.mjs?import',
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
});
|