@equinor/fusion-framework-app 13.0.3 → 13.1.1

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.
Files changed (46) hide show
  1. package/README.md +35 -65
  2. package/dist/esm/__tests__/mock/AppMockConfigurator.test.js +70 -0
  3. package/dist/esm/__tests__/mock/AppMockConfigurator.test.js.map +1 -0
  4. package/dist/esm/__tests__/mock/mock-app.test.js +86 -0
  5. package/dist/esm/__tests__/mock/mock-app.test.js.map +1 -0
  6. package/dist/esm/__tests__/mock/msal-hoisting.test.js +36 -0
  7. package/dist/esm/__tests__/mock/msal-hoisting.test.js.map +1 -0
  8. package/dist/esm/configure-modules.js +2 -42
  9. package/dist/esm/configure-modules.js.map +1 -1
  10. package/dist/esm/initialize-app-modules.js +65 -0
  11. package/dist/esm/initialize-app-modules.js.map +1 -0
  12. package/dist/esm/mock/AppMockConfigurator.js +183 -0
  13. package/dist/esm/mock/AppMockConfigurator.js.map +1 -0
  14. package/dist/esm/mock/enable-app-manifest-mock.js +49 -0
  15. package/dist/esm/mock/enable-app-manifest-mock.js.map +1 -0
  16. package/dist/esm/mock/index.js +21 -0
  17. package/dist/esm/mock/index.js.map +1 -0
  18. package/dist/esm/mock/mock-app-modules.js +82 -0
  19. package/dist/esm/mock/mock-app-modules.js.map +1 -0
  20. package/dist/esm/version.js +1 -1
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/dist/types/__tests__/mock/AppMockConfigurator.test.d.ts +1 -0
  23. package/dist/types/__tests__/mock/mock-app.test.d.ts +1 -0
  24. package/dist/types/__tests__/mock/msal-hoisting.test.d.ts +1 -0
  25. package/dist/types/initialize-app-modules.d.ts +31 -0
  26. package/dist/types/mock/AppMockConfigurator.d.ts +142 -0
  27. package/dist/types/mock/enable-app-manifest-mock.d.ts +33 -0
  28. package/dist/types/mock/index.d.ts +20 -0
  29. package/dist/types/mock/mock-app-modules.d.ts +72 -0
  30. package/dist/types/version.d.ts +1 -1
  31. package/package.json +25 -13
  32. package/CHANGELOG.md +0 -1990
  33. package/src/AppConfigurator.ts +0 -280
  34. package/src/AppConfiguratorError.ts +0 -34
  35. package/src/AppModulesConfiguredEvent.ts +0 -43
  36. package/src/AppModulesInitializedEvent.ts +0 -40
  37. package/src/__tests__/AppConfigurator.test.ts +0 -49
  38. package/src/configure-modules.ts +0 -121
  39. package/src/enable-bookmark.ts +0 -95
  40. package/src/enable-state.ts +0 -49
  41. package/src/index.ts +0 -34
  42. package/src/types.ts +0 -145
  43. package/src/utils.ts +0 -50
  44. package/src/version.ts +0 -2
  45. package/tsconfig.json +0 -42
  46. package/vitest.config.ts +0 -10
@@ -1,49 +0,0 @@
1
- import { enableStateModule } from '@equinor/fusion-framework-module-state';
2
- import type { IStateModuleConfigurator } from '@equinor/fusion-framework-module-state';
3
- import type { IAppConfigurator } from './AppConfigurator';
4
- import type { AnyModule } from '@equinor/fusion-framework-module';
5
- import type { FusionModulesInstance } from '@equinor/fusion-framework';
6
-
7
- /**
8
- * Enables state management for the application with persistent storage.
9
- *
10
- * This is a thin, app-scoped convenience wrapper around `enableStateModule` — it registers
11
- * the state module on the app's configurator so app code can reach it via the app namespace,
12
- * and scopes the module's default storage to this app's own `manifest.appKey` (so unrelated
13
- * apps or widgets hosted alongside it never share its state). The state module resolves a
14
- * local PouchDB database, optionally synced with the Fusion App State backend when service
15
- * discovery and auth are configured; call `setStorage` on the configurator to override it.
16
- *
17
- * @warning Local storage is NOT encrypted. Do not store sensitive data such as passwords,
18
- * tokens, personal information, or any data that requires security protection.
19
- *
20
- * @see {@link https://github.com/equinor/fusion-framework/blob/main/packages/modules/state/README.md | State Module Documentation} for comprehensive usage examples and API reference.
21
- *
22
- * @template M - Array of modules to be configured.
23
- * @template R - The fusion modules instance type.
24
- * @param configurator - The application configurator to enable state management on.
25
- * @param configure - Optional config callback, receiving the module's `IStateModuleConfigurator`.
26
- *
27
- * @example
28
- * ```typescript
29
- * import { enableState } from '@equinor/fusion-framework-app';
30
- *
31
- * export const configure = (configurator) => {
32
- * enableState(configurator);
33
- * };
34
- *
35
- * // Later in your app, access the state provider
36
- * const stateProvider = modules.state;
37
- * await stateProvider.storeItem({ key: 'user-preference', value: { theme: 'dark' } });
38
- * const item = await stateProvider.getItem('user-preference');
39
- * ```
40
- */
41
- export function enableState<M extends AnyModule[], R extends FusionModulesInstance>(
42
- configurator: IAppConfigurator<M, R>,
43
- configure?: (builder: IStateModuleConfigurator) => void | Promise<void>,
44
- ): void {
45
- enableStateModule(configurator, async (builder) => {
46
- builder.setName(configurator.manifest.appKey);
47
- await configure?.(builder);
48
- });
49
- }
package/src/index.ts DELETED
@@ -1,34 +0,0 @@
1
- /**
2
- * @packageDocumentation
3
- *
4
- * `@equinor/fusion-framework-app` provides the configuration and initialization
5
- * layer for Fusion applications. Use this package to set up application modules,
6
- * configure HTTP clients, enable bookmarks, and integrate with telemetry and
7
- * service discovery.
8
- *
9
- * The main entry points are:
10
- *
11
- * - {@link configureModules} — factory that creates an application initializer
12
- * - {@link AppConfigurator} / {@link IAppConfigurator} — configurator for registering modules and HTTP clients
13
- * - Type aliases such as {@link AppModuleInitiator}, {@link AppEnv}, and {@link AppRenderFn}
14
- *
15
- * Bookmark support is available via the `@equinor/fusion-framework-app/enable-bookmark`
16
- * sub-path export.
17
- */
18
-
19
- export { AppConfigurator, IAppConfigurator, AppConfiguratorConstructor } from './AppConfigurator';
20
-
21
- export * from './types';
22
-
23
- export { configureModules, default } from './configure-modules';
24
-
25
- export { AppConfiguratorError } from './AppConfiguratorError';
26
-
27
- export { AppModulesConfiguredEvent } from './AppModulesConfiguredEvent';
28
-
29
- export { AppModulesInitializedEvent } from './AppModulesInitializedEvent';
30
-
31
- /**
32
- * @deprecated Use {@link configureModules} instead. This alias will be removed in a future major version.
33
- */
34
- export { configureModules as initAppModules } from './configure-modules';
package/src/types.ts DELETED
@@ -1,145 +0,0 @@
1
- import type { Fusion } from '@equinor/fusion-framework';
2
-
3
- import type { AnyModule } from '@equinor/fusion-framework-module';
4
-
5
- import type {
6
- AppConfig,
7
- AppManifest,
8
- AppModulesInstance,
9
- ComponentRenderArgs,
10
- } from '@equinor/fusion-framework-module-app';
11
-
12
- import type { IAppConfigurator } from './AppConfigurator';
13
- import type { ConfigEnvironment } from '@equinor/fusion-framework-module-app';
14
-
15
- /**
16
- * Re-exported application module types from `@equinor/fusion-framework-module-app`.
17
- *
18
- * - `AppModules` — union of default application modules
19
- * - `AppManifest` — application manifest metadata (app key, version, etc.)
20
- * - `AppConfig` — environment-specific application configuration
21
- * - `AppModulesInstance` — resolved module instances after initialization
22
- */
23
- export type {
24
- AppModules,
25
- AppManifest,
26
- AppConfig,
27
- AppModulesInstance,
28
- } from '@equinor/fusion-framework-module-app';
29
-
30
- /**
31
- * Environment descriptor passed to the application during module initialization.
32
- *
33
- * Contains the application manifest, optional config (with endpoint definitions),
34
- * an optional base path for routing, and optional component props.
35
- *
36
- * @template TConfig - Shape of the environment-specific configuration object.
37
- * @template TProps - Additional properties forwarded to the application component (currently unused).
38
- */
39
- export type AppEnv<TConfig extends ConfigEnvironment = ConfigEnvironment, TProps = unknown> = {
40
- /** Base routing path of the application (e.g. `/apps/my-app`). */
41
- basename?: string;
42
- /** Application manifest describing the app key, version, and build metadata. */
43
- manifest: AppManifest;
44
- /** Environment-specific configuration with optional endpoint definitions. */
45
- config?: AppConfig<TConfig>;
46
- /** Optional properties forwarded to the application component. */
47
- props?: TProps;
48
- };
49
-
50
- /**
51
- * Configuration callback for setting up application modules.
52
- *
53
- * This is the function signature accepted by {@link configureModules}. Implement
54
- * this callback to register HTTP clients, enable bookmarks, and add custom modules
55
- * to the application’s module pipeline.
56
- *
57
- * @template TModules - Additional modules registered by the application.
58
- * @template TRef - The Fusion instance type used as a configuration reference.
59
- * @template TEnv - The application environment descriptor.
60
- *
61
- * @param configurator - The application configurator with HTTP and module helpers.
62
- * @param args - Object containing the Fusion instance and the application environment.
63
- * @returns `void` or a `Promise<void>` for async configuration steps.
64
- *
65
- * @example
66
- * ```ts
67
- * import type { AppModuleInitiator } from '@equinor/fusion-framework-app';
68
- *
69
- * const configure: AppModuleInitiator = (configurator, { fusion, env }) => {
70
- * configurator.useFrameworkServiceClient('portal-api');
71
- * };
72
- * ```
73
- */
74
- export type AppModuleInitiator<
75
- TModules extends Array<AnyModule> | unknown = unknown,
76
- TRef extends Fusion = Fusion,
77
- TEnv = AppEnv,
78
- > = (
79
- configurator: IAppConfigurator<TModules, TRef['modules']>,
80
- args: { fusion: TRef; env: TEnv },
81
- ) => void | Promise<void>;
82
-
83
- /**
84
- * Factory type that wraps {@link AppModuleInitiator} into a complete initializer.
85
- *
86
- * Accepts a configuration callback and returns an async function that, given the
87
- * Fusion instance and environment, produces the initialized module instance.
88
- * This is the signature of the {@link configureModules} function itself.
89
- *
90
- * @template TModules - Additional modules registered by the application.
91
- * @template TRef - The Fusion instance type used as a configuration reference.
92
- * @template TEnv - The application environment descriptor.
93
- */
94
- export type AppModuleInit<
95
- TModules extends Array<AnyModule> | unknown = [],
96
- TRef extends Fusion = Fusion,
97
- TEnv = AppEnv,
98
- > = (
99
- cb: AppModuleInitiator<TModules, TRef, TEnv>,
100
- ) => (args: AppModuleInitArgs<TRef, TEnv>) => Promise<AppModulesInstance<TModules>>;
101
-
102
- /**
103
- * Arguments passed to the async initializer returned by {@link configureModules}.
104
- *
105
- * @template TRef - The Fusion instance type.
106
- * @template TEnv - The application environment descriptor.
107
- */
108
- export type AppModuleInitArgs<TRef extends Fusion = Fusion, TEnv = AppEnv> = {
109
- fusion: TRef;
110
- env: TEnv;
111
- };
112
-
113
- /**
114
- * Render function signature for mounting a Fusion application into the DOM.
115
- *
116
- * Called by the Fusion portal or dev-server to render the application. The
117
- * function receives the root element and render arguments (Fusion instance,
118
- * environment, and modules) and optionally returns a cleanup function that
119
- * is invoked when the application is unmounted.
120
- *
121
- * @template TFusion - The Fusion instance type providing framework modules.
122
- * @template TEnv - The application environment descriptor.
123
- *
124
- * @param el - The root HTML element where the application will be rendered.
125
- * @param args - Render arguments including the Fusion instance, environment,
126
- * and resolved modules.
127
- * @returns A cleanup / teardown function, or `void` if no cleanup is needed.
128
- *
129
- * @example
130
- * ```ts
131
- * import type { AppRenderFn } from '@equinor/fusion-framework-app';
132
- * import { createRoot } from 'react-dom/client';
133
- *
134
- * export const renderApp: AppRenderFn = (el, args) => {
135
- * const root = createRoot(el);
136
- * root.render(<App />);
137
- * return () => root.unmount();
138
- * };
139
- * ```
140
- */
141
- export type AppRenderFn<TFusion extends Fusion = Fusion, TEnv = AppEnv> = (
142
- el: HTMLHtmlElement,
143
- args: ComponentRenderArgs<TFusion, TEnv>,
144
- // biome-ignore lint/suspicious/noConfusingVoidType: `void` here relies on TypeScript's special-cased "void-returning callback accepts any return value" behavior \u2014 `undefined` would break assignability of render functions that return a cleanup function
145
- ) => VoidFunction | void;
package/src/utils.ts DELETED
@@ -1,50 +0,0 @@
1
- export { default as deepClone } from 'lodash.clonedeep';
2
-
3
- /**
4
- * Utility type that makes all properties of an object deeply readonly.
5
- *
6
- * @typeParam T - The type to make deeply readonly.
7
- */
8
- export type DeepImmutable<T> = {
9
- readonly [P in keyof T]: T[P] extends object ? DeepImmutable<T[P]> : T[P];
10
- };
11
-
12
- /**
13
- * Determines if the provided object is eligible to be frozen.
14
- *
15
- * Checks whether the input is a non-null object or array that is not already frozen.
16
- *
17
- * @param obj - The value to check for isMutable.
18
- * @returns True if the object is a non-null object or array and is not already frozen; otherwise, false.
19
- */
20
- function isMutable(obj: unknown): obj is Record<string, unknown> | Array<unknown> {
21
- return typeof obj === 'object' && obj !== null && !Object.isFrozen(obj);
22
- }
23
-
24
- /**
25
- * Recursively applies Object.freeze to an object and all nested properties, making them immutable.
26
- *
27
- * @remarks
28
- * - Plain objects and arrays are deeply frozen.
29
- * - Does not handle circular references. Use with caution on complex object graphs.
30
- * - Symbol properties are not frozen.
31
- *
32
- * @template T - The type of the object to freeze.
33
- * @param obj - The object to deeply freeze.
34
- * @returns The deeply frozen (read-only) object.
35
- */
36
- export function deepFreeze<T>(source: T): DeepImmutable<T> {
37
- // Skip primitives and objects already frozen to avoid unnecessary recursion.
38
- if (isMutable(source)) {
39
- // Arrays require traversing their values directly before freezing the container.
40
- if (Array.isArray(source)) {
41
- // Freeze every nested array value so the result is immutable at every depth.
42
- source.forEach(deepFreeze);
43
- } else {
44
- // Freeze every nested object value so the result is immutable at every depth.
45
- Object.values(source).forEach(deepFreeze);
46
- }
47
- Object.freeze(source);
48
- }
49
- return source;
50
- }
package/src/version.ts DELETED
@@ -1,2 +0,0 @@
1
- // Generated by genversion.
2
- export const version = '13.0.3';
package/tsconfig.json DELETED
@@ -1,42 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "dist/esm",
5
- "rootDir": "src",
6
- "declarationDir": "./dist/types"
7
- },
8
- "references": [
9
- {
10
- "path": "../modules/module"
11
- },
12
- {
13
- "path": "../modules/http"
14
- },
15
- {
16
- "path": "../modules/msal"
17
- },
18
- {
19
- "path": "../modules/event"
20
- },
21
- {
22
- "path": "../modules/telemetry"
23
- },
24
- {
25
- "path": "../modules/bookmark"
26
- },
27
- {
28
- "path": "../modules/state"
29
- },
30
- {
31
- "path": "../modules/app"
32
- },
33
- {
34
- "path": "../modules/feature-flag"
35
- },
36
- {
37
- "path": "../framework"
38
- }
39
- ],
40
- "include": ["src/**/*"],
41
- "exclude": ["node_modules", "lib"]
42
- }
package/vitest.config.ts DELETED
@@ -1,10 +0,0 @@
1
- import { defineProject } from 'vitest/config';
2
-
3
- import { name, version } from './package.json';
4
-
5
- export default defineProject({
6
- test: {
7
- include: ['src/__tests__/**'],
8
- name: `${name}@${version}`,
9
- },
10
- });