brix-runtime-sdk-api-web 1.0.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/dist/index.js +190 -0
- package/dist/types/api-exports.test.d.ts +33 -0
- package/dist/types/api-exports.test.d.ts.map +1 -0
- package/dist/types/context/RuntimeContext.d.ts +69 -0
- package/dist/types/context/RuntimeContext.d.ts.map +1 -0
- package/dist/types/context/index.d.ts +23 -0
- package/dist/types/context/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +52 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types/auth.d.ts +405 -0
- package/dist/types/types/auth.d.ts.map +1 -0
- package/dist/types/types/capability.d.ts +218 -0
- package/dist/types/types/capability.d.ts.map +1 -0
- package/dist/types/types/common.d.ts +99 -0
- package/dist/types/types/common.d.ts.map +1 -0
- package/dist/types/types/config.d.ts +85 -0
- package/dist/types/types/config.d.ts.map +1 -0
- package/dist/types/types/event.d.ts +658 -0
- package/dist/types/types/event.d.ts.map +1 -0
- package/dist/types/types/http.d.ts +132 -0
- package/dist/types/types/http.d.ts.map +1 -0
- package/dist/types/types/i18n.d.ts +327 -0
- package/dist/types/types/i18n.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +61 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/layout.d.ts +301 -0
- package/dist/types/types/layout.d.ts.map +1 -0
- package/dist/types/types/module.d.ts +78 -0
- package/dist/types/types/module.d.ts.map +1 -0
- package/dist/types/types/navigation.d.ts +295 -0
- package/dist/types/types/navigation.d.ts.map +1 -0
- package/dist/types/types/plugin-loader-capability.d.ts +142 -0
- package/dist/types/types/plugin-loader-capability.d.ts.map +1 -0
- package/dist/types/types/plugin.d.ts +250 -0
- package/dist/types/types/plugin.d.ts.map +1 -0
- package/dist/types/types/state.d.ts +306 -0
- package/dist/types/types/state.d.ts.map +1 -0
- package/dist/types/types/theme.d.ts +279 -0
- package/dist/types/types/theme.d.ts.map +1 -0
- package/dist/types/types/ui/adapter.d.ts +181 -0
- package/dist/types/types/ui/adapter.d.ts.map +1 -0
- package/dist/types/types/ui/avatar.d.ts +102 -0
- package/dist/types/types/ui/avatar.d.ts.map +1 -0
- package/dist/types/types/ui/badge.d.ts +101 -0
- package/dist/types/types/ui/badge.d.ts.map +1 -0
- package/dist/types/types/ui/button.d.ts +135 -0
- package/dist/types/types/ui/button.d.ts.map +1 -0
- package/dist/types/types/ui/card.d.ts +105 -0
- package/dist/types/types/ui/card.d.ts.map +1 -0
- package/dist/types/types/ui/common.d.ts +29 -0
- package/dist/types/types/ui/common.d.ts.map +1 -0
- package/dist/types/types/ui/icon.d.ts +78 -0
- package/dist/types/types/ui/icon.d.ts.map +1 -0
- package/dist/types/types/ui/index.d.ts +59 -0
- package/dist/types/types/ui/index.d.ts.map +1 -0
- package/dist/types/types/ui/input.d.ts +200 -0
- package/dist/types/types/ui/input.d.ts.map +1 -0
- package/dist/types/types/ui/menu.d.ts +211 -0
- package/dist/types/types/ui/menu.d.ts.map +1 -0
- package/dist/types/types/ui/message.d.ts +121 -0
- package/dist/types/types/ui/message.d.ts.map +1 -0
- package/dist/types/types/ui/modal.d.ts +167 -0
- package/dist/types/types/ui/modal.d.ts.map +1 -0
- package/dist/types/types/ui/select.d.ts +213 -0
- package/dist/types/types/ui/select.d.ts.map +1 -0
- package/dist/types/types/ui/theme-tokens.d.ts +226 -0
- package/dist/types/types/ui/theme-tokens.d.ts.map +1 -0
- package/dist/types/types/ui/tooltip.d.ts +98 -0
- package/dist/types/types/ui/tooltip.d.ts.map +1 -0
- package/dist/types/types/ui.d.ts +49 -0
- package/dist/types/types/ui.d.ts.map +1 -0
- package/package.json +34 -0
- package/src/api-exports.test.ts +199 -0
- package/src/context/RuntimeContext.d.ts +69 -0
- package/src/context/RuntimeContext.d.ts.map +1 -0
- package/src/context/RuntimeContext.ts +75 -0
- package/src/context/index.d.ts +23 -0
- package/src/context/index.d.ts.map +1 -0
- package/src/context/index.ts +23 -0
- package/src/index.d.ts +52 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.ts +59 -0
- package/src/types/auth.d.ts +146 -0
- package/src/types/auth.d.ts.map +1 -0
- package/src/types/auth.ts +479 -0
- package/src/types/capability.d.ts +218 -0
- package/src/types/capability.d.ts.map +1 -0
- package/src/types/capability.ts +302 -0
- package/src/types/common.d.ts +99 -0
- package/src/types/common.d.ts.map +1 -0
- package/src/types/common.ts +115 -0
- package/src/types/config.d.ts +64 -0
- package/src/types/config.d.ts.map +1 -0
- package/src/types/config.ts +96 -0
- package/src/types/event.d.ts +206 -0
- package/src/types/event.d.ts.map +1 -0
- package/src/types/event.ts +776 -0
- package/src/types/http.d.ts +132 -0
- package/src/types/http.d.ts.map +1 -0
- package/src/types/http.ts +156 -0
- package/src/types/i18n.ts +420 -0
- package/src/types/index.d.ts +50 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.ts +120 -0
- package/src/types/layout.ts +394 -0
- package/src/types/module.d.ts +78 -0
- package/src/types/module.d.ts.map +1 -0
- package/src/types/module.ts +92 -0
- package/src/types/navigation.d.ts +101 -0
- package/src/types/navigation.d.ts.map +1 -0
- package/src/types/navigation.ts +361 -0
- package/src/types/plugin-loader-capability.ts +159 -0
- package/src/types/plugin.d.ts +250 -0
- package/src/types/plugin.d.ts.map +1 -0
- package/src/types/plugin.ts +344 -0
- package/src/types/state.d.ts +119 -0
- package/src/types/state.d.ts.map +1 -0
- package/src/types/state.ts +366 -0
- package/src/types/theme.ts +378 -0
- package/src/types/ui/adapter.ts +222 -0
- package/src/types/ui/avatar.ts +113 -0
- package/src/types/ui/badge.ts +112 -0
- package/src/types/ui/button.ts +148 -0
- package/src/types/ui/card.ts +116 -0
- package/src/types/ui/common.ts +29 -0
- package/src/types/ui/icon.ts +85 -0
- package/src/types/ui/index.ts +78 -0
- package/src/types/ui/input.ts +225 -0
- package/src/types/ui/menu.ts +237 -0
- package/src/types/ui/message.ts +135 -0
- package/src/types/ui/modal.ts +188 -0
- package/src/types/ui/select.ts +239 -0
- package/src/types/ui/theme-tokens.ts +357 -0
- package/src/types/ui/tooltip.ts +120 -0
- package/src/types/ui.ts +49 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Brix Platform Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @file Module-Related Type Definitions
|
|
18
|
+
* @description Defines core types for the module system, including module metadata, state, lifecycle events, etc.
|
|
19
|
+
* @module @brix/runtime-sdk-api-web/types/module
|
|
20
|
+
* @version 3.2.0
|
|
21
|
+
*
|
|
22
|
+
* [v3.2 Changes]
|
|
23
|
+
* Extracted from index.ts into a standalone type file.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
// =========================================
|
|
27
|
+
// Module Metadata
|
|
28
|
+
// =========================================
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Module Metadata
|
|
32
|
+
*
|
|
33
|
+
* <p>Describes basic information about a module.</p>
|
|
34
|
+
*/
|
|
35
|
+
export interface ModuleMetadata {
|
|
36
|
+
/** Module ID */
|
|
37
|
+
readonly moduleId: string;
|
|
38
|
+
/** Module Name */
|
|
39
|
+
readonly name: string;
|
|
40
|
+
/** Module Version */
|
|
41
|
+
readonly version: string;
|
|
42
|
+
/** Module Description */
|
|
43
|
+
readonly description?: string;
|
|
44
|
+
/** Author */
|
|
45
|
+
readonly author?: string;
|
|
46
|
+
/** Dependent Module List */
|
|
47
|
+
readonly dependencies?: string[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// =========================================
|
|
51
|
+
// Module State
|
|
52
|
+
// =========================================
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Module State Enum
|
|
56
|
+
*/
|
|
57
|
+
export enum ModuleState {
|
|
58
|
+
/** Unloaded */
|
|
59
|
+
UNLOADED = 'UNLOADED',
|
|
60
|
+
/** Loading */
|
|
61
|
+
LOADING = 'LOADING',
|
|
62
|
+
/** Loaded */
|
|
63
|
+
LOADED = 'LOADED',
|
|
64
|
+
/** Active */
|
|
65
|
+
ACTIVE = 'ACTIVE',
|
|
66
|
+
/** Error State */
|
|
67
|
+
ERROR = 'ERROR',
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// =========================================
|
|
71
|
+
// Module Lifecycle Events
|
|
72
|
+
// =========================================
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Module Lifecycle Event Enum
|
|
76
|
+
*/
|
|
77
|
+
export enum ModuleLifecycleEvent {
|
|
78
|
+
/** Before Load */
|
|
79
|
+
BEFORE_LOAD = 'BEFORE_LOAD',
|
|
80
|
+
/** After Load */
|
|
81
|
+
AFTER_LOAD = 'AFTER_LOAD',
|
|
82
|
+
/** Before Activate */
|
|
83
|
+
BEFORE_ACTIVATE = 'BEFORE_ACTIVATE',
|
|
84
|
+
/** After Activate */
|
|
85
|
+
AFTER_ACTIVATE = 'AFTER_ACTIVATE',
|
|
86
|
+
/** Before Deactivate */
|
|
87
|
+
BEFORE_DEACTIVATE = 'BEFORE_DEACTIVATE',
|
|
88
|
+
/** After Deactivate */
|
|
89
|
+
AFTER_DEACTIVATE = 'AFTER_DEACTIVATE',
|
|
90
|
+
/** Error */
|
|
91
|
+
ERROR = 'ERROR',
|
|
92
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Brix Platform Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @file Navigation-Related Type Definitions
|
|
18
|
+
* @description Defines core types for the navigation system, including navigation options, route change listening, etc.
|
|
19
|
+
* @module @brix/runtime-sdk-api-web/types/navigation
|
|
20
|
+
* @version 3.2.0
|
|
21
|
+
*
|
|
22
|
+
* [v3.2 Changes]
|
|
23
|
+
* Extracted from index.ts into a standalone type file, and promoted common contracts from infra-adapter-router-web.
|
|
24
|
+
*
|
|
25
|
+
* [Design Principles]
|
|
26
|
+
* - Define common navigation contracts, router adapters implement specific logic
|
|
27
|
+
* - Support declarative navigation (PageId) and imperative navigation (Path)
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Navigation Options
|
|
31
|
+
*
|
|
32
|
+
* <p>Configuration options controlling navigation behavior.</p>
|
|
33
|
+
*/
|
|
34
|
+
export interface NavigateOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Whether to Replace Current History Entry
|
|
37
|
+
*
|
|
38
|
+
* <p>When true, the new page replaces the current page's position in the history stack.</p>
|
|
39
|
+
*/
|
|
40
|
+
replace?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Route State
|
|
43
|
+
*
|
|
44
|
+
* <p>State data passed to the target page.</p>
|
|
45
|
+
*/
|
|
46
|
+
state?: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Navigation Capability Type Identifier
|
|
50
|
+
*/
|
|
51
|
+
export declare const NavigationCapabilityType: unique symbol;
|
|
52
|
+
/**
|
|
53
|
+
* Navigation Capability Contract
|
|
54
|
+
*
|
|
55
|
+
* <p>Provides page navigation capability for plugins, replacing direct use of react-router.</p>
|
|
56
|
+
*
|
|
57
|
+
* <h3>Usage Example</h3>
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const nav = context.getCapability<NavigationCapability>(NavigationCapabilityType);
|
|
60
|
+
* nav.navigate('/booking/list');
|
|
61
|
+
* nav.goBack();
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export interface NavigationCapability {
|
|
65
|
+
/**
|
|
66
|
+
* Navigate to Specified Path
|
|
67
|
+
*
|
|
68
|
+
* @param path Target path
|
|
69
|
+
* @param options Navigation options
|
|
70
|
+
*/
|
|
71
|
+
navigate(path: string, options?: NavigateOptions): void;
|
|
72
|
+
/**
|
|
73
|
+
* Go Back to Previous Page
|
|
74
|
+
*/
|
|
75
|
+
goBack(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Get Current Path
|
|
78
|
+
*
|
|
79
|
+
* @returns Current URL path
|
|
80
|
+
*/
|
|
81
|
+
getCurrentPath(): string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Navigation Options (Compatibility Alias)
|
|
85
|
+
*/
|
|
86
|
+
export type NavigationOptions = NavigateOptions;
|
|
87
|
+
/**
|
|
88
|
+
* Route Change Listener
|
|
89
|
+
*
|
|
90
|
+
* <p>Used to listen for route change events.</p>
|
|
91
|
+
*/
|
|
92
|
+
export type RouteChangeListener = (path: string) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Router Capability Type Identifier (Compatibility Alias)
|
|
95
|
+
*/
|
|
96
|
+
export declare const RouterCapabilityType: symbol;
|
|
97
|
+
/**
|
|
98
|
+
* Router Capability (Compatibility Alias)
|
|
99
|
+
*/
|
|
100
|
+
export type RouterCapability = NavigationCapability;
|
|
101
|
+
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["navigation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAMD;;GAEG;AACH,eAAO,MAAM,wBAAwB,eAAqC,CAAC;AAE3E;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAExD;;OAEG;IACH,MAAM,IAAI,IAAI,CAAC;IAEf;;;;OAIG;IACH,cAAc,IAAI,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAMhD;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAMzD;;GAEG;AACH,eAAO,MAAM,oBAAoB,QAA2B,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Brix Platform Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @file Navigation-Related Type Definitions
|
|
18
|
+
* @description Defines core types for the navigation system, including navigation options, route change listening, etc.
|
|
19
|
+
* @module @brix/runtime-sdk-api-web/types/navigation
|
|
20
|
+
* @version 3.2.0
|
|
21
|
+
*
|
|
22
|
+
* [v3.2 Changes]
|
|
23
|
+
* Extracted from index.ts into a standalone type file, and promoted common contracts from infra-adapter-router-web.
|
|
24
|
+
*
|
|
25
|
+
* [v3.2.0 Phase 1 Additions]
|
|
26
|
+
* - Added NavigateResult: Navigation result type
|
|
27
|
+
* - Added WebNavigateOptions: Web navigation options
|
|
28
|
+
* - Added PageChangeEvent: Page change event
|
|
29
|
+
* - Added PageChangeHandler: Page change handler
|
|
30
|
+
*
|
|
31
|
+
* [Design Principles]
|
|
32
|
+
* - Define common navigation contracts, router adapters implement specific logic
|
|
33
|
+
* - Support declarative navigation (PageId) and imperative navigation (Path)
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import type { Unsubscribe } from './event';
|
|
37
|
+
|
|
38
|
+
// =========================================
|
|
39
|
+
// Navigation Options (Adapter Contract)
|
|
40
|
+
// =========================================
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Navigation Options
|
|
44
|
+
*
|
|
45
|
+
* <p>Configuration options controlling navigation behavior.</p>
|
|
46
|
+
*/
|
|
47
|
+
export interface NavigateOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Whether to Replace Current History Entry
|
|
50
|
+
*
|
|
51
|
+
* <p>When true, the new page replaces the current page's position in the history stack.</p>
|
|
52
|
+
*/
|
|
53
|
+
replace?: boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Route State
|
|
57
|
+
*
|
|
58
|
+
* <p>State data passed to the target page.</p>
|
|
59
|
+
*/
|
|
60
|
+
state?: Record<string, unknown>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// =========================================
|
|
64
|
+
// Web Navigation Options (Extended)
|
|
65
|
+
// =========================================
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Web Navigation Options
|
|
69
|
+
*
|
|
70
|
+
* <p>Compared to basic NavigateOptions, provides richer navigation control.</p>
|
|
71
|
+
*
|
|
72
|
+
* @since 3.2.0
|
|
73
|
+
*/
|
|
74
|
+
export interface WebNavigateOptions extends NavigateOptions {
|
|
75
|
+
/**
|
|
76
|
+
* Whether to Open in New Window
|
|
77
|
+
*
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
80
|
+
openInNewWindow?: boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Skip Governance Policy Check
|
|
84
|
+
*
|
|
85
|
+
* <p>For Host internal use only, plugins setting this has no effect.</p>
|
|
86
|
+
*
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
skipGovernance?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// =========================================
|
|
93
|
+
// Navigation Result
|
|
94
|
+
// =========================================
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Navigation Result
|
|
98
|
+
*
|
|
99
|
+
* <p>Describes the execution result of a navigation request. In governance mode,
|
|
100
|
+
* navigation initiated by plugins is a "request" not a "command", Host may reject navigation.</p>
|
|
101
|
+
*
|
|
102
|
+
* @since 3.2.0
|
|
103
|
+
*/
|
|
104
|
+
export interface NavigateResult {
|
|
105
|
+
/**
|
|
106
|
+
* Whether Navigation Succeeded
|
|
107
|
+
*/
|
|
108
|
+
readonly success: boolean;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Failure Reason (only has value when success=false)
|
|
112
|
+
*
|
|
113
|
+
* - 'permission_denied': Insufficient permissions
|
|
114
|
+
* - 'feature_disabled': Feature is disabled
|
|
115
|
+
* - 'page_not_found': Page does not exist
|
|
116
|
+
* - 'host_rejected': Host rejected navigation
|
|
117
|
+
* - 'navigation_blocked': Navigation was blocked (e.g., unsaved form)
|
|
118
|
+
*/
|
|
119
|
+
readonly reason?: 'permission_denied' | 'feature_disabled' | 'page_not_found' | 'host_rejected' | 'navigation_blocked';
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Detailed Error Message
|
|
123
|
+
*/
|
|
124
|
+
readonly message?: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// =========================================
|
|
128
|
+
// Page Change Event
|
|
129
|
+
// =========================================
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Page Change Event
|
|
133
|
+
*
|
|
134
|
+
* <p>Describes page switch details for page monitoring and analytics.</p>
|
|
135
|
+
*
|
|
136
|
+
* @since 3.2.0
|
|
137
|
+
*/
|
|
138
|
+
export interface PageChangeEvent {
|
|
139
|
+
/**
|
|
140
|
+
* Current Page ID
|
|
141
|
+
*
|
|
142
|
+
* <p>Format: {pluginId}:{pageName}, e.g., 'booking:detail'.</p>
|
|
143
|
+
*/
|
|
144
|
+
readonly pageId: string;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Page Parameters
|
|
148
|
+
*
|
|
149
|
+
* <p>Parameter object passed to the target page.</p>
|
|
150
|
+
*/
|
|
151
|
+
readonly params?: Record<string, unknown>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Source Page ID (if any)
|
|
155
|
+
*/
|
|
156
|
+
readonly fromPageId?: string;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Navigation Type
|
|
160
|
+
*
|
|
161
|
+
* - 'push': Forward navigation (clicking link/button)
|
|
162
|
+
* - 'pop': Back navigation (browser back)
|
|
163
|
+
* - 'replace': Replace navigation
|
|
164
|
+
*/
|
|
165
|
+
readonly navigationType: 'push' | 'pop' | 'replace';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Page Change Handler
|
|
170
|
+
*
|
|
171
|
+
* @since 3.2.0
|
|
172
|
+
*/
|
|
173
|
+
export type PageChangeHandler = (event: PageChangeEvent) => void;
|
|
174
|
+
|
|
175
|
+
// =========================================
|
|
176
|
+
// Navigation Capability
|
|
177
|
+
// =========================================
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Navigation Capability Type Identifier
|
|
181
|
+
*/
|
|
182
|
+
export const NavigationCapabilityType = Symbol.for('NavigationCapability');
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Navigation Capability Contract
|
|
186
|
+
*
|
|
187
|
+
* <p>Provides page navigation capability for plugins, replacing direct use of react-router.</p>
|
|
188
|
+
*
|
|
189
|
+
* <h3>Design Principles</h3>
|
|
190
|
+
* <ul>
|
|
191
|
+
* <li>Plugins only perceive PageId, not URL</li>
|
|
192
|
+
* <li>All navigation is a "request", Host can reject</li>
|
|
193
|
+
* <li>Governance policies support permission checks, plugin isolation, Feature Flags</li>
|
|
194
|
+
* </ul>
|
|
195
|
+
*
|
|
196
|
+
* <h3>Basic Usage (Imperative Navigation)</h3>
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const nav = context.getCapability<NavigationCapability>(NavigationCapabilityType);
|
|
199
|
+
* nav.navigate('/booking/list');
|
|
200
|
+
* nav.goBack();
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* <h3>Advanced Usage (Request-Based Navigation)</h3>
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const nav = context.getCapability<NavigationCapability>(NavigationCapabilityType);
|
|
206
|
+
*
|
|
207
|
+
* // Request navigation to page (may be rejected)
|
|
208
|
+
* const result = await nav.requestNavigate('booking:detail', { id: '123' });
|
|
209
|
+
* if (!result.success) {
|
|
210
|
+
* console.error('Navigation failed:', result.reason, result.message);
|
|
211
|
+
* }
|
|
212
|
+
*
|
|
213
|
+
* // Subscribe to page changes
|
|
214
|
+
* const unsubscribe = nav.onPageChange((event) => {
|
|
215
|
+
* console.log('Page changed:', event.pageId);
|
|
216
|
+
* });
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @since 3.0.0
|
|
220
|
+
*/
|
|
221
|
+
export interface NavigationCapability {
|
|
222
|
+
// =========================================
|
|
223
|
+
// Basic Navigation Methods (Imperative, Directly Executed)
|
|
224
|
+
// =========================================
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Navigate to Specified Path
|
|
228
|
+
*
|
|
229
|
+
* <p>Imperative navigation, executed directly. For controlled navigation, use requestNavigate.</p>
|
|
230
|
+
*
|
|
231
|
+
* @param path Target path
|
|
232
|
+
* @param options Navigation options
|
|
233
|
+
*/
|
|
234
|
+
navigate(path: string, options?: NavigateOptions): void;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Go Back to Previous Page
|
|
238
|
+
*/
|
|
239
|
+
goBack(): void;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Get Current Path
|
|
243
|
+
*
|
|
244
|
+
* @returns Current URL path
|
|
245
|
+
*/
|
|
246
|
+
getCurrentPath(): string;
|
|
247
|
+
|
|
248
|
+
// =========================================
|
|
249
|
+
// Advanced Navigation Methods (Request-Based, Governable)
|
|
250
|
+
// =========================================
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Request Navigation to Specified Page
|
|
254
|
+
*
|
|
255
|
+
* <p>This is a "request" not a "command", Host can reject navigation based on governance policies.</p>
|
|
256
|
+
*
|
|
257
|
+
* @param pageId Target page ID (format: {pluginId}:{pageName})
|
|
258
|
+
* @param params Page parameters
|
|
259
|
+
* @param options Navigation options
|
|
260
|
+
* @returns Navigation result
|
|
261
|
+
*
|
|
262
|
+
* @since 3.2.0
|
|
263
|
+
*/
|
|
264
|
+
requestNavigate?(
|
|
265
|
+
pageId: string,
|
|
266
|
+
params?: Record<string, unknown>,
|
|
267
|
+
options?: WebNavigateOptions
|
|
268
|
+
): Promise<NavigateResult>;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Check If Navigation to Specified Page Is Possible
|
|
272
|
+
*
|
|
273
|
+
* <p>Pre-check, does not execute actual navigation.</p>
|
|
274
|
+
*
|
|
275
|
+
* @param pageId Target page ID
|
|
276
|
+
* @returns Whether navigation is possible
|
|
277
|
+
*
|
|
278
|
+
* @since 3.2.0
|
|
279
|
+
*/
|
|
280
|
+
canNavigate?(pageId: string): boolean;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Get Current Page ID
|
|
284
|
+
*
|
|
285
|
+
* @returns Current page ID, returns empty string if unrecognized
|
|
286
|
+
*
|
|
287
|
+
* @since 3.2.0
|
|
288
|
+
*/
|
|
289
|
+
getCurrentPageId?(): string;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Get Current Page Parameters
|
|
293
|
+
*
|
|
294
|
+
* @typeParam T Parameter type
|
|
295
|
+
* @returns Page parameter object
|
|
296
|
+
*
|
|
297
|
+
* @since 3.2.0
|
|
298
|
+
*/
|
|
299
|
+
getPageParams?<T extends Record<string, unknown> = Record<string, unknown>>(): T;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Request Go Back to Previous Page
|
|
303
|
+
*
|
|
304
|
+
* @returns Navigation result
|
|
305
|
+
*
|
|
306
|
+
* @since 3.2.0
|
|
307
|
+
*/
|
|
308
|
+
requestGoBack?(): Promise<NavigateResult>;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Subscribe to Page Change Events
|
|
312
|
+
*
|
|
313
|
+
* @param handler Page change handler
|
|
314
|
+
* @returns Unsubscribe function
|
|
315
|
+
*
|
|
316
|
+
* @since 3.2.0
|
|
317
|
+
*/
|
|
318
|
+
onPageChange?(handler: PageChangeHandler): Unsubscribe;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Navigation Options (Compatibility Alias)
|
|
323
|
+
*/
|
|
324
|
+
export type NavigationOptions = NavigateOptions;
|
|
325
|
+
|
|
326
|
+
// =========================================
|
|
327
|
+
// Route Change Listening
|
|
328
|
+
// =========================================
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Route Change Listener
|
|
332
|
+
*
|
|
333
|
+
* <p>Used to listen for route change events.</p>
|
|
334
|
+
*/
|
|
335
|
+
export type RouteChangeListener = (path: string) => void;
|
|
336
|
+
|
|
337
|
+
// =========================================
|
|
338
|
+
// Router Capability (Compatibility Alias)
|
|
339
|
+
// =========================================
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Router Capability Type Identifier (Compatibility Alias)
|
|
343
|
+
*
|
|
344
|
+
* @deprecated Please use NavigationCapabilityType.
|
|
345
|
+
* This alias will be removed in v4.0.0.
|
|
346
|
+
*
|
|
347
|
+
* @since 3.0.0
|
|
348
|
+
* @see NavigationCapabilityType
|
|
349
|
+
*/
|
|
350
|
+
export const RouterCapabilityType = NavigationCapabilityType;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Router Capability (Compatibility Alias)
|
|
354
|
+
*
|
|
355
|
+
* @deprecated Please use NavigationCapability.
|
|
356
|
+
* This alias will be removed in v4.0.0.
|
|
357
|
+
*
|
|
358
|
+
* @since 3.0.0
|
|
359
|
+
* @see NavigationCapability
|
|
360
|
+
*/
|
|
361
|
+
export type RouterCapability = NavigationCapability;
|