@equinor/fusion-framework-react-module 4.0.1 → 4.0.3-next.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.
- package/CHANGELOG.md +26 -0
- package/dist/esm/{ModuleProvider.js → create-module-provider.js} +2 -4
- package/dist/esm/create-module-provider.js.map +1 -0
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{context.js → module-context.js} +1 -1
- package/dist/esm/module-context.js.map +1 -0
- package/dist/esm/module-provider.js +4 -0
- package/dist/esm/module-provider.js.map +1 -0
- package/dist/esm/useModule.js +26 -0
- package/dist/esm/useModule.js.map +1 -0
- package/dist/esm/useModules.js +1 -25
- package/dist/esm/useModules.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/{ModuleProvider.d.ts → create-module-provider.d.ts} +1 -2
- package/dist/types/index.d.ts +4 -2
- package/dist/types/module-provider.d.ts +2 -0
- package/dist/types/useModule.d.ts +22 -0
- package/dist/types/useModules.d.ts +1 -22
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/{ModuleProvider.tsx → create-module-provider.tsx} +1 -5
- package/src/index.ts +4 -2
- package/src/module-provider.ts +5 -0
- package/src/useModule.ts +35 -0
- package/src/useModules.ts +2 -40
- package/src/version.ts +1 -1
- package/dist/esm/ModuleProvider.js.map +0 -1
- package/dist/esm/context.js.map +0 -1
- /package/dist/types/{context.d.ts → module-context.d.ts} +0 -0
- /package/src/{context.ts → module-context.ts} +0 -0
|
@@ -33,5 +33,4 @@ type ModuleProviderCreator = <TModules extends Array<AnyModule> = Array<AnyModul
|
|
|
33
33
|
* @returns Suspensive `ModuleProvider`
|
|
34
34
|
*/
|
|
35
35
|
export declare const createModuleProvider: ModuleProviderCreator;
|
|
36
|
-
export
|
|
37
|
-
export default ModuleProvider;
|
|
36
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export type { Modules, ModulesInstanceType, AnyModule, ModulesInstance, } from '@equinor/fusion-framework-module';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export { createModuleProvider } from './create-module-provider.js';
|
|
3
|
+
export { ModuleProvider } from './module-provider.js';
|
|
4
|
+
export { useModules } from './useModules.js';
|
|
5
|
+
export { useModule } from './useModule.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AnyModule, ModuleKey, Modules, ModuleType } from '@equinor/fusion-framework-module';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for accessing a single module instance from the current context scope.
|
|
4
|
+
*
|
|
5
|
+
* Convenience hook that retrieves a single module by its key/name. This is useful
|
|
6
|
+
* when you only need one module and want to avoid destructuring from `useModules`.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of the module to retrieve. Defaults to any module from the available `Modules`.
|
|
9
|
+
* @template TKey - The string key/name of the module. Automatically inferred from `T` when possible.
|
|
10
|
+
* @param key - The name/key of the module to retrieve from the context.
|
|
11
|
+
* @returns The initialized instance of the requested module, with proper type inference.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Get a specific module by name
|
|
16
|
+
* const navigation = useModule('navigation');
|
|
17
|
+
*
|
|
18
|
+
* // With explicit type
|
|
19
|
+
* const navigation = useModule<NavigationModule>('navigation');
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const useModule: <T extends AnyModule = Modules[keyof Modules], TKey extends string = ModuleKey<T>>(key: TKey) => ModuleType<TKey extends keyof Modules ? Modules[TKey] : T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyModule,
|
|
1
|
+
import type { AnyModule, Modules, ModulesInstanceType } from '@equinor/fusion-framework-module';
|
|
2
2
|
/**
|
|
3
3
|
* Hook for accessing module instances from the current context scope.
|
|
4
4
|
*
|
|
@@ -19,25 +19,4 @@ import type { AnyModule, ModuleKey, Modules, ModulesInstanceType, ModuleType } f
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export declare const useModules: <TModules extends Array<AnyModule> | Record<string, AnyModule> = Modules>() => ModulesInstanceType<TModules>;
|
|
22
|
-
/**
|
|
23
|
-
* Hook for accessing a single module instance from the current context scope.
|
|
24
|
-
*
|
|
25
|
-
* Convenience hook that retrieves a single module by its key/name. This is useful
|
|
26
|
-
* when you only need one module and want to avoid destructuring from `useModules`.
|
|
27
|
-
*
|
|
28
|
-
* @template T - The type of the module to retrieve. Defaults to any module from the available `Modules`.
|
|
29
|
-
* @template TKey - The string key/name of the module. Automatically inferred from `T` when possible.
|
|
30
|
-
* @param key - The name/key of the module to retrieve from the context.
|
|
31
|
-
* @returns The initialized instance of the requested module, with proper type inference.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* // Get a specific module by name
|
|
36
|
-
* const navigation = useModule('navigation');
|
|
37
|
-
*
|
|
38
|
-
* // With explicit type
|
|
39
|
-
* const navigation = useModule<NavigationModule>('navigation');
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare const useModule: <T extends AnyModule = Modules[keyof Modules], TKey extends string = ModuleKey<T>>(key: TKey) => ModuleType<TKey extends keyof Modules ? Modules[TKey] : T>;
|
|
43
22
|
export default useModules;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.0.
|
|
1
|
+
export declare const version = "4.0.3-next.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-react-module",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3-next.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"directory": "packages/react/modules/module"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@equinor/fusion-framework-module": "^6.1.0"
|
|
29
|
+
"@equinor/fusion-framework-module": "^6.1.3-next.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/react": "^19.2.7",
|
|
33
33
|
"@types/react-dom": "^19.2.3",
|
|
34
34
|
"react": "^19.2.1",
|
|
35
35
|
"react-dom": "^19.2.1",
|
|
36
|
-
"typescript": "^
|
|
36
|
+
"typescript": "^7.0.2"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@types/react": "^18.0.0 || ^19.0.0",
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
type AnyModule,
|
|
15
15
|
} from '@equinor/fusion-framework-module';
|
|
16
16
|
|
|
17
|
-
import
|
|
17
|
+
import { ModuleProvider } from './module-provider.js';
|
|
18
18
|
|
|
19
19
|
type ModuleProviderCreator = <
|
|
20
20
|
TModules extends Array<AnyModule> = Array<AnyModule>,
|
|
@@ -76,7 +76,3 @@ export const createModuleProvider: ModuleProviderCreator = async <
|
|
|
76
76
|
});
|
|
77
77
|
return Component;
|
|
78
78
|
};
|
|
79
|
-
|
|
80
|
-
export const ModuleProvider = moduleContext.Provider;
|
|
81
|
-
|
|
82
|
-
export default ModuleProvider;
|
package/src/index.ts
CHANGED
|
@@ -5,5 +5,7 @@ export type {
|
|
|
5
5
|
ModulesInstance,
|
|
6
6
|
} from '@equinor/fusion-framework-module';
|
|
7
7
|
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
8
|
+
export { createModuleProvider } from './create-module-provider.js';
|
|
9
|
+
export { ModuleProvider } from './module-provider.js';
|
|
10
|
+
export { useModules } from './useModules.js';
|
|
11
|
+
export { useModule } from './useModule.js';
|
package/src/useModule.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnyModule,
|
|
3
|
-
ModuleKey,
|
|
4
|
-
Modules,
|
|
5
|
-
ModulesInstanceType,
|
|
6
|
-
ModuleType,
|
|
7
|
-
} from '@equinor/fusion-framework-module';
|
|
1
|
+
import type { AnyModule, Modules, ModulesInstanceType } from '@equinor/fusion-framework-module';
|
|
8
2
|
import { useContext } from 'react';
|
|
9
3
|
|
|
10
|
-
import { moduleContext } from './context.js';
|
|
4
|
+
import { moduleContext } from './module-context.js';
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
7
|
* Hook for accessing module instances from the current context scope.
|
|
@@ -32,36 +26,4 @@ export const useModules = <
|
|
|
32
26
|
TModules extends Array<AnyModule> | Record<string, AnyModule> = Modules,
|
|
33
27
|
>(): ModulesInstanceType<TModules> => useContext(moduleContext) as ModulesInstanceType<TModules>;
|
|
34
28
|
|
|
35
|
-
/**
|
|
36
|
-
* Hook for accessing a single module instance from the current context scope.
|
|
37
|
-
*
|
|
38
|
-
* Convenience hook that retrieves a single module by its key/name. This is useful
|
|
39
|
-
* when you only need one module and want to avoid destructuring from `useModules`.
|
|
40
|
-
*
|
|
41
|
-
* @template T - The type of the module to retrieve. Defaults to any module from the available `Modules`.
|
|
42
|
-
* @template TKey - The string key/name of the module. Automatically inferred from `T` when possible.
|
|
43
|
-
* @param key - The name/key of the module to retrieve from the context.
|
|
44
|
-
* @returns The initialized instance of the requested module, with proper type inference.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```ts
|
|
48
|
-
* // Get a specific module by name
|
|
49
|
-
* const navigation = useModule('navigation');
|
|
50
|
-
*
|
|
51
|
-
* // With explicit type
|
|
52
|
-
* const navigation = useModule<NavigationModule>('navigation');
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export const useModule = <
|
|
56
|
-
T extends AnyModule = Modules[keyof Modules],
|
|
57
|
-
TKey extends string = ModuleKey<T>,
|
|
58
|
-
>(
|
|
59
|
-
key: TKey,
|
|
60
|
-
): ModuleType<TKey extends keyof Modules ? Modules[TKey] : T> => {
|
|
61
|
-
const modules = useModules<Record<string, AnyModule>>();
|
|
62
|
-
return (modules as Record<string, unknown>)[key] as ModuleType<
|
|
63
|
-
TKey extends keyof Modules ? Modules[TKey] : T
|
|
64
|
-
>;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
29
|
export default useModules;
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '4.0.
|
|
2
|
+
export const version = '4.0.3-next.0';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleProvider.js","sourceRoot":"","sources":["../../src/ModuleProvider.tsx"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,OAAO,EACL,IAAI,EACJ,SAAS,GAIV,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,iBAAiB,GAIlB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,aAAa,MAAM,cAAc,CAAC;AAWzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA0B,KAAK,EAK9D,YAAiD,EACjD,GAAU,EACuC,EAAE;IACnD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;QAChC,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,iBAAiB,CAAiB,YAAY,EAAE,GAAG,CAAC,CAAC;QAC5F,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,QAAQ,EAA4B,EAAE,EAAE;gBAClD,wGAAwG;gBACxG,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACrC,OAAO,KAAC,cAAc,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAAkB,CAAC;YACtE,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,QAAQ,CAAC;AAErD,eAAe,cAAc,CAAC"}
|
package/dist/esm/context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAA0B,EAAE,CAAC,CAAC;AAExE,eAAe,aAAa,CAAC"}
|
|
File without changes
|
|
File without changes
|