@equinor/fusion-framework-module-widget 14.0.1 → 15.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 (59) hide show
  1. package/CHANGELOG.md +34 -7
  2. package/README.md +171 -0
  3. package/dist/esm/Widget.js +91 -27
  4. package/dist/esm/Widget.js.map +1 -1
  5. package/dist/esm/WidgetModuleConfigurator.js +31 -15
  6. package/dist/esm/WidgetModuleConfigurator.js.map +1 -1
  7. package/dist/esm/WidgetModuleProvider.js +52 -20
  8. package/dist/esm/WidgetModuleProvider.js.map +1 -1
  9. package/dist/esm/enable-widget-module.js +16 -2
  10. package/dist/esm/enable-widget-module.js.map +1 -1
  11. package/dist/esm/errors.js +50 -0
  12. package/dist/esm/errors.js.map +1 -1
  13. package/dist/esm/index.js +9 -0
  14. package/dist/esm/index.js.map +1 -1
  15. package/dist/esm/module.js +12 -0
  16. package/dist/esm/module.js.map +1 -1
  17. package/dist/esm/state/actions.js +18 -3
  18. package/dist/esm/state/actions.js.map +1 -1
  19. package/dist/esm/state/create-reducer.js +10 -0
  20. package/dist/esm/state/create-reducer.js.map +1 -1
  21. package/dist/esm/state/create-state.js +12 -0
  22. package/dist/esm/state/create-state.js.map +1 -1
  23. package/dist/esm/state/flows.js +22 -0
  24. package/dist/esm/state/flows.js.map +1 -1
  25. package/dist/esm/utils.js +29 -0
  26. package/dist/esm/utils.js.map +1 -1
  27. package/dist/esm/version.js +1 -1
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/dist/types/Widget.d.ts +91 -25
  30. package/dist/types/WidgetModuleConfigurator.d.ts +44 -10
  31. package/dist/types/WidgetModuleProvider.d.ts +80 -20
  32. package/dist/types/enable-widget-module.d.ts +16 -2
  33. package/dist/types/errors.d.ts +57 -0
  34. package/dist/types/events.d.ts +37 -17
  35. package/dist/types/index.d.ts +11 -2
  36. package/dist/types/module.d.ts +21 -0
  37. package/dist/types/state/actions.d.ts +29 -4
  38. package/dist/types/state/create-reducer.d.ts +10 -0
  39. package/dist/types/state/create-state.d.ts +12 -0
  40. package/dist/types/state/flows.d.ts +22 -0
  41. package/dist/types/types.d.ts +82 -15
  42. package/dist/types/utils.d.ts +29 -0
  43. package/dist/types/version.d.ts +1 -1
  44. package/package.json +13 -13
  45. package/src/Widget.ts +94 -27
  46. package/src/WidgetModuleConfigurator.ts +44 -17
  47. package/src/WidgetModuleProvider.ts +82 -20
  48. package/src/enable-widget-module.ts +16 -2
  49. package/src/errors.ts +57 -0
  50. package/src/events.ts +36 -17
  51. package/src/index.ts +12 -2
  52. package/src/module.ts +21 -0
  53. package/src/state/actions.ts +21 -3
  54. package/src/state/create-reducer.ts +10 -0
  55. package/src/state/create-state.ts +12 -0
  56. package/src/state/flows.ts +22 -0
  57. package/src/types.ts +88 -16
  58. package/src/utils.ts +29 -0
  59. package/src/version.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Change Log
2
2
 
3
+ ## 15.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - abffa53: Major version bump for Fusion Framework React 19 release.
8
+
9
+ All packages are bumped to the next major version as part of the React 19 upgrade. This release drops support for React versions below 18 and includes breaking changes across the framework.
10
+
11
+ **Breaking changes:**
12
+ - Peer dependencies now require React 18 or 19 (`^18.0.0 || ^19.0.0`)
13
+ - React Router upgraded from v6 to v7
14
+ - Navigation module refactored with new history API
15
+ - `renderComponent` and `renderApp` now use `createRoot` API
16
+
17
+ **Migration:**
18
+ - Update your React version to 18.0.0 or higher before upgrading
19
+ - Replace `NavigationProvider.createRouter()` with `@equinor/fusion-framework-react-router`
20
+ - See individual package changelogs for package-specific migration steps
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [abffa53]
25
+ - Updated dependencies [abffa53]
26
+ - Updated dependencies [abffa53]
27
+ - Updated dependencies [abffa53]
28
+ - Updated dependencies [abffa53]
29
+ - Updated dependencies [8f30948]
30
+ - @equinor/fusion-framework-module@6.0.0
31
+ - @equinor/fusion-framework-module-event@6.0.0
32
+ - @equinor/fusion-framework-module-http@8.0.0
33
+ - @equinor/fusion-framework-module-service-discovery@10.0.0
34
+ - @equinor/fusion-observable@9.0.0
35
+ - @equinor/fusion-query@7.0.0
36
+
3
37
  ## 14.0.1
4
38
 
5
39
  ### Patch Changes
@@ -77,19 +111,16 @@
77
111
  - [#3395](https://github.com/equinor/fusion-framework/pull/3395) [`29f6710`](https://github.com/equinor/fusion-framework/commit/29f6710238baf9b29f42394b30cb8b97f25462c3) Thanks [@odinr](https://github.com/odinr)! - Updated immer from 9.0.16 to 10.1.3 across all packages.
78
112
 
79
113
  ### Breaking Changes
80
-
81
114
  - Immer 10.x introduces stricter TypeScript types for draft functions
82
115
  - `ValidRecipeReturnType` type constraints have changed
83
116
  - Promise return types in draft functions are no longer automatically handled
84
117
 
85
118
  ### Fixes Applied
86
-
87
119
  - Updated BookmarkProvider to handle new immer type constraints
88
120
  - Fixed ObservableInput type assignments in mergeScan operations
89
121
  - Removed async/await from immer draft functions to comply with new type requirements
90
122
 
91
123
  ### Links
92
-
93
124
  - [Immer 10.0.0 Release Notes](https://github.com/immerjs/immer/releases/tag/v10.0.0)
94
125
  - [Immer Migration Guide](https://github.com/immerjs/immer/blob/main/MIGRATION.md)
95
126
 
@@ -112,7 +143,6 @@
112
143
  ### Patch Changes
113
144
 
114
145
  - [#3088](https://github.com/equinor/fusion-framework/pull/3088) [`7441b13`](https://github.com/equinor/fusion-framework/commit/7441b13aa50dd7362d1629086a27b6b4e571575d) Thanks [@eikeland](https://github.com/eikeland)! - chore: update package typesVersions
115
-
116
146
  - Updated package.json typesVersions.
117
147
  - Ensures backward compatibility with older node versions.
118
148
  - Ensured consistency with workspace and repository configuration.
@@ -362,7 +392,6 @@
362
392
  - [#2320](https://github.com/equinor/fusion-framework/pull/2320) [`1dd85f3`](https://github.com/equinor/fusion-framework/commit/1dd85f3a408a73df556d1812a5f280945cc100ee) Thanks [@odinr](https://github.com/odinr)! - Removed the `removeComments` option from the `tsconfig.base.json` file.
363
393
 
364
394
  Removing the `removeComments` option allows TypeScript to preserve comments in the compiled JavaScript output. This can be beneficial for several reasons:
365
-
366
395
  1. Improved debugging: Preserved comments can help developers understand the code better during debugging sessions.
367
396
  2. Documentation: JSDoc comments and other important code documentation will be retained in the compiled output.
368
397
  3. Source map accuracy: Keeping comments can lead to more accurate source maps, which is crucial for debugging and error tracking.
@@ -415,7 +444,6 @@
415
444
  ### Patch Changes
416
445
 
417
446
  - [#2235](https://github.com/equinor/fusion-framework/pull/2235) [`97e41a5`](https://github.com/equinor/fusion-framework/commit/97e41a55d05644b6684c6cb165b65b115bd416eb) Thanks [@odinr](https://github.com/odinr)! - - **Refactored**: The `actionBaseType` function has been renamed to `getBaseType` and its implementation has been updated.
418
-
419
447
  - **Added**: New utility types and functions for handling action types and payloads in a more type-safe manner.
420
448
 
421
449
  - [#2248](https://github.com/equinor/fusion-framework/pull/2248) [`da9dd83`](https://github.com/equinor/fusion-framework/commit/da9dd83c9352def5365b6c962dc8443589ac9526) Thanks [@asbjornhaland](https://github.com/asbjornhaland)! - #2235 renamed a method and changed type. This PR forgot to change to the correct param when using this method. Fixes typo - update to use actions `type` in the reducer.
@@ -687,7 +715,6 @@
687
715
  ### Patch Changes
688
716
 
689
717
  - [#905](https://github.com/equinor/fusion-framework/pull/905) [`a7858a1c`](https://github.com/equinor/fusion-framework/commit/a7858a1c01542e2dc94370709f122b4b99c3219c) Thanks [@odinr](https://github.com/odinr)! - **🚧 Chore: dedupe packages**
690
-
691
718
  - align all versions of typescript
692
719
  - update types to build
693
720
  - a couple of typecasts did not [satisfies](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#satisfies-support-in-jsdoc) and was recasted as `unknwon`, marked with `TODO`, should be fixed in future
package/README.md ADDED
@@ -0,0 +1,171 @@
1
+ # @equinor/fusion-framework-module-widget
2
+
3
+ Fusion Framework module for loading, managing, and rendering **widgets** — self-contained UI micro-frontends that can be dynamically fetched, configured, and mounted into a host application.
4
+
5
+ ## When to use this module
6
+
7
+ Use this module when your application needs to:
8
+
9
+ - Load remote widget manifests and scripts at runtime
10
+ - Render isolated micro-frontend widgets inside a host app
11
+ - Manage widget lifecycle (initialize → load manifest → import script → render → dispose)
12
+ - React to widget lifecycle events via the Fusion event system
13
+
14
+ ## Installation
15
+
16
+ ```sh
17
+ pnpm add @equinor/fusion-framework-module-widget
18
+ ```
19
+
20
+ ### Peer dependencies
21
+
22
+ The module requires these Fusion Framework modules as peer dependencies:
23
+
24
+ | Package | Required |
25
+ |---|---|
26
+ | `@equinor/fusion-framework-module` | **yes** |
27
+ | `@equinor/fusion-framework-module-event` | optional |
28
+ | `@equinor/fusion-framework-module-http` | optional |
29
+ | `@equinor/fusion-framework-module-service-discovery` | optional |
30
+
31
+ ## Key concepts
32
+
33
+ ### Widget lifecycle
34
+
35
+ A widget moves through the following states:
36
+
37
+ 1. **Create** — `getWidget(name)` creates a `Widget` instance with initial state
38
+ 2. **Load manifest** — fetches the widget manifest (name, version, entry point, asset path)
39
+ 3. **Import script** — dynamically imports the widget's JavaScript entry point
40
+ 4. **Initialize** — combines manifest + script (+ optional config) and emits the result
41
+ 5. **Render** — the imported script module exposes render functions (`renderWidget`, `render`, etc.)
42
+ 6. **Dispose** — cleans up subscriptions and resources
43
+
44
+ ### Architecture
45
+
46
+ ```
47
+ enableWidgetModule()
48
+ └─► WidgetModuleConfigurator (configure HTTP client, endpoints)
49
+ └─► WidgetModuleProvider (create and manage Widget instances)
50
+ └─► Widget (manifest, script, config, state machine)
51
+ └─► state/ (actions, reducer, flows — RxJS-based)
52
+ ```
53
+
54
+ - **`WidgetModuleConfigurator`** — configures the HTTP client used to fetch widget manifests and configs from the backend API
55
+ - **`WidgetModuleProvider`** — implements `IWidgetModuleProvider` and serves as the entry point for creating `Widget` instances
56
+ - **`Widget`** — manages a single widget's full lifecycle using an RxJS-based state machine (`FlowSubject`)
57
+
58
+ ## Quick start
59
+
60
+ ### Enable the module
61
+
62
+ ```typescript
63
+ import { enableWidgetModule } from '@equinor/fusion-framework-module-widget';
64
+
65
+ // In your framework configuration callback:
66
+ enableWidgetModule(configurator);
67
+ ```
68
+
69
+ ### Customize the HTTP client
70
+
71
+ ```typescript
72
+ enableWidgetModule(configurator, (widgetConfigurator) => {
73
+ widgetConfigurator.setClient(async (client) => {
74
+ // Return a custom IClient implementation
75
+ return myCustomClient;
76
+ });
77
+ });
78
+ ```
79
+
80
+ ### Retrieve and initialize a widget
81
+
82
+ ```typescript
83
+ const provider = modules.widget; // IWidgetModuleProvider
84
+
85
+ // Create a widget instance
86
+ const widget = provider.getWidget('my-widget');
87
+
88
+ // Initialize: loads manifest, imports script, prepares config
89
+ widget.initialize().subscribe({
90
+ next: ({ manifest, script, config }) => {
91
+ // Mount the widget into a DOM element
92
+ const cleanup = script.renderWidget(hostElement, { fusion, env: { manifest } });
93
+ },
94
+ error: (err) => console.error('Widget initialization failed', err),
95
+ complete: () => console.log('Widget ready'),
96
+ });
97
+ ```
98
+
99
+ ### Observe manifest or config individually
100
+
101
+ ```typescript
102
+ // Stream the manifest
103
+ provider.getWidgetManifest('my-widget').subscribe((manifest) => {
104
+ console.log('Manifest:', manifest);
105
+ });
106
+
107
+ // Stream the config
108
+ provider.getWidgetConfig('my-widget').subscribe((config) => {
109
+ console.log('Config:', config);
110
+ });
111
+ ```
112
+
113
+ ## Exported entry points
114
+
115
+ | Export path | Description |
116
+ |---|---|
117
+ | `@equinor/fusion-framework-module-widget` | Main entry — module definition, configurator, provider, types, and `enableWidgetModule` |
118
+ | `@equinor/fusion-framework-module-widget/errors.js` | Error classes: `WidgetManifestLoadError`, `WidgetConfigLoadError`, `WidgetScriptModuleError` |
119
+
120
+ ## Events
121
+
122
+ When the optional `@equinor/fusion-framework-module-event` peer dependency is available, the module dispatches lifecycle events on the framework event bus:
123
+
124
+ | Event | Fired when |
125
+ |---|---|
126
+ | `onWidgetManifestLoad` | Manifest fetch starts |
127
+ | `onWidgetManifestLoaded` | Manifest fetch succeeds |
128
+ | `onWidgetManifestFailure` | Manifest fetch fails |
129
+ | `onWidgetScriptLoad` | Script import starts |
130
+ | `onWidgetScriptLoaded` | Script import succeeds |
131
+ | `onWidgetScriptFailure` | Script import fails |
132
+ | `onWidgetInitialize` | Widget initialization starts |
133
+ | `onWidgetInitialized` | Widget initialization completes |
134
+ | `onWidgetInitializeFailure` | Widget initialization fails |
135
+ | `onWidgetDispose` | Widget is disposed |
136
+
137
+ ## Error handling
138
+
139
+ The module provides typed error classes for HTTP-level failures:
140
+
141
+ - **`WidgetManifestLoadError`** — manifest fetch failed (maps 401 → `unauthorized`, 404 → `not_found`)
142
+ - **`WidgetConfigLoadError`** — config fetch failed (same HTTP status mapping)
143
+ - **`WidgetScriptModuleError`** — script import failed
144
+
145
+ Each error carries a `type` discriminator (`'not_found' | 'unauthorized' | 'unknown'`) for programmatic branching.
146
+
147
+ ## API reference
148
+
149
+ ### `enableWidgetModule(configurator, builder?)`
150
+
151
+ Registers the widget module on a framework configurator. Accepts an optional builder callback to customize the `WidgetModuleConfigurator`.
152
+
153
+ ### `WidgetModuleProvider` / `IWidgetModuleProvider`
154
+
155
+ - `getWidget(name, args?)` — creates a `Widget` instance
156
+ - `getWidgetManifest(name, args?)` — returns `Observable<WidgetManifest>`
157
+ - `getWidgetConfig(name, args?)` — returns `Observable<WidgetConfig>`
158
+ - `dispose()` — cleans up all query subscriptions
159
+
160
+ ### `Widget`
161
+
162
+ - `state` — current `WidgetState` snapshot
163
+ - `initialize()` — returns `Observable<{ manifest, script, config }>`
164
+ - `getManifest(force?)` — returns `Observable<WidgetManifest>`
165
+ - `getConfig(force?)` — returns `Observable<WidgetConfig>`
166
+ - `getWidgetModule(force?)` — returns `Observable<WidgetScriptModule>`
167
+ - `getWidgetModuleAsync(allowCache?)` — returns `Promise<WidgetScriptModule>`
168
+ - `loadManifest(update?)` — dispatches manifest fetch action
169
+ - `loadConfig(update?)` — dispatches config fetch action
170
+ - `updateManifest(manifest, replace?)` — sets manifest in state
171
+ - `dispose()` — unsubscribes all internal subscriptions
@@ -2,21 +2,50 @@ import { actions } from './state/actions';
2
2
  import { createState } from './state/create-state';
3
3
  import { Observable, Subscription, combineLatest, firstValueFrom, lastValueFrom, of } from 'rxjs';
4
4
  import './events';
5
- // Class representing a fusion widget
5
+ /**
6
+ * Manages the full lifecycle of a single Fusion widget.
7
+ *
8
+ * A `Widget` encapsulates fetching its manifest, dynamically importing its
9
+ * script entry point, loading configuration, and emitting lifecycle events.
10
+ * Internally it uses an RxJS-based `FlowSubject` state machine driven by
11
+ * actions and flows defined in the `state/` directory.
12
+ *
13
+ * Create instances via {@link WidgetModuleProvider.getWidget} rather than
14
+ * constructing directly.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const widget = provider.getWidget('my-widget');
19
+ * widget.initialize().subscribe(({ manifest, script }) => {
20
+ * script.renderWidget(el, { fusion, env: { manifest } });
21
+ * });
22
+ * ```
23
+ */
6
24
  export class Widget {
7
25
  #state;
26
+ /** Human-readable widget name used as the lookup key for manifest and config. */
8
27
  name;
28
+ /** Module-level HTTP client configuration used to resolve asset URLs. */
9
29
  config;
30
+ /** Optional version or tag parameters forwarded to manifest/config endpoints. */
10
31
  widgetPrams;
11
32
  #subscription = new Subscription();
12
- // Getter for accessing the current state of the widget
33
+ /** Current snapshot of the widget's internal state (manifest, config, modules, status). */
13
34
  get state() {
14
35
  return this.#state.value;
15
36
  }
16
37
  /**
17
- * Constructs a new Widget instance.
18
- * @param value - Initial state of the widget.
19
- * @param args - Configuration and event parameters for the widget.
38
+ * Constructs a new `Widget` instance.
39
+ *
40
+ * Prefer using {@link WidgetModuleProvider.getWidget} instead of calling
41
+ * this constructor directly.
42
+ *
43
+ * @param value - Initial widget state (at minimum, the widget `name`).
44
+ * @param args - Dependencies required by the widget.
45
+ * @param args.provider - The owning {@link WidgetModuleProvider}.
46
+ * @param args.config - Optional module-level HTTP client configuration.
47
+ * @param args.event - Optional event module for dispatching lifecycle events.
48
+ * @param args.widgetPrams - Optional version/tag selector for the widget.
20
49
  */
21
50
  constructor(value, args) {
22
51
  this.name = value.name;
@@ -87,9 +116,15 @@ export class Widget {
87
116
  });
88
117
  }
89
118
  /**
90
- * Retrieves the manifest of the widget as an observable stream.
91
- * @param force_refresh - Flag to force refresh the manifest.
92
- * @returns An observable stream of the widget manifest.
119
+ * Retrieves the widget manifest as an observable stream.
120
+ *
121
+ * If the manifest is already cached in state it is emitted immediately.
122
+ * When `force_refresh` is `true`, a new fetch is dispatched regardless of
123
+ * cache status.
124
+ *
125
+ * @param force_refresh - When `true`, re-fetches the manifest even if cached.
126
+ * @returns Observable that emits the {@link WidgetManifest} and completes.
127
+ * @throws {Error} When the manifest fetch fails (wraps the underlying cause).
93
128
  */
94
129
  getManifest(force_refresh = false) {
95
130
  return new Observable((subscriber) => {
@@ -115,9 +150,14 @@ export class Widget {
115
150
  });
116
151
  }
117
152
  /**
118
- * Retrieves the configuration of the widget as an observable stream.
119
- * @param force_refresh - Flag to force refresh the configuration.
120
- * @returns An observable stream of the widget configuration.
153
+ * Retrieves the widget configuration as an observable stream.
154
+ *
155
+ * Returns the cached config immediately when available. Set `force_refresh`
156
+ * to `true` to force a new fetch from the backend API.
157
+ *
158
+ * @param force_refresh - When `true`, re-fetches the config even if cached.
159
+ * @returns Observable that emits the {@link WidgetConfig} and completes.
160
+ * @throws {Error} When the config fetch fails (wraps the underlying cause).
121
161
  */
122
162
  getConfig(force_refresh = false) {
123
163
  return new Observable((subscriber) => {
@@ -144,23 +184,33 @@ export class Widget {
144
184
  });
145
185
  }
146
186
  /**
147
- * Loads the configuration for the widget.
148
- * @param update - Flag to force an update of the configuration.
187
+ * Dispatches a config fetch action into the state machine.
188
+ *
189
+ * @param update - When `true`, merges the fetched config with existing state
190
+ * instead of replacing it.
149
191
  */
150
192
  loadConfig(update) {
151
193
  this.#state.next(actions.fetchConfig({ key: this.name, ...this.widgetPrams }, update));
152
194
  }
153
195
  /**
154
- * Loads the manifest for the widget.
155
- * @param update - Flag to force an update of the manifest.
196
+ * Dispatches a manifest fetch action into the state machine.
197
+ *
198
+ * @param update - When `true`, merges the fetched manifest with existing
199
+ * state instead of replacing it.
156
200
  */
157
201
  loadManifest(update) {
158
202
  this.#state.next(actions.fetchManifest({ key: this.name, ...this.widgetPrams }, update));
159
203
  }
160
204
  /**
161
- * Retrieves the widget module as an observable stream.
162
- * @param force_refresh - Flag to force refresh the widget module.
163
- * @returns An observable stream of the widget module.
205
+ * Retrieves the widget's script module as an observable stream.
206
+ *
207
+ * Resolves the manifest first, builds the full import URL from the asset
208
+ * path and entry point, then dynamically imports the script. The imported
209
+ * module is cached in state for subsequent calls.
210
+ *
211
+ * @param force_refresh - When `true`, re-imports the script even if cached.
212
+ * @returns Observable that emits the {@link WidgetScriptModule} and completes.
213
+ * @throws {Error} When the script import fails (wraps the underlying cause).
164
214
  */
165
215
  getWidgetModule(force_refresh = false) {
166
216
  return new Observable((subscriber) => {
@@ -192,8 +242,12 @@ export class Widget {
192
242
  });
193
243
  }
194
244
  /**
195
- * Initializes the widget and returns an observable stream with the combined results.
196
- * @returns An observable stream with the manifest, script, and configuration.
245
+ * Initializes the widget by loading the manifest, importing the script, and
246
+ * preparing configuration. Emits a combined result when all resources are ready.
247
+ *
248
+ * @returns Observable that emits `{ manifest, script, config }` and completes
249
+ * once all resources have been resolved.
250
+ * @throws {Error} When any initialization step fails.
197
251
  */
198
252
  initialize() {
199
253
  return new Observable((observer) => {
@@ -223,24 +277,34 @@ export class Widget {
223
277
  });
224
278
  }
225
279
  /**
226
- * Retrieves the widget module asynchronously as a Promise.
227
- * @param allow_cache - Flag to allow caching of the widget module.
228
- * @returns A Promise containing the widget module.
280
+ * Retrieves the widget script module as a `Promise`.
281
+ *
282
+ * When `allow_cache` is `true` (default), resolves with the first emitted
283
+ * value (which may be cached). When `false`, waits for the last emission
284
+ * after a forced refresh.
285
+ *
286
+ * @param allow_cache - When `true`, uses `firstValueFrom`; when `false`,
287
+ * uses `lastValueFrom` after forcing a re-import.
288
+ * @returns Promise that resolves with the {@link WidgetScriptModule}.
229
289
  */
230
290
  getWidgetModuleAsync(allow_cache = true) {
231
291
  const operator = allow_cache ? firstValueFrom : lastValueFrom;
232
292
  return operator(this.getWidgetModule(!allow_cache));
233
293
  }
234
294
  /**
235
- * Updates the manifest of the widget.
236
- * @param manifest - The new manifest for the widget.
237
- * @param replace - Flag to replace the existing manifest.
295
+ * Replaces or merges the widget manifest in state.
296
+ *
297
+ * @param manifest - The new or partial manifest to set.
298
+ * @param replace - When `false` (default), the new manifest is merged with
299
+ * the existing one. Pass explicit `false` to merge, or omit to merge.
238
300
  */
239
301
  updateManifest(manifest, replace) {
240
302
  this.#state.next(actions.setManifest(manifest, !replace));
241
303
  }
242
304
  /**
243
- * Disposes of the widget by unsubscribing from any active subscriptions.
305
+ * Disposes of the widget by unsubscribing from all internal subscriptions.
306
+ *
307
+ * After disposal the widget instance should not be reused.
244
308
  */
245
309
  dispose() {
246
310
  this.#subscription.unsubscribe();
@@ -1 +1 @@
1
- {"version":3,"file":"Widget.js","sourceRoot":"","sources":["../../src/Widget.ts"],"names":[],"mappings":"AASA,OAAO,EAAgB,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAIlG,OAAO,UAAU,CAAC;AAElB,qCAAqC;AACrC,MAAM,OAAO,MAAM;IACjB,MAAM,CAAoC;IAC1C,IAAI,CAAS;IACb,MAAM,CAAsB;IAC5B,WAAW,CAA+B;IAE1C,aAAa,GAAG,IAAI,YAAY,EAAE,CAAC;IAEnC,uDAAuD;IACvD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,YACE,KAAyB,EACzB,I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AmG;oBACnG,MAAM,EAAE;wBACN,WAAW,EAAE,EAAE;wBACf,SAAS,EAAE,EAAE;qBACd;iBACF,CAAC;gBACJ,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;oBACb,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;gBACzE,CAAC;gBACD,QAAQ,EAAE,GAAG,EAAE;oBACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;oBAC/C,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACtB,CAAC;aACF,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACD;;;;;;;;;;OAUG;IACI,oBAAoB,CAAC,WAAW,GAAG,IAAI;QAC5C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC;QAC9D,OAAO,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IACtD,CAAC;IACD;;;;;;OAMG;IACI,cAAc,CAAC,QAAwB,EAAE,OAAe;QAC7D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACI,OAAO;QACZ,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC;CACF"}
@@ -1,21 +1,38 @@
1
1
  import { BaseConfigBuilder } from '@equinor/fusion-framework-module';
2
2
  import { createDefaultClient } from './utils';
3
- // Class responsible for configuring the WidgetModule
3
+ /**
4
+ * Configuration builder for the widget module.
5
+ *
6
+ * Extends `BaseConfigBuilder` to produce a {@link WidgetModuleConfig}. If no
7
+ * custom client is provided via {@link setClient}, a default HTTP client is
8
+ * created from the `apps` service-discovery endpoint.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * enableWidgetModule(configurator, (builder) => {
13
+ * builder.setClient(async () => myCustomClient);
14
+ * });
15
+ * ```
16
+ */
4
17
  export class WidgetModuleConfigurator extends BaseConfigBuilder {
5
- // Default expiration time for configurations (1 minute)
18
+ /** Default cache expiration time in milliseconds (1 minute). */
6
19
  defaultExpireTime = 1 * 60 * 1000;
7
20
  /**
8
- * Set the client for the WidgetModule configuration.
9
- * @param cb - Callback function to configure the client.
21
+ * Registers a custom {@link IClient} factory for the widget module.
22
+ *
23
+ * @param cb - Callback that receives config-builder args and returns an
24
+ * `IClient` instance (or a `Promise` thereof).
10
25
  */
11
26
  setClient(cb) {
12
27
  this._set('client', cb);
13
28
  }
14
29
  /**
15
- * Create an HTTP client based on the provided parameters.
16
- * @param clientId - Identifier for the client.
17
- * @param init - Configuration builder callback arguments.
18
- * @returns An instance of the HTTP client.
30
+ * Creates an HTTP client by resolving the `apps` client from the HTTP module
31
+ * or falling back to service discovery.
32
+ *
33
+ * @param clientId - Registered HTTP client identifier (typically `'apps'`).
34
+ * @param init - Framework config-builder callback args providing module instances.
35
+ * @returns An `IHttpClient` instance for widget API calls.
19
36
  */
20
37
  async _createHttpClient(clientId, init) {
21
38
  const http = await init.requireInstance('http');
@@ -29,19 +46,18 @@ export class WidgetModuleConfigurator extends BaseConfigBuilder {
29
46
  }
30
47
  }
31
48
  /**
32
- * Process the WidgetModule configuration and create an HTTP client if needed.
33
- * @param config - Partial configuration for the WidgetModule.
34
- * @param _init - Configuration builder callback arguments.
35
- * @returns The processed WidgetModule configuration.
49
+ * Finalizes the configuration by creating the default HTTP client when no
50
+ * custom client has been set.
51
+ *
52
+ * @param config - Partial configuration accumulated by builder callbacks.
53
+ * @param _init - Framework config-builder callback args.
54
+ * @returns The fully resolved {@link WidgetModuleConfig}.
36
55
  */
37
56
  async _processConfig(config, _init) {
38
- // Create an HTTP client using the specified client ID and initialization parameters
39
57
  const httpClient = await this._createHttpClient('apps', _init);
40
- // If the configuration does not have a client, use the default client
41
58
  if (!config.client) {
42
59
  config.client = createDefaultClient(httpClient);
43
60
  }
44
- // Return the processed configuration as a WidgetModuleConfig object
45
61
  return config;
46
62
  }
47
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"WidgetModuleConfigurator.js","sourceRoot":"","sources":["../../src/WidgetModuleConfigurator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA8B,MAAM,kCAAkC,CAAC;AAEjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAa9C,qDAAqD;AACrD,MAAM,OAAO,wBAAyB,SAAQ,iBAAqC;IACjF,wDAAwD;IACxD,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IAElC;;;OAGG;IACI,SAAS,CAAC,EAAkC;QACjD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,iBAAiB,CAAC,QAAgB,EAAE,IAA+B;QAC/E,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAEhD,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,oCAAoC;YACpC,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;YACxE,OAAO,MAAM,gBAAgB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,cAAc,CAC5B,MAAmC,EACnC,KAAgC;QAEhC,oFAAoF;QACpF,MAAM,UAAU,GAAG,MAAM,IAAI,CA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