vue-micro-router 1.0.1
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/LICENSE +21 -0
- package/README.md +617 -0
- package/dist/audio.d.ts +104 -0
- package/dist/audio.mjs +100 -0
- package/dist/index.d.ts +887 -0
- package/dist/index.mjs +1230 -0
- package/dist/styles.css +1 -0
- package/dist/styles.d.ts +1 -0
- package/dist/styles.mjs +1 -0
- package/dist/timer-manager.mjs +20 -0
- package/package.json +94 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,887 @@
|
|
|
1
|
+
import { AsyncComponentLoader } from 'vue';
|
|
2
|
+
import { Component } from 'vue';
|
|
3
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
4
|
+
import { ComponentProvideOptions } from 'vue';
|
|
5
|
+
import { ComputedOptions } from 'vue';
|
|
6
|
+
import { ComputedRef } from 'vue';
|
|
7
|
+
import { CreateComponentPublicInstanceWithMixins } from 'vue';
|
|
8
|
+
import { DefineComponent } from 'vue';
|
|
9
|
+
import { GlobalComponents } from 'vue';
|
|
10
|
+
import { GlobalDirectives } from 'vue';
|
|
11
|
+
import { InjectionKey } from 'vue';
|
|
12
|
+
import { MethodOptions } from 'vue';
|
|
13
|
+
import { PublicProps } from 'vue';
|
|
14
|
+
import { Ref } from 'vue';
|
|
15
|
+
import { TransitionGroupProps } from 'vue';
|
|
16
|
+
|
|
17
|
+
declare const __VLS_component: DefineComponent<Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
18
|
+
pageContainerRef: CreateComponentPublicInstanceWithMixins<Readonly<TransitionGroupProps>, {}, {}, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {}, true, {}, {}, GlobalComponents, GlobalDirectives, string, {}, any, ComponentProvideOptions, {
|
|
19
|
+
P: {};
|
|
20
|
+
B: {};
|
|
21
|
+
D: {};
|
|
22
|
+
C: {};
|
|
23
|
+
M: {};
|
|
24
|
+
Defaults: {};
|
|
25
|
+
}, Readonly<TransitionGroupProps>, {}, {}, ComputedOptions, MethodOptions, {}> | null;
|
|
26
|
+
}, any>;
|
|
27
|
+
|
|
28
|
+
declare const __VLS_component_2: DefineComponent<Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props_2> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
29
|
+
|
|
30
|
+
declare const __VLS_component_3: DefineComponent<Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
|
|
31
|
+
close: (path: string) => any;
|
|
32
|
+
}, string, PublicProps, Readonly<Props_3> & Readonly<{
|
|
33
|
+
onClose?: ((path: string) => any) | undefined;
|
|
34
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
35
|
+
dialogRef: HTMLDialogElement;
|
|
36
|
+
}, any>;
|
|
37
|
+
|
|
38
|
+
declare function __VLS_template(): {
|
|
39
|
+
attrs: Partial<{}>;
|
|
40
|
+
slots: {
|
|
41
|
+
default?(_: {}): any;
|
|
42
|
+
};
|
|
43
|
+
refs: {
|
|
44
|
+
pageContainerRef: CreateComponentPublicInstanceWithMixins<Readonly<TransitionGroupProps>, {}, {}, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {}, true, {}, {}, GlobalComponents, GlobalDirectives, string, {}, any, ComponentProvideOptions, {
|
|
45
|
+
P: {};
|
|
46
|
+
B: {};
|
|
47
|
+
D: {};
|
|
48
|
+
C: {};
|
|
49
|
+
M: {};
|
|
50
|
+
Defaults: {};
|
|
51
|
+
}, Readonly<TransitionGroupProps>, {}, {}, ComputedOptions, MethodOptions, {}> | null;
|
|
52
|
+
};
|
|
53
|
+
rootEl: any;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
declare function __VLS_template_2(): {
|
|
57
|
+
attrs: Partial<{}>;
|
|
58
|
+
slots: {
|
|
59
|
+
default?(_: {}): any;
|
|
60
|
+
};
|
|
61
|
+
refs: {};
|
|
62
|
+
rootEl: HTMLDivElement;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
declare function __VLS_template_3(): {
|
|
66
|
+
attrs: Partial<{}>;
|
|
67
|
+
slots: {
|
|
68
|
+
default?(_: {}): any;
|
|
69
|
+
};
|
|
70
|
+
refs: {
|
|
71
|
+
dialogRef: HTMLDialogElement;
|
|
72
|
+
};
|
|
73
|
+
rootEl: any;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
77
|
+
|
|
78
|
+
declare type __VLS_TemplateResult_2 = ReturnType<typeof __VLS_template_2>;
|
|
79
|
+
|
|
80
|
+
declare type __VLS_TemplateResult_3 = ReturnType<typeof __VLS_template_3>;
|
|
81
|
+
|
|
82
|
+
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
83
|
+
new (): {
|
|
84
|
+
$slots: S;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
declare type __VLS_WithTemplateSlots_2<T, S> = T & {
|
|
89
|
+
new (): {
|
|
90
|
+
$slots: S;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
declare type __VLS_WithTemplateSlots_3<T, S> = T & {
|
|
95
|
+
new (): {
|
|
96
|
+
$slots: S;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** Join segments into path: ["home", "missions"] → "/home/missions" */
|
|
101
|
+
export declare function buildPathFromSegments(segments: string[]): string;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Per-control attrs — augment from each control component.
|
|
105
|
+
* Keys = control name strings, values = attrs type for that control.
|
|
106
|
+
*/
|
|
107
|
+
export declare interface ControlAttrsMap {
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export declare interface ControlLifecycleHooks {
|
|
111
|
+
/** Called when this control becomes the active control */
|
|
112
|
+
onControlEnter?: () => void;
|
|
113
|
+
/** Called when this control is deactivated */
|
|
114
|
+
onControlLeave?: () => void;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
declare interface ControlManagerConfig {
|
|
118
|
+
defaultControlName: string;
|
|
119
|
+
onboardingControlName?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export declare interface ControlManagerState {
|
|
123
|
+
resolveControls: ComputedRef<MicroControl[]>;
|
|
124
|
+
activeControl: ComputedRef<boolean>;
|
|
125
|
+
currentControl: ComputedRef<string>;
|
|
126
|
+
toggleControl: (name: string, active: boolean, attrs?: Record<string, unknown>) => void;
|
|
127
|
+
registerControl: (control: MicroControl) => void;
|
|
128
|
+
registerControls: (controls: MicroControl[]) => void;
|
|
129
|
+
getControlAttrs: (name: string) => Record<string, unknown> | undefined;
|
|
130
|
+
updateControlAttrs: (name: string, attrs: Record<string, unknown>) => void;
|
|
131
|
+
cleanup: () => void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Factory to create unique injection keys for nested routers */
|
|
135
|
+
export declare function createRouterKey(): InjectionKey<MicroRouterStore>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Define a feature plugin — a bundle of routes, dialogs, and controls.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* export const inventoryPlugin = defineFeaturePlugin({
|
|
143
|
+
* name: 'inventory',
|
|
144
|
+
* routes: [{ path: 'inventory', component: () => import('./InventoryPage.vue') }],
|
|
145
|
+
* dialogs: [{ path: 'item-detail', component: ItemDetail, activated: false }],
|
|
146
|
+
* controls: [{ name: 'inventory_gui', component: InventoryHUD, activated: false }],
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
/**
|
|
151
|
+
* Generic overload preserves literal path/name types when `as const` is used.
|
|
152
|
+
* Without `as const`, falls back to loose FeaturePlugin type (backward compatible).
|
|
153
|
+
*/
|
|
154
|
+
export declare function defineFeaturePlugin<const T extends FeaturePluginConfig>(config: T): T;
|
|
155
|
+
|
|
156
|
+
export declare function defineFeaturePlugin(config: FeaturePluginConfig): FeaturePlugin;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Per-dialog attrs — augment from each dialog component.
|
|
160
|
+
* Keys = dialog path strings, values = attrs type for that dialog.
|
|
161
|
+
*/
|
|
162
|
+
export declare interface DialogAttrsMap {
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export declare interface DialogInstance {
|
|
166
|
+
path: string;
|
|
167
|
+
attrs?: Record<string, unknown>;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export declare interface DialogLifecycleHooks {
|
|
171
|
+
/** Called when this dialog becomes the active (topmost) dialog */
|
|
172
|
+
onDialogEnter?: () => void;
|
|
173
|
+
/** Called when this dialog is no longer the active dialog (another opened on top, or this one closed) */
|
|
174
|
+
onDialogLeave?: () => void;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export declare interface DialogManagerState {
|
|
178
|
+
activeDialog: ComputedRef<string>;
|
|
179
|
+
fromDialog: ComputedRef<string>;
|
|
180
|
+
toDialog: ComputedRef<string>;
|
|
181
|
+
resolveDialogs: ComputedRef<MicroDialog[]>;
|
|
182
|
+
openDialog: (path: string, props?: Record<string, unknown>) => DialogInstance;
|
|
183
|
+
closeDialog: (path: string) => void;
|
|
184
|
+
closeAllDialogs: () => void;
|
|
185
|
+
registerDialog: (dialog: MicroDialog) => void;
|
|
186
|
+
registerDialogs: (dialogs: MicroDialog[]) => void;
|
|
187
|
+
getDialogAttrs: (path: string) => Record<string, unknown> | undefined;
|
|
188
|
+
updateDialogAttrs: (path: string, attrs: Record<string, unknown>) => void;
|
|
189
|
+
cleanup: () => void;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export declare type DialogPosition = 'standard' | 'top' | 'right' | 'bottom' | 'left';
|
|
193
|
+
|
|
194
|
+
export declare interface DialogProps {
|
|
195
|
+
path: string;
|
|
196
|
+
open?: boolean;
|
|
197
|
+
attrs?: Record<string, unknown>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** Extract control name literals from a plugin config type */
|
|
201
|
+
export declare type ExtractControlNames<T> = T extends {
|
|
202
|
+
controls: readonly (infer C)[];
|
|
203
|
+
} ? C extends {
|
|
204
|
+
name: infer N;
|
|
205
|
+
} ? N & string : never : never;
|
|
206
|
+
|
|
207
|
+
/** Extract dialog path literals from a plugin config type */
|
|
208
|
+
export declare type ExtractDialogPaths<T> = T extends {
|
|
209
|
+
dialogs: readonly (infer D)[];
|
|
210
|
+
} ? D extends {
|
|
211
|
+
path: infer P;
|
|
212
|
+
} ? P & string : never : never;
|
|
213
|
+
|
|
214
|
+
/** Extract route path literals from a plugin config type */
|
|
215
|
+
export declare type ExtractRoutePaths<T> = T extends {
|
|
216
|
+
routes: readonly (infer R)[];
|
|
217
|
+
} ? R extends {
|
|
218
|
+
path: infer P;
|
|
219
|
+
} ? P & string : never : never;
|
|
220
|
+
|
|
221
|
+
export declare type FeaturePlugin = FeaturePluginConfig;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Bundle of routes, dialogs, and controls to register as a single feature.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* const shopPlugin = defineFeaturePlugin({
|
|
229
|
+
* name: 'shop',
|
|
230
|
+
* routes: [{ path: 'shop', component: ShopPage }],
|
|
231
|
+
* dialogs: [{ path: 'buy-confirm', component: BuyDialog, activated: false }],
|
|
232
|
+
* });
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
export declare interface FeaturePluginConfig {
|
|
236
|
+
name: string;
|
|
237
|
+
routes?: MicroRoute[];
|
|
238
|
+
dialogs?: MicroDialog[];
|
|
239
|
+
controls?: MicroControl[];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export declare interface GestureConfig {
|
|
243
|
+
/** Enable gesture navigation. Default: false */
|
|
244
|
+
enabled?: boolean;
|
|
245
|
+
/** Pixels from left edge that starts gesture. Default: 20 */
|
|
246
|
+
edgeWidth?: number;
|
|
247
|
+
/** Percentage (0-1) to trigger navigation. Default: 0.3 */
|
|
248
|
+
threshold?: number;
|
|
249
|
+
/** px/ms — fast swipe always triggers. Default: 0.5 */
|
|
250
|
+
velocityThreshold?: number;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
declare interface GestureContext {
|
|
254
|
+
/** The DOM element or Vue component instance ref to attach gesture listeners to */
|
|
255
|
+
containerRef: Ref<HTMLElement | Record<string, unknown> | null>;
|
|
256
|
+
/** Go back one step — respects guards */
|
|
257
|
+
goBack: () => Promise<void>;
|
|
258
|
+
/** Check if there's a page to go back to */
|
|
259
|
+
canGoBack: () => boolean;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Get last segment from path: "/home/missions/detail" → "detail" */
|
|
263
|
+
export declare function getLastSegment(path: string): string;
|
|
264
|
+
|
|
265
|
+
declare interface GuardConfig {
|
|
266
|
+
beforeEach?: NavigationGuard[];
|
|
267
|
+
afterEach?: NavigationAfterHook[];
|
|
268
|
+
guardTimeout?: number;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** True if user has augmented Register with a plugin */
|
|
272
|
+
declare type HasRegisteredPlugin = [RegisteredPlugin] extends [never] ? false : true;
|
|
273
|
+
|
|
274
|
+
/** True if user has augmented Register with a route map */
|
|
275
|
+
declare type HasRegisteredRouteMap = [RegisteredRouteMap] extends [never] ? false : true;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Check if a value is an async component loader (arrow fn returning import()),
|
|
279
|
+
* not a Vue component object or functional component.
|
|
280
|
+
*/
|
|
281
|
+
export declare function isAsyncLoader(component: AsyncComponentLoader | Component): component is AsyncComponentLoader;
|
|
282
|
+
|
|
283
|
+
/** Inject/provide key for reading attrs — consumed by useMicroState to read parent-injected props */
|
|
284
|
+
export declare const MICRO_ATTRS_READ_KEY: InjectionKey<() => Record<string, unknown> | undefined>;
|
|
285
|
+
|
|
286
|
+
/** Inject/provide key for writing attrs — consumed by useMicroState to sync mutations back to store */
|
|
287
|
+
export declare const MICRO_ATTRS_WRITE_KEY: InjectionKey<(attrs: Record<string, unknown>) => void>;
|
|
288
|
+
|
|
289
|
+
/** Inject/provide key for the current control name — injected per MicroControlWrapper for useControlLifecycle */
|
|
290
|
+
export declare const MICRO_CONTROL_NAME_KEY: InjectionKey<string>;
|
|
291
|
+
|
|
292
|
+
/** Inject/provide key for the current dialog path — injected per MicroDialog for useDialogLifecycle */
|
|
293
|
+
export declare const MICRO_DIALOG_PATH_KEY: InjectionKey<string>;
|
|
294
|
+
|
|
295
|
+
/** Inject/provide key for the current route path — injected per RoutePage slot for useRouteLifecycle */
|
|
296
|
+
export declare const MICRO_ROUTE_PATH_KEY: InjectionKey<string>;
|
|
297
|
+
|
|
298
|
+
/** Default inject/provide key for the MicroRouterStore — used by useGlobalMicroRouter / useMicroRouter */
|
|
299
|
+
export declare const MICRO_ROUTER_KEY: InjectionKey<MicroRouterStore>;
|
|
300
|
+
|
|
301
|
+
/** Inject/provide key for the ROOT router — always points to the outermost MicroRouterView */
|
|
302
|
+
export declare const MICRO_ROUTER_ROOT_KEY: InjectionKey<MicroRouterStore>;
|
|
303
|
+
|
|
304
|
+
export declare interface MicroControl {
|
|
305
|
+
/** Unique control name, e.g. "main_gui", "inventory" */
|
|
306
|
+
name: string;
|
|
307
|
+
/** Whether the control overlay is currently visible */
|
|
308
|
+
activated: boolean;
|
|
309
|
+
/** Vue component or async loader */
|
|
310
|
+
component: AsyncComponentLoader | Component;
|
|
311
|
+
/** Props passed to the component */
|
|
312
|
+
attrs?: Record<string, unknown>;
|
|
313
|
+
/** Internal: incremented on each activation to force component remount */
|
|
314
|
+
componentKey?: number;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export declare const MicroControlWrapper: DefineComponent<Props_4, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props_4> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
318
|
+
|
|
319
|
+
export declare interface MicroDialog {
|
|
320
|
+
/** Unique dialog identifier, e.g. "confirm", "settings-modal" */
|
|
321
|
+
path: string;
|
|
322
|
+
/** Vue component or async loader */
|
|
323
|
+
component: AsyncComponentLoader | Component;
|
|
324
|
+
/** Whether the dialog is currently visible */
|
|
325
|
+
activated: boolean;
|
|
326
|
+
/** True during exit animation — keeps dialog in DOM until animation completes */
|
|
327
|
+
closing?: boolean;
|
|
328
|
+
/** Render dialog at full viewport size */
|
|
329
|
+
fullscreen?: boolean;
|
|
330
|
+
/** If true, clicking backdrop or pressing Escape won't close the dialog */
|
|
331
|
+
persistent?: boolean;
|
|
332
|
+
/** Props passed to the component, includes injected onClose callback */
|
|
333
|
+
attrs?: Record<string, unknown>;
|
|
334
|
+
/** Where the dialog appears: 'standard' (center), 'top', 'right', 'bottom', 'left' */
|
|
335
|
+
position?: DialogPosition;
|
|
336
|
+
/** Custom transition duration in ms. Defaults: slide=500ms, fade/scale=300ms */
|
|
337
|
+
transitionDuration?: number;
|
|
338
|
+
/** Animation type: 'fade' (scale+fade), 'scale' (pop), 'slide' (page-style) */
|
|
339
|
+
transition?: TransitionType;
|
|
340
|
+
/** If true (default), dialog has transparent background and no shadow */
|
|
341
|
+
seamless?: boolean;
|
|
342
|
+
/** Internal: incremented on each open to force component remount */
|
|
343
|
+
componentKey?: number;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export declare const MicroDialogComponent: __VLS_WithTemplateSlots_3<typeof __VLS_component_3, __VLS_TemplateResult_3["slots"]>;
|
|
347
|
+
|
|
348
|
+
export declare interface MicroRoute {
|
|
349
|
+
/** Unique segment name, e.g. "home", "settings" — used in path like "home/settings" */
|
|
350
|
+
path: string;
|
|
351
|
+
/** Vue component or async loader (() => import('./MyPage.vue')) */
|
|
352
|
+
component: AsyncComponentLoader | Component;
|
|
353
|
+
/** Props passed to the component via useMicroState */
|
|
354
|
+
attrs?: Record<string, unknown>;
|
|
355
|
+
/** Background music track name — resolved by audio manager's urlResolver */
|
|
356
|
+
bgm?: string;
|
|
357
|
+
/** Preloading strategy: 'eager' (on mount), 'adjacent' (after each nav), false (default) */
|
|
358
|
+
preload?: 'eager' | 'adjacent' | false;
|
|
359
|
+
/** Page transition type: 'slide' (default), 'fade', or 'none' to disable */
|
|
360
|
+
transition?: TransitionType | 'none';
|
|
361
|
+
/** Custom transition duration in ms. Defaults: slide=500ms, fade=300ms */
|
|
362
|
+
transitionDuration?: number;
|
|
363
|
+
/** Guard called before navigating TO this route. Return false to cancel. */
|
|
364
|
+
beforeEnter?: NavigationGuard;
|
|
365
|
+
/** Guard called before navigating AWAY from this route. Return false to cancel. */
|
|
366
|
+
beforeLeave?: NavigationGuard;
|
|
367
|
+
/** Internal: cache key for transition identity */
|
|
368
|
+
key?: string;
|
|
369
|
+
/** Internal: incremented to force full component remount */
|
|
370
|
+
componentKey?: number;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export declare interface MicroRouterConfig {
|
|
374
|
+
/** Initial page path on mount — must match a registered route segment */
|
|
375
|
+
defaultPath: string;
|
|
376
|
+
/** Delay between step-wise navigation transitions in ms. Defaults to 600 */
|
|
377
|
+
stepDelay?: number;
|
|
378
|
+
/** Name of the default GUI control — auto-activated on mount, auto-restored on deactivate */
|
|
379
|
+
defaultControlName: string;
|
|
380
|
+
/** Name of the onboarding control (exempt from auto-restore). Optional — only needed for onboarding flows. */
|
|
381
|
+
onboardingControlName?: string;
|
|
382
|
+
/** Navigation history tracking — opt-in, records sequence of paths visited */
|
|
383
|
+
history?: {
|
|
384
|
+
enabled?: boolean;
|
|
385
|
+
/** Max entries before FIFO eviction. Default: 50 */
|
|
386
|
+
maxEntries?: number;
|
|
387
|
+
};
|
|
388
|
+
/** Swipe-back gesture navigation config (opt-in) */
|
|
389
|
+
gesture?: {
|
|
390
|
+
enabled?: boolean;
|
|
391
|
+
edgeWidth?: number;
|
|
392
|
+
threshold?: number;
|
|
393
|
+
velocityThreshold?: number;
|
|
394
|
+
};
|
|
395
|
+
/** Navigation guard hooks — beforeEach runs before every navigation, afterEach runs after */
|
|
396
|
+
guards?: {
|
|
397
|
+
beforeEach?: NavigationGuard[];
|
|
398
|
+
afterEach?: NavigationAfterHook[];
|
|
399
|
+
};
|
|
400
|
+
/** Analytics hooks for page/dialog/control enter/leave events */
|
|
401
|
+
tracker?: PageTrackerHooks;
|
|
402
|
+
/** Reactive volume ref (0-100) for audio manager. Only used with vue-micro-router/audio */
|
|
403
|
+
volumeRef?: Ref<number>;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Main store interface — injected by useMicroRouter(), provided by useGlobalMicroRouter().
|
|
408
|
+
* Contains all navigation, dialog, control, and optional audio APIs.
|
|
409
|
+
*/
|
|
410
|
+
export declare interface MicroRouterStore {
|
|
411
|
+
/** Current full path, e.g. "/home/menu/settings" */
|
|
412
|
+
activePath: ComputedRef<string>;
|
|
413
|
+
fromPath: ComputedRef<string>;
|
|
414
|
+
toPath: ComputedRef<string>;
|
|
415
|
+
activePage: ComputedRef<string>;
|
|
416
|
+
fromPage: ComputedRef<string>;
|
|
417
|
+
toPage: ComputedRef<string>;
|
|
418
|
+
resolveRoutes: ComputedRef<MicroRoute[]>;
|
|
419
|
+
/**
|
|
420
|
+
* Navigate to a destination. Guarded against rapid double-clicks.
|
|
421
|
+
* @param destination - Relative segment ("menu"), absolute path ("/home/menu"), or negative number (-1 = back)
|
|
422
|
+
* @param props - Optional attrs to pass to the target page via useMicroState
|
|
423
|
+
*/
|
|
424
|
+
push: (destination: string | number, props?: Record<string, unknown>) => Promise<void>;
|
|
425
|
+
/** Navigate through intermediate pages one-by-one with stepDelay between each */
|
|
426
|
+
stepWisePush: (targetPath: string, props?: Record<string, unknown>) => Promise<void>;
|
|
427
|
+
/** Go back N steps, animating through each intermediate page */
|
|
428
|
+
stepWiseBack: (steps: number) => Promise<void>;
|
|
429
|
+
registerRoute: (route: MicroRoute) => void;
|
|
430
|
+
registerRoutes: (routes: MicroRoute[]) => void;
|
|
431
|
+
updateRouteAttrs: (segment: string, attrs: Record<string, unknown>) => void;
|
|
432
|
+
getRouteAttrs: (segment: string) => Record<string, unknown> | undefined;
|
|
433
|
+
/** Manually preload an async route component by segment name */
|
|
434
|
+
preloadRoute: (segment: string) => Promise<void>;
|
|
435
|
+
/** Path of the topmost open dialog, or "" if none */
|
|
436
|
+
activeDialog: ComputedRef<string>;
|
|
437
|
+
fromDialog: ComputedRef<string>;
|
|
438
|
+
toDialog: ComputedRef<string>;
|
|
439
|
+
resolveDialogs: ComputedRef<MicroDialog[]>;
|
|
440
|
+
/** Open a dialog by path. Returns a DialogInstance handle. Props available via useMicroState inside the dialog. */
|
|
441
|
+
openDialog: (path: string, props?: Record<string, unknown>) => DialogInstance;
|
|
442
|
+
/** Close a specific dialog by path. Triggers exit animation. */
|
|
443
|
+
closeDialog: (path: string) => void;
|
|
444
|
+
/** Close all open dialogs at once. Invokes onClose callbacks after DOM updates. */
|
|
445
|
+
closeAllDialogs: () => void;
|
|
446
|
+
registerDialog: (dialog: MicroDialog) => void;
|
|
447
|
+
registerDialogs: (dialogs: MicroDialog[]) => void;
|
|
448
|
+
getDialogAttrs: (path: string) => Record<string, unknown> | undefined;
|
|
449
|
+
updateDialogAttrs: (path: string, attrs: Record<string, unknown>) => void;
|
|
450
|
+
/** All currently activated controls */
|
|
451
|
+
resolveControls: ComputedRef<MicroControl[]>;
|
|
452
|
+
activeControl: ComputedRef<boolean>;
|
|
453
|
+
currentControl: ComputedRef<string>;
|
|
454
|
+
/**
|
|
455
|
+
* Activate or deactivate a GUI control by name.
|
|
456
|
+
* Activating a non-default control auto-hides the default GUI.
|
|
457
|
+
* Deactivating a non-default control auto-restores the default GUI.
|
|
458
|
+
*/
|
|
459
|
+
toggleControl: (name: string, active: boolean, attrs?: Record<string, unknown>) => void;
|
|
460
|
+
registerControl: (control: MicroControl) => void;
|
|
461
|
+
registerControls: (controls: MicroControl[]) => void;
|
|
462
|
+
getControlAttrs: (name: string) => Record<string, unknown> | undefined;
|
|
463
|
+
updateControlAttrs: (name: string, attrs: Record<string, unknown>) => void;
|
|
464
|
+
/** Whether there's a previous entry to go back to */
|
|
465
|
+
canGoBack?: ComputedRef<boolean>;
|
|
466
|
+
/** Whether there's a forward entry (after going back) */
|
|
467
|
+
canGoForward?: ComputedRef<boolean>;
|
|
468
|
+
/** Navigate to previous history entry */
|
|
469
|
+
historyBack?: () => Promise<void>;
|
|
470
|
+
/** Navigate to next history entry */
|
|
471
|
+
historyForward?: () => Promise<void>;
|
|
472
|
+
/** Navigate by delta in history */
|
|
473
|
+
historyGo?: (delta: number) => Promise<void>;
|
|
474
|
+
/** Serialize current router state to a JSON-safe object */
|
|
475
|
+
serialize?: () => SerializedState;
|
|
476
|
+
/** Restore router state from a serialized snapshot */
|
|
477
|
+
restore?: (state: SerializedState) => Promise<void>;
|
|
478
|
+
playSound?: (soundSrc: string, loop?: boolean) => Promise<void>;
|
|
479
|
+
stopSound?: () => void;
|
|
480
|
+
updateBackgroundMusic?: (route: string) => Promise<void>;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export declare const MicroRouterView: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Hook called after navigation completes. Cannot cancel — purely observational.
|
|
487
|
+
*/
|
|
488
|
+
export declare type NavigationAfterHook = (to: string, from: string) => void;
|
|
489
|
+
|
|
490
|
+
declare interface NavigationConfig {
|
|
491
|
+
defaultPath: string;
|
|
492
|
+
stepDelay?: number;
|
|
493
|
+
guards?: GuardConfig;
|
|
494
|
+
history?: NavigationHistoryConfig;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Guard called before navigation. Return false (or resolve to false) to cancel.
|
|
499
|
+
* @param to - target path
|
|
500
|
+
* @param from - current path
|
|
501
|
+
*/
|
|
502
|
+
export declare type NavigationGuard = (to: string, from: string) => boolean | Promise<boolean>;
|
|
503
|
+
|
|
504
|
+
declare interface NavigationHistory {
|
|
505
|
+
entries: ComputedRef<NavigationHistoryEntry_2[]>;
|
|
506
|
+
canGoBack: ComputedRef<boolean>;
|
|
507
|
+
canGoForward: ComputedRef<boolean>;
|
|
508
|
+
/** Navigate to the previous history entry */
|
|
509
|
+
back: () => Promise<void>;
|
|
510
|
+
/** Navigate to the next history entry (after going back) */
|
|
511
|
+
forward: () => Promise<void>;
|
|
512
|
+
/** Navigate by delta: negative = back, positive = forward */
|
|
513
|
+
go: (delta: number) => Promise<void>;
|
|
514
|
+
/** Clear all history entries */
|
|
515
|
+
clear: () => void;
|
|
516
|
+
/** Record a navigation event — called internally after successful push */
|
|
517
|
+
record: (path: string, props?: Record<string, unknown>) => void;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
declare interface NavigationHistoryConfig {
|
|
521
|
+
enabled?: boolean;
|
|
522
|
+
maxEntries?: number;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
declare interface NavigationHistoryEntry_2 {
|
|
526
|
+
path: string;
|
|
527
|
+
timestamp: number;
|
|
528
|
+
props?: Record<string, unknown>;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
export declare interface NavigationState {
|
|
532
|
+
activePath: ComputedRef<string>;
|
|
533
|
+
fromPath: ComputedRef<string>;
|
|
534
|
+
toPath: ComputedRef<string>;
|
|
535
|
+
activePage: ComputedRef<string>;
|
|
536
|
+
fromPage: ComputedRef<string>;
|
|
537
|
+
toPage: ComputedRef<string>;
|
|
538
|
+
resolveRoutes: ComputedRef<MicroRoute[]>;
|
|
539
|
+
push: (destination: string | number, props?: Record<string, unknown>) => Promise<void>;
|
|
540
|
+
stepWisePush: (targetPath: string, props?: Record<string, unknown>) => Promise<void>;
|
|
541
|
+
stepWiseBack: (steps: number) => Promise<void>;
|
|
542
|
+
registerRoute: (route: MicroRoute) => void;
|
|
543
|
+
registerRoutes: (routes: MicroRoute[]) => void;
|
|
544
|
+
updateRouteAttrs: (segment: string, attrs: Record<string, unknown>) => void;
|
|
545
|
+
getRouteAttrs: (segment: string) => Record<string, unknown> | undefined;
|
|
546
|
+
/** Manually preload an async route component */
|
|
547
|
+
preloadRoute: (segment: string) => Promise<void>;
|
|
548
|
+
/** Navigation history (only populated when config.history.enabled) */
|
|
549
|
+
history?: NavigationHistory;
|
|
550
|
+
cleanup: () => void;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** Ensure path starts with / */
|
|
554
|
+
export declare function normalizePath(path: string): string;
|
|
555
|
+
|
|
556
|
+
export declare interface PageTrackerHooks {
|
|
557
|
+
trackPageEnter?: (page: string, from?: string, to?: string) => void;
|
|
558
|
+
trackPageLeave?: (page: string, from?: string, to?: string) => void;
|
|
559
|
+
trackDialogEnter?: (dialog: string, from?: string, to?: string) => void;
|
|
560
|
+
trackDialogLeave?: (dialog: string, from?: string, to?: string) => void;
|
|
561
|
+
trackGuiEnter?: (name: string) => void;
|
|
562
|
+
trackGuiLeave?: (name: string) => void;
|
|
563
|
+
cleanupAllSessions?: () => void;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** Split path into segments: "/home/missions/detail" → ["home", "missions", "detail"] */
|
|
567
|
+
export declare function parsePathSegments(path: string): string[];
|
|
568
|
+
|
|
569
|
+
export declare interface PluginTypedCloseDialog<Dialogs extends string> {
|
|
570
|
+
(path: Dialogs): void;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Typed store from plugin(s) — push/openDialog/closeDialog/toggleControl all validate names.
|
|
575
|
+
* Accepts single plugin or union of plugins: `typeof pluginA | typeof pluginB`
|
|
576
|
+
*/
|
|
577
|
+
export declare type PluginTypedMicroRouterStore<T> = Omit<MicroRouterStore, 'push' | 'stepWisePush' | 'stepWiseBack' | 'openDialog' | 'closeDialog' | 'toggleControl'> & {
|
|
578
|
+
push: PluginTypedPush<ExtractRoutePaths<T>, RegisteredRouteAttrs>;
|
|
579
|
+
stepWisePush: PluginTypedStepWisePush<ExtractRoutePaths<T>, RegisteredRouteAttrs>;
|
|
580
|
+
stepWiseBack: PluginTypedStepWiseBack;
|
|
581
|
+
openDialog: PluginTypedOpenDialog<ExtractDialogPaths<T>, RegisteredDialogAttrs>;
|
|
582
|
+
closeDialog: PluginTypedCloseDialog<ExtractDialogPaths<T>>;
|
|
583
|
+
toggleControl: PluginTypedToggleControl<ExtractControlNames<T>, RegisteredControlAttrs>;
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
export declare interface PluginTypedOpenDialog<Dialogs extends string, AttrsMap = {}> {
|
|
587
|
+
<K extends Dialogs>(path: K, ...args: K extends keyof AttrsMap ? [props: AttrsMap[K]] : [props?: Record<string, unknown>]): {
|
|
588
|
+
path: string;
|
|
589
|
+
attrs?: Record<string, unknown>;
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Per-call generic: TypeScript infers K from the destination string literal,
|
|
595
|
+
* then resolves props type specifically for that route.
|
|
596
|
+
* K extends keyof AttrsMap → AttrsMap[K]
|
|
597
|
+
* K not in AttrsMap → Record<string, unknown>
|
|
598
|
+
*/
|
|
599
|
+
/**
|
|
600
|
+
* Conditional rest args pattern:
|
|
601
|
+
* - Route in AttrsMap → [props: AttrsMap[K]] (required)
|
|
602
|
+
* - Route not in AttrsMap → [props?: Record<string, unknown>] (optional)
|
|
603
|
+
*/
|
|
604
|
+
export declare interface PluginTypedPush<Routes extends string, AttrsMap = {}> {
|
|
605
|
+
<K extends Routes>(destination: K, ...args: K extends keyof AttrsMap ? [props: AttrsMap[K]] : [props?: Record<string, unknown>]): Promise<void>;
|
|
606
|
+
(destination: number, props?: Record<string, unknown>): Promise<void>;
|
|
607
|
+
(destination: `/${string}`, props?: Record<string, unknown>): Promise<void>;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
declare interface PluginTypedStepWiseBack {
|
|
611
|
+
(steps: number): Promise<void>;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
declare interface PluginTypedStepWisePush<Routes extends string, AttrsMap = {}> {
|
|
615
|
+
<K extends Routes>(targetPath: K, ...args: K extends keyof AttrsMap ? [props: AttrsMap[K]] : [props?: Record<string, unknown>]): Promise<void>;
|
|
616
|
+
(targetPath: `/${string}`, props?: Record<string, unknown>): Promise<void>;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
export declare interface PluginTypedToggleControl<Controls extends string, AttrsMap = {}> {
|
|
620
|
+
<K extends Controls>(name: K, active: boolean, ...args: K extends keyof AttrsMap ? [attrs: AttrsMap[K]] : [attrs?: Record<string, unknown>]): void;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
declare interface Props {
|
|
624
|
+
/** Required config — must provide defaultPath and defaultControlName */
|
|
625
|
+
config: MicroRouterConfig;
|
|
626
|
+
plugins?: FeaturePlugin[];
|
|
627
|
+
/** Mark as a nested router — each nested instance has its own independent page/dialog/control state */
|
|
628
|
+
nested?: boolean;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
declare interface Props_2 {
|
|
632
|
+
routePath?: string;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
declare interface Props_3 {
|
|
636
|
+
dialog: MicroDialog;
|
|
637
|
+
stackIndex: number;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
declare interface Props_4 {
|
|
641
|
+
control: MicroControl;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/** Register plugin type — declare once in app-plugin.ts */
|
|
645
|
+
export declare interface Register {
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
export declare type RegisteredControlAttrs = ControlAttrsMap;
|
|
649
|
+
|
|
650
|
+
export declare type RegisteredDialogAttrs = DialogAttrsMap;
|
|
651
|
+
|
|
652
|
+
/** Resolved plugin type from Register — `never` if not augmented */
|
|
653
|
+
export declare type RegisteredPlugin = Register extends {
|
|
654
|
+
plugin: infer T;
|
|
655
|
+
} ? T : never;
|
|
656
|
+
|
|
657
|
+
/** Resolved attrs maps — from augmented interfaces */
|
|
658
|
+
export declare type RegisteredRouteAttrs = RouteAttrsMap;
|
|
659
|
+
|
|
660
|
+
/** Resolved route map from Register — `never` if not augmented */
|
|
661
|
+
declare type RegisteredRouteMap = Register extends {
|
|
662
|
+
routeMap: infer T extends RouteMap;
|
|
663
|
+
} ? T : never;
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Register all plugins' routes/dialogs/controls with the router store.
|
|
667
|
+
* Call synchronously before onMounted (typically in MicroRouterView setup).
|
|
668
|
+
*/
|
|
669
|
+
export declare function registerFeaturePlugins(plugins: FeaturePlugin[], store: MicroRouterStore): void;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Auto-resolved store type based on Register augmentation.
|
|
673
|
+
* Priority: plugin > routeMap > untyped MicroRouterStore
|
|
674
|
+
* Attrs maps (routeAttrs/dialogAttrs/controlAttrs) are passed through when declared.
|
|
675
|
+
*/
|
|
676
|
+
export declare type ResolvedMicroRouterStore = HasRegisteredPlugin extends true ? Omit<MicroRouterStore, 'push' | 'stepWisePush' | 'stepWiseBack' | 'openDialog' | 'closeDialog' | 'toggleControl'> & {
|
|
677
|
+
push: PluginTypedPush<ExtractRoutePaths<RegisteredPlugin>, RegisteredRouteAttrs>;
|
|
678
|
+
stepWisePush: PluginTypedStepWisePush<ExtractRoutePaths<RegisteredPlugin>, RegisteredRouteAttrs>;
|
|
679
|
+
stepWiseBack: PluginTypedStepWiseBack;
|
|
680
|
+
openDialog: PluginTypedOpenDialog<ExtractDialogPaths<RegisteredPlugin>, RegisteredDialogAttrs>;
|
|
681
|
+
closeDialog: PluginTypedCloseDialog<ExtractDialogPaths<RegisteredPlugin>>;
|
|
682
|
+
toggleControl: PluginTypedToggleControl<ExtractControlNames<RegisteredPlugin>, RegisteredControlAttrs>;
|
|
683
|
+
} : HasRegisteredRouteMap extends true ? Omit<MicroRouterStore, 'push'> & {
|
|
684
|
+
push: TypedPush<RegisteredRouteMap>;
|
|
685
|
+
} : MicroRouterStore;
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Per-route attrs — augment from each route component.
|
|
689
|
+
* Keys = route path strings, values = attrs type for that route.
|
|
690
|
+
* TS interface merging combines declarations across all files.
|
|
691
|
+
*/
|
|
692
|
+
export declare interface RouteAttrsMap {
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
export declare interface RouteLifecycleHooks {
|
|
696
|
+
onRouteEnter?: () => void;
|
|
697
|
+
onRouteLeave?: () => void;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Type-level helpers for opt-in type safety across routes, dialogs, and controls.
|
|
702
|
+
*
|
|
703
|
+
* Two usage patterns:
|
|
704
|
+
*
|
|
705
|
+
* 1. Infer from plugin (recommended — zero duplication):
|
|
706
|
+
* ```ts
|
|
707
|
+
* const plugin = defineFeaturePlugin({ ... } as const);
|
|
708
|
+
* const store = useMicroRouter<typeof plugin>();
|
|
709
|
+
* ```
|
|
710
|
+
*
|
|
711
|
+
* 2. Manual route map (when you need typed props):
|
|
712
|
+
* ```ts
|
|
713
|
+
* interface AppRoutes { home: undefined; profile: { userId: number } }
|
|
714
|
+
* const store = useMicroRouter<AppRoutes>();
|
|
715
|
+
* ```
|
|
716
|
+
*/
|
|
717
|
+
/** Route map: keys are route segment names, values are props type or undefined */
|
|
718
|
+
export declare type RouteMap = Record<string, Record<string, unknown> | undefined>;
|
|
719
|
+
|
|
720
|
+
export declare const RoutePage: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, __VLS_TemplateResult_2["slots"]>;
|
|
721
|
+
|
|
722
|
+
/** Extract route names that don't require props */
|
|
723
|
+
export declare type RoutesWithoutProps<T extends RouteMap> = {
|
|
724
|
+
[K in keyof T]: T[K] extends undefined ? K : never;
|
|
725
|
+
}[keyof T];
|
|
726
|
+
|
|
727
|
+
/** Extract route names that require props */
|
|
728
|
+
export declare type RoutesWithProps<T extends RouteMap> = {
|
|
729
|
+
[K in keyof T]: T[K] extends undefined ? never : K;
|
|
730
|
+
}[keyof T];
|
|
731
|
+
|
|
732
|
+
/** Safely mark a Vue component as raw to prevent reactivity */
|
|
733
|
+
export declare function safeMarkRaw<T extends object>(component: T): T;
|
|
734
|
+
|
|
735
|
+
export declare interface SerializedState {
|
|
736
|
+
/** Schema version for future migration support */
|
|
737
|
+
version: 1;
|
|
738
|
+
navigation: {
|
|
739
|
+
activePath: string;
|
|
740
|
+
routeAttrs: Record<string, Record<string, unknown>>;
|
|
741
|
+
};
|
|
742
|
+
dialogs: {
|
|
743
|
+
/** Open dialog paths in stack order */
|
|
744
|
+
stack: string[];
|
|
745
|
+
attrs: Record<string, Record<string, unknown>>;
|
|
746
|
+
};
|
|
747
|
+
controls: {
|
|
748
|
+
/** Active control names */
|
|
749
|
+
active: string[];
|
|
750
|
+
attrs: Record<string, Record<string, unknown>>;
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Like ToRefs but all keys are required (ref always exists).
|
|
756
|
+
* Optional fields → Ref<T | undefined> (value may be undefined, ref itself never is).
|
|
757
|
+
* Required fields → Ref<T> (value always present).
|
|
758
|
+
*
|
|
759
|
+
* This means: `meta.value?.title` ✅ (not `meta?.value?.title`)
|
|
760
|
+
*/
|
|
761
|
+
export declare type StateRefs<T extends object> = {
|
|
762
|
+
[K in keyof T]-?: Ref<T[K]>;
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Default delay (ms) between step-wise navigation transitions and navigation lock release.
|
|
767
|
+
* Must be >= the longest page transition (500ms slide) + buffer for Vue DOM patching.
|
|
768
|
+
* Too short = overlapping animations. Too long = sluggish feel.
|
|
769
|
+
*/
|
|
770
|
+
export declare const STEP_DELAY = 550;
|
|
771
|
+
|
|
772
|
+
export declare type TransitionType = 'fade' | 'slide' | 'scale';
|
|
773
|
+
|
|
774
|
+
/** Typed store from manual RouteMap — push() validates route names + props */
|
|
775
|
+
export declare type TypedMicroRouterStore<T extends RouteMap> = Omit<MicroRouterStore, 'push'> & {
|
|
776
|
+
push: TypedPush<T>;
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
/** Typed push overloads for manual RouteMap */
|
|
780
|
+
export declare interface TypedPush<T extends RouteMap> {
|
|
781
|
+
(destination: RoutesWithoutProps<T>): Promise<void>;
|
|
782
|
+
<K extends RoutesWithProps<T>>(destination: K, props: T[K]): Promise<void>;
|
|
783
|
+
(destination: number): Promise<void>;
|
|
784
|
+
(destination: `/${string}`, props?: Record<string, unknown>): Promise<void>;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
export declare function useControlLifecycle(hooks: ControlLifecycleHooks): void;
|
|
788
|
+
|
|
789
|
+
export declare function useControlManager(config: ControlManagerConfig, tracker?: Required<PageTrackerHooks>): ControlManagerState;
|
|
790
|
+
|
|
791
|
+
export declare function useDialogLifecycle(hooks: DialogLifecycleHooks): void;
|
|
792
|
+
|
|
793
|
+
export declare function useDialogManager(tracker?: Required<PageTrackerHooks>): DialogManagerState;
|
|
794
|
+
|
|
795
|
+
export declare function useGestureNavigation(config: GestureConfig, ctx: GestureContext): void;
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Create and provide the MicroRouter store.
|
|
799
|
+
* Call once in the root MicroRouterView component.
|
|
800
|
+
*/
|
|
801
|
+
export declare function useGlobalMicroRouter(config: MicroRouterConfig): MicroRouterStore;
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Inject the MicroRouter store from a parent MicroRouterView.
|
|
805
|
+
*
|
|
806
|
+
* @example Auto-typed via Register (recommended — declare once, typed everywhere)
|
|
807
|
+
* ```ts
|
|
808
|
+
* // env.d.ts — declare once
|
|
809
|
+
* declare module 'vue-micro-router' {
|
|
810
|
+
* interface Register { plugin: typeof appPlugin }
|
|
811
|
+
* }
|
|
812
|
+
*
|
|
813
|
+
* // Any component — no generic needed
|
|
814
|
+
* const { push } = useMicroRouter();
|
|
815
|
+
* push('shop'); // ✅ type-safe
|
|
816
|
+
* push('unknown'); // ❌ compile error
|
|
817
|
+
* ```
|
|
818
|
+
*
|
|
819
|
+
* @example Explicit generic (override or without Register)
|
|
820
|
+
* ```ts
|
|
821
|
+
* const store = useMicroRouter<typeof plugin>();
|
|
822
|
+
* ```
|
|
823
|
+
*
|
|
824
|
+
* @example Manual RouteMap (for typed props)
|
|
825
|
+
* ```ts
|
|
826
|
+
* interface AppRoutes { home: undefined; profile: { userId: number } }
|
|
827
|
+
* const store = useMicroRouter<AppRoutes>();
|
|
828
|
+
* store.push('profile', { userId: 42 }); // OK
|
|
829
|
+
* ```
|
|
830
|
+
*/
|
|
831
|
+
export declare function useMicroRouter(options?: UseMicroRouterOptions): ResolvedMicroRouterStore;
|
|
832
|
+
|
|
833
|
+
export declare function useMicroRouter<T extends RouteMap>(options?: UseMicroRouterOptions): TypedMicroRouterStore<T>;
|
|
834
|
+
|
|
835
|
+
export declare function useMicroRouter<T extends {
|
|
836
|
+
name: string;
|
|
837
|
+
}>(options?: UseMicroRouterOptions): PluginTypedMicroRouterStore<T>;
|
|
838
|
+
|
|
839
|
+
declare interface UseMicroRouterOptions {
|
|
840
|
+
/** If true, injects the root (outermost) router instead of the nearest parent */
|
|
841
|
+
root?: boolean;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Reactive state bridge for routes, dialogs, and controls.
|
|
846
|
+
* Auto-reads attrs from parent wrapper (RoutePage/MicroDialog/MicroControlWrapper).
|
|
847
|
+
* Mutations auto-sync back to the store — state survives remount.
|
|
848
|
+
*
|
|
849
|
+
* Returns a reactive object — no `.value` needed, works like Vue's `reactive()`.
|
|
850
|
+
* Reactive in template: `{{ state.userId }}` auto-updates.
|
|
851
|
+
* Writable: `state.userId = 42` triggers sync back to store.
|
|
852
|
+
*
|
|
853
|
+
* @example
|
|
854
|
+
* ```ts
|
|
855
|
+
* const state = useMicroState<{ userId: number; username: string }>();
|
|
856
|
+
* state.userId // number — no .value
|
|
857
|
+
* state.userId = 42 // reactive, syncs back
|
|
858
|
+
*
|
|
859
|
+
* // With defaults
|
|
860
|
+
* const state = useMicroState({ count: 0 });
|
|
861
|
+
* state.count++ // reactive
|
|
862
|
+
* ```
|
|
863
|
+
*/
|
|
864
|
+
export declare function useMicroState<T extends object>(): StateRefs<T>;
|
|
865
|
+
|
|
866
|
+
export declare function useMicroState<T extends object>(defaults: T): StateRefs<T>;
|
|
867
|
+
|
|
868
|
+
export declare function useNavigation(config: NavigationConfig, tracker?: Required<PageTrackerHooks>): NavigationState;
|
|
869
|
+
|
|
870
|
+
/** Create a page tracker with optional hook implementations. No-ops by default. */
|
|
871
|
+
export declare function usePageTracker(hooks?: PageTrackerHooks): Required<PageTrackerHooks>;
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* Route lifecycle hooks — fire when a route becomes/stops being the active (top) page.
|
|
875
|
+
* Similar to iOS viewWillAppear/viewWillDisappear or Vue Router's navigation guards.
|
|
876
|
+
*
|
|
877
|
+
* @example
|
|
878
|
+
* ```ts
|
|
879
|
+
* useRouteLifecycle({
|
|
880
|
+
* onRouteEnter: () => console.log('Page visible'),
|
|
881
|
+
* onRouteLeave: () => console.log('Page hidden'),
|
|
882
|
+
* });
|
|
883
|
+
* ```
|
|
884
|
+
*/
|
|
885
|
+
export declare function useRouteLifecycle(hooks: RouteLifecycleHooks): void;
|
|
886
|
+
|
|
887
|
+
export { }
|