vue-multi-router 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/README.md +203 -4
- package/dist/index.d.ts +134 -81
- package/dist/index.js +393 -239
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -25,19 +25,218 @@ npm install vue-multi-router
|
|
|
25
25
|
|
|
26
26
|
## Features
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
- **Multiple Independent Routers** - Run multiple Vue Router instances simultaneously in a single app
|
|
29
|
+
- **Context-Based Navigation** - Each routing context maintains its own navigation history
|
|
30
|
+
- **Browser History Integration** - Back/forward buttons work across contexts with proper URL updates
|
|
31
|
+
- **Session Persistence** - Context states persist across page reloads via SessionStorage or other implementations
|
|
32
|
+
- **TypeScript Support** - Full type definitions included
|
|
33
|
+
- **Composable API** - Easy-to-use composables for accessing router state
|
|
29
34
|
|
|
30
35
|
## Basic Usage
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
### 1. Create Multi Router
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
// router.ts
|
|
41
|
+
import { createMultiRouter } from 'vue-multi-router'
|
|
42
|
+
import { createWebHistory } from 'vue-router'
|
|
43
|
+
|
|
44
|
+
export const multiRouter = createMultiRouter({
|
|
45
|
+
history: () => createWebHistory(),
|
|
46
|
+
routes: [
|
|
47
|
+
{
|
|
48
|
+
path: '/',
|
|
49
|
+
component: () => import('./views/Layout.vue'),
|
|
50
|
+
children: [
|
|
51
|
+
{ path: 'home', component: () => import('./views/Home.vue') },
|
|
52
|
+
{ path: 'about', component: () => import('./views/About.vue') },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
})
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 2. Install Plugin
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
// main.ts
|
|
63
|
+
import { createApp } from 'vue'
|
|
64
|
+
import App from './App.vue'
|
|
65
|
+
import { multiRouter } from './router'
|
|
66
|
+
|
|
67
|
+
const app = createApp(App)
|
|
68
|
+
app.use(multiRouter)
|
|
69
|
+
app.mount('#app')
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 3. Define Contexts
|
|
73
|
+
|
|
74
|
+
```vue
|
|
75
|
+
<!-- App.vue -->
|
|
76
|
+
<template>
|
|
77
|
+
<MultiRouterContext type="main" name="main" default>
|
|
78
|
+
<RouterView />
|
|
79
|
+
</MultiRouterContext>
|
|
80
|
+
</template>
|
|
81
|
+
|
|
82
|
+
<script setup>
|
|
83
|
+
import { MultiRouterContext } from 'vue-multi-router'
|
|
84
|
+
</script>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`MultiRouterContext` acts as an activator by default — clicking anywhere inside it activates the context. No extra wrapper needed.
|
|
88
|
+
|
|
89
|
+
### 4. Create Additional Contexts
|
|
90
|
+
|
|
91
|
+
```vue
|
|
92
|
+
<!-- Panels.vue -->
|
|
93
|
+
<template>
|
|
94
|
+
<div v-for="panel in panels" :key="panel.id">
|
|
95
|
+
<MultiRouterContext
|
|
96
|
+
type="panel"
|
|
97
|
+
:name="`panel-${panel.id}`"
|
|
98
|
+
initial-location="/home"
|
|
99
|
+
>
|
|
100
|
+
<RouterView />
|
|
101
|
+
</MultiRouterContext>
|
|
102
|
+
</div>
|
|
103
|
+
</template>
|
|
104
|
+
```
|
|
33
105
|
|
|
34
106
|
## API Reference
|
|
35
107
|
|
|
36
|
-
|
|
108
|
+
### `createMultiRouter(options)`
|
|
109
|
+
|
|
110
|
+
Creates a multi-router instance.
|
|
111
|
+
|
|
112
|
+
**Options:**
|
|
113
|
+
- `history: () => RouterHistory` - Factory function returning a Vue Router history instance
|
|
114
|
+
- `routes: RouteRecordRaw[]` - Route definitions (same as Vue Router)
|
|
115
|
+
- `historyOptions?: MultiRouterHistoryManagerOptions` - History management options
|
|
116
|
+
|
|
117
|
+
### Route Meta Options
|
|
118
|
+
|
|
119
|
+
**`multiRouterRoot: boolean`**
|
|
120
|
+
|
|
121
|
+
Marks a route as the root for context rendering. When a context navigates to a nested route, `RouterView` inside the context will start rendering from the route marked with `multiRouterRoot: true`, skipping parent routes.
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
const routes = [
|
|
125
|
+
{
|
|
126
|
+
path: '/dashboard',
|
|
127
|
+
component: DashboardLayout,
|
|
128
|
+
children: [
|
|
129
|
+
{
|
|
130
|
+
path: 'panels',
|
|
131
|
+
component: PanelsContainer,
|
|
132
|
+
children: [
|
|
133
|
+
{
|
|
134
|
+
path: 'content',
|
|
135
|
+
component: PanelContent,
|
|
136
|
+
meta: { multiRouterRoot: true }, // Context renders from here
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
This is useful when contexts are nested inside shared layouts but should render independently from their root component.
|
|
146
|
+
|
|
147
|
+
### `<MultiRouterContext>`
|
|
148
|
+
|
|
149
|
+
Component that defines a routing context boundary. By default, it also acts as an activator — clicking inside the context activates it.
|
|
150
|
+
|
|
151
|
+
**Props:**
|
|
152
|
+
- `type: string` - Context type identifier (for debugging/organization)
|
|
153
|
+
- `name: string` - Unique context identifier
|
|
154
|
+
- `location?: string` - Force specific location (overrides storage)
|
|
155
|
+
- `initial-location?: string` - Initial location for new contexts
|
|
156
|
+
- `history-enabled?: boolean` - Whether to track in browser history (default: `true`)
|
|
157
|
+
- `default?: boolean` - Activate by default if no saved context exists
|
|
158
|
+
- `activator?: boolean` - Whether to activate context on mousedown (default: `true`). Set to `false` to opt out of built-in activation behavior
|
|
159
|
+
- `prevent-class?: string` - CSS class that prevents activation on click, useful if you want to prevent activation on click of a button that destroys the context
|
|
160
|
+
|
|
161
|
+
To disable the built-in activator:
|
|
162
|
+
|
|
163
|
+
```vue
|
|
164
|
+
<MultiRouterContext type="panel" name="panel-1" :activator="false">
|
|
165
|
+
<!-- manage activation manually -->
|
|
166
|
+
</MultiRouterContext>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### `<MultiRouterContextActivator>`
|
|
170
|
+
|
|
171
|
+
Standalone wrapper component that activates context on user interaction. Useful for advanced cases where you need fine-grained control over which element triggers activation, separate from the `MultiRouterContext` boundary.
|
|
172
|
+
|
|
173
|
+
**Props:**
|
|
174
|
+
- `prevent-class?: string` - CSS class that prevents activation on click
|
|
175
|
+
- `as?: string` - HTML element to render as wrapper (default: fragment/div)
|
|
176
|
+
|
|
177
|
+
### `useMultiRouter()`
|
|
178
|
+
|
|
179
|
+
Composable for accessing multi-router outside a context.
|
|
180
|
+
|
|
181
|
+
**Returns:**
|
|
182
|
+
- `activeContextKey: ComputedRef<string | undefined>` - Currently active context
|
|
183
|
+
- `activeHistoryContextKey: ComputedRef<string | undefined>` - Context controlling browser URL
|
|
184
|
+
- `setActive(contextKey: string, updateHistory?: boolean): void` - Activate a context
|
|
185
|
+
- `hasContext(contextKey: string): boolean` - Check if context exists
|
|
186
|
+
|
|
187
|
+
### `useMultiRouterContext()`
|
|
188
|
+
|
|
189
|
+
Composable for use inside a `MultiRouterContext`.
|
|
190
|
+
|
|
191
|
+
**Returns:**
|
|
192
|
+
- `manager: useMultiRouter()` - MultiRouter manager instance
|
|
193
|
+
- `contextKey: string` - This context's key
|
|
194
|
+
- `isActive: ComputedRef<boolean>` - Whether this context is active
|
|
195
|
+
- `isHistoryActive: ComputedRef<boolean>` - Whether this context controls browser URL
|
|
196
|
+
- `activeContextKey: ComputedRef<string>` - Currently active context key
|
|
197
|
+
- `activeHistoryContextKey: ComputedRef<string>` - Currently active history context key
|
|
198
|
+
- `historyEnabled: ComputedRef<boolean>` - Whether history is enabled for this context
|
|
199
|
+
- `activate(updateHistory?: boolean): void` - Activate this context
|
|
200
|
+
- `setActive(contextKey: string, updateHistory?: boolean): void` - Activate a context
|
|
201
|
+
- `hasContext(contextKey: string): boolean` - Check if context exists
|
|
37
202
|
|
|
38
203
|
## Examples
|
|
39
204
|
|
|
40
|
-
|
|
205
|
+
### Cards with Query Parameters
|
|
206
|
+
|
|
207
|
+
```vue
|
|
208
|
+
<template>
|
|
209
|
+
<div v-for="card in cards" :key="card.id">
|
|
210
|
+
<MultiRouterContext
|
|
211
|
+
type="card"
|
|
212
|
+
:name="`card-${card.id}`"
|
|
213
|
+
initial-location="/card/content"
|
|
214
|
+
:history-enabled="false"
|
|
215
|
+
>
|
|
216
|
+
<CardContent @close="removeCard(card.id)" />
|
|
217
|
+
</MultiRouterContext>
|
|
218
|
+
</div>
|
|
219
|
+
</template>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Accessing Route in Context
|
|
223
|
+
|
|
224
|
+
```vue
|
|
225
|
+
<script setup>
|
|
226
|
+
import { useRouter, useRoute } from 'vue-router'
|
|
227
|
+
|
|
228
|
+
const router = useRouter()
|
|
229
|
+
const route = useRoute()
|
|
230
|
+
|
|
231
|
+
// Navigate within this context
|
|
232
|
+
function goToPage(path) {
|
|
233
|
+
router.push(path)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Access query params
|
|
237
|
+
const searchQuery = computed(() => route.query.q)
|
|
238
|
+
</script>
|
|
239
|
+
```
|
|
41
240
|
|
|
42
241
|
## Peer Dependencies
|
|
43
242
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vue7 from "vue";
|
|
2
2
|
import { App, InjectionKey, PropType } from "vue";
|
|
3
|
-
import * as vue_router0 from "vue-router";
|
|
4
3
|
import { Router, RouterHistory, RouterOptions } from "vue-router";
|
|
5
4
|
|
|
6
5
|
//#region src/history/types.d.ts
|
|
7
6
|
type HistoryLocation = string;
|
|
8
7
|
type HistoryState = Record<string, any>;
|
|
9
|
-
type HistoryBuilder = () => RouterHistory;
|
|
10
8
|
declare enum NavigationType {
|
|
11
9
|
pop = "pop",
|
|
12
10
|
push = "push",
|
|
@@ -48,8 +46,26 @@ interface ContextStorageAdapter {
|
|
|
48
46
|
clearStack(contextKey: string): MaybePromise<void>;
|
|
49
47
|
saveActiveContext(contextKey: string): MaybePromise<void>;
|
|
50
48
|
getActiveContext(): MaybePromise<string | null>;
|
|
49
|
+
clearActiveContext(): MaybePromise<void>;
|
|
51
50
|
saveActiveHistoryContext(contextKey: string): MaybePromise<void>;
|
|
52
51
|
getActiveHistoryContext(): MaybePromise<string | null>;
|
|
52
|
+
clearActiveHistoryContext(): MaybePromise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Save the stack of previously active contexts (for fallback when closing a context)
|
|
55
|
+
*/
|
|
56
|
+
saveContextStack(stack: string[]): MaybePromise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Get the stack of previously active contexts
|
|
59
|
+
*/
|
|
60
|
+
getContextStack(): MaybePromise<string[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Save the stack of previously active history contexts (for fallback when closing a context)
|
|
63
|
+
*/
|
|
64
|
+
saveHistoryContextStack(stack: string[]): MaybePromise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Get the stack of previously active history contexts
|
|
67
|
+
*/
|
|
68
|
+
getHistoryContextStack(): MaybePromise<string[]>;
|
|
53
69
|
}
|
|
54
70
|
//#endregion
|
|
55
71
|
//#region src/history/manager.d.ts
|
|
@@ -86,14 +102,16 @@ interface MultiRouterHistoryManagerOptions {
|
|
|
86
102
|
onContextActivate?: (contextKey: string) => void;
|
|
87
103
|
}
|
|
88
104
|
declare class MultiRouterHistoryManager {
|
|
89
|
-
private
|
|
105
|
+
private history;
|
|
90
106
|
private stacks;
|
|
91
107
|
private activeHistoryContextKey;
|
|
92
108
|
private historyContextStack;
|
|
109
|
+
private contextStack;
|
|
93
110
|
private baseHistoryCleanup;
|
|
94
111
|
private contextSwitchMode;
|
|
95
112
|
private onContextActivate?;
|
|
96
|
-
constructor(
|
|
113
|
+
constructor(history: RouterHistory, options?: MultiRouterHistoryManagerOptions);
|
|
114
|
+
private restoreContextStacks;
|
|
97
115
|
get base(): string;
|
|
98
116
|
get location(): HistoryLocation;
|
|
99
117
|
get state(): HistoryState;
|
|
@@ -108,6 +126,24 @@ declare class MultiRouterHistoryManager {
|
|
|
108
126
|
setActiveHistoryContext(contextKey: string): void;
|
|
109
127
|
clearActiveHistoryContext(contextKey: string): void;
|
|
110
128
|
saveActiveContext(contextKey: string): void;
|
|
129
|
+
/**
|
|
130
|
+
* Push the current active context to the context stack before switching to a new one.
|
|
131
|
+
* This allows fallback to the previous context when the current one is removed.
|
|
132
|
+
*/
|
|
133
|
+
pushToContextStack(contextKey: string): void;
|
|
134
|
+
/**
|
|
135
|
+
* Get the previous context from the stack (for fallback when current context is removed).
|
|
136
|
+
* Returns null if no previous context exists.
|
|
137
|
+
*/
|
|
138
|
+
popFromContextStack(): string | null;
|
|
139
|
+
/**
|
|
140
|
+
* Remove a context from the context stack (when the context is unregistered).
|
|
141
|
+
*/
|
|
142
|
+
removeFromContextStack(contextKey: string): void;
|
|
143
|
+
/**
|
|
144
|
+
* Clear the active context from storage (when no contexts are left).
|
|
145
|
+
*/
|
|
146
|
+
clearActiveContext(): void;
|
|
111
147
|
getActiveHistoryContextKey(): string | null;
|
|
112
148
|
private fallbackToPreviousHistoryContext;
|
|
113
149
|
private createInitialVirtualStack;
|
|
@@ -124,71 +160,22 @@ declare class MultiRouterHistoryManager {
|
|
|
124
160
|
getLastActiveContextKey(): MaybePromise<string | null>;
|
|
125
161
|
}
|
|
126
162
|
//#endregion
|
|
127
|
-
//#region src/types.d.ts
|
|
128
|
-
type Wip = true;
|
|
129
|
-
interface ContextTypeOptions {
|
|
130
|
-
canUseAsHistoryContext: boolean;
|
|
131
|
-
single: boolean;
|
|
132
|
-
}
|
|
133
|
-
type ContextTypes = Record<string, ContextTypeOptions>;
|
|
134
|
-
//#endregion
|
|
135
163
|
//#region src/multi-router.d.ts
|
|
136
164
|
type MultiRouterInterface = {
|
|
137
165
|
getByContextName: (name: string) => Router;
|
|
138
166
|
install: (app: App) => void;
|
|
139
167
|
};
|
|
140
|
-
|
|
141
|
-
window: {
|
|
142
|
-
canUseAsHistoryContext: true;
|
|
143
|
-
single: false;
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
declare const contextTemplateTabs: {
|
|
147
|
-
tab: {
|
|
148
|
-
canUseAsHistoryContext: true;
|
|
149
|
-
single: false;
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
declare const contextTemplateMainWithWindows: {
|
|
153
|
-
window: {
|
|
154
|
-
canUseAsHistoryContext: true;
|
|
155
|
-
single: false;
|
|
156
|
-
};
|
|
157
|
-
main: {
|
|
158
|
-
canUseAsHistoryContext: true;
|
|
159
|
-
single: true;
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
|
-
declare const contextTemplateDesktopWithWindows: {
|
|
163
|
-
window: {
|
|
164
|
-
canUseAsHistoryContext: true;
|
|
165
|
-
single: false;
|
|
166
|
-
};
|
|
167
|
-
desktop: {
|
|
168
|
-
canUseAsHistoryContext: false;
|
|
169
|
-
single: true;
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
declare const contextTemplateTabsWithWindows: {
|
|
173
|
-
window: {
|
|
174
|
-
canUseAsHistoryContext: true;
|
|
175
|
-
single: false;
|
|
176
|
-
};
|
|
177
|
-
tab: {
|
|
178
|
-
canUseAsHistoryContext: true;
|
|
179
|
-
single: false;
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
|
-
type CustomRouterOptions = Omit<RouterOptions, 'history'> & {
|
|
183
|
-
history: () => RouterHistory;
|
|
168
|
+
type CustomRouterOptions = RouterOptions & {
|
|
184
169
|
historyOptions?: MultiRouterHistoryManagerOptions;
|
|
185
|
-
types: ContextTypes;
|
|
186
170
|
};
|
|
187
171
|
declare function createMultiRouter(options: CustomRouterOptions): MultiRouterInterface;
|
|
188
172
|
//#endregion
|
|
173
|
+
//#region src/hooks.d.ts
|
|
174
|
+
declare function onMultiRouterContextActivate(callback: (name: string) => void): void;
|
|
175
|
+
//#endregion
|
|
189
176
|
//#region src/components/MultiRouterContext.vue.d.ts
|
|
190
177
|
declare const _default: typeof __VLS_export$1;
|
|
191
|
-
declare const __VLS_export$1:
|
|
178
|
+
declare const __VLS_export$1: vue7.DefineComponent<vue7.ExtractPropTypes<{
|
|
192
179
|
type: {
|
|
193
180
|
type: StringConstructor;
|
|
194
181
|
required: true;
|
|
@@ -223,9 +210,27 @@ declare const __VLS_export$1: vue6.DefineComponent<vue6.ExtractPropTypes<{
|
|
|
223
210
|
type: BooleanConstructor;
|
|
224
211
|
default: boolean;
|
|
225
212
|
};
|
|
226
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Whether this context should act as an activator, activating the context on mousedown.
|
|
215
|
+
* Set false to opt out of built-in activation behavior.
|
|
216
|
+
* @default true
|
|
217
|
+
*/
|
|
218
|
+
activator: {
|
|
219
|
+
type: BooleanConstructor;
|
|
220
|
+
default: boolean;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* CSS class that prevents activation when the mousedown target matches.
|
|
224
|
+
* Only used when activator is true.
|
|
225
|
+
* @default null
|
|
226
|
+
*/
|
|
227
|
+
preventClass: {
|
|
228
|
+
type: PropType<string | null>;
|
|
229
|
+
default: null;
|
|
230
|
+
};
|
|
231
|
+
}>, () => vue7.VNode<vue7.RendererNode, vue7.RendererElement, {
|
|
227
232
|
[key: string]: any;
|
|
228
|
-
}>, {}, {}, {},
|
|
233
|
+
}>, {}, {}, {}, vue7.ComponentOptionsMixin, vue7.ComponentOptionsMixin, {}, string, vue7.PublicProps, Readonly<vue7.ExtractPropTypes<{
|
|
229
234
|
type: {
|
|
230
235
|
type: StringConstructor;
|
|
231
236
|
required: true;
|
|
@@ -260,30 +265,61 @@ declare const __VLS_export$1: vue6.DefineComponent<vue6.ExtractPropTypes<{
|
|
|
260
265
|
type: BooleanConstructor;
|
|
261
266
|
default: boolean;
|
|
262
267
|
};
|
|
268
|
+
/**
|
|
269
|
+
* Whether this context should act as an activator, activating the context on mousedown.
|
|
270
|
+
* Set false to opt out of built-in activation behavior.
|
|
271
|
+
* @default true
|
|
272
|
+
*/
|
|
273
|
+
activator: {
|
|
274
|
+
type: BooleanConstructor;
|
|
275
|
+
default: boolean;
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* CSS class that prevents activation when the mousedown target matches.
|
|
279
|
+
* Only used when activator is true.
|
|
280
|
+
* @default null
|
|
281
|
+
*/
|
|
282
|
+
preventClass: {
|
|
283
|
+
type: PropType<string | null>;
|
|
284
|
+
default: null;
|
|
285
|
+
};
|
|
263
286
|
}>> & Readonly<{}>, {
|
|
264
287
|
historyEnabled: boolean;
|
|
265
288
|
default: boolean;
|
|
266
|
-
|
|
289
|
+
activator: boolean;
|
|
290
|
+
preventClass: string | null;
|
|
291
|
+
}, {}, {}, {}, string, vue7.ComponentProvideOptions, true, {}, any>;
|
|
267
292
|
//#endregion
|
|
268
293
|
//#region src/components/MultiRouterContextActivator.vue.d.ts
|
|
269
294
|
declare const _default$1: typeof __VLS_export;
|
|
270
|
-
declare const __VLS_export:
|
|
295
|
+
declare const __VLS_export: vue7.DefineComponent<vue7.ExtractPropTypes<{
|
|
271
296
|
as: {
|
|
272
297
|
type: PropType<string | null>;
|
|
273
298
|
default: null;
|
|
274
299
|
};
|
|
275
|
-
|
|
300
|
+
preventClass: {
|
|
301
|
+
type: PropType<string | null>;
|
|
302
|
+
default: null;
|
|
303
|
+
required: false;
|
|
304
|
+
};
|
|
305
|
+
}>, (() => vue7.VNode<vue7.RendererNode, vue7.RendererElement, {
|
|
276
306
|
[key: string]: any;
|
|
277
|
-
}>[] | undefined) | (() =>
|
|
307
|
+
}>[] | undefined) | (() => vue7.VNode<vue7.RendererNode, vue7.RendererElement, {
|
|
278
308
|
[key: string]: any;
|
|
279
|
-
}>), {}, {}, {},
|
|
309
|
+
}>), {}, {}, {}, vue7.ComponentOptionsMixin, vue7.ComponentOptionsMixin, {}, string, vue7.PublicProps, Readonly<vue7.ExtractPropTypes<{
|
|
280
310
|
as: {
|
|
281
311
|
type: PropType<string | null>;
|
|
282
312
|
default: null;
|
|
283
313
|
};
|
|
314
|
+
preventClass: {
|
|
315
|
+
type: PropType<string | null>;
|
|
316
|
+
default: null;
|
|
317
|
+
required: false;
|
|
318
|
+
};
|
|
284
319
|
}>> & Readonly<{}>, {
|
|
320
|
+
preventClass: string | null;
|
|
285
321
|
as: string | null;
|
|
286
|
-
}, {}, {}, {}, string,
|
|
322
|
+
}, {}, {}, {}, string, vue7.ComponentProvideOptions, true, {}, any>;
|
|
287
323
|
//#endregion
|
|
288
324
|
//#region src/contextManager.d.ts
|
|
289
325
|
type ContextInterface = {
|
|
@@ -295,15 +331,14 @@ type ContextInterface = {
|
|
|
295
331
|
};
|
|
296
332
|
interface ActiveContextInterface {
|
|
297
333
|
key: string;
|
|
298
|
-
|
|
334
|
+
data: ContextInterface;
|
|
299
335
|
}
|
|
300
336
|
type ContextInitListener = (key: string) => void;
|
|
301
337
|
type MakeRouterFn = (contextKey: string, history: RouterHistory) => Router;
|
|
302
338
|
type HistoryManagerOptions = {
|
|
303
|
-
|
|
339
|
+
history: RouterHistory;
|
|
304
340
|
} & MultiRouterHistoryManagerOptions;
|
|
305
341
|
declare class MultiRouterManagerInstance {
|
|
306
|
-
private types;
|
|
307
342
|
private makeRouter;
|
|
308
343
|
private started;
|
|
309
344
|
private activeContext;
|
|
@@ -311,12 +346,12 @@ declare class MultiRouterManagerInstance {
|
|
|
311
346
|
private registered;
|
|
312
347
|
private onContextInitListeners;
|
|
313
348
|
private readonly historyManager;
|
|
314
|
-
constructor(app: App,
|
|
349
|
+
constructor(app: App, historyManagerOptions: HistoryManagerOptions, makeRouter: MakeRouterFn);
|
|
315
350
|
getHistoryManager(): MultiRouterHistoryManager;
|
|
316
351
|
getActiveContext(): ActiveContextInterface | undefined;
|
|
317
|
-
getActiveContextRef():
|
|
352
|
+
getActiveContextRef(): vue7.ShallowRef<ActiveContextInterface | undefined, ActiveContextInterface | undefined>;
|
|
318
353
|
getActiveHistoryContext(): ActiveContextInterface | undefined;
|
|
319
|
-
getActiveHistoryContextRef():
|
|
354
|
+
getActiveHistoryContextRef(): vue7.ShallowRef<ActiveContextInterface | undefined, ActiveContextInterface | undefined>;
|
|
320
355
|
setActive(key: string, updateHistory: boolean): boolean;
|
|
321
356
|
clearHistoryContext(key: string): void;
|
|
322
357
|
markAsStarted(): void;
|
|
@@ -331,26 +366,44 @@ declare class MultiRouterManagerInstance {
|
|
|
331
366
|
getContextLocation(key: string): string | undefined;
|
|
332
367
|
getContextHistoryEnabled(key: string): boolean;
|
|
333
368
|
unregister(key: string): void;
|
|
369
|
+
private activateFromStackOrFallback;
|
|
370
|
+
private fallbackToPreviousContext;
|
|
334
371
|
initialize(key: string): void;
|
|
335
372
|
onContextInit(fn: ContextInitListener): void;
|
|
336
373
|
}
|
|
337
374
|
//#endregion
|
|
375
|
+
//#region src/composables/useMultiRouter.d.ts
|
|
376
|
+
/**
|
|
377
|
+
* Composable for accessing the multi-router manager outside a context.
|
|
378
|
+
* Use this when you need to control contexts from a parent component.
|
|
379
|
+
*
|
|
380
|
+
* For usage inside a context, use `useMultiRouterContext()` instead.
|
|
381
|
+
*/
|
|
382
|
+
declare function useMultiRouter(): {
|
|
383
|
+
manager: MultiRouterManagerInstance;
|
|
384
|
+
activeContext: vue7.ComputedRef<ActiveContextInterface | undefined>;
|
|
385
|
+
activeContextKey: vue7.ComputedRef<string | undefined>;
|
|
386
|
+
activeHistoryContextKey: vue7.ComputedRef<string | undefined>;
|
|
387
|
+
setActive: (contextKey: string, updateHistory?: boolean) => void;
|
|
388
|
+
hasContext: (contextKey: string) => boolean;
|
|
389
|
+
};
|
|
390
|
+
//#endregion
|
|
338
391
|
//#region src/composables/useMultiRouterContext.d.ts
|
|
339
392
|
declare function useMultiRouterContext(): {
|
|
340
393
|
manager: MultiRouterManagerInstance;
|
|
341
394
|
contextKey: string;
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
activeHistoryContextKey: vue6.ComputedRef<string | undefined>;
|
|
348
|
-
historyEnabled: vue6.ComputedRef<boolean>;
|
|
395
|
+
isActive: vue7.ComputedRef<boolean>;
|
|
396
|
+
isHistoryActive: vue7.ComputedRef<boolean>;
|
|
397
|
+
activeContextKey: vue7.ComputedRef<string | undefined>;
|
|
398
|
+
activeHistoryContextKey: vue7.ComputedRef<string | undefined>;
|
|
399
|
+
historyEnabled: vue7.ComputedRef<boolean>;
|
|
349
400
|
activate: (updateHistory?: boolean) => void;
|
|
401
|
+
setActive: (contextKey: string, updateHistory?: boolean) => void;
|
|
402
|
+
hasContext: (contextKey: string) => boolean;
|
|
350
403
|
};
|
|
351
404
|
//#endregion
|
|
352
405
|
//#region src/injectionSymbols.d.ts
|
|
353
406
|
declare const multiRouterContextManagerKey: InjectionKey<MultiRouterManagerInstance>;
|
|
354
407
|
declare const multiRouterContextKey: InjectionKey<string>;
|
|
355
408
|
//#endregion
|
|
356
|
-
export { type ContextSwitchMode,
|
|
409
|
+
export { type ContextSwitchMode, type HistoryLocation, type HistoryState, _default as MultiRouterContext, _default$1 as MultiRouterContextActivator, type MultiRouterHistoryManagerOptions, type NavigationCallback, type NavigationInformation, type VirtualStack, createMultiRouter, multiRouterContextKey, multiRouterContextManagerKey, onMultiRouterContextActivate, useMultiRouter, useMultiRouterContext };
|