@equinor/fusion-framework-react 8.0.0-next.0 → 8.0.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 (123) hide show
  1. package/CHANGELOG.md +60 -12
  2. package/README.md +164 -31
  3. package/dist/esm/Framework.js +32 -0
  4. package/dist/esm/Framework.js.map +1 -1
  5. package/dist/esm/app/index.js.map +1 -1
  6. package/dist/esm/app/useAppProvider.js +12 -2
  7. package/dist/esm/app/useAppProvider.js.map +1 -1
  8. package/dist/esm/app/useApps.js +17 -3
  9. package/dist/esm/app/useApps.js.map +1 -1
  10. package/dist/esm/app/useCurrentApp.js +26 -4
  11. package/dist/esm/app/useCurrentApp.js.map +1 -1
  12. package/dist/esm/app/useCurrentAppModule.js +26 -13
  13. package/dist/esm/app/useCurrentAppModule.js.map +1 -1
  14. package/dist/esm/app/useCurrentAppModules.js +14 -4
  15. package/dist/esm/app/useCurrentAppModules.js.map +1 -1
  16. package/dist/esm/context/index.js +10 -0
  17. package/dist/esm/context/index.js.map +1 -1
  18. package/dist/esm/context/useCurrentContext.js +16 -0
  19. package/dist/esm/context/useCurrentContext.js.map +1 -1
  20. package/dist/esm/context.js +6 -16
  21. package/dist/esm/context.js.map +1 -1
  22. package/dist/esm/create-framework-provider.js +30 -9
  23. package/dist/esm/create-framework-provider.js.map +1 -1
  24. package/dist/esm/feature-flag/index.js +10 -0
  25. package/dist/esm/feature-flag/index.js.map +1 -1
  26. package/dist/esm/feature-flag/useCurrentAppFeatures.js +12 -2
  27. package/dist/esm/feature-flag/useCurrentAppFeatures.js.map +1 -1
  28. package/dist/esm/feature-flag/useFeature.js +16 -6
  29. package/dist/esm/feature-flag/useFeature.js.map +1 -1
  30. package/dist/esm/feature-flag/useFeatures.js +24 -6
  31. package/dist/esm/feature-flag/useFeatures.js.map +1 -1
  32. package/dist/esm/feature-flag/useFrameworkFeature.js +13 -5
  33. package/dist/esm/feature-flag/useFrameworkFeature.js.map +1 -1
  34. package/dist/esm/feature-flag/useFrameworkFeatures.js +12 -4
  35. package/dist/esm/feature-flag/useFrameworkFeatures.js.map +1 -1
  36. package/dist/esm/framework-provider.js +21 -0
  37. package/dist/esm/framework-provider.js.map +1 -0
  38. package/dist/esm/hooks/index.js +10 -2
  39. package/dist/esm/hooks/index.js.map +1 -1
  40. package/dist/esm/hooks/useCurrentUser.js +20 -0
  41. package/dist/esm/hooks/useCurrentUser.js.map +1 -0
  42. package/dist/esm/hooks/useHttpClient.js +28 -0
  43. package/dist/esm/hooks/useHttpClient.js.map +1 -0
  44. package/dist/esm/http/index.js +11 -1
  45. package/dist/esm/http/index.js.map +1 -1
  46. package/dist/esm/index.js +9 -1
  47. package/dist/esm/index.js.map +1 -1
  48. package/dist/esm/signalr/index.js +1 -31
  49. package/dist/esm/signalr/index.js.map +1 -1
  50. package/dist/esm/signalr/useSignalR.js +33 -0
  51. package/dist/esm/signalr/useSignalR.js.map +1 -0
  52. package/dist/esm/useFramework.js +18 -4
  53. package/dist/esm/useFramework.js.map +1 -1
  54. package/dist/esm/useFrameworkModule.js +16 -8
  55. package/dist/esm/useFrameworkModule.js.map +1 -1
  56. package/dist/esm/version.js +1 -1
  57. package/dist/esm/version.js.map +1 -1
  58. package/dist/tsconfig.tsbuildinfo +1 -1
  59. package/dist/types/Framework.d.ts +38 -1
  60. package/dist/types/app/index.d.ts +10 -0
  61. package/dist/types/app/useAppProvider.d.ts +12 -3
  62. package/dist/types/app/useApps.d.ts +17 -3
  63. package/dist/types/app/useCurrentApp.d.ts +25 -4
  64. package/dist/types/app/useCurrentAppModule.d.ts +13 -7
  65. package/dist/types/app/useCurrentAppModules.d.ts +14 -4
  66. package/dist/types/context/index.d.ts +10 -0
  67. package/dist/types/context/useCurrentContext.d.ts +16 -0
  68. package/dist/types/context.d.ts +1 -21
  69. package/dist/types/create-framework-provider.d.ts +29 -8
  70. package/dist/types/feature-flag/index.d.ts +10 -0
  71. package/dist/types/feature-flag/useCurrentAppFeatures.d.ts +12 -2
  72. package/dist/types/feature-flag/useFeature.d.ts +23 -6
  73. package/dist/types/feature-flag/useFeatures.d.ts +23 -6
  74. package/dist/types/feature-flag/useFrameworkFeature.d.ts +12 -5
  75. package/dist/types/feature-flag/useFrameworkFeatures.d.ts +11 -4
  76. package/dist/types/framework-provider.d.ts +19 -0
  77. package/dist/types/hooks/index.d.ts +10 -2
  78. package/dist/types/hooks/useCurrentUser.d.ts +16 -0
  79. package/dist/types/hooks/useHttpClient.d.ts +20 -0
  80. package/dist/types/http/index.d.ts +11 -1
  81. package/dist/types/index.d.ts +9 -1
  82. package/dist/types/signalr/index.d.ts +1 -24
  83. package/dist/types/signalr/useSignalR.d.ts +24 -0
  84. package/dist/types/useFramework.d.ts +16 -4
  85. package/dist/types/useFrameworkModule.d.ts +13 -6
  86. package/dist/types/version.d.ts +1 -1
  87. package/package.json +15 -14
  88. package/src/Framework.tsx +37 -0
  89. package/src/app/index.ts +10 -0
  90. package/src/app/useAppProvider.ts +12 -2
  91. package/src/app/useApps.ts +17 -3
  92. package/src/app/useCurrentApp.ts +26 -4
  93. package/src/app/useCurrentAppModule.ts +26 -14
  94. package/src/app/useCurrentAppModules.ts +14 -4
  95. package/src/context/index.ts +10 -0
  96. package/src/context/useCurrentContext.ts +16 -0
  97. package/src/context.ts +6 -17
  98. package/src/create-framework-provider.tsx +31 -10
  99. package/src/feature-flag/index.ts +10 -0
  100. package/src/feature-flag/useCurrentAppFeatures.ts +12 -2
  101. package/src/feature-flag/useFeature.ts +31 -7
  102. package/src/feature-flag/useFeatures.ts +33 -7
  103. package/src/feature-flag/useFrameworkFeature.ts +13 -5
  104. package/src/feature-flag/useFrameworkFeatures.ts +12 -4
  105. package/src/framework-provider.ts +21 -0
  106. package/src/hooks/index.ts +10 -2
  107. package/src/hooks/useCurrentUser.ts +21 -0
  108. package/src/hooks/useHttpClient.ts +36 -0
  109. package/src/http/index.ts +11 -1
  110. package/src/index.tsx +9 -1
  111. package/src/signalr/index.ts +1 -39
  112. package/src/signalr/useSignalR.ts +40 -0
  113. package/src/useFramework.ts +18 -4
  114. package/src/useFrameworkModule.ts +16 -8
  115. package/src/version.ts +1 -1
  116. package/dist/esm/hooks/use-current-user.js +0 -6
  117. package/dist/esm/hooks/use-current-user.js.map +0 -1
  118. package/dist/esm/hooks/use-http-client.js +0 -14
  119. package/dist/esm/hooks/use-http-client.js.map +0 -1
  120. package/dist/types/hooks/use-current-user.d.ts +0 -2
  121. package/dist/types/hooks/use-http-client.d.ts +0 -5
  122. package/src/hooks/use-current-user.ts +0 -7
  123. package/src/hooks/use-http-client.ts +0 -19
@@ -1,23 +1,13 @@
1
1
  import { createContext } from 'react';
2
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
- export const context = createContext(null);
4
2
  /**
5
- * Component for providing framework.
3
+ * Internal React context that holds the current {@link Fusion} instance.
6
4
  *
7
5
  * @remarks
8
- * Should be created by {@link createFrameworkProvider}
6
+ * Consumers should not use this directly — prefer the {@link useFramework}
7
+ * hook or the {@link FrameworkProvider} component.
9
8
  *
10
- * @example
11
- * ```tsx
12
- * import {FrameworkProvider} from '@equinor/fusion-framework-react';
13
- * export const Component = (args: React.PropsWithChildren<{framework: Fusion}>) => {
14
- * return (
15
- * <FrameworkProvider value={args.framework}>
16
- * {args.children}
17
- * </FrameworkProvider>
18
- * );
19
- * }
20
- * ```
9
+ * @internal
21
10
  */
22
- export const FrameworkProvider = context.Provider;
11
+ // biome-ignore lint/suspicious/noExplicitAny: `Fusion<any>` widens the context to accept a Fusion instance with any concrete module set
12
+ export const context = createContext(null);
23
13
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAqB,IAAI,CAAC,CAAC;AAE/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC"}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC;;;;;;;;GAQG;AACH,wIAAwI;AACxI,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAqB,IAAI,CAAC,CAAC"}
@@ -2,23 +2,44 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { lazy } from 'react';
3
3
  import initFusion from '@equinor/fusion-framework';
4
4
  import { FrameworkConfigurator } from '@equinor/fusion-framework';
5
- import { FrameworkProvider } from './context';
5
+ import { FrameworkProvider } from './framework-provider';
6
6
  import { ModuleProvider } from '@equinor/fusion-framework-react-module';
7
7
  /**
8
- * Create a framework provider for react.
8
+ * Creates a lazy-loaded React component that initialises a Fusion Framework
9
+ * instance and exposes it via context providers.
9
10
  *
10
- * This function is for providers of framework, like a portal.
11
+ * @remarks
12
+ * This is the low-level factory used by the {@link Framework} component.
13
+ * Call it when you need fine-grained control over memoisation or when you
14
+ * want to embed the provider in a custom `<Suspense>` boundary.
15
+ *
16
+ * The returned component is created with `React.lazy`, so it **must** be
17
+ * rendered inside a `<Suspense>` boundary.
18
+ *
19
+ * @template TModules - Tuple of additional module types to register.
20
+ * @template TRef - Type of the optional parent module-instance reference.
21
+ *
22
+ * @param cb - Callback that receives a {@link FrameworkConfigurator} (and an
23
+ * optional parent ref) for registering modules and configuration.
24
+ * @param ref - Optional parent module instance to inherit configuration from.
25
+ * @returns A `React.lazy` component that provides the initialised framework
26
+ * to its children.
11
27
  *
12
- * @param configurator - callback for configuring modules
13
28
  * @example
14
29
  * ```tsx
15
- * const config: FrameworkConfigurator = (config) => {}
30
+ * import { createFrameworkProvider } from '@equinor/fusion-framework-react';
31
+ *
16
32
  * const Portal = () => {
17
- * const Framework = createFrameworkProvider(config);
33
+ * const FrameworkProvider = createFrameworkProvider((config) => {
34
+ * config.http.configureClient('my-api', { baseUri: 'https://api.example.com' });
35
+ * });
36
+ *
18
37
  * return (
19
- * <Suspense fallback={<span>loading...</span>}>
20
- * <Framework>{children}</Framework>
21
- * </Suspense>
38
+ * <Suspense fallback={<span>Loading…</span>}>
39
+ * <FrameworkProvider>
40
+ * <App />
41
+ * </FrameworkProvider>
42
+ * </Suspense>
22
43
  * );
23
44
  * };
24
45
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"create-framework-provider.js","sourceRoot":"","sources":["../../src/create-framework-provider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAKrC,EAAuF,EACvF,GAAU,EAC4E,EAAE,CACxF,IAAI,CAAC,KAAK,IAAI,EAAE;IACd,MAAM,YAAY,GAAG,IAAI,qBAAqB,EAAY,CAAC;IAC3D,MAAM,EAAE,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAC5B,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IACtD,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAkC,EAAE,EAAE,CAAC,CACzD,KAAC,iBAAiB,IAAC,KAAK,EAAE,SAAS,YACjC,KAAC,cAAc,IAAC,KAAK,EAAE,SAAS,CAAC,OAAO,YAAG,QAAQ,GAAkB,GACnD,CACrB;KACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"create-framework-provider.js","sourceRoot":"","sources":["../../src/create-framework-provider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAKrC,EAAuF,EACvF,GAAU,EAC4E,EAAE,CACxF,IAAI,CAAC,KAAK,IAAI,EAAE;IACd,MAAM,YAAY,GAAG,IAAI,qBAAqB,EAAY,CAAC;IAC3D,MAAM,EAAE,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAC5B,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IACtD,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAkC,EAAE,EAAE,CAAC,CACzD,KAAC,iBAAiB,IAAC,KAAK,EAAE,SAAS,YACjC,KAAC,cAAc,IAAC,KAAK,EAAE,SAAS,CAAC,OAAO,YAAG,QAAQ,GAAkB,GACnD,CACrB;KACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Feature-flag React hooks.
3
+ *
4
+ * @remarks
5
+ * Available via the `@equinor/fusion-framework-react/feature-flag` sub-entry-point.
6
+ * Provides hooks to read, toggle, and observe feature flags at the
7
+ * framework or application level.
8
+ *
9
+ * @module
10
+ */
1
11
  export { useFeature } from './useFeature';
2
12
  export { useFeatures } from './useFeatures';
3
13
  export { useCurrentAppFeatures } from './useCurrentAppFeatures';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-flag/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-flag/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,8 +1,18 @@
1
1
  import { useCurrentAppModule } from '../app';
2
2
  import { useFeatures } from './useFeatures';
3
3
  /**
4
- * Custom hook that returns the current app features and provides a function to toggle a feature.
5
- * @returns An object containing the current app features, a function to toggle a feature, and any error that occurred.
4
+ * React hook that returns feature flags registered on the current application.
5
+ *
6
+ * @returns A {@link UseFeaturesResult} containing:
7
+ * - `features` — Array of feature flags for the current app.
8
+ * - `toggleFeature(key, enable?)` — Toggles a feature flag on or off.
9
+ * - `error` — Any error from the feature-flag or app-module streams.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const { features, toggleFeature } = useCurrentAppFeatures();
14
+ * toggleFeature('dark-mode', true);
15
+ * ```
6
16
  */
7
17
  export const useCurrentAppFeatures = () => {
8
18
  const { module, error: moduleError } = useCurrentAppModule('featureFlag');
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrentAppFeatures.js","sourceRoot":"","sources":["../../../src/feature-flag/useCurrentAppFeatures.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,WAAW,EAA0B,MAAM,eAAe,CAAC;AAEpE;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAsB,EAAE;IAC3D,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,mBAAmB,CAAoB,aAAa,CAAC,CAAC;IAE7F,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAE/D,OAAO;QACL,QAAQ;QACR,aAAa;QACb,KAAK,EAAE,KAAK,IAAI,WAAW;KAC5B,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"useCurrentAppFeatures.js","sourceRoot":"","sources":["../../../src/feature-flag/useCurrentAppFeatures.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,WAAW,EAA0B,MAAM,eAAe,CAAC;AAEpE;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAsB,EAAE;IAC3D,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,mBAAmB,CAAoB,aAAa,CAAC,CAAC;IAE7F,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAE/D,OAAO;QACL,QAAQ;QACR,aAAa;QACb,KAAK,EAAE,KAAK,IAAI,WAAW;KAC5B,CAAC;AACJ,CAAC,CAAC"}
@@ -3,15 +3,25 @@ import { EMPTY } from 'rxjs';
3
3
  import { useObservableState } from '@equinor/fusion-observable/react';
4
4
  import { findFeature } from '@equinor/fusion-framework-module-feature-flag/selectors';
5
5
  /**
6
- * Custom hook that retrieves a feature flag from a feature flag provider.
6
+ * React hook that retrieves and manages a single feature flag.
7
7
  *
8
- * @template T - The type of the feature flag value.
9
- * @param {IFeatureFlagProvider} provider - The feature flag provider.
10
- * @param {string} key - The key of the feature flag.
11
- * @returns {UseFeatureResult<T>} - An object containing the feature flag value, a function to toggle the feature flag, and any error that occurred.
8
+ * @template T - Value type carried by the feature flag.
9
+ * @param provider - The feature-flag provider instance.
10
+ * @param key - Unique key identifying the feature flag.
11
+ * @returns A {@link UseFeatureResult} with the flag value, toggle helper,
12
+ * and any error.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const { feature, toggleFeature } = useFeature(provider, 'dark-mode');
17
+ * console.log(feature?.enabled);
18
+ * ```
12
19
  */
13
20
  export const useFeature = (provider, key) => {
14
- const feature$ = useMemo(() => provider.features$.pipe(findFeature(key)), [provider, key]);
21
+ // Narrow the features stream down to just the one matching feature by key.
22
+ const feature$ = useMemo(() => provider.features$
23
+ // Keep the observable scoped to the requested feature key.
24
+ .pipe(findFeature(key)), [provider, key]);
15
25
  const { value: feature, error } = useObservableState(feature$ ?? EMPTY);
16
26
  const toggleFeature = useCallback((enable) => {
17
27
  const enabled = enable === undefined ? !provider.getFeature(key)?.enabled : enable;
@@ -1 +1 @@
1
- {"version":3,"file":"useFeature.js","sourceRoot":"","sources":["../../../src/feature-flag/useFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAO7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,yDAAyD,CAAC;AAWtF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,QAA8B,EAC9B,GAAW,EACU,EAAE;IACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAI,GAAG,CAAC,CAAC,EAAE,CAAC,Q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AAK,EAAE,GAAG,kBAAkB,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC;IACxE,MAAM,aAAa,GAAG,WAAW,CAC/B,CAAC,MAAgB,EAAE,EAAE;QACnB,MAAM,OAAO,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;QACnF,QAAQ,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3C,CAAC,EACD,CAAC,QAAQ,EAAE,GAAG,CAAC,CAChB,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAC3C,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -3,12 +3,21 @@ import { of } from 'rxjs';
3
3
  import { map } from 'rxjs/operators';
4
4
  import { useObservableState } from '@equinor/fusion-observable/react';
5
5
  /**
6
- * Custom hook that provides access to the feature flags and their values.
6
+ * React hook that returns all feature flags from a provider, with optional
7
+ * filtering.
7
8
  *
8
- * @param provider - The feature flag provider.
9
- * @param selector - Optional function to filter the feature flags.
10
- * @returns An object containing the features, any error that occurred while retrieving them, and a function to set the enabled state of a feature flag.
11
- * @throws Error if the feature flag provider is missing.
9
+ * @param provider - The feature-flag provider instance, or `null`/`undefined`
10
+ * when not yet available.
11
+ * @param selector - Optional predicate to filter the feature flags.
12
+ * @returns A {@link UseFeaturesResult} with the flags, a toggle helper,
13
+ * and any error.
14
+ * @throws {Error} If `toggleFeature` is called when the provider is missing.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const { features, toggleFeature } = useFeatures(provider);
19
+ * toggleFeature('beta', true);
20
+ * ```
12
21
  */
13
22
  export const useFeatures = (provider, selector) => {
14
23
  /**
@@ -17,10 +26,18 @@ export const useFeatures = (provider, selector) => {
17
26
  * @returns An object containing the features and any error that occurred while retrieving them.
18
27
  */
19
28
  const { value: features, error } = useObservableState(useMemo(() => {
29
+ // Only compute the feature list when a provider is available; otherwise there's nothing to observe
20
30
  if (provider) {
31
+ // Map the feature dictionary to a list, optionally narrowed by the caller-provided selector
21
32
  return provider?.features$.pipe(map((x) => {
22
33
  const values = Object.values(x);
23
- return selector ? values.filter(selector) : values;
34
+ // Return everything when no selector is provided
35
+ if (!selector) {
36
+ return values;
37
+ }
38
+ // Apply the caller-provided selector to narrow down the feature list
39
+ const filtered = values.filter(selector);
40
+ return filtered;
24
41
  }));
25
42
  }
26
43
  return of([]);
@@ -33,6 +50,7 @@ export const useFeatures = (provider, selector) => {
33
50
  * @throws Error if IFeatureFlagProvider is missing.
34
51
  */
35
52
  const toggleFeature = useCallback((key, enable) => {
53
+ // Cannot toggle a feature without a provider to persist the change
36
54
  if (!provider) {
37
55
  throw new Error('Missing IFeatureFlagProvider.');
38
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useFeatures.js","sourceRoot":"","sources":["../../../src/feature-flag/useFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AASrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAYtE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,QAAsC,EACtC,QAA4B,EACT,EAAE;IACrB;;;;OAIG;IACH,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,kBAAkB,CACnD,OAAO,CAAC,GAAG,EAAE;QACX,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,EAAE,SAAS,CAAC,IAAI,CAC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACR,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,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AAa,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3C,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IACF,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AAC5C,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,15 +1,23 @@
1
1
  import { useFrameworkModule } from '../useFrameworkModule';
2
2
  import { useFeature } from './useFeature';
3
3
  /**
4
- * Custom hook that allows accessing a framework feature based on a given feature flag key.
4
+ * React hook that retrieves a single feature flag from the **framework-level**
5
+ * feature-flag provider.
5
6
  *
6
- * @template T - The type of the feature.
7
- * @param {string} key - The feature flag key.
8
- * @returns {ReturnType<typeof useFeature<T>>} - The result of the feature hook.
9
- * @throws {Error} - If feature flagging is not enabled in the framework.
7
+ * @template T - Value type carried by the feature flag.
8
+ * @param key - Unique key identifying the feature flag.
9
+ * @returns A {@link UseFeatureResult} with the flag value, toggle helper,
10
+ * and any error.
11
+ * @throws {Error} If the `FeatureFlagModule` is not enabled in the framework.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const { feature, toggleFeature } = useFrameworkFeature('experimental-ui');
16
+ * ```
10
17
  */
11
18
  export const useFrameworkFeature = (key) => {
12
19
  const provider = useFrameworkModule('featureFlag');
20
+ // Fail fast when the FeatureFlagModule has not been enabled on the framework
13
21
  if (!provider) {
14
22
  throw Error('Feature flagging is not enabled in the framework');
15
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useFrameworkFeature.js","sourceRoot":"","sources":["../../../src/feature-flag/useFrameworkFeature.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAI,GAAW,EAAoC,EAAE;IACtF,MAAM,QAAQ,GAAG,kBAAkB,CAAoB,aAAa,CAAC,CAAC;IACtE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"useFrameworkFeature.js","sourceRoot":"","sources":["../../../src/feature-flag/useFrameworkFeature.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAI,GAAW,EAAoC,EAAE;IACtF,MAAM,QAAQ,GAAG,kBAAkB,CAAoB,aAAa,CAAC,CAAC;IACtE,6EAA6E;IAC7E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -1,13 +1,21 @@
1
1
  import { useFrameworkModule } from '../useFrameworkModule';
2
2
  import { useFeatures } from './useFeatures';
3
3
  /**
4
- * Custom hook that provides access to framework-specific feature flags.
5
- * It returns the result of the `useFeatures` hook from the `featureFlag` module.
6
- * @returns The result of the `useFeatures` hook.
7
- * @throws Error if feature flagging is not enabled in the framework.
4
+ * React hook that returns all feature flags from the **framework-level**
5
+ * feature-flag provider.
6
+ *
7
+ * @returns A {@link UseFeaturesResult} containing all framework feature flags,
8
+ * a toggle helper, and any error.
9
+ * @throws {Error} If the `FeatureFlagModule` is not enabled in the framework.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const { features, toggleFeature } = useFrameworkFeatures();
14
+ * ```
8
15
  */
9
16
  export const useFrameworkFeatures = () => {
10
17
  const provider = useFrameworkModule('featureFlag');
18
+ // Fail fast when the FeatureFlagModule has not been enabled on the framework
11
19
  if (!provider) {
12
20
  throw Error('Feature flagging is not enabled in the framework');
13
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useFrameworkFeatures.js","sourceRoot":"","sources":["../../../src/feature-flag/useFrameworkFeatures.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAmC,EAAE;IACvE,MAAM,QAAQ,GAAG,kBAAkB,CAAoB,aAAa,CAAC,CAAC;IACtE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"useFrameworkFeatures.js","sourceRoot":"","sources":["../../../src/feature-flag/useFrameworkFeatures.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAmC,EAAE;IACvE,MAAM,QAAQ,GAAG,kBAAkB,CAAoB,aAAa,CAAC,CAAC;IACtE,6EAA6E;IAC7E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { context } from './context';
2
+ /**
3
+ * Component for providing framework.
4
+ *
5
+ * @remarks
6
+ * Should be created by {@link createFrameworkProvider}
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * import {FrameworkProvider} from '@equinor/fusion-framework-react';
11
+ * export const Component = (args: React.PropsWithChildren<{framework: Fusion}>) => {
12
+ * return (
13
+ * <FrameworkProvider value={args.framework}>
14
+ * {args.children}
15
+ * </FrameworkProvider>
16
+ * );
17
+ * }
18
+ * ```
19
+ */
20
+ export const FrameworkProvider = context.Provider;
21
+ //# sourceMappingURL=framework-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-provider.js","sourceRoot":"","sources":["../../src/framework-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC"}
@@ -1,3 +1,11 @@
1
- export { useCurrentUser } from './use-current-user';
2
- export { useHttpClient } from './use-http-client';
1
+ /**
2
+ * Convenience hooks for common framework operations.
3
+ *
4
+ * @remarks
5
+ * Available via the `@equinor/fusion-framework-react/hooks` sub-entry-point.
6
+ *
7
+ * @module
8
+ */
9
+ export { useCurrentUser } from './useCurrentUser';
10
+ export { useHttpClient } from './useHttpClient';
3
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { useFramework } from '../useFramework';
2
+ /**
3
+ * React hook that returns the currently authenticated user's account info.
4
+ *
5
+ * @returns The {@link AccountInfo} of the signed-in user, or `undefined` if
6
+ * no user is authenticated.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * const UserGreeting = () => {
11
+ * const user = useCurrentUser();
12
+ * return <span>Hello, {user?.name ?? 'Guest'}</span>;
13
+ * };
14
+ * ```
15
+ */
16
+ export const useCurrentUser = () => {
17
+ const framework = useFramework();
18
+ return framework.modules.auth.account || undefined;
19
+ };
20
+ //# sourceMappingURL=useCurrentUser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentUser.js","sourceRoot":"","sources":["../../../src/hooks/useCurrentUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAA4B,EAAE;IAC1D,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,SAAS,CAAC;AACrD,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { useMemo } from 'react';
2
+ import { useFramework } from '../useFramework';
3
+ /**
4
+ * React hook that returns a pre-configured HTTP client from the framework.
5
+ *
6
+ * @param name - Key of the HTTP client to retrieve (e.g. `'portal'` or `'people'`).
7
+ * @returns The resolved {@link HttpClient} instance.
8
+ * @throws {Error} If no client is configured for the given key.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const client = useHttpClient('portal');
13
+ * client.fetch('/api/data').subscribe(console.log);
14
+ * ```
15
+ */
16
+ export const useHttpClient = (name) => {
17
+ const framework = useFramework();
18
+ const client = useMemo(() => {
19
+ // Reuse an already-configured client for this key when one exists
20
+ if (framework.modules.http.hasClient(name)) {
21
+ return framework.modules.http.createClient(name);
22
+ }
23
+ throw Error(`no configured client for key [${name}]`);
24
+ }, [framework, name]);
25
+ // TODO(#5085): abort on unmount?
26
+ return client;
27
+ };
28
+ //# sourceMappingURL=useHttpClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHttpClient.js","sourceRoot":"","sources":["../../../src/hooks/useHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQ/C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAyB,EAAc,EAAE;IACrE,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IAEjC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE;QAC1B,kEAAkE;QAClE,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3C,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACnD,CAAC;QACD,MAAM,KAAK,CAAC,iCAAiC,IAAI,GAAG,CAAC,CAAC;IACxD,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IACtB,iCAAiC;IACjC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -1,3 +1,13 @@
1
- export { useHttpClient as useFrameworkHttpClient } from '../hooks/use-http-client';
1
+ /**
2
+ * HTTP sub-entry-point (`@equinor/fusion-framework-react/http`).
3
+ *
4
+ * @remarks
5
+ * Re-exports the framework-level {@link useHttpClient} hook as
6
+ * `useFrameworkHttpClient` together with all exports from the
7
+ * standalone HTTP React module.
8
+ *
9
+ * @module
10
+ */
11
+ export { useHttpClient as useFrameworkHttpClient } from '../hooks/useHttpClient';
2
12
  export * from '@equinor/fusion-framework-react-module-http';
3
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,cAAc,6CAA6C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/http/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,IAAI,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,cAAc,6CAA6C,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,10 +1,18 @@
1
1
  /**
2
+ * React bindings for the Fusion Framework.
3
+ *
4
+ * @remarks
5
+ * This package provides React components, context providers, and hooks for
6
+ * initialising and consuming a Fusion Framework instance inside a React
7
+ * application tree. It is the main entry-point for portals and host
8
+ * applications that need to bootstrap the framework with React.
9
+ *
2
10
  * [[include:framework-react/README.MD]]
3
11
  * @module
4
12
  */
5
13
  export { FusionConfigurator } from '@equinor/fusion-framework';
6
14
  export { createFrameworkProvider } from './create-framework-provider';
7
- export { FrameworkProvider } from './context';
15
+ export { FrameworkProvider } from './framework-provider';
8
16
  export { useFramework } from './useFramework';
9
17
  export { useFrameworkModule } from './useFrameworkModule';
10
18
  export { default, Framework } from './Framework';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
@@ -1,32 +1,2 @@
1
- import { useFramework } from '../useFramework';
2
- import { useProviderTopic, } from '@equinor/fusion-framework-react-module-signalr';
3
- /**
4
- * hook for subscribing to a topic of a SignalR hub
5
- *
6
- * @example
7
- ```ts
8
- // config.ts
9
- import {enableSignalR} from '@equinor/fusion-framework-react-module-signalr';
10
- (configurator) => enableSignalR(configurator, 'notifications');
11
-
12
- // myHook.ts
13
- const myHook = () => {
14
- const topic = useSignalR('notifications', 'foo');
15
- return useObservableState(topic).next;
16
- }
17
- ```
18
- *
19
- * @see {@link [module signalr](https://equinor.github.io/fusion-framework/modules/signalr)}
20
- *
21
- * @param hubId identifier of connection hub (must be configured)
22
- * @param topicId identifier of topic to connect to
23
- * @returns Topic
24
- */
25
- export const useSignalR = (hubId, topicId) => {
26
- const provider = useFramework().modules.signalR;
27
- if (!provider) {
28
- throw Error('SignalR is not configured, see @equinor/fusion-framework-react-module-signalr');
29
- }
30
- return useProviderTopic(provider, hubId, topicId);
31
- };
1
+ export { useSignalR } from './useSignalR.js';
32
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/signalr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAEL,gBAAgB,GACjB,MAAM,gDAAgD,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,KAAa,EACb,OAAe,EACyB,EAAE;IAC1C,MAAM,QAAQ,GAAG,YAAY,EAAmB,CAAC,OAAO,CAAC,OAAO,CAAC;IACjE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,CAAC,+EAA+E,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/signalr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { useFramework } from '../useFramework';
2
+ import { useProviderTopic, } from '@equinor/fusion-framework-react-module-signalr';
3
+ /**
4
+ * hook for subscribing to a topic of a SignalR hub
5
+ *
6
+ * @example
7
+ ```ts
8
+ // config.ts
9
+ import {enableSignalR} from '@equinor/fusion-framework-react-module-signalr';
10
+ (configurator) => enableSignalR(configurator, 'notifications');
11
+
12
+ // myHook.ts
13
+ const myHook = () => {
14
+ const topic = useSignalR('notifications', 'foo');
15
+ return useObservableState(topic).next;
16
+ }
17
+ ```
18
+ *
19
+ * @see {@link [module signalr](https://equinor.github.io/fusion-framework/modules/signalr)}
20
+ *
21
+ * @param hubId identifier of connection hub (must be configured)
22
+ * @param topicId identifier of topic to connect to
23
+ * @returns Topic
24
+ */
25
+ export const useSignalR = (hubId, topicId) => {
26
+ const provider = useFramework().modules.signalR;
27
+ // Fail fast when the SignalRModule has not been configured on the framework
28
+ if (!provider) {
29
+ throw Error('SignalR is not configured, see @equinor/fusion-framework-react-module-signalr');
30
+ }
31
+ return useProviderTopic(provider, hubId, topicId);
32
+ };
33
+ //# sourceMappingURL=useSignalR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSignalR.js","sourceRoot":"","sources":["../../../src/signalr/useSignalR.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAEL,gBAAgB,GACjB,MAAM,gDAAgD,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,KAAa,EACb,OAAe,EACyB,EAAE;IAC1C,MAAM,QAAQ,GAAG,YAAY,EAAmB,CAAC,OAAO,CAAC,OAAO,CAAC;IACjE,4EAA4E;IAC5E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,CAAC,+EAA+E,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC,CAAC"}
@@ -1,20 +1,34 @@
1
1
  import { useContext } from 'react';
2
2
  import { context } from './context';
3
3
  /**
4
+ * React hook that returns the current Fusion Framework instance from context.
5
+ *
6
+ * @remarks
7
+ * The hook first looks for a framework instance provided via
8
+ * {@link FrameworkProvider}. If none is found it falls back to the global
9
+ * `window.Fusion` object. A console warning / error is emitted when the
10
+ * framework cannot be resolved.
11
+ *
12
+ * @template TModules - Tuple of additional module types expected on the
13
+ * framework instance (used for type-narrowing only).
14
+ * @returns The active {@link Fusion} instance.
15
+ *
4
16
  * @example
5
17
  * ```ts
6
- * const useSometing = () => {
7
- * const fusion = useFramework();
8
- * return fusion.something;
9
- * }
18
+ * const useMyService = () => {
19
+ * const fusion = useFramework();
20
+ * return fusion.modules.http.createClient('my-service');
21
+ * };
10
22
  * ```
11
23
  */
12
24
  export const useFramework = () => {
13
25
  let framework = useContext(context);
26
+ // Warn loudly when the framework context is missing so integrators notice the misuse
14
27
  if (!framework) {
15
28
  console.warn('could not locate fusion in context!');
16
29
  }
17
30
  framework ??= window.Fusion;
31
+ // Surface an error when neither context nor the global fallback has the framework instance
18
32
  if (!framework) {
19
33
  console.error('Could not load framework, might not be initiated?');
20
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useFramework.js","sourceRoot":"","sources":["../../src/useFramework.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAA6D,EAAE;IACzF,IAAI,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;IACtD,CAAC;IACD,SAAS,KAAK,MAAM,CAAC,MAAM,CAAC;IAC5B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"useFramework.js","sourceRoot":"","sources":["../../src/useFramework.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAA6D,EAAE;IACzF,IAAI,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,qFAAqF;IACrF,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;IACtD,CAAC;IACD,SAAS,KAAK,MAAM,CAAC,MAAM,CAAC;IAC5B,2FAA2F;IAC3F,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}