@equinor/fusion-framework-app 11.0.11 → 12.0.0

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 (41) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +38 -1
  3. package/dist/esm/AppConfigurator.js +28 -3
  4. package/dist/esm/AppConfigurator.js.map +1 -1
  5. package/dist/esm/AppConfiguratorError.js +32 -0
  6. package/dist/esm/AppConfiguratorError.js.map +1 -0
  7. package/dist/esm/AppModulesConfiguredEvent.js +18 -0
  8. package/dist/esm/AppModulesConfiguredEvent.js.map +1 -0
  9. package/dist/esm/AppModulesInitializedEvent.js +23 -0
  10. package/dist/esm/AppModulesInitializedEvent.js.map +1 -0
  11. package/dist/esm/configure-modules.js +6 -0
  12. package/dist/esm/configure-modules.js.map +1 -1
  13. package/dist/esm/enable-state.js +42 -0
  14. package/dist/esm/enable-state.js.map +1 -0
  15. package/dist/esm/index.js +3 -0
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/utils.js +41 -0
  18. package/dist/esm/utils.js.map +1 -0
  19. package/dist/esm/version.js +1 -1
  20. package/dist/esm/version.js.map +1 -1
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/dist/types/AppConfigurator.d.ts +20 -2
  23. package/dist/types/AppConfiguratorError.d.ts +26 -0
  24. package/dist/types/AppModulesConfiguredEvent.d.ts +37 -0
  25. package/dist/types/AppModulesInitializedEvent.d.ts +34 -0
  26. package/dist/types/configure-modules.d.ts +6 -0
  27. package/dist/types/enable-state.d.ts +39 -0
  28. package/dist/types/index.d.ts +4 -1
  29. package/dist/types/utils.d.ts +22 -0
  30. package/dist/types/version.d.ts +1 -1
  31. package/package.json +22 -8
  32. package/src/AppConfigurator.ts +50 -4
  33. package/src/AppConfiguratorError.ts +34 -0
  34. package/src/AppModulesConfiguredEvent.ts +43 -0
  35. package/src/AppModulesInitializedEvent.ts +40 -0
  36. package/src/configure-modules.ts +8 -0
  37. package/src/enable-state.ts +49 -0
  38. package/src/index.ts +7 -1
  39. package/src/utils.ts +50 -0
  40. package/src/version.ts +1 -1
  41. package/tsconfig.json +3 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # Change Log
2
2
 
3
+ ## 12.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b92698d: Add state management module support to @equinor/fusion-framework-app
8
+
9
+ This change introduces comprehensive state management capabilities to the app package, allowing developers to easily enable persistent state storage in their Fusion applications.
10
+
11
+ **Features**
12
+
13
+ - **State Module Enabler**: Added `enableState` function that configures the state module with PouchDB storage
14
+ - **Package Exports**: Added new export path `./enable-state` for the state enabler function
15
+ - **Type Definitions**: Added typesVersions support for the new state enabler
16
+ - **Peer Dependencies**: Added `@equinor/fusion-framework-module-state` as an optional peer dependency
17
+ - **Storage Configuration**: Automatic app-scoped storage with key prefixing to prevent state collisions
18
+
19
+ **Usage**
20
+
21
+ Applications can now enable state management by:
22
+
23
+ ```typescript
24
+ import { enableState } from "@equinor/fusion-framework-app/enable-state";
25
+
26
+ export const configure = (configurator) => {
27
+ enableState(configurator);
28
+ };
29
+ ```
30
+
31
+ The state module provides persistent storage with automatic app-key scoping and uses PouchDB for reliable data persistence across browser sessions.
32
+
33
+ **Note**: Applications must install `@equinor/fusion-framework-module-state` to use this functionality.
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [0d6ef3a]
38
+ - Updated dependencies [020d9e5]
39
+ - Updated dependencies [0d9d876]
40
+ - Updated dependencies [05586e7]
41
+ - Updated dependencies [b92698d]
42
+ - Updated dependencies [b92698d]
43
+ - @equinor/fusion-framework-module-state@1.0.0
44
+ - @equinor/fusion-framework-module@6.1.2
45
+ - @equinor/fusion-framework@8.0.13
46
+ - @equinor/fusion-framework-module-telemetry@7.0.2
47
+
48
+ ## 11.0.12
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies [de2b4fb]
53
+ - @equinor/fusion-framework-module-app@8.0.4
54
+ - @equinor/fusion-framework-module-http@8.0.5
55
+ - @equinor/fusion-framework@8.0.12
56
+
3
57
  ## 11.0.11
4
58
 
5
59
  ### Patch Changes
package/README.md CHANGED
@@ -1,4 +1,15 @@
1
- # @equinor/fusion-framework-app
1
+ ---
2
+ title: "@equinor/fusion-framework-app"
3
+ description: "Application foundation package for the Fusion Framework"
4
+ category: "Application"
5
+ tag:
6
+ - app
7
+ - core
8
+ - foundation
9
+ - modules
10
+ - framework
11
+ - typescript
12
+ ---
2
13
 
3
14
  Configuration and initialization layer for Fusion applications.
4
15
 
@@ -16,6 +27,32 @@ pnpm add @equinor/fusion-framework-app
16
27
  ```
17
28
 
18
29
  ## Quick Start
30
+ ```typescript
31
+ import type { AppModuleInitiator } from '@equinor/fusion-framework-app';
32
+ import { enableState } from '@equinor/fusion-framework-app/enable-state';
33
+
34
+ const configure: AppModuleInitiator = (configurator) => {
35
+ enableState(configurator);
36
+ };
37
+ ```
38
+
39
+ > [!CAUTION]
40
+ > The state management module is a powerful tool, but it's important to know the potential pitfalls and limitations when using it in your application. The state management is global and can lead to unexpected behavior if not used carefully.
41
+ >
42
+ > __example 1:__ If you have multiple components that rely on the same state, updating the state in one component can cause re-renders in all components that use that state, potentially leading to performance issues.
43
+ >
44
+ > __example 2:__ The user has open multiple tabs of the application, and each tab is modifying the same state. This can lead to unexpected behavior, as changes made in one tab will be reflected to all tabs. (like storing user preferences for selected columns)
45
+
46
+ #### Bookmarks
47
+
48
+ [<img src="https://img.shields.io/github/package-json/v/equinor/fusion-framework?filename=packages%2Fmodules%2Fbookmark%2Fpackage.json&label=@equinor/fusion-framework-module-bookmark&style=for-the-badge" />](https://github.com/equinor/fusion-framework/tree/main/packages/modules/bookmark)
49
+
50
+ _The bookmark module provides a way to save and restore the state of the application. This is useful for saving the state of the application when the user navigates away from the application and then returns to the application._
51
+
52
+ ```sh
53
+ # Install the bookmark module
54
+ pnpm add @equinor/fusion-framework-module-bookmark
55
+ ```
19
56
 
20
57
  ```ts
21
58
  import { configureModules } from '@equinor/fusion-framework-app';
@@ -2,13 +2,16 @@ import { ModulesConfigurator, } from '@equinor/fusion-framework-module';
2
2
  import event from '@equinor/fusion-framework-module-event';
3
3
  import http, { configureHttpClient, configureHttp, } from '@equinor/fusion-framework-module-http';
4
4
  import auth from '@equinor/fusion-framework-module-msal';
5
+ import { AppModulesConfiguredEvent } from './AppModulesConfiguredEvent';
6
+ import { AppConfiguratorError } from './AppConfiguratorError';
7
+ import { deepClone, deepFreeze } from './utils';
5
8
  /**
6
9
  * Configurator that bootstraps default Fusion application modules and provides
7
10
  * helper methods for HTTP client and service-discovery setup.
8
11
  *
9
12
  * `AppConfigurator` is created internally by {@link configureModules}. It registers
10
13
  * the `event`, `http`, and `msal` (auth) modules by default and reads any HTTP
11
- * endpoints declared in the applications environment config.
14
+ * endpoints declared in the application's environment config.
12
15
  *
13
16
  * @template TModules - Additional application-specific modules beyond the defaults.
14
17
  * @template TRef - The resolved Fusion modules instance used as an initialization reference.
@@ -31,6 +34,7 @@ export class AppConfigurator extends ModulesConfigurator {
31
34
  * the name is preserved through compilation and minification.
32
35
  */
33
36
  static className = 'AppConfigurator';
37
+ #manifest;
34
38
  /**
35
39
  * Create an application configurator with default modules and environment.
36
40
  *
@@ -38,11 +42,32 @@ export class AppConfigurator extends ModulesConfigurator {
38
42
  * HTTP clients declared in `env.config.endpoints`.
39
43
  *
40
44
  * @param env - The application environment containing manifest, config, and optional basename.
45
+ * @param ref - Optional reference to the Fusion modules instance, used for event dispatching.
41
46
  */
42
- constructor(env) {
47
+ constructor(env, ref) {
43
48
  super([event, http, auth]);
44
49
  this.env = env;
50
+ this.#manifest = deepFreeze(deepClone(env.manifest));
45
51
  this._configureHttpClientsFromAppConfig();
52
+ this.onConfigured((configs) => {
53
+ const configuredEvent = new AppModulesConfiguredEvent({
54
+ detail: {
55
+ appKey: this.#manifest.appKey,
56
+ configs,
57
+ },
58
+ });
59
+ ref?.event.dispatchEvent(configuredEvent);
60
+ });
61
+ }
62
+ /**
63
+ * The immutable application manifest.
64
+ *
65
+ * Deeply frozen at construction time to prevent accidental mutations.
66
+ *
67
+ * @returns The deeply immutable application manifest.
68
+ */
69
+ get manifest() {
70
+ return this.#manifest;
46
71
  }
47
72
  /**
48
73
  * Read HTTP endpoint definitions from the application config and register each
@@ -102,7 +127,7 @@ export class AppConfigurator extends ModulesConfigurator {
102
127
  const service = await ref?.serviceDiscovery.resolveService(serviceName);
103
128
  // Guard: service must resolve before the HTTP client can be configured.
104
129
  if (!service) {
105
- throw Error(`failed to configure service [${serviceName}]`);
130
+ throw new AppConfiguratorError(`Unable to resolve service [${serviceName}] during configuration.`, 'configuration');
106
131
  }
107
132
  // Check if serviceName is already configured (potentially with app-config)
108
133
  // If the service is session overridden - we need the configuration to run
@@ -1 +1 @@
1
- {"version":3,"file":"AppConfigurator.js","sourceRoot":"","sources":["../../src/AppConfigurator.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,mBAAmB,GACpB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,MAAM,wCAAwC,CAAC;AAE3D,OAAO,IAAI,EAAE,EACX,mBAAmB,EACnB,aAAa,GAEd,MAAM,uCAAuC,CAAC;AAE/C,OAAO,IAAI,MAAM,uCAAuC,CAAC;AAgFzD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,eAKX,SAAQ,mBAA+C;IAiB3B,GAAG;IAd/B;;;OAGG;IACH,MAAM,CAAU,SAAS,GAAW,iBAAiB,CAAC;IAEtD;;;;;;;OAOG;IACH,YAA4B,GAAS;QACnC,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;mBADD,GAAG;QAG7B,IAAI,CAAC,kCAAkC,EAAE,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACO,kCAAkC;QAC1C,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;QACjD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,wEAAwE;gBACxE,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,MAAM,IAAI,oBAAoB,CAC5B,8BAA8B,WAAW,yBAAyB,EAClE,eAAe,CAChB,CAAC;gBACJ,CAAC;gBAED,2EAA2E;gBAC3E,0EAA0E;gBAC1E,uCAAuC;gBACvC,IAAI,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;oBACzD,OAAO,CAAC,IAAI,CACV,GAAG,WAAW;;oCAEU,CACzB,CAAC;oBACF,OAAO;gBACT,CAAC;gBACD,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE;oBAClC,GAAG,OAAO;oBACV,OAAO,EAAE,OAAO,CAAC,GAAG;oBACpB,aAAa,EAAE,OAAO,CAAC,aAAa;iBACrC,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Custom error class for application configurator errors.
3
+ *
4
+ * Provides error context to help developers debug configuration and initialization issues.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * try {
9
+ * const modules = await initialize({ fusion, env });
10
+ * } catch (error) {
11
+ * if (error instanceof AppConfiguratorError) {
12
+ * console.log(`Error in ${error.phase}: ${error.message}`);
13
+ * }
14
+ * }
15
+ * ```
16
+ */
17
+ export class AppConfiguratorError extends Error {
18
+ phase;
19
+ /**
20
+ * @param message - Human-readable error description
21
+ * @param phase - The phase where the error occurred
22
+ * @param cause - The underlying error that caused this failure
23
+ */
24
+ constructor(message, phase, cause) {
25
+ super(message);
26
+ this.phase = phase;
27
+ this.name = 'AppConfiguratorError';
28
+ this.cause = cause;
29
+ }
30
+ }
31
+ export default AppConfiguratorError;
32
+ //# sourceMappingURL=AppConfiguratorError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppConfiguratorError.js","sourceRoot":"","sources":["../../src/AppConfiguratorError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAQ3B,KAAK;IAPvB;;;;OAIG;IACH,YACE,OAAe,EACC,KAAyC,EACzD,KAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;qBAHC,KAAK;QAIrB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { FrameworkEvent } from '@equinor/fusion-framework-module-event';
2
+ /**
3
+ * Event emitted when application modules have been configured.
4
+ *
5
+ * @template T - An array of additional modules configured in the application.
6
+ * @extends FrameworkEvent<AppModulesConfiguredEventInit<T>>
7
+ */
8
+ export class AppModulesConfiguredEvent extends FrameworkEvent {
9
+ /**
10
+ * Create an event describing configured application modules.
11
+ *
12
+ * @param init - Event initialization data containing the application key and module configs.
13
+ */
14
+ constructor(init) {
15
+ super('onAppModulesConfigured', init);
16
+ }
17
+ }
18
+ //# sourceMappingURL=AppModulesConfiguredEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppModulesConfiguredEvent.js","sourceRoot":"","sources":["../../src/AppModulesConfiguredEvent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAA2B,MAAM,wCAAwC,CAAC;AAgBjG;;;;;GAKG;AACH,MAAM,OAAO,yBAEX,SAAQ,cAAgD;IACxD;;;;OAIG;IACH,YAAY,IAAsC;QAChD,KAAK,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ import { FrameworkEvent } from '@equinor/fusion-framework-module-event';
2
+ /**
3
+ * Event triggered when application modules have been initialized.
4
+ *
5
+ * @template T - An array of modules extending `AnyModule`. Defaults to an empty array.
6
+ * @extends FrameworkEvent<AppModulesInitializedEventInit<T>>
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const event = new AppModulesInitializedEvent({ modules: [...] });
11
+ * ```
12
+ */
13
+ export class AppModulesInitializedEvent extends FrameworkEvent {
14
+ /**
15
+ * Create an event describing initialized application modules.
16
+ *
17
+ * @param init - Event initialization data containing the application key and module instance.
18
+ */
19
+ constructor(init) {
20
+ super('onAppModulesInitialized', init);
21
+ }
22
+ }
23
+ //# sourceMappingURL=AppModulesInitializedEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppModulesInitializedEvent.js","sourceRoot":"","sources":["../../src/AppModulesInitializedEvent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAA2B,MAAM,wCAAwC,CAAC;AAejG;;;;;;;;;;GAUG;AACH,MAAM,OAAO,0BAEX,SAAQ,cAAiD;IACzD;;;;OAIG;IACH,YAAY,IAAuC;QACjD,KAAK,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;CACF"}
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @fileoverview Application module configuration factory
3
+ *
4
+ * Provides the core factory function for configuring and initializing
5
+ * application-specific modules in the Fusion framework.
6
+ */
1
7
  import { enableTelemetry, } from '@equinor/fusion-framework-module-telemetry';
2
8
  import { AppConfigurator } from './AppConfigurator';
3
9
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"configure-modules.js","sourceRoot":"","sources":["../../src/configure-modules.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,GAEhB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAC3B,CAKE,EAA6C,EACmC,EAAE;AACpF;;;;;;;GAOG;AACH,KAAK,EAAE,IAAiC,EAAyC,EAAE;IACjF,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAExB,0BAA0B;IAC1B,MA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,iBAAiB,CAAC,CAAC;YACvC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC5C,kEAAkE;YAClE,OAAO,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACnC,CAAC;KACF,CAAC,CAAC;IAEH,wEAAwE;IACxE,IAAI,EAAE,EAAE,CAAC;QACP,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,kFAAkF;IAClF,gFAAgF;IAChF,+EAA+E;IAC/E,qFAAqF;IACrF,MAAM,OAAO,GAAiC,CAAC,MAAM,YAAY,CAAC,UAAU,CAC1E,IAAI,CAAC,MAAM,CAAC,OAAO,CACpB,CAA4C,CAAC;IAE9C,+DAA+D;IAC/D,kGAAkG;IAClG,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,oBAAoB,EAAE;YAChD,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE;SACnF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEJ,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { enableStateModule } from '@equinor/fusion-framework-module-state';
2
+ /**
3
+ * Enables state management for the application with persistent storage.
4
+ *
5
+ * This is a thin, app-scoped convenience wrapper around `enableStateModule` — it registers
6
+ * the state module on the app's configurator so app code can reach it via the app namespace,
7
+ * and scopes the module's default storage to this app's own `manifest.appKey` (so unrelated
8
+ * apps or widgets hosted alongside it never share its state). The state module resolves a
9
+ * local PouchDB database, optionally synced with the Fusion App State backend when service
10
+ * discovery and auth are configured; call `setStorage` on the configurator to override it.
11
+ *
12
+ * @warning Local storage is NOT encrypted. Do not store sensitive data such as passwords,
13
+ * tokens, personal information, or any data that requires security protection.
14
+ *
15
+ * @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.
16
+ *
17
+ * @template M - Array of modules to be configured.
18
+ * @template R - The fusion modules instance type.
19
+ * @param configurator - The application configurator to enable state management on.
20
+ * @param configure - Optional config callback, receiving the module's `IStateModuleConfigurator`.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * import { enableState } from '@equinor/fusion-framework-app';
25
+ *
26
+ * export const configure = (configurator) => {
27
+ * enableState(configurator);
28
+ * };
29
+ *
30
+ * // Later in your app, access the state provider
31
+ * const stateProvider = modules.state;
32
+ * await stateProvider.storeItem({ key: 'user-preference', value: { theme: 'dark' } });
33
+ * const item = await stateProvider.getItem('user-preference');
34
+ * ```
35
+ */
36
+ export function enableState(configurator, configure) {
37
+ enableStateModule(configurator, async (builder) => {
38
+ builder.setName(configurator.manifest.appKey);
39
+ await configure?.(builder);
40
+ });
41
+ }
42
+ //# sourceMappingURL=enable-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enable-state.js","sourceRoot":"","sources":["../../src/enable-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAM3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,WAAW,CACzB,YAAoC,EACpC,SAAuE;IAEvE,iBAAiB,CAAC,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChD,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/esm/index.js CHANGED
@@ -18,6 +18,9 @@
18
18
  export { AppConfigurator } from './AppConfigurator';
19
19
  export * from './types';
20
20
  export { configureModules, default } from './configure-modules';
21
+ export { AppConfiguratorError } from './AppConfiguratorError';
22
+ export { AppModulesConfiguredEvent } from './AppModulesConfiguredEvent';
23
+ export { AppModulesInitializedEvent } from './AppModulesInitializedEvent';
21
24
  /**
22
25
  * @deprecated Use {@link configureModules} instead. This alias will be removed in a future major version.
23
26
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,eAAe,EAAoB,MAAM,mBAAmB,CAAC;AAEtE,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEhE;;GAEG;AACH,OAAO,EAAE,gBAAgB,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,eAAe,EAAgD,MAAM,mBAAmB,CAAC;AAElG,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;GAEG;AACH,OAAO,EAAE,gBAAgB,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,41 @@
1
+ export { default as deepClone } from 'lodash.clonedeep';
2
+ /**
3
+ * Determines if the provided object is eligible to be frozen.
4
+ *
5
+ * Checks whether the input is a non-null object or array that is not already frozen.
6
+ *
7
+ * @param obj - The value to check for isMutable.
8
+ * @returns True if the object is a non-null object or array and is not already frozen; otherwise, false.
9
+ */
10
+ function isMutable(obj) {
11
+ return typeof obj === 'object' && obj !== null && !Object.isFrozen(obj);
12
+ }
13
+ /**
14
+ * Recursively applies Object.freeze to an object and all nested properties, making them immutable.
15
+ *
16
+ * @remarks
17
+ * - Plain objects and arrays are deeply frozen.
18
+ * - Does not handle circular references. Use with caution on complex object graphs.
19
+ * - Symbol properties are not frozen.
20
+ *
21
+ * @template T - The type of the object to freeze.
22
+ * @param obj - The object to deeply freeze.
23
+ * @returns The deeply frozen (read-only) object.
24
+ */
25
+ export function deepFreeze(source) {
26
+ // Skip primitives and objects already frozen to avoid unnecessary recursion.
27
+ if (isMutable(source)) {
28
+ // Arrays require traversing their values directly before freezing the container.
29
+ if (Array.isArray(source)) {
30
+ // Freeze every nested array value so the result is immutable at every depth.
31
+ source.forEach(deepFreeze);
32
+ }
33
+ else {
34
+ // Freeze every nested object value so the result is immutable at every depth.
35
+ Object.values(source).forEach(deepFreeze);
36
+ }
37
+ Object.freeze(source);
38
+ }
39
+ return source;
40
+ }
41
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAWxD;;;;;;;GAOG;AACH,SAAS,SAAS,CAAC,GAAY;IAC7B,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAI,MAAS;IACrC,6EAA6E;IAC7E,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,iFAAiF;QACjF,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,6EAA6E;YAC7E,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,8EAA8E;YAC9E,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // Generated by genversion.
2
- export const version = '11.0.11';
2
+ export const version = '12.0.0';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC"}