@equinor/fusion-framework-plugin-context-navigation 0.1.0 → 0.1.2
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/dist/esm/ContextNavigationConfigurator.js +178 -0
- package/dist/esm/ContextNavigationConfigurator.js.map +1 -0
- package/dist/esm/__tests__/active-app-navigation-events.test.js +115 -0
- package/dist/esm/__tests__/active-app-navigation-events.test.js.map +1 -0
- package/dist/esm/__tests__/apply-navigation.test.js +152 -0
- package/dist/esm/__tests__/apply-navigation.test.js.map +1 -0
- package/dist/esm/__tests__/enable.test.js +91 -0
- package/dist/esm/__tests__/enable.test.js.map +1 -0
- package/dist/esm/__tests__/guard-handlers.test.js +82 -0
- package/dist/esm/__tests__/guard-handlers.test.js.map +1 -0
- package/dist/esm/__tests__/plugin.test.js +483 -0
- package/dist/esm/__tests__/plugin.test.js.map +1 -0
- package/dist/esm/__tests__/reconcile.test.js +164 -0
- package/dist/esm/__tests__/reconcile.test.js.map +1 -0
- package/dist/esm/adapters/create-path-adapter.js +96 -0
- package/dist/esm/adapters/create-path-adapter.js.map +1 -0
- package/dist/esm/adapters/create-query-adapter.js +83 -0
- package/dist/esm/adapters/create-query-adapter.js.map +1 -0
- package/dist/esm/adapters/custom-adapter/create-custom-adapter.js +116 -0
- package/dist/esm/adapters/custom-adapter/create-custom-adapter.js.map +1 -0
- package/dist/esm/adapters/custom-adapter/index.js +5 -0
- package/dist/esm/adapters/custom-adapter/index.js.map +1 -0
- package/dist/esm/adapters/custom-adapter/normalize-string-result.js +37 -0
- package/dist/esm/adapters/custom-adapter/normalize-string-result.js.map +1 -0
- package/dist/esm/adapters/custom-adapter/to-app-relative.js +34 -0
- package/dist/esm/adapters/custom-adapter/to-app-relative.js.map +1 -0
- package/dist/esm/adapters/custom-adapter/to-full-path.js +28 -0
- package/dist/esm/adapters/custom-adapter/to-full-path.js.map +1 -0
- package/dist/esm/adapters/index.js +4 -0
- package/dist/esm/adapters/index.js.map +1 -0
- package/dist/esm/adapters/types.js +2 -0
- package/dist/esm/adapters/types.js.map +1 -0
- package/dist/esm/apply-navigation.js +102 -0
- package/dist/esm/apply-navigation.js.map +1 -0
- package/dist/esm/constants/context-query-param-key.js +8 -0
- package/dist/esm/constants/context-query-param-key.js.map +1 -0
- package/dist/esm/constants/index.js +3 -0
- package/dist/esm/constants/index.js.map +1 -0
- package/dist/esm/constants/uuid-pattern.js +8 -0
- package/dist/esm/constants/uuid-pattern.js.map +1 -0
- package/dist/esm/create-context-navigation-plugin.js +124 -0
- package/dist/esm/create-context-navigation-plugin.js.map +1 -0
- package/dist/esm/enable-context-navigation.js +40 -0
- package/dist/esm/enable-context-navigation.js.map +1 -0
- package/dist/esm/events.js +2 -0
- package/dist/esm/events.js.map +1 -0
- package/dist/esm/guard-handlers/consume-own-nav-token.js +29 -0
- package/dist/esm/guard-handlers/consume-own-nav-token.js.map +1 -0
- package/dist/esm/guard-handlers/guard-tick-deps.js +2 -0
- package/dist/esm/guard-handlers/guard-tick-deps.js.map +1 -0
- package/dist/esm/guard-handlers/guard-tick-payload.js +2 -0
- package/dist/esm/guard-handlers/guard-tick-payload.js.map +1 -0
- package/dist/esm/guard-handlers/handle-push-mode-guard.js +44 -0
- package/dist/esm/guard-handlers/handle-push-mode-guard.js.map +1 -0
- package/dist/esm/guard-handlers/handle-replace-mode-guard.js +40 -0
- package/dist/esm/guard-handlers/handle-replace-mode-guard.js.map +1 -0
- package/dist/esm/guard-handlers/index.js +5 -0
- package/dist/esm/guard-handlers/index.js.map +1 -0
- package/dist/esm/guard-handlers/is-in-app-scope.js +19 -0
- package/dist/esm/guard-handlers/is-in-app-scope.js.map +1 -0
- package/dist/esm/helpers/get-current-url.js +11 -0
- package/dist/esm/helpers/get-current-url.js.map +1 -0
- package/dist/esm/helpers/index.js +6 -0
- package/dist/esm/helpers/index.js.map +1 -0
- package/dist/esm/helpers/normalize-path-from-url.js +14 -0
- package/dist/esm/helpers/normalize-path-from-url.js.map +1 -0
- package/dist/esm/helpers/normalize-path.js +30 -0
- package/dist/esm/helpers/normalize-path.js.map +1 -0
- package/dist/esm/helpers/resolve-adapter.js +23 -0
- package/dist/esm/helpers/resolve-adapter.js.map +1 -0
- package/dist/esm/helpers/strip-query-params.js +14 -0
- package/dist/esm/helpers/strip-query-params.js.map +1 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/operators/active-app-navigation-events.js +52 -0
- package/dist/esm/operators/active-app-navigation-events.js.map +1 -0
- package/dist/esm/reconcile.js +76 -0
- package/dist/esm/reconcile.js.map +1 -0
- package/dist/esm/sources/app-first-source.js +41 -0
- package/dist/esm/sources/app-first-source.js.map +1 -0
- package/dist/esm/sources/context-first-source.js +47 -0
- package/dist/esm/sources/context-first-source.js.map +1 -0
- package/dist/esm/sources/index.js +4 -0
- package/dist/esm/sources/index.js.map +1 -0
- package/dist/esm/sources/types.js +16 -0
- package/dist/esm/sources/types.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/has-custom-context-generators.js +14 -0
- package/dist/esm/utils/has-custom-context-generators.js.map +1 -0
- package/dist/esm/utils/legacy-app-navigation-fix.js +45 -0
- package/dist/esm/utils/legacy-app-navigation-fix.js.map +1 -0
- package/dist/esm/utils/resolve-context-from-url.js +37 -0
- package/dist/esm/utils/resolve-context-from-url.js.map +1 -0
- package/dist/esm/utils/url/build-app-route.js +20 -0
- package/dist/esm/utils/url/build-app-route.js.map +1 -0
- package/dist/esm/utils/url/build-context-url-for-strategy.js +43 -0
- package/dist/esm/utils/url/build-context-url-for-strategy.js.map +1 -0
- package/dist/esm/utils/url/index.js +7 -0
- package/dist/esm/utils/url/index.js.map +1 -0
- package/dist/esm/utils/url/parse-app-route.js +47 -0
- package/dist/esm/utils/url/parse-app-route.js.map +1 -0
- package/dist/esm/utils/url/resolve-context-id-from-url.js +29 -0
- package/dist/esm/utils/url/resolve-context-id-from-url.js.map +1 -0
- package/dist/esm/utils/url/strip-context-query-param.js +20 -0
- package/dist/esm/utils/url/strip-context-query-param.js.map +1 -0
- package/dist/esm/version.js +3 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/ContextNavigationConfigurator.d.ts +125 -0
- package/dist/types/ContextNavigationConfigurator.d.ts.map +1 -0
- package/dist/types/__tests__/active-app-navigation-events.test.d.ts +2 -0
- package/dist/types/__tests__/active-app-navigation-events.test.d.ts.map +1 -0
- package/dist/types/__tests__/apply-navigation.test.d.ts +2 -0
- package/dist/types/__tests__/apply-navigation.test.d.ts.map +1 -0
- package/dist/types/__tests__/enable.test.d.ts +2 -0
- package/dist/types/__tests__/enable.test.d.ts.map +1 -0
- package/dist/types/__tests__/guard-handlers.test.d.ts +2 -0
- package/dist/types/__tests__/guard-handlers.test.d.ts.map +1 -0
- package/dist/types/__tests__/plugin.test.d.ts +2 -0
- package/dist/types/__tests__/plugin.test.d.ts.map +1 -0
- package/dist/types/__tests__/reconcile.test.d.ts +2 -0
- package/dist/types/__tests__/reconcile.test.d.ts.map +1 -0
- package/dist/types/adapters/create-path-adapter.d.ts +27 -0
- package/dist/types/adapters/create-path-adapter.d.ts.map +1 -0
- package/dist/types/adapters/create-query-adapter.d.ts +34 -0
- package/dist/types/adapters/create-query-adapter.d.ts.map +1 -0
- package/dist/types/adapters/custom-adapter/create-custom-adapter.d.ts +29 -0
- package/dist/types/adapters/custom-adapter/create-custom-adapter.d.ts.map +1 -0
- package/dist/types/adapters/custom-adapter/index.d.ts +5 -0
- package/dist/types/adapters/custom-adapter/index.d.ts.map +1 -0
- package/dist/types/adapters/custom-adapter/normalize-string-result.d.ts +21 -0
- package/dist/types/adapters/custom-adapter/normalize-string-result.d.ts.map +1 -0
- package/dist/types/adapters/custom-adapter/to-app-relative.d.ts +25 -0
- package/dist/types/adapters/custom-adapter/to-app-relative.d.ts.map +1 -0
- package/dist/types/adapters/custom-adapter/to-full-path.d.ts +22 -0
- package/dist/types/adapters/custom-adapter/to-full-path.d.ts.map +1 -0
- package/dist/types/adapters/index.d.ts +5 -0
- package/dist/types/adapters/index.d.ts.map +1 -0
- package/dist/types/adapters/types.d.ts +73 -0
- package/dist/types/adapters/types.d.ts.map +1 -0
- package/dist/types/apply-navigation.d.ts +88 -0
- package/dist/types/apply-navigation.d.ts.map +1 -0
- package/dist/types/constants/context-query-param-key.d.ts +8 -0
- package/dist/types/constants/context-query-param-key.d.ts.map +1 -0
- package/dist/types/constants/index.d.ts +3 -0
- package/dist/types/constants/index.d.ts.map +1 -0
- package/dist/types/constants/uuid-pattern.d.ts +8 -0
- package/dist/types/constants/uuid-pattern.d.ts.map +1 -0
- package/dist/types/create-context-navigation-plugin.d.ts +58 -0
- package/dist/types/create-context-navigation-plugin.d.ts.map +1 -0
- package/dist/types/enable-context-navigation.d.ts +21 -0
- package/dist/types/enable-context-navigation.d.ts.map +1 -0
- package/dist/types/events.d.ts +16 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/guard-handlers/consume-own-nav-token.d.ts +21 -0
- package/dist/types/guard-handlers/consume-own-nav-token.d.ts.map +1 -0
- package/dist/types/guard-handlers/guard-tick-deps.d.ts +20 -0
- package/dist/types/guard-handlers/guard-tick-deps.d.ts.map +1 -0
- package/dist/types/guard-handlers/guard-tick-payload.d.ts +15 -0
- package/dist/types/guard-handlers/guard-tick-payload.d.ts.map +1 -0
- package/dist/types/guard-handlers/handle-push-mode-guard.d.ts +24 -0
- package/dist/types/guard-handlers/handle-push-mode-guard.d.ts.map +1 -0
- package/dist/types/guard-handlers/handle-replace-mode-guard.d.ts +19 -0
- package/dist/types/guard-handlers/handle-replace-mode-guard.d.ts.map +1 -0
- package/dist/types/guard-handlers/index.d.ts +7 -0
- package/dist/types/guard-handlers/index.d.ts.map +1 -0
- package/dist/types/guard-handlers/is-in-app-scope.d.ts +15 -0
- package/dist/types/guard-handlers/is-in-app-scope.d.ts.map +1 -0
- package/dist/types/helpers/get-current-url.d.ts +10 -0
- package/dist/types/helpers/get-current-url.d.ts.map +1 -0
- package/dist/types/helpers/index.d.ts +6 -0
- package/dist/types/helpers/index.d.ts.map +1 -0
- package/dist/types/helpers/normalize-path-from-url.d.ts +11 -0
- package/dist/types/helpers/normalize-path-from-url.d.ts.map +1 -0
- package/dist/types/helpers/normalize-path.d.ts +14 -0
- package/dist/types/helpers/normalize-path.d.ts.map +1 -0
- package/dist/types/helpers/resolve-adapter.d.ts +14 -0
- package/dist/types/helpers/resolve-adapter.d.ts.map +1 -0
- package/dist/types/helpers/strip-query-params.d.ts +12 -0
- package/dist/types/helpers/strip-query-params.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/operators/active-app-navigation-events.d.ts +47 -0
- package/dist/types/operators/active-app-navigation-events.d.ts.map +1 -0
- package/dist/types/reconcile.d.ts +43 -0
- package/dist/types/reconcile.d.ts.map +1 -0
- package/dist/types/sources/app-first-source.d.ts +14 -0
- package/dist/types/sources/app-first-source.d.ts.map +1 -0
- package/dist/types/sources/context-first-source.d.ts +15 -0
- package/dist/types/sources/context-first-source.d.ts.map +1 -0
- package/dist/types/sources/index.d.ts +4 -0
- package/dist/types/sources/index.d.ts.map +1 -0
- package/dist/types/sources/types.d.ts +61 -0
- package/dist/types/sources/types.d.ts.map +1 -0
- package/dist/types/types.d.ts +126 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils/has-custom-context-generators.d.ts +13 -0
- package/dist/types/utils/has-custom-context-generators.d.ts.map +1 -0
- package/dist/types/utils/legacy-app-navigation-fix.d.ts +33 -0
- package/dist/types/utils/legacy-app-navigation-fix.d.ts.map +1 -0
- package/dist/types/utils/resolve-context-from-url.d.ts +20 -0
- package/dist/types/utils/resolve-context-from-url.d.ts.map +1 -0
- package/dist/types/utils/url/build-app-route.d.ts +11 -0
- package/dist/types/utils/url/build-app-route.d.ts.map +1 -0
- package/dist/types/utils/url/build-context-url-for-strategy.d.ts +14 -0
- package/dist/types/utils/url/build-context-url-for-strategy.d.ts.map +1 -0
- package/dist/types/utils/url/index.d.ts +8 -0
- package/dist/types/utils/url/index.d.ts.map +1 -0
- package/dist/types/utils/url/parse-app-route.d.ts +20 -0
- package/dist/types/utils/url/parse-app-route.d.ts.map +1 -0
- package/dist/types/utils/url/resolve-context-id-from-url.d.ts +8 -0
- package/dist/types/utils/url/resolve-context-id-from-url.d.ts.map +1 -0
- package/dist/types/utils/url/strip-context-query-param.d.ts +12 -0
- package/dist/types/utils/url/strip-context-query-param.d.ts.map +1 -0
- package/dist/types/version.d.ts +2 -0
- package/dist/types/version.d.ts.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { ContextItem, IContextProvider } from '@equinor/fusion-framework-module-context';
|
|
2
|
+
import type { AppModulesInstance } from '@equinor/fusion-framework-module-app';
|
|
3
|
+
import type { ContextModule } from '@equinor/fusion-framework-module-context';
|
|
4
|
+
import type { INavigationProvider } from '@equinor/fusion-framework-module-navigation';
|
|
5
|
+
import type { ContextNavigationAdapterInput } from './adapters/types';
|
|
6
|
+
import type { ReconcilerSourceFactory } from './sources/types';
|
|
7
|
+
export type { AdapterResolutionContext, ContextNavigationAdapter, ContextNavigationAdapterFactory, ContextNavigationAdapterInput, } from './adapters/types';
|
|
8
|
+
export type { ContextState, ReconcilerPhase, ReconcilerSourceEntry, ReconcilerSourceDeps, ReconcilerSourceFactory, } from './sources/types';
|
|
9
|
+
/** Fired before reconciliation navigates. Cancelable. */
|
|
10
|
+
export interface ContextNavigationNavigateDetail {
|
|
11
|
+
appKey: string;
|
|
12
|
+
adapterId: string;
|
|
13
|
+
targetURL: URL;
|
|
14
|
+
sourceURL: URL;
|
|
15
|
+
context: ContextItem | null;
|
|
16
|
+
/** The current app's loaded module instances. */
|
|
17
|
+
appModules: AppModulesInstance<[ContextModule]>;
|
|
18
|
+
}
|
|
19
|
+
/** Fired after navigation completes. */
|
|
20
|
+
export interface ContextNavigationNavigatedDetail {
|
|
21
|
+
appKey: string;
|
|
22
|
+
adapterId: string;
|
|
23
|
+
targetURL: URL;
|
|
24
|
+
context: ContextItem | null;
|
|
25
|
+
/** The current app's loaded module instances. */
|
|
26
|
+
appModules: AppModulesInstance<[ContextModule]>;
|
|
27
|
+
}
|
|
28
|
+
/** Fired when an adapter is resolved for an app. */
|
|
29
|
+
export interface ContextNavigationAdapterResolvedDetail {
|
|
30
|
+
appKey: string;
|
|
31
|
+
adapterId: string;
|
|
32
|
+
}
|
|
33
|
+
/** Fired when reconciliation skips. */
|
|
34
|
+
export interface ContextNavigationSkippedDetail {
|
|
35
|
+
appKey: string;
|
|
36
|
+
reason: 'url-matches' | 'no-context' | 'no-adapter' | 'encode-returned-null' | 'canceled';
|
|
37
|
+
}
|
|
38
|
+
export interface ContextNavigationConfig {
|
|
39
|
+
/**
|
|
40
|
+
* Human-readable name for the portal consuming this module.
|
|
41
|
+
* Used in debug logging.
|
|
42
|
+
* @default 'Portal'
|
|
43
|
+
*/
|
|
44
|
+
portalName: string;
|
|
45
|
+
/**
|
|
46
|
+
* Origin for constructing absolute URLs.
|
|
47
|
+
* @default window.location.origin
|
|
48
|
+
*/
|
|
49
|
+
origin: string;
|
|
50
|
+
/**
|
|
51
|
+
* Registered adapters in evaluation order.
|
|
52
|
+
* Each entry is either a static adapter object or a factory function.
|
|
53
|
+
*/
|
|
54
|
+
adapters: ContextNavigationAdapterInput[];
|
|
55
|
+
/**
|
|
56
|
+
* Enable reconciliation on URL changes (guard behavior).
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
enableUrlGuard: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Enable verbose debug logging.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
debug: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Optional side-effect hook called after navigation completes.
|
|
67
|
+
*/
|
|
68
|
+
onTransition?: (detail: ContextNavigationNavigatedDetail) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Resolves the initial context from the URL and sets it on the context
|
|
71
|
+
* provider before the reconciler activates.
|
|
72
|
+
*
|
|
73
|
+
* The default implementation iterates registered adapters, decodes the
|
|
74
|
+
* first matching context ID, and calls `setCurrentContextByIdAsync`.
|
|
75
|
+
* Override to customise initial context resolution or disable it by
|
|
76
|
+
* setting to `undefined`.
|
|
77
|
+
*
|
|
78
|
+
* @param args.context - The portal's context provider.
|
|
79
|
+
* @param args.navigation - The navigation provider (for reading the current URL).
|
|
80
|
+
*/
|
|
81
|
+
resolveInitialContext?: (args: {
|
|
82
|
+
context: IContextProvider;
|
|
83
|
+
navigation: INavigationProvider;
|
|
84
|
+
}) => Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Factory that produces the observable stream driving the reconciler.
|
|
87
|
+
*
|
|
88
|
+
* Controls whether app switches or context changes lead the stream,
|
|
89
|
+
* which is the primary behavioral difference between app-portal and
|
|
90
|
+
* context-portal.
|
|
91
|
+
*
|
|
92
|
+
* @default createAppFirstSource()
|
|
93
|
+
* @see createAppFirstSource
|
|
94
|
+
* @see createContextFirstSource
|
|
95
|
+
*/
|
|
96
|
+
sourceFactory: ReconcilerSourceFactory;
|
|
97
|
+
/**
|
|
98
|
+
* Compute the URL to navigate to when context is cleared (`null`).
|
|
99
|
+
*
|
|
100
|
+
* When set, the reconciler calls this function on null context instead
|
|
101
|
+
* of delegating to the adapter's `encode(null, ...)`.
|
|
102
|
+
*
|
|
103
|
+
* Typical usage: context-portal returns `'/'` so clearing context
|
|
104
|
+
* returns to the portal landing page regardless of adapter type.
|
|
105
|
+
*
|
|
106
|
+
* @param args.appKey - The current app key.
|
|
107
|
+
* @param args.currentURL - The current browser URL.
|
|
108
|
+
* @returns The target URL path string (e.g. `'/'` or `/apps/${appKey}`).
|
|
109
|
+
*
|
|
110
|
+
* @default undefined — adapters handle null context themselves
|
|
111
|
+
*/
|
|
112
|
+
nullContextUrl?: (args: {
|
|
113
|
+
appKey: string;
|
|
114
|
+
currentURL: URL;
|
|
115
|
+
}) => string;
|
|
116
|
+
/**
|
|
117
|
+
* Options passed to `navigation.navigate()` when the reconciler performs URL updates.
|
|
118
|
+
*
|
|
119
|
+
* @default { replace: true }
|
|
120
|
+
*/
|
|
121
|
+
navigationOptions: {
|
|
122
|
+
replace?: boolean;
|
|
123
|
+
state?: unknown;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC9F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAEvF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAG/D,YAAY,EACV,wBAAwB,EACxB,wBAAwB,EACxB,+BAA+B,EAC/B,6BAA6B,GAC9B,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AAIzB,yDAAyD;AACzD,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,GAAG,CAAC;IACf,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,iDAAiD;IACjD,UAAU,EAAE,kBAAkB,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;CACjD;AAED,wCAAwC;AACxC,MAAM,WAAW,gCAAgC;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,GAAG,CAAC;IACf,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,iDAAiD;IACjD,UAAU,EAAE,kBAAkB,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;CACjD;AAED,oDAAoD;AACpD,MAAM,WAAW,sCAAsC;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,uCAAuC;AACvC,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,GAAG,YAAY,GAAG,YAAY,GAAG,sBAAsB,GAAG,UAAU,CAAC;CAC3F;AAID,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,QAAQ,EAAE,6BAA6B,EAAE,CAAC;IAE1C;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,gCAAgC,KAAK,IAAI,CAAC;IAElE;;;;;;;;;;;OAWG;IACH,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE;QAC7B,OAAO,EAAE,gBAAgB,CAAC;QAC1B,UAAU,EAAE,mBAAmB,CAAC;KACjC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpB;;;;;;;;;;OAUG;IACH,aAAa,EAAE,uBAAuB,CAAC;IAEvC;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAE,KAAK,MAAM,CAAC;IAEvE;;;;OAIG;IACH,iBAAiB,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IContextProvider } from '@equinor/fusion-framework-module-context';
|
|
2
|
+
/**
|
|
3
|
+
* Check whether an app's context provider has custom path generators registered.
|
|
4
|
+
*
|
|
5
|
+
* Returns `true` when both `extractContextIdFromPath` and
|
|
6
|
+
* `generatePathFromContext` are present, indicating the app owns its own
|
|
7
|
+
* URL shape and should be handled by the custom adapter.
|
|
8
|
+
*
|
|
9
|
+
* @param appContext - The app's context provider instance.
|
|
10
|
+
* @returns `true` if the app has custom context generators, `false` otherwise.
|
|
11
|
+
*/
|
|
12
|
+
export declare function hasCustomContextGenerators(appContext: IContextProvider): boolean;
|
|
13
|
+
//# sourceMappingURL=has-custom-context-generators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-custom-context-generators.d.ts","sourceRoot":"","sources":["../../../src/utils/has-custom-context-generators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAEjF;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAEhF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IEventModuleProvider } from '@equinor/fusion-framework-module-event';
|
|
2
|
+
import '../events';
|
|
3
|
+
/**
|
|
4
|
+
* Dependencies required by the legacy app navigation fix.
|
|
5
|
+
*/
|
|
6
|
+
interface LegacyAppNavigationFixDeps {
|
|
7
|
+
/** The framework event module provider. */
|
|
8
|
+
event: IEventModuleProvider;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Register a legacy app navigation fix that resets the app's internal
|
|
12
|
+
* router when context navigation occurs and the app uses a navigation
|
|
13
|
+
* module older than v7.
|
|
14
|
+
*
|
|
15
|
+
* Apps with navigation <v7 don't respond to portal navigation events
|
|
16
|
+
* correctly. This listener detects them and calls `appNavigation.replace('/')`
|
|
17
|
+
* after each context navigation to keep the app router in sync.
|
|
18
|
+
*
|
|
19
|
+
* Call this during framework configuration (e.g. in `postInitialize`)
|
|
20
|
+
* and store the returned teardown function to clean up when needed.
|
|
21
|
+
*
|
|
22
|
+
* @param deps - The required framework module instances.
|
|
23
|
+
* @returns A teardown function that removes the listener.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* // In portal framework configuration:
|
|
28
|
+
* const teardown = legacyAppNavigationFix({ event });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function legacyAppNavigationFix(deps: LegacyAppNavigationFixDeps): VoidFunction;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=legacy-app-navigation-fix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-app-navigation-fix.d.ts","sourceRoot":"","sources":["../../../src/utils/legacy-app-navigation-fix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAInF,OAAO,WAAW,CAAC;AAInB;;GAEG;AACH,UAAU,0BAA0B;IAClC,2CAA2C;IAC3C,KAAK,EAAE,oBAAoB,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,0BAA0B,GAAG,YAAY,CA0BrF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IContextProvider } from '@equinor/fusion-framework-module-context';
|
|
2
|
+
import type { INavigationProvider } from '@equinor/fusion-framework-module-navigation';
|
|
3
|
+
import type { ContextNavigationAdapterInput } from '../adapters/types';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a resolver that decodes a context ID from the current URL using
|
|
6
|
+
* the provided adapters and sets it on the context provider.
|
|
7
|
+
*
|
|
8
|
+
* Iterates adapters in priority order — the first static adapter whose
|
|
9
|
+
* `decode()` returns a non-null value wins. Factory adapters are skipped
|
|
10
|
+
* since no app context is available at initial resolution time.
|
|
11
|
+
*
|
|
12
|
+
* @param adapters - Registered adapters, evaluated in order.
|
|
13
|
+
* @param origin - The origin to use when constructing the URL (defaults to `window.location.origin`).
|
|
14
|
+
* @returns An async function compatible with `ContextNavigationConfig.resolveInitialContext`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const resolveContextFromUrl: (adapters: ContextNavigationAdapterInput[], origin?: string) => ({ context, navigation, }: {
|
|
17
|
+
context: IContextProvider;
|
|
18
|
+
navigation: INavigationProvider;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
//# sourceMappingURL=resolve-context-from-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-context-from-url.d.ts","sourceRoot":"","sources":["../../../src/utils/resolve-context-from-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,aACrB,6BAA6B,EAAE,WAAW,MAAM,gCAIxD;IACD,OAAO,EAAE,gBAAgB,CAAC;IAC1B,UAAU,EAAE,mBAAmB,CAAC;CACjC,KAAG,OAAO,CAAC,IAAI,CA+Bf,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds `/apps/:appKey[/:contextId][/:rest]` from named segments.
|
|
3
|
+
* Inverse of `parseAppRoute` — used by all write/upsert helpers.
|
|
4
|
+
*
|
|
5
|
+
* @param appKey - The application key (e.g. `'my-app'`).
|
|
6
|
+
* @param contextId - Optional context id to embed as the third path segment.
|
|
7
|
+
* @param rest - Optional sub-route tail to append after the context segment.
|
|
8
|
+
* @returns The constructed app route path string.
|
|
9
|
+
*/
|
|
10
|
+
export declare const buildAppRoute: (appKey: string, contextId?: string, rest?: string) => string;
|
|
11
|
+
//# sourceMappingURL=build-app-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-app-route.d.ts","sourceRoot":"","sources":["../../../../src/utils/url/build-app-route.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,WAAY,MAAM,cAAc,MAAM,SAAS,MAAM,KAAG,MAUjF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FrameworkOptions } from '@equinor/fusion-framework-module-app';
|
|
2
|
+
/**
|
|
3
|
+
* Builds the correct context URL for the given routing strategy.
|
|
4
|
+
*
|
|
5
|
+
* Designed for `setContextPathGenerator` — the adapter layer handles
|
|
6
|
+
* runtime URL encoding; this is only for the context module's own hooks.
|
|
7
|
+
*
|
|
8
|
+
* @param contextId - The context id to embed in the URL, or `undefined` to clear it.
|
|
9
|
+
* @param path - The current URL path to modify.
|
|
10
|
+
* @param routingStrategy - The routing strategy (`'query'` or `'path'`).
|
|
11
|
+
* @returns The modified URL path with the context id applied.
|
|
12
|
+
*/
|
|
13
|
+
export declare const buildContextUrlForStrategy: (contextId: string | undefined, path: string, routingStrategy?: FrameworkOptions['contextRouting']) => string;
|
|
14
|
+
//# sourceMappingURL=build-context-url-for-strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-context-url-for-strategy.d.ts","sourceRoot":"","sources":["../../../../src/utils/url/build-context-url-for-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAK7E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B,cAC1B,MAAM,GAAG,SAAS,QACvB,MAAM,oBACM,gBAAgB,CAAC,gBAAgB,CAAC,KACnD,MA4BF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { AppRouteMatch } from './parse-app-route';
|
|
2
|
+
export { parseAppRoute } from './parse-app-route';
|
|
3
|
+
export { buildAppRoute } from './build-app-route';
|
|
4
|
+
export { CONTEXT_QUERY_PARAM_KEY, UUID_PATTERN } from '../../constants';
|
|
5
|
+
export { stripContextQueryParam } from './strip-context-query-param';
|
|
6
|
+
export { resolveContextIdFromUrl } from './resolve-context-id-from-url';
|
|
7
|
+
export { buildContextUrlForStrategy } from './build-context-url-for-strategy';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/url/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Parsed app route segments from a URLPattern match. */
|
|
2
|
+
export interface AppRouteMatch {
|
|
3
|
+
appKey: string;
|
|
4
|
+
/** Context id segment (3rd path part). Undefined when bare app route. */
|
|
5
|
+
contextId?: string;
|
|
6
|
+
/** App-owned sub-routes after the context segment (e.g. "settings/general"). */
|
|
7
|
+
rest?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Parses `/apps/:appKey/:contextId?/…rest` into named segments.
|
|
11
|
+
*
|
|
12
|
+
* Trailing slashes are stripped before matching because URLPattern's
|
|
13
|
+
* pathname matching does not treat `/apps/my-app/` and `/apps/my-app`
|
|
14
|
+
* as equivalent.
|
|
15
|
+
*
|
|
16
|
+
* @param pathname - The URL pathname to parse.
|
|
17
|
+
* @returns Named segments, or undefined if the pathname is not an app route.
|
|
18
|
+
*/
|
|
19
|
+
export declare const parseAppRoute: (pathname: string) => AppRouteMatch | undefined;
|
|
20
|
+
//# sourceMappingURL=parse-app-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-app-route.d.ts","sourceRoot":"","sources":["../../../../src/utils/url/parse-app-route.ts"],"names":[],"mappings":"AAeA,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,aAAc,MAAM,KAAG,aAAa,GAAG,SAyBhE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts a context id from a URL — checks query param first, falls back to path segment.
|
|
3
|
+
* Designed for use with `setContextPathExtractor`.
|
|
4
|
+
* @param path - The URL path to parse.
|
|
5
|
+
* @returns The context id, or `undefined` if none was found.
|
|
6
|
+
*/
|
|
7
|
+
export declare const resolveContextIdFromUrl: (path: string) => string | undefined;
|
|
8
|
+
//# sourceMappingURL=resolve-context-id-from-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-context-id-from-url.d.ts","sourceRoot":"","sources":["../../../../src/utils/url/resolve-context-id-from-url.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,SAAU,MAAM,KAAG,MAAM,GAAG,SAsB/D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes the `$contextId` query parameter from a URL in-place.
|
|
3
|
+
*
|
|
4
|
+
* Path and custom adapters encode context in the URL path, not the query
|
|
5
|
+
* string. If a previous adapter (or an external link) left `$contextId`
|
|
6
|
+
* in the query, carrying it forward creates a confusing duplicate signal.
|
|
7
|
+
* This utility strips it so the URL only contains the path-based encoding.
|
|
8
|
+
*
|
|
9
|
+
* @param url - The URL object to mutate (parameter is deleted in-place).
|
|
10
|
+
*/
|
|
11
|
+
export declare function stripContextQueryParam(url: URL): void;
|
|
12
|
+
//# sourceMappingURL=strip-context-query-param.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-context-query-param.d.ts","sourceRoot":"","sources":["../../../../src/utils/url/strip-context-query-param.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAOrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-plugin-context-navigation",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Adapter-based context-to-URL reconciler for Fusion Framework portals",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"rxjs": "^7.8.1",
|
|
28
28
|
"@equinor/fusion-framework-module": "^6.1.2",
|
|
29
|
-
"@equinor/fusion-framework-module-
|
|
30
|
-
"@equinor/fusion-framework-module-context": "^8.0.2",
|
|
29
|
+
"@equinor/fusion-framework-module-context": "^8.0.3",
|
|
31
30
|
"@equinor/fusion-framework-module-event": "^6.0.1",
|
|
31
|
+
"@equinor/fusion-framework-module-app": "^8.0.4",
|
|
32
32
|
"@equinor/fusion-framework-module-navigation": "^7.0.7"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"rxjs": "^7.8.1",
|
|
36
|
-
"typescript": "^
|
|
36
|
+
"typescript": "^7.0.2",
|
|
37
37
|
"vitest": "^4.1.10",
|
|
38
38
|
"@equinor/fusion-framework-module": "^6.1.2",
|
|
39
39
|
"@equinor/fusion-framework-module-app": "^8.0.4",
|
|
40
|
-
"@equinor/fusion-framework-module-context": "^8.0.
|
|
40
|
+
"@equinor/fusion-framework-module-context": "^8.0.3",
|
|
41
41
|
"@equinor/fusion-framework-module-event": "^6.0.1",
|
|
42
42
|
"@equinor/fusion-framework-module-navigation": "^7.0.7"
|
|
43
43
|
},
|