@equinor/fusion-framework-module-context 8.0.2 → 8.0.3
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 +6 -0
- package/dist/esm/configurator.js +6 -1
- package/dist/esm/configurator.js.map +1 -1
- package/dist/esm/utils/resolve-initial-context.js +14 -7
- package/dist/esm/utils/resolve-initial-context.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/resolve-initial-context.d.ts +6 -3
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/configurator.ts +6 -1
- package/src/utils/resolve-initial-context.ts +22 -7
- package/src/version.ts +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ContextModuleConfig } from '../configurator';
|
|
2
|
+
import { type ContextPathResolveArgs } from './resolve-context-from-path';
|
|
2
3
|
/**
|
|
3
4
|
* Resolves the initial context from the parent module.
|
|
4
5
|
*
|
|
@@ -9,10 +10,12 @@ export declare const resolveContextFromParent: ContextModuleConfig['resolveIniti
|
|
|
9
10
|
/**
|
|
10
11
|
* Resolves the initial context for a Fusion Framework context module.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
* URL-based resolution is handled by the context-navigation plugin.
|
|
13
|
+
* will try to resolve the initial context from the path, and if that fails, it will try to resolve the context from the parent.
|
|
14
14
|
*
|
|
15
|
+
* @param options - Optional configuration for resolving the context path.
|
|
15
16
|
* @returns A function that accepts the module's reference and modules, and returns an Observable of the resolved initial context.
|
|
16
17
|
*/
|
|
17
|
-
export declare const resolveInitialContext: (
|
|
18
|
+
export declare const resolveInitialContext: (options?: {
|
|
19
|
+
path?: ContextPathResolveArgs;
|
|
20
|
+
}) => Required<ContextModuleConfig>['resolveInitialContext'];
|
|
18
21
|
export default resolveInitialContext;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "8.0.
|
|
1
|
+
export declare const version = "8.0.3";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-module-context",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@equinor/fusion-framework-module-event": "^6.0.1",
|
|
56
56
|
"@equinor/fusion-framework-module-navigation": "^7.0.7",
|
|
57
57
|
"@equinor/fusion-framework-module": "^6.1.2",
|
|
58
|
-
"@equinor/fusion-framework-module-services": "^8.0
|
|
58
|
+
"@equinor/fusion-framework-module-services": "^8.1.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@types/semver": "^7.0.0",
|
package/src/configurator.ts
CHANGED
|
@@ -249,7 +249,12 @@ export class ContextModuleConfigurator implements IContextModuleConfigurator {
|
|
|
249
249
|
Promise.resolve({} as Partial<ContextModuleConfig>),
|
|
250
250
|
);
|
|
251
251
|
|
|
252
|
-
config.resolveInitialContext ??= resolveInitialContext(
|
|
252
|
+
config.resolveInitialContext ??= resolveInitialContext({
|
|
253
|
+
path: {
|
|
254
|
+
extract: config.extractContextIdFromPath,
|
|
255
|
+
validate: config.extractContextIdFromPath ? () => true : undefined,
|
|
256
|
+
},
|
|
257
|
+
});
|
|
253
258
|
|
|
254
259
|
// TODO(#5119) - make less lazy
|
|
255
260
|
config.client ??= await (async (): Promise<ContextModuleConfig['client']> => {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ModulesInstance } from '@equinor/fusion-framework-module';
|
|
2
2
|
import type { ContextModule } from '../module';
|
|
3
3
|
import type { ContextModuleConfig } from '../configurator';
|
|
4
|
-
import { concat, EMPTY,
|
|
4
|
+
import { concat, EMPTY, first, of } from 'rxjs';
|
|
5
|
+
import resolveContextFromPath, { type ContextPathResolveArgs } from './resolve-context-from-path';
|
|
6
|
+
import type { NavigationModule } from '@equinor/fusion-framework-module-navigation';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Resolves the initial context from the parent module.
|
|
@@ -11,6 +13,7 @@ import { concat, EMPTY, of, take } from 'rxjs';
|
|
|
11
13
|
*/
|
|
12
14
|
export const resolveContextFromParent: ContextModuleConfig['resolveInitialContext'] = ({ ref }) => {
|
|
13
15
|
const parentContext = (ref as ModulesInstance<[ContextModule]>)?.context;
|
|
16
|
+
// check if the parent has context module
|
|
14
17
|
if (!parentContext) {
|
|
15
18
|
// No parent context available — either portal level or parent lacks context module.
|
|
16
19
|
return EMPTY;
|
|
@@ -22,19 +25,31 @@ export const resolveContextFromParent: ContextModuleConfig['resolveInitialContex
|
|
|
22
25
|
/**
|
|
23
26
|
* Resolves the initial context for a Fusion Framework context module.
|
|
24
27
|
*
|
|
25
|
-
*
|
|
26
|
-
* URL-based resolution is handled by the context-navigation plugin.
|
|
28
|
+
* will try to resolve the initial context from the path, and if that fails, it will try to resolve the context from the parent.
|
|
27
29
|
*
|
|
30
|
+
* @param options - Optional configuration for resolving the context path.
|
|
28
31
|
* @returns A function that accepts the module's reference and modules, and returns an Observable of the resolved initial context.
|
|
29
32
|
*/
|
|
33
|
+
|
|
30
34
|
// Deliberately co-located with resolveContextFromParent, which it composes with
|
|
31
35
|
// fusion-lint-disable-next-line single-export-per-file
|
|
32
36
|
export const resolveInitialContext =
|
|
33
|
-
(
|
|
37
|
+
(options?: {
|
|
38
|
+
path?: ContextPathResolveArgs;
|
|
39
|
+
}): Required<ContextModuleConfig>['resolveInitialContext'] =>
|
|
34
40
|
({ ref, modules }) => {
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
|
|
41
|
+
const { context, navigation } = modules;
|
|
42
|
+
// create a path resolver from the context module
|
|
43
|
+
const pathResolver = resolveContextFromPath(context, options?.path);
|
|
44
|
+
// use the path from the navigation module, or the path from the parent navigation module
|
|
45
|
+
const pathname =
|
|
46
|
+
navigation?.path.pathname ??
|
|
47
|
+
(ref as Partial<ModulesInstance<[NavigationModule]>>).navigation?.path.pathname;
|
|
48
|
+
// try to resolve the context from the path, and if that fails, try to resolve the context from the parent
|
|
49
|
+
return concat(
|
|
50
|
+
pathname ? pathResolver(pathname) : EMPTY,
|
|
51
|
+
resolveContextFromParent({ ref, modules }),
|
|
52
|
+
).pipe(first());
|
|
38
53
|
};
|
|
39
54
|
|
|
40
55
|
export default resolveInitialContext;
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '8.0.
|
|
2
|
+
export const version = '8.0.3';
|