vue-multi-router 0.1.1 → 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 +7 -3
- package/dist/index.d.ts +26 -27
- package/dist/index.js +32 -30
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -189,12 +189,16 @@ Composable for accessing multi-router outside a context.
|
|
|
189
189
|
Composable for use inside a `MultiRouterContext`.
|
|
190
190
|
|
|
191
191
|
**Returns:**
|
|
192
|
-
- `
|
|
193
|
-
- `
|
|
192
|
+
- `manager: useMultiRouter()` - MultiRouter manager instance
|
|
193
|
+
- `contextKey: string` - This context's key
|
|
194
194
|
- `isActive: ComputedRef<boolean>` - Whether this context is active
|
|
195
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
|
|
196
199
|
- `activate(updateHistory?: boolean): void` - Activate this context
|
|
197
|
-
- `contextKey: string` -
|
|
200
|
+
- `setActive(contextKey: string, updateHistory?: boolean): void` - Activate a context
|
|
201
|
+
- `hasContext(contextKey: string): boolean` - Check if context exists
|
|
198
202
|
|
|
199
203
|
## Examples
|
|
200
204
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vue7 from "vue";
|
|
2
2
|
import { App, InjectionKey, PropType } from "vue";
|
|
3
3
|
import { Router, RouterHistory, RouterOptions } from "vue-router";
|
|
4
4
|
|
|
5
5
|
//#region src/history/types.d.ts
|
|
6
6
|
type HistoryLocation = string;
|
|
7
7
|
type HistoryState = Record<string, any>;
|
|
8
|
-
type HistoryBuilder = () => RouterHistory;
|
|
9
8
|
declare enum NavigationType {
|
|
10
9
|
pop = "pop",
|
|
11
10
|
push = "push",
|
|
@@ -103,7 +102,7 @@ interface MultiRouterHistoryManagerOptions {
|
|
|
103
102
|
onContextActivate?: (contextKey: string) => void;
|
|
104
103
|
}
|
|
105
104
|
declare class MultiRouterHistoryManager {
|
|
106
|
-
private
|
|
105
|
+
private history;
|
|
107
106
|
private stacks;
|
|
108
107
|
private activeHistoryContextKey;
|
|
109
108
|
private historyContextStack;
|
|
@@ -111,7 +110,7 @@ declare class MultiRouterHistoryManager {
|
|
|
111
110
|
private baseHistoryCleanup;
|
|
112
111
|
private contextSwitchMode;
|
|
113
112
|
private onContextActivate?;
|
|
114
|
-
constructor(
|
|
113
|
+
constructor(history: RouterHistory, options?: MultiRouterHistoryManagerOptions);
|
|
115
114
|
private restoreContextStacks;
|
|
116
115
|
get base(): string;
|
|
117
116
|
get location(): HistoryLocation;
|
|
@@ -166,8 +165,7 @@ type MultiRouterInterface = {
|
|
|
166
165
|
getByContextName: (name: string) => Router;
|
|
167
166
|
install: (app: App) => void;
|
|
168
167
|
};
|
|
169
|
-
type CustomRouterOptions =
|
|
170
|
-
history: () => RouterHistory;
|
|
168
|
+
type CustomRouterOptions = RouterOptions & {
|
|
171
169
|
historyOptions?: MultiRouterHistoryManagerOptions;
|
|
172
170
|
};
|
|
173
171
|
declare function createMultiRouter(options: CustomRouterOptions): MultiRouterInterface;
|
|
@@ -177,7 +175,7 @@ declare function onMultiRouterContextActivate(callback: (name: string) => void):
|
|
|
177
175
|
//#endregion
|
|
178
176
|
//#region src/components/MultiRouterContext.vue.d.ts
|
|
179
177
|
declare const _default: typeof __VLS_export$1;
|
|
180
|
-
declare const __VLS_export$1:
|
|
178
|
+
declare const __VLS_export$1: vue7.DefineComponent<vue7.ExtractPropTypes<{
|
|
181
179
|
type: {
|
|
182
180
|
type: StringConstructor;
|
|
183
181
|
required: true;
|
|
@@ -230,9 +228,9 @@ declare const __VLS_export$1: vue0.DefineComponent<vue0.ExtractPropTypes<{
|
|
|
230
228
|
type: PropType<string | null>;
|
|
231
229
|
default: null;
|
|
232
230
|
};
|
|
233
|
-
}>, () =>
|
|
231
|
+
}>, () => vue7.VNode<vue7.RendererNode, vue7.RendererElement, {
|
|
234
232
|
[key: string]: any;
|
|
235
|
-
}>, {}, {}, {},
|
|
233
|
+
}>, {}, {}, {}, vue7.ComponentOptionsMixin, vue7.ComponentOptionsMixin, {}, string, vue7.PublicProps, Readonly<vue7.ExtractPropTypes<{
|
|
236
234
|
type: {
|
|
237
235
|
type: StringConstructor;
|
|
238
236
|
required: true;
|
|
@@ -290,11 +288,11 @@ declare const __VLS_export$1: vue0.DefineComponent<vue0.ExtractPropTypes<{
|
|
|
290
288
|
default: boolean;
|
|
291
289
|
activator: boolean;
|
|
292
290
|
preventClass: string | null;
|
|
293
|
-
}, {}, {}, {}, string,
|
|
291
|
+
}, {}, {}, {}, string, vue7.ComponentProvideOptions, true, {}, any>;
|
|
294
292
|
//#endregion
|
|
295
293
|
//#region src/components/MultiRouterContextActivator.vue.d.ts
|
|
296
294
|
declare const _default$1: typeof __VLS_export;
|
|
297
|
-
declare const __VLS_export:
|
|
295
|
+
declare const __VLS_export: vue7.DefineComponent<vue7.ExtractPropTypes<{
|
|
298
296
|
as: {
|
|
299
297
|
type: PropType<string | null>;
|
|
300
298
|
default: null;
|
|
@@ -304,11 +302,11 @@ declare const __VLS_export: vue0.DefineComponent<vue0.ExtractPropTypes<{
|
|
|
304
302
|
default: null;
|
|
305
303
|
required: false;
|
|
306
304
|
};
|
|
307
|
-
}>, (() =>
|
|
305
|
+
}>, (() => vue7.VNode<vue7.RendererNode, vue7.RendererElement, {
|
|
308
306
|
[key: string]: any;
|
|
309
|
-
}>[] | undefined) | (() =>
|
|
307
|
+
}>[] | undefined) | (() => vue7.VNode<vue7.RendererNode, vue7.RendererElement, {
|
|
310
308
|
[key: string]: any;
|
|
311
|
-
}>), {}, {}, {},
|
|
309
|
+
}>), {}, {}, {}, vue7.ComponentOptionsMixin, vue7.ComponentOptionsMixin, {}, string, vue7.PublicProps, Readonly<vue7.ExtractPropTypes<{
|
|
312
310
|
as: {
|
|
313
311
|
type: PropType<string | null>;
|
|
314
312
|
default: null;
|
|
@@ -321,7 +319,7 @@ declare const __VLS_export: vue0.DefineComponent<vue0.ExtractPropTypes<{
|
|
|
321
319
|
}>> & Readonly<{}>, {
|
|
322
320
|
preventClass: string | null;
|
|
323
321
|
as: string | null;
|
|
324
|
-
}, {}, {}, {}, string,
|
|
322
|
+
}, {}, {}, {}, string, vue7.ComponentProvideOptions, true, {}, any>;
|
|
325
323
|
//#endregion
|
|
326
324
|
//#region src/contextManager.d.ts
|
|
327
325
|
type ContextInterface = {
|
|
@@ -333,12 +331,12 @@ type ContextInterface = {
|
|
|
333
331
|
};
|
|
334
332
|
interface ActiveContextInterface {
|
|
335
333
|
key: string;
|
|
336
|
-
|
|
334
|
+
data: ContextInterface;
|
|
337
335
|
}
|
|
338
336
|
type ContextInitListener = (key: string) => void;
|
|
339
337
|
type MakeRouterFn = (contextKey: string, history: RouterHistory) => Router;
|
|
340
338
|
type HistoryManagerOptions = {
|
|
341
|
-
|
|
339
|
+
history: RouterHistory;
|
|
342
340
|
} & MultiRouterHistoryManagerOptions;
|
|
343
341
|
declare class MultiRouterManagerInstance {
|
|
344
342
|
private makeRouter;
|
|
@@ -351,9 +349,9 @@ declare class MultiRouterManagerInstance {
|
|
|
351
349
|
constructor(app: App, historyManagerOptions: HistoryManagerOptions, makeRouter: MakeRouterFn);
|
|
352
350
|
getHistoryManager(): MultiRouterHistoryManager;
|
|
353
351
|
getActiveContext(): ActiveContextInterface | undefined;
|
|
354
|
-
getActiveContextRef():
|
|
352
|
+
getActiveContextRef(): vue7.ShallowRef<ActiveContextInterface | undefined, ActiveContextInterface | undefined>;
|
|
355
353
|
getActiveHistoryContext(): ActiveContextInterface | undefined;
|
|
356
|
-
getActiveHistoryContextRef():
|
|
354
|
+
getActiveHistoryContextRef(): vue7.ShallowRef<ActiveContextInterface | undefined, ActiveContextInterface | undefined>;
|
|
357
355
|
setActive(key: string, updateHistory: boolean): boolean;
|
|
358
356
|
clearHistoryContext(key: string): void;
|
|
359
357
|
markAsStarted(): void;
|
|
@@ -383,8 +381,9 @@ declare class MultiRouterManagerInstance {
|
|
|
383
381
|
*/
|
|
384
382
|
declare function useMultiRouter(): {
|
|
385
383
|
manager: MultiRouterManagerInstance;
|
|
386
|
-
|
|
387
|
-
|
|
384
|
+
activeContext: vue7.ComputedRef<ActiveContextInterface | undefined>;
|
|
385
|
+
activeContextKey: vue7.ComputedRef<string | undefined>;
|
|
386
|
+
activeHistoryContextKey: vue7.ComputedRef<string | undefined>;
|
|
388
387
|
setActive: (contextKey: string, updateHistory?: boolean) => void;
|
|
389
388
|
hasContext: (contextKey: string) => boolean;
|
|
390
389
|
};
|
|
@@ -393,11 +392,11 @@ declare function useMultiRouter(): {
|
|
|
393
392
|
declare function useMultiRouterContext(): {
|
|
394
393
|
manager: MultiRouterManagerInstance;
|
|
395
394
|
contextKey: string;
|
|
396
|
-
isActive:
|
|
397
|
-
isHistoryActive:
|
|
398
|
-
activeContextKey:
|
|
399
|
-
activeHistoryContextKey:
|
|
400
|
-
historyEnabled:
|
|
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>;
|
|
401
400
|
activate: (updateHistory?: boolean) => void;
|
|
402
401
|
setActive: (contextKey: string, updateHistory?: boolean) => void;
|
|
403
402
|
hasContext: (contextKey: string) => boolean;
|
|
@@ -407,4 +406,4 @@ declare function useMultiRouterContext(): {
|
|
|
407
406
|
declare const multiRouterContextManagerKey: InjectionKey<MultiRouterManagerInstance>;
|
|
408
407
|
declare const multiRouterContextKey: InjectionKey<string>;
|
|
409
408
|
//#endregion
|
|
410
|
-
export { type ContextSwitchMode, type
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -372,7 +372,7 @@ var ContextHistoryProxy = class {
|
|
|
372
372
|
const CONTEXT_KEY_STATE = "__multiRouterContext";
|
|
373
373
|
const STACK_INDEX_STATE = "__multiRouterStackIndex";
|
|
374
374
|
var MultiRouterHistoryManager = class {
|
|
375
|
-
|
|
375
|
+
history;
|
|
376
376
|
stacks;
|
|
377
377
|
activeHistoryContextKey = null;
|
|
378
378
|
historyContextStack = [];
|
|
@@ -380,12 +380,12 @@ var MultiRouterHistoryManager = class {
|
|
|
380
380
|
baseHistoryCleanup = null;
|
|
381
381
|
contextSwitchMode;
|
|
382
382
|
onContextActivate;
|
|
383
|
-
constructor(
|
|
384
|
-
this.
|
|
383
|
+
constructor(history, options) {
|
|
384
|
+
this.history = history;
|
|
385
385
|
this.stacks = new VirtualStackManager(options?.storageAdapter);
|
|
386
386
|
this.contextSwitchMode = options?.contextSwitchMode ?? "replace";
|
|
387
387
|
this.onContextActivate = options?.onContextActivate;
|
|
388
|
-
this.baseHistoryCleanup = this.
|
|
388
|
+
this.baseHistoryCleanup = this.history.listen(this.handlePopState.bind(this));
|
|
389
389
|
this.restoreContextStacks();
|
|
390
390
|
}
|
|
391
391
|
restoreContextStacks() {
|
|
@@ -397,13 +397,13 @@ var MultiRouterHistoryManager = class {
|
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
399
|
get base() {
|
|
400
|
-
return this.
|
|
400
|
+
return this.history.base;
|
|
401
401
|
}
|
|
402
402
|
get location() {
|
|
403
|
-
return this.
|
|
403
|
+
return this.history.location;
|
|
404
404
|
}
|
|
405
405
|
get state() {
|
|
406
|
-
return this.
|
|
406
|
+
return this.history.state;
|
|
407
407
|
}
|
|
408
408
|
createContextHistory(contextKey, options) {
|
|
409
409
|
if (this.stacks.has(contextKey)) return new ContextHistoryProxy(contextKey, this);
|
|
@@ -418,19 +418,19 @@ var MultiRouterHistoryManager = class {
|
|
|
418
418
|
let virtualStack;
|
|
419
419
|
if (restoredStack) {
|
|
420
420
|
if (isLastActive && historyEnabled) {
|
|
421
|
-
const browserUrl = this.
|
|
421
|
+
const browserUrl = this.history.location;
|
|
422
422
|
restoredStack.entries[restoredStack.position] = {
|
|
423
423
|
location: browserUrl,
|
|
424
|
-
state: this.
|
|
424
|
+
state: this.history.state ?? {}
|
|
425
425
|
};
|
|
426
426
|
}
|
|
427
427
|
virtualStack = restoredStack;
|
|
428
428
|
} else if (isLastActive && historyEnabled) {
|
|
429
|
-
const browserUrl = this.
|
|
429
|
+
const browserUrl = this.history.location;
|
|
430
430
|
virtualStack = this.createInitialVirtualStack(browserUrl);
|
|
431
431
|
} else if (initialLocation) virtualStack = this.createInitialVirtualStack(initialLocation);
|
|
432
432
|
else {
|
|
433
|
-
const browserUrl = this.
|
|
433
|
+
const browserUrl = this.history.location;
|
|
434
434
|
virtualStack = this.createInitialVirtualStack(browserUrl);
|
|
435
435
|
}
|
|
436
436
|
return this.finalizeContextCreation(contextKey, virtualStack, isLastActive, historyEnabled);
|
|
@@ -557,13 +557,13 @@ var MultiRouterHistoryManager = class {
|
|
|
557
557
|
[CONTEXT_KEY_STATE]: contextKey,
|
|
558
558
|
[STACK_INDEX_STATE]: context.virtualStack.position
|
|
559
559
|
};
|
|
560
|
-
if (this.contextSwitchMode === "push") if (entry.location !== this.
|
|
561
|
-
else this.
|
|
562
|
-
else this.
|
|
560
|
+
if (this.contextSwitchMode === "push") if (entry.location !== this.history.location) this.history.push(entry.location, state);
|
|
561
|
+
else this.history.replace(entry.location, state);
|
|
562
|
+
else this.history.replace(entry.location, state);
|
|
563
563
|
}
|
|
564
564
|
handlePopState(to, from, info) {
|
|
565
|
-
const stateContextKey = this.
|
|
566
|
-
const stateStackIndex = this.
|
|
565
|
+
const stateContextKey = this.history.state?.[CONTEXT_KEY_STATE];
|
|
566
|
+
const stateStackIndex = this.history.state?.[STACK_INDEX_STATE];
|
|
567
567
|
let ownerContextKey = null;
|
|
568
568
|
let targetStackIndex = null;
|
|
569
569
|
if (stateContextKey && this.stacks.has(stateContextKey)) {
|
|
@@ -588,7 +588,7 @@ var MultiRouterHistoryManager = class {
|
|
|
588
588
|
push(contextKey, to, data) {
|
|
589
589
|
const stackIndex = this.stacks.push(contextKey, to, data ?? {});
|
|
590
590
|
const historyEnabled = this.stacks.isHistoryEnabled(contextKey);
|
|
591
|
-
if (this.activeHistoryContextKey === contextKey && historyEnabled) this.
|
|
591
|
+
if (this.activeHistoryContextKey === contextKey && historyEnabled) this.history.push(to, {
|
|
592
592
|
...data,
|
|
593
593
|
[CONTEXT_KEY_STATE]: contextKey,
|
|
594
594
|
[STACK_INDEX_STATE]: stackIndex
|
|
@@ -597,7 +597,7 @@ var MultiRouterHistoryManager = class {
|
|
|
597
597
|
replace(contextKey, to, data) {
|
|
598
598
|
const stackIndex = this.stacks.replace(contextKey, to, data ?? {});
|
|
599
599
|
const historyEnabled = this.stacks.isHistoryEnabled(contextKey);
|
|
600
|
-
if (this.activeHistoryContextKey === contextKey && historyEnabled) this.
|
|
600
|
+
if (this.activeHistoryContextKey === contextKey && historyEnabled) this.history.replace(to, {
|
|
601
601
|
...data,
|
|
602
602
|
[CONTEXT_KEY_STATE]: contextKey,
|
|
603
603
|
[STACK_INDEX_STATE]: stackIndex
|
|
@@ -605,7 +605,7 @@ var MultiRouterHistoryManager = class {
|
|
|
605
605
|
}
|
|
606
606
|
go(contextKey, delta, triggerListeners = true) {
|
|
607
607
|
if (!this.stacks.has(contextKey)) throw new Error(`[MultiRouterHistory] Context "${contextKey}" not registered`);
|
|
608
|
-
if (this.activeHistoryContextKey === contextKey) this.
|
|
608
|
+
if (this.activeHistoryContextKey === contextKey) this.history.go(delta, triggerListeners);
|
|
609
609
|
else {
|
|
610
610
|
const result = this.stacks.navigate(contextKey, delta);
|
|
611
611
|
if (result && triggerListeners) this.stacks.notifyListeners(contextKey, result.to, result.from, {
|
|
@@ -619,13 +619,13 @@ var MultiRouterHistoryManager = class {
|
|
|
619
619
|
return this.stacks.addListener(contextKey, callback);
|
|
620
620
|
}
|
|
621
621
|
getContextLocation(contextKey) {
|
|
622
|
-
return this.stacks.getLocation(contextKey, this.
|
|
622
|
+
return this.stacks.getLocation(contextKey, this.history.location);
|
|
623
623
|
}
|
|
624
624
|
getContextState(contextKey) {
|
|
625
625
|
return this.stacks.getState(contextKey);
|
|
626
626
|
}
|
|
627
627
|
createHref(location) {
|
|
628
|
-
return this.
|
|
628
|
+
return this.history.createHref(location);
|
|
629
629
|
}
|
|
630
630
|
destroy() {
|
|
631
631
|
if (this.baseHistoryCleanup) {
|
|
@@ -633,7 +633,7 @@ var MultiRouterHistoryManager = class {
|
|
|
633
633
|
this.baseHistoryCleanup = null;
|
|
634
634
|
}
|
|
635
635
|
this.stacks.clear();
|
|
636
|
-
this.
|
|
636
|
+
this.history.destroy();
|
|
637
637
|
}
|
|
638
638
|
getLastActiveContextKey() {
|
|
639
639
|
return this.stacks.getStoredActiveContext();
|
|
@@ -645,15 +645,15 @@ var MultiRouterHistoryManager = class {
|
|
|
645
645
|
var MultiRouterManagerInstance = class {
|
|
646
646
|
constructor(app, historyManagerOptions, makeRouter) {
|
|
647
647
|
this.makeRouter = makeRouter;
|
|
648
|
-
const {
|
|
649
|
-
this.historyManager = new MultiRouterHistoryManager(
|
|
648
|
+
const { history, ...historyOptions } = historyManagerOptions;
|
|
649
|
+
this.historyManager = new MultiRouterHistoryManager(history, {
|
|
650
650
|
...historyOptions,
|
|
651
651
|
onContextActivate: (contextKey) => {
|
|
652
652
|
this.setActive(contextKey, false);
|
|
653
653
|
const context = this.registered.get(contextKey);
|
|
654
654
|
if (context?.historyEnabled && this.activeHistoryContext.value?.key !== contextKey) this.activeHistoryContext.value = {
|
|
655
655
|
key: contextKey,
|
|
656
|
-
context
|
|
656
|
+
data: context
|
|
657
657
|
};
|
|
658
658
|
}
|
|
659
659
|
});
|
|
@@ -688,7 +688,7 @@ var MultiRouterManagerInstance = class {
|
|
|
688
688
|
this.historyManager.removeFromContextStack(key);
|
|
689
689
|
this.activeContext.value = {
|
|
690
690
|
key,
|
|
691
|
-
|
|
691
|
+
data: item
|
|
692
692
|
};
|
|
693
693
|
modified = true;
|
|
694
694
|
}
|
|
@@ -710,7 +710,7 @@ var MultiRouterManagerInstance = class {
|
|
|
710
710
|
const newContext = this.registered.get(newActiveKey);
|
|
711
711
|
if (newContext) this.activeHistoryContext.value = {
|
|
712
712
|
key: newActiveKey,
|
|
713
|
-
|
|
713
|
+
data: newContext
|
|
714
714
|
};
|
|
715
715
|
} else this.activeHistoryContext.value = void 0;
|
|
716
716
|
}
|
|
@@ -746,7 +746,7 @@ var MultiRouterManagerInstance = class {
|
|
|
746
746
|
mapMaybePromise(this.historyManager.tryRestoreActiveHistoryContext(key), (restored) => {
|
|
747
747
|
if (restored && !this.activeHistoryContext.value) this.activeHistoryContext.value = {
|
|
748
748
|
key,
|
|
749
|
-
|
|
749
|
+
data: this.registered.get(key)
|
|
750
750
|
};
|
|
751
751
|
});
|
|
752
752
|
mapMaybePromise(this.historyManager.getLastActiveContextKey(), (resolvedLastActiveKey) => {
|
|
@@ -793,7 +793,7 @@ var MultiRouterManagerInstance = class {
|
|
|
793
793
|
if (previousContext) {
|
|
794
794
|
this.activeContext.value = {
|
|
795
795
|
key: previousKey,
|
|
796
|
-
|
|
796
|
+
data: previousContext
|
|
797
797
|
};
|
|
798
798
|
this.historyManager.saveActiveContext(previousKey);
|
|
799
799
|
return;
|
|
@@ -932,7 +932,7 @@ function createMultiRouter(options) {
|
|
|
932
932
|
return router;
|
|
933
933
|
};
|
|
934
934
|
contextManager = new MultiRouterManagerInstance(app, {
|
|
935
|
-
|
|
935
|
+
history: options.history,
|
|
936
936
|
...options.historyOptions
|
|
937
937
|
}, makeRouter);
|
|
938
938
|
app.provide(multiRouterContextManagerKey, contextManager);
|
|
@@ -948,6 +948,7 @@ function useMultiRouter() {
|
|
|
948
948
|
const manager = inject(multiRouterContextManagerKey);
|
|
949
949
|
if (!manager) throw new Error("[useMultiRouter] Must be used within MultiRouterContextProvider");
|
|
950
950
|
const activeContextKey = computed(() => manager.getActiveContextRef().value?.key);
|
|
951
|
+
const activeContext = computed(() => manager.getActiveContextRef().value);
|
|
951
952
|
const activeHistoryContextKey = computed(() => manager.getActiveHistoryContextRef().value?.key);
|
|
952
953
|
const setActive = (contextKey, updateHistory = true) => {
|
|
953
954
|
manager.setActive(contextKey, updateHistory);
|
|
@@ -957,6 +958,7 @@ function useMultiRouter() {
|
|
|
957
958
|
};
|
|
958
959
|
return {
|
|
959
960
|
manager,
|
|
961
|
+
activeContext,
|
|
960
962
|
activeContextKey,
|
|
961
963
|
activeHistoryContextKey,
|
|
962
964
|
setActive,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-multi-router",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"description": "Vue 3 multi router",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,14 +31,17 @@
|
|
|
31
31
|
"dev": "tsdown --watch",
|
|
32
32
|
"check": "npm run ts:check && npm run lint:check && npm run format:check && npm run dependency-cruiser:check",
|
|
33
33
|
"ts:check": "vue-tsc --noEmit",
|
|
34
|
-
"format": "prettier --write src/ playground/src",
|
|
35
|
-
"format:check": "prettier --check src/ playground/src",
|
|
34
|
+
"format": "prettier --write src/ playground/src docs/.vitepress/theme",
|
|
35
|
+
"format:check": "prettier --check src/ playground/src docs/.vitepress/config.ts docs/.vitepress/theme",
|
|
36
36
|
"lint": "eslint . --fix",
|
|
37
37
|
"lint:check": "eslint .",
|
|
38
|
-
"dependency-cruiser:check": "depcruise --config .dependency-cruiser.cjs src playground/src",
|
|
38
|
+
"dependency-cruiser:check": "depcruise --config .dependency-cruiser.cjs src playground/src docs/.vitepress/config.ts docs/.vitepress/theme",
|
|
39
39
|
"play": "vite --port 5174",
|
|
40
40
|
"build:playground": "vite build",
|
|
41
41
|
"preview:playground": "vite preview --outDir playground/dist",
|
|
42
|
+
"docs:dev": "vitepress dev docs",
|
|
43
|
+
"docs:build": "vitepress build docs",
|
|
44
|
+
"docs:preview": "vitepress preview docs",
|
|
42
45
|
"test": "vitest run",
|
|
43
46
|
"release": "bumpp && npm publish",
|
|
44
47
|
"prepublishOnly": "npm run check && npm run test && npm run build"
|
|
@@ -48,6 +51,7 @@
|
|
|
48
51
|
"vue-router": "^4.0.0"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
54
|
+
"vitepress": "^1.6.3",
|
|
51
55
|
"@tailwindcss/vite": "^4.1.18",
|
|
52
56
|
"@types/lodash": "^4.17.21",
|
|
53
57
|
"@types/node": "^25.0.3",
|