@equinor/fusion-framework-react-module 4.0.3 → 4.0.4

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.
package/src/useModule.ts DELETED
@@ -1,35 +0,0 @@
1
- import type { AnyModule, ModuleKey, Modules, ModuleType } from '@equinor/fusion-framework-module';
2
-
3
- import { useModules } from './useModules.js';
4
-
5
- /**
6
- * Hook for accessing a single module instance from the current context scope.
7
- *
8
- * Convenience hook that retrieves a single module by its key/name. This is useful
9
- * when you only need one module and want to avoid destructuring from `useModules`.
10
- *
11
- * @template T - The type of the module to retrieve. Defaults to any module from the available `Modules`.
12
- * @template TKey - The string key/name of the module. Automatically inferred from `T` when possible.
13
- * @param key - The name/key of the module to retrieve from the context.
14
- * @returns The initialized instance of the requested module, with proper type inference.
15
- *
16
- * @example
17
- * ```ts
18
- * // Get a specific module by name
19
- * const navigation = useModule('navigation');
20
- *
21
- * // With explicit type
22
- * const navigation = useModule<NavigationModule>('navigation');
23
- * ```
24
- */
25
- export const useModule = <
26
- T extends AnyModule = Modules[keyof Modules],
27
- TKey extends string = ModuleKey<T>,
28
- >(
29
- key: TKey,
30
- ): ModuleType<TKey extends keyof Modules ? Modules[TKey] : T> => {
31
- const modules = useModules<Record<string, AnyModule>>();
32
- return (modules as Record<string, unknown>)[key] as ModuleType<
33
- TKey extends keyof Modules ? Modules[TKey] : T
34
- >;
35
- };
package/src/useModules.ts DELETED
@@ -1,29 +0,0 @@
1
- import type { AnyModule, Modules, ModulesInstanceType } from '@equinor/fusion-framework-module';
2
- import { useContext } from 'react';
3
-
4
- import { moduleContext } from './module-context.js';
5
-
6
- /**
7
- * Hook for accessing module instances from the current context scope.
8
- *
9
- * Retrieves initialized module instances that were provided via a `ModuleProvider`.
10
- * The hook supports both array and object-based module collections, with full type safety.
11
- *
12
- * @template TModules - The type of modules to retrieve. Can be an array of modules or a record/object mapping module names to module types. Defaults to all available `Modules`.
13
- * @returns An object containing the initialized module instances, with types inferred from the provided module definitions.
14
- *
15
- * @example
16
- * ```ts
17
- * // Using with a specific module object
18
- * const modules = useModules<{ navigation: NavigationModule }>();
19
- * const navigation = modules.navigation;
20
- *
21
- * // Using with default modules
22
- * const allModules = useModules();
23
- * ```
24
- */
25
- export const useModules = <
26
- TModules extends Array<AnyModule> | Record<string, AnyModule> = Modules,
27
- >(): ModulesInstanceType<TModules> => useContext(moduleContext) as ModulesInstanceType<TModules>;
28
-
29
- export default useModules;
package/src/version.ts DELETED
@@ -1,2 +0,0 @@
1
- // Generated by genversion.
2
- export const version = '4.0.3';
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.react.json",
3
- "compilerOptions": {
4
- "outDir": "dist/esm",
5
- "rootDir": "src",
6
- "declarationDir": "./dist/types",
7
- "paths": {
8
- "react": ["./node_modules/@types/react"]
9
- }
10
- },
11
- "references": [
12
- {
13
- "path": "../../../modules/module"
14
- }
15
- ],
16
- "include": ["src/**/*"],
17
- "exclude": ["node_modules", "lib"]
18
- }