@equinor/fusion-framework-vite-plugin-spa 4.0.3 → 4.0.5

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.
@@ -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.3\">\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";
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.5\">\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;
@@ -1 +1 @@
1
- export declare const version = "4.0.3";
1
+ export declare const version = "4.0.5";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-vite-plugin-spa",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "description": "Vite plugin for SPA development",
5
5
  "type": "module",
6
6
  "types": "dist/types/index.d.ts",
@@ -37,11 +37,11 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@equinor/fusion-framework-module": "6.0.0",
41
40
  "@equinor/fusion-framework-module-http": "8.0.0",
42
- "@equinor/fusion-framework-module-telemetry": "5.0.1",
41
+ "@equinor/fusion-framework-module-msal": "8.0.3",
43
42
  "@equinor/fusion-framework-module-service-discovery": "10.0.0",
44
- "@equinor/fusion-framework-module-msal": "8.0.2"
43
+ "@equinor/fusion-framework-module-telemetry": "5.0.1",
44
+ "@equinor/fusion-framework-module": "6.0.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@rollup/plugin-commonjs": "^29.0.0",
@@ -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.3';
2
+ export const version = '4.0.5';
@@ -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
+ });
@@ -0,0 +1,10 @@
1
+ import { defineProject } from 'vitest/config';
2
+
3
+ import { name, version } from './package.json';
4
+
5
+ export default defineProject({
6
+ test: {
7
+ include: ['tests/**/*.test.ts'],
8
+ name: `${name}@${version}`,
9
+ },
10
+ });