@equinor/fusion-framework-vite-plugin-spa 4.1.0 → 4.1.2

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.
@@ -1,44 +0,0 @@
1
- /**
2
- * Flattens a nested object into a single-level record with
3
- * `UPPER_SNAKE_CASE` keys suitable for Vite's `config.define`.
4
- *
5
- * @remarks
6
- * Used internally by the Fusion SPA plugin to convert the object
7
- * returned by {@link PluginOptions.generateTemplateEnv} into
8
- * `import.meta.env.*` defines.
9
- *
10
- * - camelCase keys are converted to UPPER_SNAKE_CASE.
11
- * - Nested objects are recursively flattened with `_` separators.
12
- * - Arrays and primitives are JSON-stringified.
13
- *
14
- * @param obj - The object to flatten.
15
- * @param prefix - Key prefix prepended to every output key.
16
- * @returns A flat record mapping `PREFIX_KEY` strings to JSON-stringified values.
17
- *
18
- * @defaultValue prefix — `'FUSION_SPA'`
19
- *
20
- * @example
21
- * ```ts
22
- * objectToEnv({ portal: { id: 'my-portal' } }, 'FUSION_SPA');
23
- * // => { FUSION_SPA_PORTAL_ID: '"my-portal"' }
24
- * ```
25
- */
26
- export function objectToEnv(obj: object, prefix = 'FUSION_SPA'): Record<string, string> {
27
- // Build up the flat env record one entry at a time, recursing into nested objects
28
- return Object.entries(obj).reduce((result, [key, value]) => {
29
- // Convert camelCase to snake_case and uppercase
30
- const snakeKey = key.replace(/([A-Z])/g, '_$1').toUpperCase();
31
-
32
- const newPrefix = prefix ? `${prefix.replace(/_$/, '')}_${snakeKey}` : snakeKey;
33
-
34
- // Nested (non-array) objects are flattened recursively under the extended prefix
35
- if (value && typeof value === 'object' && !Array.isArray(value)) {
36
- // Recursively flatten nested objects
37
- return Object.assign(result, objectToEnv(value, newPrefix));
38
- }
39
- // Stringify non-object values
40
- return Object.assign(result, { [newPrefix]: JSON.stringify(value) });
41
- }, {});
42
- }
43
-
44
- export default objectToEnv;
package/src/version.ts DELETED
@@ -1,2 +0,0 @@
1
- // Generated by genversion.
2
- export const version = '4.1.0';
@@ -1,36 +0,0 @@
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
- });
@@ -1,13 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
-
3
- import { isEnabledEnvValue } from '../src/html/is-enabled-env-value';
4
-
5
- describe('isEnabledEnvValue', () => {
6
- it.each([true, 'true'])('enables the toggle for %j', (value) => {
7
- expect(isEnabledEnvValue(value)).toBe(true);
8
- });
9
-
10
- it.each([false, 'false', undefined, '', 1])('keeps the toggle disabled for %j', (value) => {
11
- expect(isEnabledEnvValue(value)).toBe(false);
12
- });
13
- });
package/tsconfig.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "dist/esm",
5
- "rootDir": "src",
6
- "declarationDir": "./dist/types",
7
- "paths": {
8
- "*": ["./*"]
9
- },
10
- "types": ["vite/client"],
11
- "lib": ["dom", "esnext", "webworker"]
12
- },
13
- "references": [
14
- {
15
- "path": "../../modules/module"
16
- },
17
- {
18
- "path": "../../modules/http"
19
- },
20
- {
21
- "path": "../../modules/msal"
22
- },
23
- {
24
- "path": "../../modules/service-discovery"
25
- },
26
- {
27
- "path": "../../modules/telemetry"
28
- },
29
- {
30
- "path": "../../modules/services"
31
- }
32
- ],
33
- "include": ["src/**/*"],
34
- "exclude": ["node_modules"]
35
- }
package/vitest.config.ts DELETED
@@ -1,10 +0,0 @@
1
- import { defineProject } from 'vitest/config';
2
-
3
- import { name, version } from './package.json' with { type: 'json' };
4
-
5
- export default defineProject({
6
- test: {
7
- include: ['tests/**/*.test.ts'],
8
- name: `${name}@${version}`,
9
- },
10
- });