@viteplus/versions 2.0.5 → 2.0.7

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.d.ts CHANGED
@@ -1,2522 +1,892 @@
1
-
2
- /**
3
- * This file was automatically generated by xBuild.
4
- * DO NOT EDIT MANUALLY.
5
- */
6
- import type { UserConfig } from 'vitepress';
7
- export type * from 'vitepress';
8
- import type { DefaultTheme, UserConfig } from 'vitepress';
9
- import type { DefaultTheme } from 'vitepress';
10
- import type { LocaleSpecificConfig } from 'vitepress';
11
- import type { SidebarItemType } from '@viteplus/versions';
12
-
13
- /**
14
- * Import will remove at compile time
15
- */
16
- /**
17
- * Export interfaces
18
- */
19
- export declare function defineVersionedConfig(userConfiguration: PartialConfigurationType): UserConfig;
20
-
21
- /**
22
- * Import will remove at compile time
23
- */
24
- /**
25
- * Defines hooks for version- and locale-specific behavior.
26
- *
27
- * @remarks
28
- * The `rewritesHook` function allows you to programmatically rewrite
29
- * paths or content based on the documentation version and locale being served.
30
- *
31
- * @example
32
- * ```ts
33
- * const hooks: VersionsHooksInterface = {
34
- * rewritesHook: (source, version, locale) =>
35
- * `${version}/${locale}/${source}`
36
- * };
37
- * ```
38
- *
39
- * @since 2.0.0
40
- */
41
- export interface VersionsHooksInterface {
42
- /**
43
- * A function that rewrites a source path based on version and locale.
44
- *
45
- * @param source - The original file path or source string.
46
- * @param version - The current documentation version (e.g., "2.0").
47
- * @param locale - The locale code or folder name (e.g., "en", "de").
48
- *
49
- * @returns The rewritten path string, which can be used for routing or file organization.
50
- *
51
- * @remarks
52
- * This hook is invoked whenever paths need to be version- and locale-aware,
53
- * allowing complete control over URL or file structure.
54
- *
55
- * @since 2.0.0
56
- */
57
- rewritesHook(source: string, version: string, locale: string): string;
58
- }
59
- /**
60
- * Configuration for a version switcher component.
61
- *
62
- * @remarks
63
- * - `text` is the display label for the version switcher.
64
- * - `includeCurrentVersion` determines whether the currently active version
65
- * should appear in the switcher dropdown.
66
- *
67
- * @example
68
- * ```ts
69
- * const switcher: VersionsSwitcherInterface = {
70
- * text: "Version",
71
- * includeCurrentVersion: true
72
- * };
73
- * ```
74
- *
75
- * @since 2.0.0
76
- */
77
- export interface VersionsSwitcherInterface {
78
- /**
79
- * The display label for the version switcher component.
80
- *
81
- * @remarks
82
- * This text is shown in the UI as the version selector label.
83
- *
84
- * @since 2.0.0
85
- */
86
- text: string;
87
- /**
88
- * Determines whether the currently active version should appear in the switcher dropdown.
89
- *
90
- * @remarks
91
- * If `true`, the current version will be included; if `false`, it will be omitted.
92
- *
93
- * @since 2.0.0
94
- */
95
- includeCurrentVersion: boolean;
96
- }
97
- /**
98
- * Configuration for documentation versions.
99
- *
100
- * @remarks
101
- * - `current` specifies the currently active version.
102
- * - `sources` is the folder or path where current versioned sources reside.
103
- * - `archive` is the folder or path for archived versions.
104
- * - `hooks` allows for custom rewriting logic per version.
105
- * - `versionSwitcher` enables or disables the version switcher, or provides its configuration.
106
- *
107
- * @example
108
- * ```ts
109
- * const versionsConfig: VersionsConfigInterface = {
110
- * current: "2.0",
111
- * sources: "src",
112
- * archive: "archive",
113
- * hooks: {
114
- * rewritesHook: (source, version) => `/v${version}/${source}`
115
- * },
116
- * versionSwitcher: { text: "Version", includeCurrentVersion: true }
117
- * };
118
- * ```
119
- *
120
- * @since 2.0.0
121
- */
122
- export interface VersionsConfigInterface {
123
- /**
124
- * The currently active documentation version.
125
- *
126
- * @remarks
127
- * Used to determine which version to serve by default and which version
128
- * should be highlighted in the version switcher.
129
- *
130
- * @since 2.0.0
131
- */
132
- current: string;
133
- /**
134
- * The folder or path where the current versioned sources reside.
135
- *
136
- * @since 2.0.0
137
- */
138
- sources: string;
139
- /**
140
- * The folder or path where archived versions are stored.
141
- *
142
- * @since 2.0.0
143
- */
144
- archive: string;
145
- /**
146
- * Hooks for custom behavior when working with versioned content.
147
- *
148
- * @remarks
149
- * Currently, supports `rewritesHook`, which can programmatically rewrite
150
- * paths based on version and locale.
151
- *
152
- * @see VersionsHooksInterface
153
- * @since 2.0.0
154
- */
155
- hooks: VersionsHooksInterface;
156
- /**
157
- * Configuration for the version switcher or `false` to disable it.
158
- *
159
- * @remarks
160
- * If enabled, this object defines the switcher text and whether the
161
- * current version is included in the switcher options.
162
- *
163
- * @see VersionsSwitcherInterface
164
- * @since 2.0.0
165
- */
166
- versionSwitcher: false | VersionsSwitcherInterface;
167
- }
168
- /**
169
- * Main configuration interface for a VitePress site with extended features.
170
- *
171
- * @remarks
172
- * Extends VitePress's `UserConfig` but overrides:
173
- * - `locales` to use a strongly typed `LocalesInterface`.
174
- * - `rewrites` to define path rewrites for the site.
175
- * - `versionsConfig` to manage documentation versions and the version switcher.
176
- *
177
- * @example
178
- * ```ts
179
- * const config: ConfigurationInterface = {
180
- * locales: {
181
- * en: { link: "/en/", label: "English" },
182
- * de: { link: "/de/", label: "Deutsch" }
183
- * },
184
- * rewrites: {
185
- * "/old-path": "/new-path"
186
- * },
187
- * versionsConfig: {
188
- * current: "2.0",
189
- * sources: "src",
190
- * archive: "archive",
191
- * hooks: { rewritesHook: (src, ver) => `/v${ver}/${src}` },
192
- * versionSwitcher: { text: "Version", includeCurrentVersion: true }
193
- * }
194
- * };
195
- * ```
196
- *
197
- * @since 2.0.0
198
- */
199
- export interface ConfigurationInterface extends Omit<UserConfig<ThemeInterface>, 'rewrites' | 'locales'> {
200
- /**
201
- * Locale-specific configuration for the site.
202
- *
203
- * @remarks
204
- * Uses {@link LocalesInterface} to strongly type each locale's settings.
205
- *
206
- * @since 2.0.0
207
- */
208
- locales: LocalesInterface;
209
- /**
210
- * Path rewrites for the site.
211
- *
212
- * @remarks
213
- * Maps old paths to new paths, enabling URL restructuring without breaking links.
214
- *
215
- * @since 2.0.0
216
- */
217
- rewrites: Record<string, string>;
218
- /**
219
- * Versioning configuration for documentation.
220
- *
221
- * @remarks
222
- * Defines the current version, source directory, archive, hooks, and version switcher behavior.
223
- *
224
- * @see VersionsConfigInterface
225
- * @since 2.0.0
226
- */
227
- versionsConfig: VersionsConfigInterface;
228
- }
229
- /**
230
- * Represents a deeply partial version of the `ConfigurationInterface`.
231
- *
232
- * @remarks
233
- * This type allows any property of `ConfigurationInterface` to be optional,
234
- * including all nested properties. It is based on the `DeepPartialType` utility type.
235
- *
236
- * Useful for scenarios where you want to provide only a subset of the configuration,
237
- * for example, when overriding default settings or merging user-provided options.
238
- *
239
- * @example
240
- * ```ts
241
- * const partialConfig: PartialConfigurationType = {
242
- * locales: {
243
- * en: { label: "English" }
244
- * },
245
- * versionsConfig: {
246
- * versionSwitcher: { text: "Version" }
247
- * }
248
- * };
249
- * ```
250
- *
251
- * @since 2.0.0
252
- */
253
- export type PartialConfigurationType = DeepPartialType<ConfigurationInterface>;
254
- /**
255
- * A strongly typed VitePress configuration where specific keys are required.
256
- *
257
- * @remarks
258
- * This type uses {@link RequireKeysType} to ensure that the following properties
259
- * of `UserConfig<DefaultTheme.Config>` are always present:
260
- * - `locales`
261
- * - `rewrites`
262
- * - `themeConfig`
263
- *
264
- * All other properties remain optional, preserving the flexibility of the standard
265
- * VitePress configuration type.
266
- *
267
- * @example
268
- * ```ts
269
- * const config: VitepressConfigType = {
270
- * locales: { en: { link: "/en/", label: "English" } },
271
- * rewrites: { "/old-path": "/new-path" },
272
- * themeConfig: { nav: [], sidebar: {} }
273
- * };
274
- * ```
275
- *
276
- * @since 2.0.0
277
- */
278
- export type VitepressConfigType = RequireKeysType<UserConfig<DefaultTheme.Config>, 'locales' | 'rewrites' | 'themeConfig'>;
279
- /**
280
- * Strongly typed VitePress configuration interface with custom locales support.
281
- *
282
- * @remarks
283
- * Extends {@link VitepressConfigType} but overrides the `locales` property
284
- * to use a strongly typed {@link LocalesInterface}.
285
- *
286
- * This ensures:
287
- * - `locales` are fully typed with per-locale configurations.
288
- * - Other required properties from `VitepressConfigType` (`rewrites`, `themeConfig`) remain enforced.
289
- * - Remaining properties from `UserConfig<DefaultTheme.Config>` retain their optionality.
290
- *
291
- * @example
292
- * ```ts
293
- * const config: VitepressConfigInterface = {
294
- * locales: {
295
- * en: { link: "/en/", label: "English" },
296
- * de: { link: "/de/", label: "Deutsch" }
297
- * },
298
- * rewrites: { "/old-path": "/new-path" },
299
- * themeConfig: { nav: [], sidebar: {} }
300
- * };
301
- * ```
302
- *
303
- * @since 2.0.0
304
- */
305
- export interface VitepressConfigInterface extends Omit<VitepressConfigType, 'locales'> {
306
- /**
307
- * Locale-specific configuration for the site.
308
- *
309
- * @remarks
310
- * Uses {@link LocalesInterface} to strongly type each locale's settings.
311
- *
312
- * @since 2.0.0
313
- */
314
- locales: LocalesInterface;
315
- }
316
-
317
- /**
318
- * Import will remove at compile time
319
- */
320
- /**
321
- * Represents the configuration interface for a VitePress theme.
322
- *
323
- * @remarks
324
- * Extends VitePress's {@link DefaultTheme.Config} type but overrides the
325
- * `nav` and `sidebar` properties to use custom, strongly typed interfaces
326
- * ({@link NavType} and {@link SidebarType}).
327
- *
328
- * This allows for enhanced type safety and additional functionality such as
329
- * versioning control in navigation and sidebar items.
330
- *
331
- * @example
332
- * ```ts
333
- * const themeConfig: ThemeInterface = {
334
- * nav: [
335
- * { text: "Home", link: "/" },
336
- * { text: "Docs", items: [{ text: "Guide", link: "/guide/" }] }
337
- * ],
338
- * sidebar: {
339
- * guide: [
340
- * { text: "Introduction", link: "/guide/introduction" },
341
- * { text: "Setup", link: "/guide/setup" }
342
- * ]
343
- * },
344
- * lastUpdated: true
345
- * };
346
- * ```
347
- *
348
- * @since 2.0.0
349
- */
350
- export interface ThemeInterface extends Omit<DefaultTheme.Config, 'nav' | 'sidebar'> {
351
- /**
352
- * Navigation structure of the site.
353
- *
354
- * @remarks
355
- * Typed as {@link NavType}, which allows versioning-aware navigation items.
356
- *
357
- * @since 2.0.0
358
- */
359
- nav?: NavType;
360
- /**
361
- * Sidebar structure of the site.
362
- *
363
- * @remarks
364
- * Typed as {@link SidebarType}, which allows versioning-aware sidebar items.
365
- *
366
- * @since 2.0.0
367
- */
368
- sidebar?: SidebarType;
369
- }
370
-
371
- /**
372
- * Import will remove at compile time
373
- */
374
- /**
375
- * Represents a component-based navigation item from VitePress.
376
- *
377
- * @remarks
378
- * This type is directly imported from VitePress and allows using custom
379
- * Vue components as navigation items.
380
- *
381
- * @since 2.0.0
382
- */
383
- export type NavItemComponentType = DefaultTheme.NavItemComponent;
384
- /**
385
- * Represents a navigation item with a link.
386
- *
387
- * @remarks
388
- * Extends VitePress's {@link DefaultTheme.NavItemWithLink} with an optional
389
- * `skipVersioning` flag. Use `skipVersioning` to indicate that this
390
- * navigation item should not be automatically versioned in multi-version
391
- * documentation setups.
392
- *
393
- * @example
394
- * ```ts
395
- * const navItem: NavItemWithLinkType = {
396
- * text: "Home",
397
- * link: "/",
398
- * skipVersioning: true
399
- * };
400
- * ```
401
- *
402
- * @since 2.0.0
403
- */
404
- export type NavItemWithLinkType = DefaultTheme.NavItemWithLink & {
405
- /**
406
- * Indicates whether this navigation item should be excluded from automatic versioning.
407
- *
408
- * @default false
409
- * @remarks
410
- * When set to `true`, this item will remain the same across all documentation versions.
411
- *
412
- * @since 2.0.0
413
- */
414
- skipVersioning?: boolean;
415
- };
416
- /**
417
- * Represents a navigation item with children.
418
- *
419
- * @remarks
420
- * Extends VitePress's {@link DefaultTheme.NavItemWithChildren} but requires
421
- * `items` to be an array of navigation items of various types:
422
- * - {@link NavItemComponentType}
423
- * - {@link NavItemWithLinkType}
424
- * - Recursively, {@link NavItemWithChildrenType}
425
- *
426
- * Supports the optional `skipVersioning` flag to exclude the item from automatic
427
- * versioning in multi-version documentation setups.
428
- *
429
- * @example
430
- * ```ts
431
- * const nav: NavItemWithChildrenType = {
432
- * text: "Docs",
433
- * items: [
434
- * { text: "Guide", link: "/guide/" },
435
- * {
436
- * text: "API",
437
- * items: [
438
- * { text: "Functions", link: "/api/functions" }
439
- * ]
440
- * }
441
- * ],
442
- * skipVersioning: true
443
- * };
444
- * ```
445
- *
446
- * @since 2.0.0
447
- */
448
- export type NavItemWithChildrenType = Omit<DefaultTheme.NavItemWithChildren, 'items'> & {
449
- /**
450
- * Child navigation items for this item.
451
- *
452
- * @remarks
453
- * Can include standard components, link items, or nested child items.
454
- *
455
- * @since 2.0.0
456
- */
457
- items: Array<NavItemComponentType | NavItemWithChildrenType | NavItemWithLinkType>;
458
- /**
459
- * Indicates whether this navigation item should be excluded from automatic versioning.
460
- *
461
- * @default false
462
- * @remarks
463
- * When set to `true`, this item and all its children remain unchanged across versions.
464
- *
465
- * @since 2.0.0
466
- */
467
- skipVersioning?: boolean;
468
- };
469
- /**
470
- * Represents a single navigation item of any type.
471
- *
472
- * @remarks
473
- * Can be a component, a link, or a navigation item with children.
474
- *
475
- * @since 2.0.0
476
- */
477
- export type NavItemType = NavItemComponentType | NavItemWithLinkType | NavItemWithChildrenType;
478
- /**
479
- * Represents a record of named navigation groups.
480
- *
481
- * @remarks
482
- * - Each key in the record is a group identifier (commonly a section name or locale).
483
- * - Each value is an array of {@link NavItemType}, which can include links, components,
484
- * or nested navigation structures.
485
- * - Useful for organizing navigation into multiple top-level groups instead of a single array.
486
- *
487
- * @example
488
- * ```ts
489
- * const nav: NavObjectType = {
490
- * root: [
491
- * { text: "Home", link: "/" },
492
- * { text: "Guide", link: "/guide/" }
493
- * ],
494
- * 'v1.0.0': [
495
- * { text: "Functions", link: "/api/functions" },
496
- * { text: "Classes", link: "/api/classes" }
497
- * ]
498
- * };
499
- * ```
500
- *
501
- * @since 2.0.0
502
- */
503
- export type NavObjectType = Record<string, Array<NavItemType>>;
504
- /**
505
- * Represents the navigation structure.
506
- *
507
- * @remarks
508
- * Can be either:
509
- * - An array of navigation items (`NavItemType[]`), or
510
- * - A record mapping strings (e.g., section names) to arrays of navigation items.
511
- *
512
- * @since 2.0.0
513
- */
514
- export type NavType = Array<NavItemType> | NavObjectType;
515
-
516
- /**
517
- * Import will remove at compile time
518
- */
519
- /**
520
- * Represents a sidebar item from VitePress with optional versioning control.
521
- *
522
- * @remarks
523
- * Extends VitePress's {@link DefaultTheme.SidebarItem} type by adding an optional
524
- * `skipVersioning` flag. Use this flag to indicate that the item should not be
525
- * automatically versioned in multi-version documentation setups.
526
- *
527
- * @example
528
- * ```ts
529
- * const item: SidebarItemType = {
530
- * text: "Introduction",
531
- * link: "/guide/introduction",
532
- * skipVersioning: true
533
- * };
534
- * ```
535
- *
536
- * @since 2.0.0
537
- */
538
- export type SidebarItemType = DefaultTheme.SidebarItem & {
539
- /**
540
- * Determines whether this sidebar item should be excluded from automatic versioning.
541
- *
542
- * @default false
543
- * @remarks
544
- * When `true`, this sidebar item will remain consistent across all documentation versions.
545
- *
546
- * @since 2.0.0
547
- */
548
- skipVersioning?: boolean;
549
- };
550
- /**
551
- * Represents a sidebar group containing multiple sidebar items.
552
- *
553
- * @remarks
554
- * Each group has a `base` path and an array of sidebar items.
555
- * Useful for organizing related pages under a common path prefix.
556
- *
557
- * @example
558
- * ```ts
559
- * const group: SidebarGroupInterface = {
560
- * base: "/guide/",
561
- * items: [
562
- * { text: "Introduction", link: "/guide/introduction" },
563
- * { text: "Setup", link: "/guide/setup" }
564
- * ]
565
- * };
566
- * ```
567
- *
568
- * @see SidebarItemType
569
- * @since 2.0.0
570
- */
571
- export interface SidebarGroupInterface {
572
- /**
573
- * The base path for the sidebar group.
574
- *
575
- * @remarks
576
- * This path is prepended to all child sidebar items within the group.
577
- * Typically corresponds to the folder containing the group’s pages, e.g., `"en"`.
578
- *
579
- * @since 2.0.0
580
- */
581
- base: string;
582
- /**
583
- * The list of sidebar items within this group.
584
- *
585
- * @remarks
586
- * Each item is typed as {@link SidebarItemType}, which may include links,
587
- * collapsible sections, or other sidebar elements.
588
- *
589
- * @since 2.0.0
590
- */
591
- items: Array<SidebarItemType>;
592
- }
593
- /**
594
- * Represents a mapping of paths to sidebar items or groups.
595
- *
596
- * @remarks
597
- * The keys are path strings, and the values can be either:
598
- * - An array of sidebar items (`SidebarItemType[]`), or
599
- * - A sidebar group (`SidebarGroupInterface`).
600
- *
601
- * @example
602
- * ```ts
603
- * const sidebar: PathSidebarInterface = {
604
- * guide: [
605
- * { text: "Intro", link: "/guide/intro" },
606
- * { text: "Setup", link: "/guide/setup" }
607
- * ],
608
- * api: { base: "/api/", items: [ { text: "Functions", link: "/api/functions" } ] }
609
- * };
610
- * ```
611
- *
612
- * @see SidebarItemType
613
- * @see SidebarGroupInterface
614
- *
615
- * @since 2.0.0
616
- */
617
- export interface PathSidebarInterface {
618
- [path: string]: Array<SidebarItemType> | SidebarGroupInterface;
619
- }
620
- /**
621
- * Represents the overall sidebar configuration.
622
- *
623
- * @remarks
624
- * Can be defined in one of two ways:
625
- * - As a flat array of {@link SidebarItemType}, or
626
- * - As a path-based mapping using {@link PathSidebarInterface}.
627
- *
628
- * This flexibility allows defining either a single global sidebar
629
- * or multiple sidebars scoped to different route prefixes.
630
- *
631
- * @example
632
- * Flat sidebar:
633
- * ```ts
634
- * const sidebar: SidebarType = [
635
- * { text: "Home", link: "/" },
636
- * { text: "Guide", link: "/guide/" }
637
- * ];
638
- * ```
639
- *
640
- * @example
641
- * Path-based sidebars:
642
- * ```ts
643
- * const sidebar: SidebarType = {
644
- * "/guide/": [
645
- * { text: "Introduction", link: "/guide/introduction" }
646
- * ],
647
- * "/api/": [
648
- * { text: "API Reference", link: "/api/" }
649
- * ]
650
- * };
651
- * ```
652
- *
653
- * @see SidebarItemType
654
- * @see PathSidebarInterface
655
- *
656
- * @since 2.0.0
657
- */
658
- export type SidebarType = Array<SidebarItemType> | PathSidebarInterface;
659
- /**
660
- * Represents a mapping of paths to sidebar item arrays.
661
- *
662
- * @remarks
663
- * This structure allows defining sidebars on a per-path basis,
664
- * where each key is a route prefix (e.g., `"/guide/"`) and its value
665
- * is an array of {@link SidebarItemType}.
666
- *
667
- * @example
668
- * ```ts
669
- * const sidebars: SidebarObjectType = {
670
- * "/guide/": [
671
- * { text: "Introduction", link: "/guide/introduction" },
672
- * { text: "Setup", link: "/guide/setup" }
673
- * ],
674
- * "/api/": [
675
- * { text: "API Reference", link: "/api/" }
676
- * ]
677
- * };
678
- * ```
679
- *
680
- * @see SidebarItemType
681
- * @since 2.0.0
682
- */
683
- export type SidebarObjectType = Record<string, Array<SidebarItemType | SidebarGroupInterface>>;
684
-
685
- /**
686
- * Import will remove at compile time
687
- */
688
- /**
689
- * Represents a locale-specific configuration for a VitePress site.
690
- *
691
- * @remarks
692
- * Extends VitePress's `LocaleSpecificConfig` with a custom {@link ThemeInterface}.
693
- * Adds optional properties:
694
- * - `link` — the base URL or path for this locale.
695
- * - `label` — a human-readable label for the locale (e.g., "English", "Deutsch").
696
- *
697
- * This interface allows configuring per-locale theme settings, navigation,
698
- * sidebar, and other locale-specific behavior.
699
- *
700
- * @example
701
- * ```ts
702
- * const enLocale: LocaleInterface = {
703
- * link: "/en/",
704
- * label: "English",
705
- * themeConfig: {
706
- * nav: [{ text: "Home", link: "/en/" }],
707
- * sidebar: { "/en/guide/": [{ text: "Intro", link: "/en/guide/" }] }
708
- * }
709
- * };
710
- * ```
711
- *
712
- * @since 2.0.0
713
- */
714
- export interface LocaleInterface extends LocaleSpecificConfig<ThemeInterface> {
715
- /**
716
- * The base path for the locale.
717
- *
718
- * @default undefined
719
- * @since 2.0.0
720
- */
721
- link?: string;
722
- /**
723
- * A human-readable label for the locale.
724
- *
725
- * @default undefined
726
- * @since 2.0.0
727
- */
728
- label?: string;
729
- }
730
1
  /**
731
- * Represents a mapping of locale codes to their corresponding locale configurations.
732
- *
733
- * @remarks
734
- * The keys are locale codes (e.g., `"en"`, `"de"`), and the values are `LocaleInterface` objects.
735
- * Useful for multi-language or localized documentation setups in VitePress.
736
- *
737
- * @example
738
- * ```ts
739
- * const locales: LocalesInterface = {
740
- * en: { link: "/en/", label: "English" },
741
- * de: { link: "/de/", label: "Deutsch" }
742
- * };
743
- * ```
744
- *
745
- * @see LocaleInterface
746
- * @since 2.0.0
747
- */
748
- export interface LocalesInterface {
749
- [key: string]: LocaleInterface;
750
- }
751
-
752
- /**
753
- * A generic type representing a function with any arguments and any return type.
754
- *
755
- * @remarks
756
- * This type is a very flexible function type, allowing any arguments of any type
757
- * and returning any type. Use with caution, as it bypasses TypeScript's type safety.
758
- *
759
- * @example
760
- * ```ts
761
- * const exampleFn: FunctionType = (a, b, c) => a + b + c;
762
- *
763
- * const anotherFn: FunctionType = (...args) => args.length;
764
- * ```
765
- *
766
- * @since 2.0.0
767
- */
768
- type FunctionType = (...args: Array<any>) => any;
769
- /**
770
- * Represents a generic constructor type.
771
- *
772
- * @remarks
773
- * This utility type describes a class constructor that accepts any number of arguments
774
- * and returns any instance type. Useful for mixins or generic factory functions.
775
- *
776
- * @example
777
- * ```ts
778
- * function WithTimestamp<TBase extends ConstructorType>(Base: TBase) {
779
- * return class extends Base {
780
- * timestamp = Date.now();
781
- * };
782
- * }
783
- * ```
784
- *
785
- * @since 2.0.0
786
- */
787
- type ConstructorType = new (...args: Array<any>) => any;
788
- /**
789
- * A type representing a function with a specific return type, arguments, and optional context.
790
- *
791
- * @typeParam Return - The type returned by the function. Defaults to `unknown`.
792
- * @typeParam Args - A tuple of argument types for the function. Defaults to an empty array `[]`.
793
- * @typeParam Context - The type of `this` context for the function. Defaults to `unknown`.
794
- *
795
- * @remarks
796
- * This type allows you to strongly type functions with a specific `this` context and arguments.
797
- *
798
- * @example
799
- * ```ts
800
- * const fn: FunctionLikeType<number, [string, string], { prefix: string }> = function(this, a, b) {
801
- * return (this.prefix + a + b).length;
802
- * }
803
- * ```
804
- *
805
- * @since 2.0.0
806
- */
807
- type FunctionLikeType<Return = unknown, Args extends Array<unknown> = [], Context = unknown> = (this: Context, ...args: Args) => Return;
808
- /**
809
- * A type representing a constructor with specific arguments and return type.
810
- *
811
- * @typeParam Return - The instance type returned by the constructor. Defaults to `unknown`.
812
- * @typeParam Args - A tuple of argument types for the constructor. Defaults to an empty array `[]`.
813
- *
814
- * @remarks
815
- * This type allows strong typing of class constructors with defined argument types.
816
- *
817
- * @example
818
- * ```ts
819
- * class MyClass {
820
- * constructor(public name: string) {}
821
- * }
822
- *
823
- * const ctor: ConstructorLikeType<MyClass, [string]> = MyClass;
824
- * const instance = new ctor("Hello");
825
- * ```
826
- *
827
- * @since 2.0.0
828
- */
829
- type ConstructorLikeType<Return = unknown, Args extends Array<unknown> = []> = new (...args: Args) => Return;
830
- /**
831
- * Recursively makes all properties of a type optional.
832
- *
833
- * @typeParam T - The type to transform into a deeply partial type.
834
- *
835
- * @remarks
836
- * This type is similar to TypeScript's built-in `Partial<T>`, but it applies recursively
837
- * to all nested objects. Arrays and other non-object types are left unchanged.
838
- *
839
- * Use `DeepPartialType` when you need to work with objects where only some properties,
840
- * including nested properties, may be provided.
841
- *
842
- * @example
843
- * ```ts
844
- * interface User {
845
- * name: string;
846
- * address: {
847
- * street: string;
848
- * city: string;
849
- * };
850
- * }
851
- *
852
- * const partialUser: DeepPartialType<User> = {
853
- * name: "Alice",
854
- * address: { city: "Wonderland" }
855
- * };
856
- * ```
857
- *
858
- * @since 2.0.0
859
- */
860
- type DeepPartialType<T> = T extends object ? {
861
- [P in keyof T]?: DeepPartialType<T[P]>;
862
- } : T;
863
- /**
864
- * Makes specific keys of a type required while leaving the rest unchanged.
865
- *
866
- * @typeParam T - The base type.
867
- * @typeParam K - The subset of keys from `T` that should be required.
868
- *
869
- * @remarks
870
- * This utility type is useful when you want to enforce that certain properties
871
- * of a type are mandatory, without affecting the optionality of other properties.
872
- * It works by combining:
873
- * - `Omit<T, K>` to remove the keys that will become required.
874
- * - `Required<Pick<T, K>>` to mark the specified keys as required.
875
- *
876
- * @example
877
- * ```ts
878
- * interface User {
879
- * id?: number;
880
- * name?: string;
881
- * email?: string;
882
- * }
883
- *
884
- * // Make 'id' and 'name' required, 'email' remains optional
885
- * type UserWithRequiredIdName = RequireKeysType<User, 'id' | 'name'>;
886
- *
887
- * const user: UserWithRequiredIdName = {
888
- * id: 1,
889
- * name: "Alice"
890
- * };
891
- * ```
892
- *
893
- * @since 2.0.0
894
- */
895
- type RequireKeysType<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
896
-
897
- /**
898
- * Import will remove at compile time
899
- */
900
- /**
901
- * Manages the state of a versioned VitePress documentation project.
902
- *
903
- * @remarks
904
- * The `StateModel` class is responsible for:
905
- * - Managing source and archive directories for versioned documentation.
906
- * - Initializing the VitePress configuration (`VitepressConfigInterface`) from
907
- * a provided {@link ConfigurationInterface}.
908
- * - Maintaining a list of documentation versions and a map of Markdown files per version.
909
- * - Ensuring the necessary directories exist and are initialized.
910
- *
911
- * This service is designed as a singleton, making it safe to inject across
912
- * your application using `@Injectable({ scope: 'singleton' })`.
913
- *
914
- * @example
915
- * ```ts
916
- * import { StateModel } from "@models/state.model";
917
- *
918
- * const state = new StateModel(config).init();
919
- * console.log(state.versionsList);
920
- * ```
921
- *
922
- * @since 2.0.0
923
- */
924
- declare class StateModel {
925
- readonly configuration: ConfigurationInterface;
926
- /**
927
- * The root path of the documentation project,
928
- * based on the current working directory and optional srcDir.
929
- *
930
- * @since 2.0.0
931
- */
932
- readonly root: string;
933
- /**
934
- * The name of the sources directory from which current content.
935
- *
936
- * @default `src`
937
- * @since 2.0.0
938
- */
939
- readonly sources: string;
940
- /**
941
- * The name of the archive directory where old versions are stored.
942
- *
943
- * @default `archive`
944
- * @since 2.0.0
945
- */
946
- readonly archive: string;
947
- /**
948
- * Full path to the `sources` directory.
949
- *
950
- * @since 2.0.0
951
- */
952
- readonly sourcesPath: string;
953
- /**
954
- * Full path to the `archive` directory.
955
- *
956
- * @since 2.0.0
957
- */
958
- readonly archivePath: string;
959
- /**
960
- * The `versions` configuration object for the plugin.
961
- *
962
- * @remarks
963
- * This property holds the currently active versions configuration
964
- * as defined in {@link VersionsConfigInterface}. It includes settings
965
- * like the current version, sources, archive, hooks, and version switcher.
966
- *
967
- * @see VersionsConfigInterface
968
- * @since 2.0.0
969
- */
970
- readonly versionsConfig: VersionsConfigInterface;
971
- /**
972
- * The VitePress configuration object crafted from the user-provided configuration,
973
- * with versioning support added.
974
- *
975
- * @remarks
976
- * This object is based on the user configuration and extended to include
977
- * locales, rewrites, and versioning-aware settings. It is typed as
978
- * {@link VitepressConfigInterface}.
979
- *
980
- * @see VitepressConfigInterface
981
- * @since 2.0.0
982
- */
983
- readonly vitepressConfig: VitepressConfigInterface;
984
- /**
985
- * List of all available documentation versions.
986
- *
987
- * @remarks
988
- * This array is populated during initialization (`init()`) by reading the archive
989
- * and sources directories. Each element is a version string (e.g., `"1.0"`, `"2.0"`).
990
- *
991
- * @since 2.0.0
992
- */
993
- readonly versionsList: Array<string>;
994
- /**
995
- * Maps locale keys to their effective base paths.
996
- *
997
- * @remarks
998
- * - Keys are the locale identifiers as defined in the user configuration
999
- * (e.g., `"de"`, `"root"`).
1000
- * - Values are the corresponding effective base paths or link prefixes
1001
- * used inside the generated VitePress config.
1002
- * - The `"root"` locale always maps to the default language of the site.
1003
- *
1004
- * This mapping is used internally to resolve and normalize locale-based
1005
- * routing for both source files and versioned archives.
1006
- *
1007
- * @example
1008
- * ```ts
1009
- * localesMap = {
1010
- * en: "root",
1011
- * de: "de"
1012
- * };
1013
- * ```
1014
- *
1015
- * @since 2.0.0
1016
- */
1017
- readonly localesMap: Record<string, string>;
1018
- /**
1019
- * Creates an instance of `StateModel`.
1020
- *
1021
- * @param configuration - Optional configuration object; defaults to {@link defaultConfiguration}.
1022
- *
1023
- * @throws Will throw an error if the sources directory does not exist.
1024
- *
1025
- * @remarks
1026
- * Initializes the state of the documentation project by:
1027
- * - Extracting `sources` and `archive` from the provided configuration.
1028
- * - Constructing full paths for `root`, `sourcesPath`, and `archivePath`.
1029
- * - Validating that the sources directory exists.
1030
- * - Ensuring the archive directory exists and creating a `.gitkeep` file if necessary.
1031
- * - Creating a VitePress configuration object with versioning support.
1032
- *
1033
- * @since 2.0.0
1034
- */
1035
- constructor(configuration?: ConfigurationInterface);
1036
- /**
1037
- * Initializes the state model by scanning archive directory and setting up locale configuration.
1038
- *
1039
- * @returns The current instance for method chaining.
1040
- *
1041
- * @remarks
1042
- * This method performs the initial setup sequence for a multi-version documentation system
1043
- * by discovering available versions and preparing the locale infrastructure. It executes
1044
- * three primary operations:
1045
- *
1046
- * 1. **Root Locale Initialization**: Sets up the root locale entry in {@link vitepressConfig.locales}
1047
- * with an empty theme configuration, establishing the foundation for all locale-specific settings
1048
- * 2. **Version Discovery**: Scans {@link archivePath} using {@link readdirSync} to identify all
1049
- * subdirectories, which represent available documentation versions. Each subdirectory name
1050
- * is added to {@link versionsList}
1051
- * 3. **Locale Map Setup**: Calls {@link initializeLocalesMap} to establish the locale mapping
1052
- * structure and populate versioned locale entries
1053
- *
1054
- * The archive directory structure is expected to contain version folders:
1055
- * ```
1056
- * archive/
1057
- * ├── v1.0/
1058
- * ├── v2.0/
1059
- * └── latest/
1060
- * ```
1061
- *
1062
- * Each subdirectory discovered becomes a version entry, enabling the system to generate
1063
- * versioned locale configurations and routing structures for multi-version documentation.
1064
- *
1065
- * The root locale is initialized first to ensure a consistent base exists before user-defined
1066
- * locale configurations are applied through {@link initializeLocalesMap}.
1067
- *
1068
- * Method chaining support allows for fluent initialization patterns, making it easy to
1069
- * combine multiple setup operations in a readable sequence.
1070
- *
1071
- * @example
1072
- * ```ts
1073
- * // Basic initialization
1074
- * const state = new StateModel(config);
1075
- * state.init();
1076
- *
1077
- * console.log(state.versionsList);
1078
- * // ['v1.0', 'v2.0', 'v3.0', 'latest']
1079
- *
1080
- * console.log(state.vitepressConfig.locales['root']);
1081
- * // { themeConfig: {} }
1082
- *
1083
- * // Method chaining pattern
1084
- * const state = new StateModel(config)
1085
- * .init();
1086
- *
1087
- * console.log(`Initialized with ${state.versionsList.length} versions`);
1088
- *
1089
- * // Use case: Dynamic version detection
1090
- * const config = {
1091
- * versionsConfig: {
1092
- * sources: 'src',
1093
- * archive: 'versions'
1094
- * },
1095
- * locales: {
1096
- * root: { lang: 'en-US', label: 'English' },
1097
- * '/de/': { lang: 'de-DE', label: 'Deutsch' }
1098
- * }
1099
- * };
1100
- *
1101
- * const state = new StateModel(config).init();
1102
- *
1103
- * // Archive structure:
1104
- * // versions/
1105
- * // ├── v1.0.0/
1106
- * // ├── v2.0.0/
1107
- * // └── latest/
1108
- *
1109
- * console.log(state.versionsList);
1110
- * // ['v1.0.0', 'v2.0.0']
1111
- *
1112
- * // Locale entries created for each version
1113
- * console.log(Object.keys(state.vitepressConfig.locales));
1114
- * // ['root', 'v1.0.0', 'v2.0.0', 'latest', '/de/', 'de/v1.0.0', 'de/v2.0.0']
1115
- *
1116
- * // Use case: Error handling
1117
- * try {
1118
- * const state = new StateModel(config).init();
1119
- * if (state.versionsList.length === 0) {
1120
- * console.warn('No versions found in archive');
1121
- * }
1122
- * } catch (error) {
1123
- * console.error('Failed to initialize state:', error);
1124
- * }
1125
- * ```
1126
- *
1127
- * @see archivePath
1128
- * @see readdirSync
1129
- * @see versionsList
1130
- * @see vitepressConfig
1131
- * @see initializeLocalesMap
1132
- *
1133
- * @since 2.0.0
1134
- */
1135
- init(): this;
2
+ * This file was automatically generated by xBuild.
3
+ * DO NOT EDIT MANUALLY.
4
+ */
5
+
6
+ import { DefaultTheme, LocaleSpecificConfig, UserConfig } from 'vitepress';
7
+
8
+ export * from 'vitepress';
9
+
10
+ /**
11
+ * Represents a sidebar item from VitePress with optional versioning control.
12
+ *
13
+ * @remarks
14
+ * Extends VitePress's {@link DefaultTheme.SidebarItem} type by adding an optional
15
+ * `skipVersioning` flag. Use this flag to indicate that the item should not be
16
+ * automatically versioned in multi-version documentation setups.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const item: SidebarItemType = {
21
+ * text: "Introduction",
22
+ * link: "/guide/introduction",
23
+ * skipVersioning: true
24
+ * };
25
+ * ```
26
+ *
27
+ * @since 2.0.0
28
+ */
29
+ type SidebarItemType = DefaultTheme.SidebarItem & {
1136
30
  /**
1137
- * Initializes the locale entries in the VitePress configuration and builds a mapping
1138
- * of locales to their links for all versions.
31
+ * Determines whether this sidebar item should be excluded from automatic versioning.
1139
32
  *
33
+ * @default false
1140
34
  * @remarks
1141
- * - Adds a `root` locale entry.
1142
- * - Copies all user-defined locales into the VitePress config.
1143
- * - Populates `localesMap` with locale keys and their corresponding links (or folder names).
1144
- * - Ensures that for each documentation version, a locale entry exists in the VitePress config.
1145
- * - Handles both root and non-root locales, creating versioned paths automatically.
35
+ * When `true`, this sidebar item will remain consistent across all documentation versions.
1146
36
  *
1147
37
  * @since 2.0.0
1148
38
  */
1149
- private initializeLocalesMap;
39
+ skipVersioning?: boolean;
40
+ };
41
+ /**
42
+ * Represents a sidebar group containing multiple sidebar items.
43
+ *
44
+ * @remarks
45
+ * Each group has a `base` path and an array of sidebar items.
46
+ * Useful for organizing related pages under a common path prefix.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const group: SidebarGroupInterface = {
51
+ * base: "/guide/",
52
+ * items: [
53
+ * { text: "Introduction", link: "/guide/introduction" },
54
+ * { text: "Setup", link: "/guide/setup" }
55
+ * ]
56
+ * };
57
+ * ```
58
+ *
59
+ * @see SidebarItemType
60
+ * @since 2.0.0
61
+ */
62
+ interface SidebarGroupInterface {
1150
63
  /**
1151
- * Ensures that the archive directory exists.
1152
- *
1153
- * @param path - The path to the archive directory.
64
+ * The base path for the sidebar group.
1154
65
  *
1155
66
  * @remarks
1156
- * - If the directory does not exist, it is created.
1157
- * - A `.gitkeep` file is also added to ensure the directory is tracked by Git.
67
+ * This path is prepended to all child sidebar items within the group.
68
+ * Typically corresponds to the folder containing the group’s pages, e.g., `"en"`.
1158
69
  *
1159
70
  * @since 2.0.0
1160
71
  */
1161
- private makeArchiveDirectory;
72
+ base: string;
1162
73
  /**
1163
- * Creates a VitePress configuration object from the user-provided configuration.
1164
- *
1165
- * @returns A `VitepressConfigInterface` object with versioning support added.
74
+ * The list of sidebar items within this group.
1166
75
  *
1167
76
  * @remarks
1168
- * - Copies all configuration properties except for `locales`, `rewrites`, `themeConfig`, and `versionsConfig`.
1169
- * - Initializes excluded properties (except `versionsConfig`) with empty objects.
1170
- * - Returns a configuration object typed as {@link VitepressConfigInterface}, ready for VitePress usage.
77
+ * Each item is typed as {@link SidebarItemType}, which may include links,
78
+ * collapsible sections, or other sidebar elements.
1171
79
  *
1172
- * @see VitepressConfigInterface
1173
80
  * @since 2.0.0
1174
81
  */
1175
- private createVitepressConfig;
82
+ items: Array<SidebarItemType>;
1176
83
  }
1177
-
1178
- /**
1179
- * Import will remove at compile time
1180
- */
1181
84
  /**
1182
- * Extracts the language code from a locale string.
1183
- *
1184
- * @param locale - The locale string to parse (e.g., 'en-US', 'fr_CA', 'zh-Hans-CN').
1185
- * @returns The language code portion of the locale (e.g., 'en', 'fr', 'zh').
1186
- *
1187
- * @remarks
1188
- * This function parses a locale string and returns only the primary language code,
1189
- * discarding region, script, and variant information. It handles both standard
1190
- * separators used in locale strings:
1191
- * - Hyphen (`-`): BCP 47 standard (e.g., 'en-US', 'zh-Hans-CN')
1192
- * - Underscore (`_`): POSIX/Java standard (e.g., 'en_US', 'pt_BR')
1193
- *
1194
- * The language code is always the first component of a locale identifier and
1195
- * represents the base language without regional or script variations.
1196
- *
1197
- * Common use cases:
1198
- * - Fallback language selection when a specific locale is unavailable
1199
- * - Grouping locales by language family
1200
- * - Simplifying locale matching for translations
1201
- * - Language detection without regional specificity
1202
- * - API requests that only accept language codes
1203
- *
1204
- * Locale format examples:
1205
- * - Language only: 'en', 'fr', 'ja'
1206
- * - Language + Region: 'en-US', 'fr-CA', 'pt-BR'
1207
- * - Language + Script + Region: 'zh-Hans-CN', 'zh-Hant-TW'
1208
- * - POSIX format: 'en_US', 'de_DE', 'es_MX'
1209
- *
1210
- * @example
1211
- * ```ts
1212
- * // BCP 47 format with region
1213
- * console.log(getLanguageOnly('en-US')); // 'en'
1214
- * console.log(getLanguageOnly('fr-CA')); // 'fr'
1215
- * console.log(getLanguageOnly('pt-BR')); // 'pt'
1216
- *
1217
- * // POSIX format with underscore
1218
- * console.log(getLanguageOnly('en_GB')); // 'en'
1219
- * console.log(getLanguageOnly('de_DE')); // 'de'
1220
- *
1221
- * // Complex locale with script
1222
- * console.log(getLanguageOnly('zh-Hans-CN')); // 'zh'
1223
- * console.log(getLanguageOnly('zh-Hant-TW')); // 'zh'
1224
- *
1225
- * // Language code only (no separator)
1226
- * console.log(getLanguageOnly('ja')); // 'ja'
1227
- * console.log(getLanguageOnly('ko')); // 'ko'
1228
- *
1229
- * // Use case: Fallback language selection
1230
- * const userLocale = 'es-MX';
1231
- * const language = getLanguageOnly(userLocale); // 'es'
1232
- * const translations = loadTranslations(language); // Load Spanish translations
1233
- * ```
1234
- *
1235
- * @since 2.0.5
1236
- */
1237
- declare function getLanguageOnly(locale: string): string;
1238
- /**
1239
- * Parses and configures locale settings for a multi-version, multi-language documentation site.
85
+ * Represents a mapping of paths to sidebar items or groups.
1240
86
  *
1241
87
  * @remarks
1242
- * This function orchestrates the complete locale configuration process by combining
1243
- * user-defined locale settings with version information to generate a comprehensive
1244
- * locale map. It handles both root and non-root locales across multiple documentation
1245
- * versions.
1246
- *
1247
- * The function operates on injected state from {@link StateModel} and processes:
1248
- * - {@link versionsList}: Available documentation versions (e.g., ['v1', 'v2', 'v3'])
1249
- * - {@link vitepressConfig}: VitePress configuration containing locale definitions
1250
- * - {@link configuration}: User-provided locale configurations
1251
- * - {@link localesMap}: Mapping between locale keys and indices
1252
- *
1253
- * Processing workflow:
1254
- * 1. Injects application state to access configuration data
1255
- * 2. Determines if 'root' key exists in user-provided locales
1256
- * 3. Iterates through each locale in the locale map
1257
- * 4. Creates sanitized base locale using {@link createSanitizedLocale} (removes nav/sidebar)
1258
- * 5. Sets up the root locale entry with a generated link via {@link generateLocaleLink}
1259
- * 6. Creates versioned locale entries for each version using {@link createVersionedLocale}
1260
- *
1261
- * Locale key structure:
1262
- * - Root locale: Direct version keys (e.g., 'v1', 'v2')
1263
- * - Non-root locales: Prefixed version keys (e.g., 'fr/v1', 'es/v2')
1264
- *
1265
- * The sanitization process removes navigation structures to reduce memory overhead
1266
- * and prevent duplication of large theme configuration objects across versions.
88
+ * The keys are path strings, and the values can be either:
89
+ * - An array of sidebar items (`SidebarItemType[]`), or
90
+ * - A sidebar group (`SidebarGroupInterface`).
1267
91
  *
1268
92
  * @example
1269
93
  * ```ts
1270
- * // Configuration state before parsing
1271
- * const state = {
1272
- * versionsList: ['v1', 'v2'],
1273
- * localesMap: {
1274
- * '/': 'root',
1275
- * '/fr/': 'fr',
1276
- * '/es/': 'es'
1277
- * },
1278
- * configuration: {
1279
- * locales: {
1280
- * root: {
1281
- * lang: 'en-US',
1282
- * label: 'English',
1283
- * themeConfig: { nav: [...], sidebar: {...} }
1284
- * },
1285
- * fr: {
1286
- * lang: 'fr-CA',
1287
- * label: 'Français',
1288
- * themeConfig: { nav: [...], sidebar: {...} }
1289
- * }
1290
- * }
1291
- * }
1292
- * };
1293
- *
1294
- * parseLocale();
1295
- *
1296
- * // Result in vitepressConfig.locales:
1297
- * // {
1298
- * // 'root': { lang: 'en-US', label: 'English', link: '/', ... },
1299
- * // 'v1': { lang: 'en-US', label: ' ', link: '/', ... },
1300
- * // 'v2': { lang: 'en-US', label: ' ', link: '/', ... },
1301
- * // 'fr': { lang: 'fr-CA', label: 'Français', link: '/fr/', ... },
1302
- * // 'fr/v1': { lang: 'fr-CA', label: ' ', link: '/fr/', ... },
1303
- * // 'fr/v2': { lang: 'fr-CA', label: ' ', link: '/fr/', ... }
1304
- * // }
1305
- *
1306
- * // Use case: Multi-version documentation with multiple languages
1307
- * const state = inject(StateModel);
1308
- * state.versionsList = ['latest', 'v3', 'v2'];
1309
- * state.configuration.locales = {
1310
- * '/': { lang: 'en-US', label: 'English' },
1311
- * '/de/': { lang: 'de-DE', label: 'Deutsch' },
1312
- * '/ja/': { lang: 'ja-JP', label: '日本語' }
94
+ * const sidebar: PathSidebarInterface = {
95
+ * guide: [
96
+ * { text: "Intro", link: "/guide/intro" },
97
+ * { text: "Setup", link: "/guide/setup" }
98
+ * ],
99
+ * api: { base: "/api/", items: [ { text: "Functions", link: "/api/functions" } ] }
1313
100
  * };
1314
- *
1315
- * parseLocale();
1316
- * // Generates 12 locale entries (3 versions × 3 languages + 3 base locales)
1317
101
  * ```
1318
102
  *
1319
- * @see StateModel
1320
- * @see generateLocaleLink
1321
- * @see createSanitizedLocale
1322
- * @see createVersionedLocale
1323
- *
1324
- * @since 2.0.5
1325
- */
1326
- declare function parseLocale(): void;
1327
-
1328
- /**
1329
- * Import will remove at compile time
1330
- */
1331
- /**
1332
- * A collection of singleton instances for injectable classes.
1333
- *
1334
- * @remarks
1335
- * This map stores instances of classes marked as `singleton` in `@Injectable` metadata.
1336
- * It ensures that only one instance exists for the lifetime of the application.
103
+ * @see SidebarItemType
104
+ * @see SidebarGroupInterface
1337
105
  *
1338
- * @see ConstructorType
1339
106
  * @since 2.0.0
1340
107
  */
1341
- declare const SINGLETONS: Map<ConstructorType, unknown>;
108
+ interface PathSidebarInterface {
109
+ [path: string]: Array<SidebarItemType> | SidebarGroupInterface;
110
+ }
1342
111
  /**
1343
- * Stores metadata for all classes marked with the `@Injectable` decorator.
112
+ * Represents the overall sidebar configuration.
1344
113
  *
1345
114
  * @remarks
1346
- * The metadata includes scope, factory function, and provider dependencies.
1347
- *
1348
- * @see Injectable
1349
- * @since 2.0.0
1350
- */
1351
- declare const INJECTABLES: Map<ConstructorType, InjectableOptionsInterface<ConstructorType>>;
1352
- /**
1353
- * Type guard to check if a provider uses a class.
1354
- *
1355
- * @param provider - The provider to check.
1356
- * @returns True if the provider is a {@link ProviderUseClassInterface}.
1357
- *
1358
- * @see ProviderUseClassInterface
1359
- * @since 2.0.0
1360
- */
1361
- declare function isProviderUseClass(provider: unknown): provider is ProviderUseClassInterface;
1362
- /**
1363
- * Type guard to check if a provider uses a factory function.
1364
- *
1365
- * @param provider - The provider to check.
1366
- * @returns True if the provider is a {@link ProviderUseFactoryInterface}.
1367
- *
1368
- * @see ProviderUseFactoryInterface
1369
- * @since 2.0.0
1370
- */
1371
- declare function isProviderUseFactory(provider: unknown): provider is ProviderUseFactoryInterface;
1372
- /**
1373
- * Type guard to check if a provider uses a value.
1374
- *
1375
- * @param provider - The provider to check.
1376
- * @returns True if the provider is a {@link ProviderUseValueInterface}.
1377
- *
1378
- * @see ProviderUseValueInterface
1379
- * @since 2.0.0
1380
- */
1381
- declare function isProviderUseValue(provider: unknown): provider is ProviderUseValueInterface;
1382
- /**
1383
- * Marks a class as injectable, optionally providing metadata.
1384
- *
1385
- * @param options - Optional configuration for the injectable class.
115
+ * Can be defined in one of two ways:
116
+ * - As a flat array of {@link SidebarItemType}, or
117
+ * - As a path-based mapping using {@link PathSidebarInterface}.
1386
118
  *
1387
- * @remarks
1388
- * The `@Injectable` decorator allows classes to be automatically instantiated
1389
- * and injected with dependencies using the `inject` function.
119
+ * This flexibility allows defining either a single global sidebar
120
+ * or multiple sidebars scoped to different route prefixes.
1390
121
  *
1391
122
  * @example
123
+ * Flat sidebar:
1392
124
  * ```ts
1393
- * @Injectable({ scope: 'singleton' })
1394
- * class MyService {}
1395
- *
1396
- * const instance = inject(MyService);
125
+ * const sidebar: SidebarType = [
126
+ * { text: "Home", link: "/" },
127
+ * { text: "Guide", link: "/guide/" }
128
+ * ];
1397
129
  * ```
1398
130
  *
1399
- * @see InjectableOptionsInterface
1400
- * @since 2.0.0
1401
- */
1402
- declare function Injectable<T extends ConstructorType = ConstructorType>(options?: InjectableOptionsInterface<T>): (target: T) => void;
1403
- /**
1404
- * Converts an array of providers into constructor arguments for injection.
1405
- *
1406
- * @param providers - An optional array of providers to resolve.
1407
- * @param args - Optional initial arguments to prepend before resolving providers.
1408
- * @returns An array of resolved arguments including the results from providers.
1409
- *
1410
- * @remarks
1411
- * This function iterates over the provided `ProvidersType` array and converts each provider
1412
- * into its resolved value. It supports class providers, factory providers, value providers,
1413
- * and direct constructor functions. The returned array can be used to construct instances
1414
- * with dependencies injected in the correct order.
1415
- *
1416
131
  * @example
132
+ * Path-based sidebars:
1417
133
  * ```ts
1418
- * const args = providersIntoArgs([{ useValue: 42 }, { useFactory: () => 'hello' }]);
1419
- * // args = [42, 'hello']
134
+ * const sidebar: SidebarType = {
135
+ * "/guide/": [
136
+ * { text: "Introduction", link: "/guide/introduction" }
137
+ * ],
138
+ * "/api/": [
139
+ * { text: "API Reference", link: "/api/" }
140
+ * ]
141
+ * };
1420
142
  * ```
1421
143
  *
1422
- * @see isProviderUseClass
1423
- * @see isProviderUseValue
1424
- * @see isProviderUseFactory
144
+ * @see SidebarItemType
145
+ * @see PathSidebarInterface
1425
146
  *
1426
147
  * @since 2.0.0
1427
148
  */
1428
- declare function providersIntoArgs(providers?: ProvidersType, args?: Array<unknown>): Array<unknown>;
149
+ type SidebarType = Array<SidebarItemType> | PathSidebarInterface;
1429
150
  /**
1430
- * Resolves and instantiates a class with its dependencies.
1431
- *
1432
- * @param token - The constructor function or class to instantiate.
1433
- * @param args - Optional arguments to pass to the constructor, which can override
1434
- * or supplement provider-resolved values.
1435
- * @returns An instance of the class with all dependencies injected.
151
+ * Represents a mapping of paths to sidebar item arrays.
1436
152
  *
1437
153
  * @remarks
1438
- * The `inject` function looks up metadata for the class marked with `@Injectable`.
1439
- * It resolves all providers recursively using `providersIntoArgs`. If the class is
1440
- * marked as a `singleton`, the same instance will be returned on further calls.
154
+ * This structure allows defining sidebars on a per-path basis,
155
+ * where each key is a route prefix (e.g., `"/guide/"`) and its value
156
+ * is an array of {@link SidebarItemType}.
1441
157
  *
1442
158
  * @example
1443
159
  * ```ts
1444
- * @Injectable({ scope: 'singleton' })
1445
- * class MyService {}
1446
- *
1447
- * const instance = inject(MyService);
160
+ * const sidebars: SidebarObjectType = {
161
+ * "/guide/": [
162
+ * { text: "Introduction", link: "/guide/introduction" },
163
+ * { text: "Setup", link: "/guide/setup" }
164
+ * ],
165
+ * "/api/": [
166
+ * { text: "API Reference", link: "/api/" }
167
+ * ]
168
+ * };
1448
169
  * ```
1449
170
  *
1450
- * @see Injectable
1451
- * @see providersIntoArgs
1452
- *
171
+ * @see SidebarItemType
1453
172
  * @since 2.0.0
1454
173
  */
1455
- declare function inject<T, Args extends Array<unknown>>(token: ConstructorLikeType<T, Args>, ...args: Partial<Args>): T;
174
+ type SidebarObjectType = Record<string, Array<SidebarItemType | SidebarGroupInterface>>;
1456
175
  /**
1457
- * Forces the instantiation of a class, bypassing any existing singleton instance.
1458
- *
1459
- * @param token - The constructor function or class to instantiate.
1460
- * @param args - Optional arguments to pass to the constructor, which can override
1461
- * or supplement provider-resolved values.
1462
- * @returns A new instance of the class, even if a singleton instance already exists.
176
+ * Represents a locale-specific configuration for a VitePress site.
1463
177
  *
1464
178
  * @remarks
1465
- * Unlike the `inject` function, `forceInject` will delete any existing singleton
1466
- * instance for the given class before creating a new one. This is useful when you
1467
- * need a fresh instance regardless of the singleton scope.
1468
- *
1469
- * @example
1470
- * ```ts
1471
- * @Injectable({ scope: 'singleton' })
1472
- * class MyService {}
1473
- *
1474
- * const freshInstance = forceInject(MyService);
1475
- * ```
1476
- *
1477
- * @see inject
1478
- * @since 2.0.0
1479
- */
1480
- declare function forceInject<T, Args extends Array<unknown>>(token: ConstructorLikeType<T, Args>, ...args: Partial<Args>): T;
1481
-
1482
- /**
1483
- * Import will remove at compile time
1484
- */
1485
- /**
1486
- * Represents a provider that uses a factory function to generate a value.
179
+ * Extends VitePress's `LocaleSpecificConfig` with a custom {@link ThemeInterface}.
180
+ * Adds optional properties:
181
+ * - `link` — the base URL or path for this locale.
182
+ * - `label` — a human-readable label for the locale (e.g., "English", "Deutsch").
1487
183
  *
1488
- * @remarks
1489
- * A factory provider can also declare dependencies through `providers`, which
1490
- * will be resolved and passed to the factory function.
184
+ * This interface allows configuring per-locale theme settings, navigation,
185
+ * sidebar, and other locale-specific behavior.
1491
186
  *
1492
187
  * @example
1493
188
  * ```ts
1494
- * const factoryProvider: ProviderUseFactoryInterface = {
1495
- * useFactory: (dep: MyService) => new AnotherService(dep),
1496
- * providers: [MyService]
189
+ * const enLocale: LocaleInterface = {
190
+ * link: "/en/",
191
+ * label: "English",
192
+ * themeConfig: {
193
+ * nav: [{ text: "Home", link: "/en/" }],
194
+ * sidebar: { "/en/guide/": [{ text: "Intro", link: "/en/guide/" }] }
195
+ * }
1497
196
  * };
1498
197
  * ```
1499
198
  *
1500
- * @see ProvidersType
1501
199
  * @since 2.0.0
1502
200
  */
1503
- interface ProviderUseFactoryInterface {
1504
- useFactory: FunctionType;
1505
- providers?: ProvidersType;
201
+ interface LocaleInterface extends LocaleSpecificConfig<ThemeInterface> {
202
+ /**
203
+ * The base path for the locale.
204
+ *
205
+ * @default undefined
206
+ * @since 2.0.0
207
+ */
208
+ link?: string;
209
+ /**
210
+ * A human-readable label for the locale.
211
+ *
212
+ * @default undefined
213
+ * @since 2.0.0
214
+ */
215
+ label?: string;
1506
216
  }
1507
217
  /**
1508
- * Represents a provider that uses a class constructor to generate a value.
218
+ * Represents a mapping of locale codes to their corresponding locale configurations.
1509
219
  *
1510
220
  * @remarks
1511
- * Class providers can also declare dependencies through `providers`, which
1512
- * will be injected when the class is instantiated.
221
+ * The keys are locale codes (e.g., `"en"`, `"de"`), and the values are `LocaleInterface` objects.
222
+ * Useful for multi-language or localized documentation setups in VitePress.
1513
223
  *
1514
224
  * @example
1515
225
  * ```ts
1516
- * const classProvider: ProviderUseClassInterface = {
1517
- * useClass: MyService,
1518
- * providers: [DependencyService]
226
+ * const locales: LocalesInterface = {
227
+ * en: { link: "/en/", label: "English" },
228
+ * de: { link: "/de/", label: "Deutsch" }
1519
229
  * };
1520
230
  * ```
1521
231
  *
1522
- * @see ProvidersType
232
+ * @see LocaleInterface
1523
233
  * @since 2.0.0
1524
234
  */
1525
- interface ProviderUseClassInterface {
1526
- useClass: ConstructorType;
1527
- providers?: ProvidersType;
235
+ interface LocalesInterface {
236
+ [key: string]: LocaleInterface;
1528
237
  }
1529
238
  /**
1530
- * Represents a provider that uses a static value.
239
+ * Represents the configuration interface for a VitePress theme.
1531
240
  *
1532
241
  * @remarks
1533
- * Value providers do not have dependencies and are injected as-is.
242
+ * Extends VitePress's {@link DefaultTheme.Config} type but overrides the
243
+ * `nav` and `sidebar` properties to use custom, strongly typed interfaces
244
+ * ({@link NavType} and {@link SidebarType}).
245
+ *
246
+ * This allows for enhanced type safety and additional functionality such as
247
+ * versioning control in navigation and sidebar items.
1534
248
  *
1535
249
  * @example
1536
250
  * ```ts
1537
- * const valueProvider: ProviderUseValueInterface = {
1538
- * useValue: 42
251
+ * const themeConfig: ThemeInterface = {
252
+ * nav: [
253
+ * { text: "Home", link: "/" },
254
+ * { text: "Docs", items: [{ text: "Guide", link: "/guide/" }] }
255
+ * ],
256
+ * sidebar: {
257
+ * guide: [
258
+ * { text: "Introduction", link: "/guide/introduction" },
259
+ * { text: "Setup", link: "/guide/setup" }
260
+ * ]
261
+ * },
262
+ * lastUpdated: true
1539
263
  * };
1540
264
  * ```
1541
265
  *
1542
- * @see ProvidersType
1543
266
  * @since 2.0.0
1544
267
  */
1545
- interface ProviderUseValueInterface {
1546
- useValue: unknown;
268
+ interface ThemeInterface extends Omit<DefaultTheme.Config, 'nav' | 'sidebar'> {
269
+ /**
270
+ * Navigation structure of the site.
271
+ *
272
+ * @remarks
273
+ * Typed as {@link NavType}, which allows versioning-aware navigation items.
274
+ *
275
+ * @since 2.0.0
276
+ */
277
+ nav?: NavType;
278
+ /**
279
+ * Sidebar structure of the site.
280
+ *
281
+ * @remarks
282
+ * Typed as {@link SidebarType}, which allows versioning-aware sidebar items.
283
+ *
284
+ * @since 2.0.0
285
+ */
286
+ sidebar?: SidebarType;
1547
287
  }
1548
288
  /**
1549
- * Type for all possible providers that can be injected.
289
+ * Represents a component-based navigation item from VitePress.
1550
290
  *
1551
291
  * @remarks
1552
- * Providers can be:
1553
- * - A class constructor (`ConstructorType`)
1554
- * - A factory provider (`ProviderUseFactoryInterface`)
1555
- * - A class provider (`ProviderUseClassInterface`)
1556
- * - A value provider (`ProviderUseValueInterface`)
1557
- *
1558
- * @example
1559
- * ```ts
1560
- * const providers: ProvidersType = [
1561
- * MyService,
1562
- * { useFactory: () => new AnotherService() },
1563
- * { useValue: 42 }
1564
- * ];
1565
- * ```
1566
- *
1567
- * @see ProviderUseClassInterface
1568
- * @see ProviderUseValueInterface
1569
- * @see ProviderUseFactoryInterface
292
+ * This type is directly imported from VitePress and allows using custom
293
+ * Vue components as navigation items.
1570
294
  *
1571
295
  * @since 2.0.0
1572
296
  */
1573
- type ProvidersType = Array<ConstructorType | ProviderUseFactoryInterface | ProviderUseClassInterface | ProviderUseValueInterface>;
297
+ type NavItemComponentType = DefaultTheme.NavItemComponent;
1574
298
  /**
1575
- * Options for configuring an injectable class.
299
+ * Represents a navigation item with a link.
1576
300
  *
1577
301
  * @remarks
1578
- * - `scope`: Determines whether the class should behave as a singleton or transient.
1579
- * - `factory`: Optional factory function to instantiate the class.
1580
- * - `providers`: Optional dependencies to inject when creating the instance.
302
+ * Extends VitePress's {@link DefaultTheme.NavItemWithLink} with an optional
303
+ * `skipVersioning` flag. Use `skipVersioning` to indicate that this
304
+ * navigation item should not be automatically versioned in multi-version
305
+ * documentation setups.
1581
306
  *
1582
307
  * @example
1583
308
  * ```ts
1584
- * @Injectable({ scope: 'singleton', providers: [DepService] })
1585
- * class MyService {}
309
+ * const navItem: NavItemWithLinkType = {
310
+ * text: "Home",
311
+ * link: "/",
312
+ * skipVersioning: true
313
+ * };
1586
314
  * ```
1587
315
  *
1588
- * @see ProvidersType
1589
316
  * @since 2.0.0
1590
317
  */
1591
- interface InjectableOptionsInterface<T extends ConstructorType = ConstructorType> {
1592
- scope?: 'singleton' | 'transient';
1593
- factory?: FunctionLikeType<InstanceType<T>, ConstructorParameters<T>>;
1594
- providers?: ProvidersType;
1595
- }
1596
-
1597
- /**
1598
- * Import will remove at compile time
1599
- */
318
+ type NavItemWithLinkType = DefaultTheme.NavItemWithLink & {
319
+ /**
320
+ * Indicates whether this navigation item should be excluded from automatic versioning.
321
+ *
322
+ * @default false
323
+ * @remarks
324
+ * When set to `true`, this item will remain the same across all documentation versions.
325
+ *
326
+ * @since 2.0.0
327
+ */
328
+ skipVersioning?: boolean;
329
+ };
1600
330
  /**
1601
- * Default configuration object for the `versions` system.
331
+ * Represents a navigation item with children.
1602
332
  *
1603
333
  * @remarks
1604
- * Provides a baseline implementation of {@link ConfigurationInterface}.
1605
- * This includes:
1606
- * - Empty `locales` and `rewrites` mappings.
1607
- * - A `versionsConfig` with:
1608
- * - `current` set to `"latest"`.
1609
- * - `sources` pointing to `"src"`.
1610
- * - `archive` pointing to `"archive"`.
1611
- * - `hooks.rewritesHook` bound to the default {@link rewritesHook}.
1612
- * - A `versionSwitcher` enabled with label `"Switch Version"` and
1613
- * `includeCurrentVersion` set to `true`.
1614
- *
1615
- * This default setup can be extended or overridden as needed when
1616
- * customizing your documentation site.
334
+ * Extends VitePress's {@link DefaultTheme.NavItemWithChildren} but requires
335
+ * `items` to be an array of navigation items of various types:
336
+ * - {@link NavItemComponentType}
337
+ * - {@link NavItemWithLinkType}
338
+ * - Recursively, {@link NavItemWithChildrenType}
339
+ *
340
+ * Supports the optional `skipVersioning` flag to exclude the item from automatic
341
+ * versioning in multi-version documentation setups.
1617
342
  *
1618
343
  * @example
1619
344
  * ```ts
1620
- * import { defaultConfiguration } from "@config/default.configuration";
1621
- *
1622
- * export default {
1623
- * ...defaultConfiguration,
1624
- * locales: {
1625
- * en: { link: "/en/", label: "English" }
1626
- * }
345
+ * const nav: NavItemWithChildrenType = {
346
+ * text: "Docs",
347
+ * items: [
348
+ * { text: "Guide", link: "/guide/" },
349
+ * {
350
+ * text: "API",
351
+ * items: [
352
+ * { text: "Functions", link: "/api/functions" }
353
+ * ]
354
+ * }
355
+ * ],
356
+ * skipVersioning: true
1627
357
  * };
1628
358
  * ```
1629
359
  *
1630
360
  * @since 2.0.0
1631
361
  */
1632
- declare const defaultConfiguration: ConfigurationInterface;
1633
-
1634
- /**
1635
- * imports
1636
- */
362
+ type NavItemWithChildrenType = Omit<DefaultTheme.NavItemWithChildren, 'items'> & {
363
+ /**
364
+ * Child navigation items for this item.
365
+ *
366
+ * @remarks
367
+ * Can include standard components, link items, or nested child items.
368
+ *
369
+ * @since 2.0.0
370
+ */
371
+ items: Array<NavItemComponentType | NavItemWithChildrenType | NavItemWithLinkType>;
372
+ /**
373
+ * Indicates whether this navigation item should be excluded from automatic versioning.
374
+ *
375
+ * @default false
376
+ * @remarks
377
+ * When set to `true`, this item and all its children remain unchanged across versions.
378
+ *
379
+ * @since 2.0.0
380
+ */
381
+ skipVersioning?: boolean;
382
+ };
1637
383
  /**
1638
- * Rewrites a documentation source path using version and locale.
384
+ * Represents a single navigation item of any type.
1639
385
  *
1640
386
  * @remarks
1641
- * This implementation joins the `version`, `locale`, and original `source`
1642
- * into a normalized POSIX-style path. It is commonly used to generate
1643
- * consistent URLs or filesystem paths for versioned and localized docs.
1644
- *
1645
- * @param source - The original file path or content identifier.
1646
- * @param version - The version string of the documentation (e.g., `"1.2.0"`).
1647
- * @param locale - The locale code (e.g., `"en"`, `"de"`).
1648
- *
1649
- * @returns The rewritten path string in the format `version/locale/source`.
1650
- *
1651
- * @example
1652
- * ```ts
1653
- * rewritesHook("guide/intro.md", "v2.0.0", "en");
1654
- * // → "en/v2.0.0/guide/intro.md"
1655
- * ```
387
+ * Can be a component, a link, or a navigation item with children.
1656
388
  *
1657
389
  * @since 2.0.0
1658
390
  */
1659
- declare function rewritesHook(source: string, version: string, locale: string): string;
391
+ type NavItemType = NavItemComponentType | NavItemWithLinkType | NavItemWithChildrenType;
1660
392
  /**
1661
- * Parses all documentation routes and generates rewritten paths for versioned and localized files.
393
+ * Represents a record of named navigation groups.
1662
394
  *
1663
395
  * @remarks
1664
- * - Iterates through the `fileMap` of the `StateModel` to process all Markdown files.
1665
- * - Determines the correct locale for each file using `localesMap`.
1666
- * - Uses the `rewritesHook` from `versionsConfig.hooks` to generate the versioned and localized path.
1667
- * - Populates the `vitepressConfig.rewrites` object with the mapping of original paths to rewritten paths.
396
+ * - Each key in the record is a group identifier (commonly a section name or locale).
397
+ * - Each value is an array of {@link NavItemType}, which can include links, components,
398
+ * or nested navigation structures.
399
+ * - Useful for organizing navigation into multiple top-level groups instead of a single array.
1668
400
  *
1669
401
  * @example
1670
402
  * ```ts
1671
- * parseRoutesComponent();
1672
- * console.log(state.vitepressConfig.rewrites);
1673
- * // → {
1674
- * "src/en/index.md": "en/index.md",
1675
- * "src/de/index.md": "index.md",
1676
- * "archive/x0.0.1/en/index.md": "x0.0.1/en/index.md"
1677
- * ...
1678
- * }
403
+ * const nav: NavObjectType = {
404
+ * root: [
405
+ * { text: "Home", link: "/" },
406
+ * { text: "Guide", link: "/guide/" }
407
+ * ],
408
+ * 'v1.0.0': [
409
+ * { text: "Functions", link: "/api/functions" },
410
+ * { text: "Classes", link: "/api/classes" }
411
+ * ]
412
+ * };
1679
413
  * ```
1680
414
  *
1681
415
  * @since 2.0.0
1682
416
  */
1683
- declare function parseRoutesComponent(): void;
1684
-
1685
- /**
1686
- * Import will remove at compile time
1687
- */
417
+ type NavObjectType = Record<string, Array<NavItemType>>;
1688
418
  /**
1689
- * Type guard to check if a navigation item has children.
1690
- *
1691
- * @param item - The navigation item to test.
1692
- * @returns `true` if the item is a {@link NavItemWithChildrenType}, `false` otherwise.
419
+ * Represents the navigation structure.
1693
420
  *
1694
421
  * @remarks
1695
- * - This function checks for the presence of an `item` property that is an array.
1696
- * - Use this type guard to safely access child navigation items when iterating
1697
- * or transforming navigation trees.
1698
- *
1699
- * @example
1700
- * ```ts
1701
- * const item: NavItemType = { text: "Docs", items: [{ text: "Guide", link: "/guide/" }] };
1702
- * if (isNavItemWithChildren(item)) {
1703
- * console.log(item.items); // Safe to access
1704
- * }
1705
- * ```
422
+ * Can be either:
423
+ * - An array of navigation items (`NavItemType[]`), or
424
+ * - A record mapping strings (e.g., section names) to arrays of navigation items.
1706
425
  *
1707
426
  * @since 2.0.0
1708
427
  */
1709
- declare function isNavItemWithChildren(item: NavItemType): item is NavItemWithChildrenType;
428
+ type NavType = Array<NavItemType> | NavObjectType;
1710
429
  /**
1711
- * Type guard to check if a navigation item has a link.
1712
- *
1713
- * @param item - The navigation item to test.
1714
- * @returns `true` if the item is a {@link NavItemWithLinkType}, `false` otherwise.
430
+ * Defines hooks for version- and locale-specific behavior.
1715
431
  *
1716
432
  * @remarks
1717
- * - This function checks for the presence of a `link` property.
1718
- * - Use this type guard to safely access the `link` property when iterating
1719
- * or transforming navigation trees.
433
+ * The `rewritesHook` function allows you to programmatically rewrite
434
+ * paths or content based on the documentation version and locale being served.
1720
435
  *
1721
436
  * @example
1722
437
  * ```ts
1723
- * const item: NavItemType = { text: "Home", link: "/" };
1724
- * if (isNavItemWithLink(item)) {
1725
- * console.log(item.link); // Safe to access
1726
- * }
438
+ * const hooks: VersionsHooksInterface = {
439
+ * rewritesHook: (source, version, locale) =>
440
+ * `${version}/${locale}/${source}`
441
+ * };
1727
442
  * ```
1728
443
  *
1729
444
  * @since 2.0.0
1730
445
  */
1731
- declare function isNavItemWithLink(item: NavItemType): item is NavItemWithLinkType;
446
+ interface VersionsHooksInterface {
447
+ /**
448
+ * A function that rewrites a source path based on version and locale.
449
+ *
450
+ * @param source - The original file path or source string.
451
+ * @param version - The current documentation version (e.g., "2.0").
452
+ * @param locale - The locale code or folder name (e.g., "en", "de").
453
+ *
454
+ * @returns The rewritten path string, which can be used for routing or file organization.
455
+ *
456
+ * @remarks
457
+ * This hook is invoked whenever paths need to be version- and locale-aware,
458
+ * allowing complete control over URL or file structure.
459
+ *
460
+ * @since 2.0.0
461
+ */
462
+ rewritesHook(source: string, version: string, locale: string): string;
463
+ }
1732
464
  /**
1733
- * Recursively prepends a version prefix to navigation item links.
1734
- *
1735
- * @param version - The version string to prefix (e.g., `"v2.0.0"`).
1736
- * @param item - The navigation item to process, which can be a link, a group with children, or a component.
1737
- * @returns A new navigation item with updated `link` values where applicable.
465
+ * Configuration for a version switcher component.
1738
466
  *
1739
467
  * @remarks
1740
- * - For {@link NavItemWithLinkType}, prepends the given `version` to the `link`
1741
- * unless `skipVersioning` is `true`.
1742
- * - For {@link NavItemWithChildrenType}, recursively traverses all children and applies
1743
- * the same transformation.
1744
- * - Component-based navigation items ({@link NavItemComponentType}) are returned as-is.
1745
- * - Preserves other properties of the navigation items.
468
+ * - `text` is the display label for the version switcher.
469
+ * - `includeCurrentVersion` determines whether the currently active version
470
+ * should appear in the switcher dropdown.
1746
471
  *
1747
472
  * @example
1748
473
  * ```ts
1749
- * const navItem: NavItemWithLinkType = { text: "Guide", link: "/guide/" };
1750
- * const result = replaceLinksRecursive("v2.0.0", navItem);
1751
- * // → { text: "Guide", link: "/v2.0.0/guide/" }
1752
- *
1753
- * const navGroup: NavItemWithChildrenType = {
1754
- * text: "Docs",
1755
- * items: [{ text: "Intro", link: "/intro/" }]
474
+ * const switcher: VersionsSwitcherInterface = {
475
+ * text: "Version",
476
+ * includeCurrentVersion: true
1756
477
  * };
1757
- * const groupResult = replaceLinksRecursive("v2.0.0", navGroup);
1758
- * // → { text: "Docs", items: [{ text: "Intro", link: "/v2.0.0/intro/" }] }
1759
478
  * ```
1760
479
  *
1761
480
  * @since 2.0.0
1762
481
  */
1763
- declare function replaceLinksRecursive(version: string, item: NavItemType): NavItemType;
482
+ interface VersionsSwitcherInterface {
483
+ /**
484
+ * The display label for the version switcher component.
485
+ *
486
+ * @remarks
487
+ * This text is shown in the UI as the version selector label.
488
+ *
489
+ * @since 2.0.0
490
+ */
491
+ text: string;
492
+ /**
493
+ * Determines whether the currently active version should appear in the switcher dropdown.
494
+ *
495
+ * @remarks
496
+ * If `true`, the current version will be included; if `false`, it will be omitted.
497
+ *
498
+ * @since 2.0.0
499
+ */
500
+ includeCurrentVersion: boolean;
501
+ }
1764
502
  /**
1765
- * Applies version prefixes to an array of navigation items.
1766
- *
1767
- * @param items - An array of navigation items to process.
1768
- * @param version - The version string to prepend to links (e.g., `"v2.0.0"`).
1769
- * - If `"root"` is provided, no version prefix is added.
1770
- * @returns A new array of navigation items with versioned links applied.
503
+ * Configuration for documentation versions.
1771
504
  *
1772
505
  * @remarks
1773
- * - Uses {@link replaceLinksRecursive} to traverse each navigation item.
1774
- * - Only items that are link-based or have children are modified; component items remain unchanged.
1775
- * - Preserves other properties of the navigation items.
506
+ * - `current` specifies the currently active version.
507
+ * - `sources` is the folder or path where current versioned sources reside.
508
+ * - `archive` is the folder or path for archived versions.
509
+ * - `hooks` allows for custom rewriting logic per version.
510
+ * - `versionSwitcher` enables or disables the version switcher, or provides its configuration.
1776
511
  *
1777
512
  * @example
1778
513
  * ```ts
1779
- * const navItems: NavItemType[] = [
1780
- * { text: "Guide", link: "/guide/" },
1781
- * { text: "Docs", items: [{ text: "Intro", link: "/intro/" }] }
1782
- * ];
1783
- * const versionedNav = populateNav(navItems, "v2.0.0");
1784
- * // → [
1785
- * // { text: "Guide", link: "/v2.0.0/guide/" },
1786
- * // { text: "Docs", items: [{ text: "Intro", link: "/v2.0.0/intro/" }] }
1787
- * // ]
514
+ * const versionsConfig: VersionsConfigInterface = {
515
+ * current: "2.0",
516
+ * sources: "src",
517
+ * archive: "archive",
518
+ * hooks: {
519
+ * rewritesHook: (source, version) => `/v${version}/${source}`
520
+ * },
521
+ * versionSwitcher: { text: "Version", includeCurrentVersion: true }
522
+ * };
1788
523
  * ```
1789
524
  *
1790
525
  * @since 2.0.0
1791
526
  */
1792
- declare function populateNav(items: Array<NavItemType>, version: string): Array<NavItemType>;
527
+ interface VersionsConfigInterface {
528
+ /**
529
+ * The currently active documentation version.
530
+ *
531
+ * @remarks
532
+ * Used to determine which version to serve by default and which version
533
+ * should be highlighted in the version switcher.
534
+ *
535
+ * @since 2.0.0
536
+ */
537
+ current: string;
538
+ /**
539
+ * The folder or path where the current versioned sources reside.
540
+ *
541
+ * @since 2.0.0
542
+ */
543
+ sources: string;
544
+ /**
545
+ * The folder or path where archived versions are stored.
546
+ *
547
+ * @since 2.0.0
548
+ */
549
+ archive: string;
550
+ /**
551
+ * Hooks for custom behavior when working with versioned content.
552
+ *
553
+ * @remarks
554
+ * Currently, supports `rewritesHook`, which can programmatically rewrite
555
+ * paths based on version and locale.
556
+ *
557
+ * @see VersionsHooksInterface
558
+ * @since 2.0.0
559
+ */
560
+ hooks: VersionsHooksInterface;
561
+ /**
562
+ * Configuration for the version switcher or `false` to disable it.
563
+ *
564
+ * @remarks
565
+ * If enabled, this object defines the switcher text and whether the
566
+ * current version is included in the switcher options.
567
+ *
568
+ * @see VersionsSwitcherInterface
569
+ * @since 2.0.0
570
+ */
571
+ versionSwitcher: false | VersionsSwitcherInterface;
572
+ }
1793
573
  /**
1794
- * Normalizes a navigation structure into a flat, prefixed record.
1795
- *
1796
- * @param results - The target {@link NavObjectType} to populate with normalized items.
1797
- * @param nav - The navigation structure to normalize. Can be:
1798
- * - An array of navigation items (`NavItemType[]`), or
1799
- * - A record mapping strings to arrays of navigation items (`NavObjectType`).
1800
- * @param prefix - Optional prefix for keys when processing nested navigation objects.
1801
- * Defaults to an empty string.
1802
- * @param root - Optional root-level navigation items to include in all normalized entries.
574
+ * Main configuration interface for a VitePress site with extended features.
1803
575
  *
1804
576
  * @remarks
1805
- * - If `nav` is an array, it merges it with the root items (if any) and appends to `results.root`.
1806
- * - If `nav` is a record:
1807
- * - Each key is prefixed with `prefix` unless it is `'root'`.
1808
- * - Items from `root` or `root.root` are merged into each key.
1809
- * - All items are accumulated in the `results` object, preserving the hierarchy as flat keys.
577
+ * Extends VitePress's `UserConfig` but overrides:
578
+ * - `locales` to use a strongly typed `LocalesInterface`.
579
+ * - `rewrites` to define path rewrites for the site.
580
+ * - `versionsConfig` to manage documentation versions and the version switcher.
1810
581
  *
1811
582
  * @example
1812
583
  * ```ts
1813
- * const nav: NavObjectType = {
1814
- * root: [{ text: "Home", link: "/" }],
1815
- * guide: [{ text: "Intro", link: "/intro/" }]
584
+ * const config: ConfigurationInterface = {
585
+ * locales: {
586
+ * en: { link: "/en/", label: "English" },
587
+ * de: { link: "/de/", label: "Deutsch" }
588
+ * },
589
+ * rewrites: {
590
+ * "/old-path": "/new-path"
591
+ * },
592
+ * versionsConfig: {
593
+ * current: "2.0",
594
+ * sources: "src",
595
+ * archive: "archive",
596
+ * hooks: { rewritesHook: (src, ver) => `/v${ver}/${src}` },
597
+ * versionSwitcher: { text: "Version", includeCurrentVersion: true }
598
+ * }
1816
599
  * };
1817
- * const results: NavObjectType = { root: [] };
1818
- * normalizeNav(results, nav, "v2.0.0");
1819
- * // results → {
1820
- * // root: [{ text: "Home", link: "/" }],
1821
- * // "v2.0.0/guide": [{ text: "Intro", link: "/intro/" }]
1822
- * // }
1823
- * ```
1824
- *
1825
- * @since 2.0.0
1826
- */
1827
- declare function normalizeNav(results: NavObjectType, nav: NavType, prefix?: string, root?: NavObjectType): void;
1828
- /**
1829
- * Normalizes all navigation structures across the global and locale-specific configurations.
1830
- *
1831
- * @param state - The current {@link StateModel} providing configuration data:
1832
- * - `configuration.themeConfig.nav` — global navigation configuration.
1833
- * - `configuration.locales` — locale-specific configurations with optional `nav`.
1834
- *
1835
- * @returns A flat record of navigation items keyed by locale or `'root'`, suitable for further processing.
1836
- *
1837
- * @remarks
1838
- * - First, global navigation items are normalized into `globalResults`.
1839
- * - If no locales are defined, `globalResults` is returned directly.
1840
- * - Otherwise, iterates through all locale keys:
1841
- * - Normalizes each locale’s `nav` configuration.
1842
- * - Merges in global navigation items as fallback where necessary.
1843
- * - Ensures that all navigation entries are flattened and ready for versioning or rendering.
1844
- *
1845
- * @example
1846
- * ```ts
1847
- * const state = inject(StateModel);
1848
- * const normalizedNavs = normalizeNavs(state);
1849
- * // normalizedNavs → {
1850
- * // root: [...global items],
1851
- * // en: [...English locale items including global fallback],
1852
- * // de: [...German locale items including global fallback]
1853
- * // }
1854
600
  * ```
1855
601
  *
1856
602
  * @since 2.0.0
1857
603
  */
1858
- declare function normalizeNavs(state: StateModel): Record<string, Array<NavItemType>>;
604
+ interface ConfigurationInterface extends Omit<UserConfig<ThemeInterface>, 'rewrites' | 'locales'> {
605
+ /**
606
+ * Locale-specific configuration for the site.
607
+ *
608
+ * @remarks
609
+ * Uses {@link LocalesInterface} to strongly type each locale's settings.
610
+ *
611
+ * @since 2.0.0
612
+ */
613
+ locales: LocalesInterface;
614
+ /**
615
+ * Path rewrites for the site.
616
+ *
617
+ * @remarks
618
+ * Maps old paths to new paths, enabling URL restructuring without breaking links.
619
+ *
620
+ * @since 2.0.0
621
+ */
622
+ rewrites: Record<string, string>;
623
+ /**
624
+ * Versioning configuration for documentation.
625
+ *
626
+ * @remarks
627
+ * Defines the current version, source directory, archive, hooks, and version switcher behavior.
628
+ *
629
+ * @see VersionsConfigInterface
630
+ * @since 2.0.0
631
+ */
632
+ versionsConfig: VersionsConfigInterface;
633
+ }
1859
634
  /**
1860
- * Retrieves the appropriate navigation configuration for a given locale key.
1861
- *
1862
- * @param navs - The navigation configurations mapped by locale keys.
1863
- * @param key - The locale key to retrieve navigation for (e.g., 'root', 'fr', 'fr/v1.0.0').
1864
- * @returns The navigation configuration for the locale, falling back to parent locale or root.
635
+ * Represents a deeply partial version of the `ConfigurationInterface`.
1865
636
  *
1866
637
  * @remarks
1867
- * This function implements a fallback strategy for finding navigation configurations:
1868
- * 1. If an exact match exists for the key, return it
1869
- * 2. If the key contains '/' (versioned locale), extract the base locale and try that
1870
- * 3. If no base locale exists, fall back to 'root'
1871
- *
1872
- * This allows versioned locales (e.g., 'fr/v1.0.0', 'de/v2.0') to inherit navigation
1873
- * from their base locale ('fr', 'de') without duplicating configuration.
638
+ * This type allows any property of `ConfigurationInterface` to be optional,
639
+ * including all nested properties. It is based on the `DeepPartialType` utility type.
1874
640
  *
1875
- * Fallback hierarchy examples:
1876
- * - `'fr'` → Direct match, returns `navs.fr`
1877
- * - `'fr/v1.0.0'` → No direct match → Checks `'fr'` → Returns `navs.fr`
1878
- * - `'es/v1.0.0'` → No direct match → Checks `'es'` (doesn't exist) → Returns `navs.root`
1879
- * - `'root'` → Direct match, returns `navs.root`
641
+ * Useful for scenarios where you want to provide only a subset of the configuration,
642
+ * for example, when overriding default settings or merging user-provided options.
1880
643
  *
1881
644
  * @example
1882
645
  * ```ts
1883
- * const navs = {
1884
- * root: [{ text: 'Home', link: '/' }],
1885
- * fr: [{ text: 'Accueil', link: '/fr/' }],
1886
- * de: [{ text: 'Startseite', link: '/de/' }]
646
+ * const partialConfig: PartialConfigurationType = {
647
+ * locales: {
648
+ * en: { label: "English" }
649
+ * },
650
+ * versionsConfig: {
651
+ * versionSwitcher: { text: "Version" }
652
+ * }
1887
653
  * };
1888
- *
1889
- * // Exact match
1890
- * getNavForLocale(navs, 'fr'); // Returns fr nav
1891
- *
1892
- * // Versioned locale - inherits from base
1893
- * getNavForLocale(navs, 'fr/v1.0.0'); // Returns fr nav
1894
- * getNavForLocale(navs, 'de/v2.0'); // Returns de nav
1895
- *
1896
- * // No base locale exists - falls back to root
1897
- * getNavForLocale(navs, 'es/v1.0.0'); // Returns root nav
1898
- *
1899
- * // Root locale
1900
- * getNavForLocale(navs, 'root'); // Returns root nav
1901
654
  * ```
1902
655
  *
1903
- * @see {@link parseNavs} - Uses this function to populate navigation for all locales
1904
- * @see {@link NavItemType} - The navigation item type structure
1905
- *
1906
- * @since 2.0.5
656
+ * @since 2.0.0
1907
657
  */
1908
- declare function getNavForLocale(navs: Record<string, Array<NavItemType>>, key: string): Array<NavItemType>;
658
+ type PartialConfigurationType = DeepPartialType<ConfigurationInterface>;
1909
659
  /**
1910
- * Parses and populates the navigation structure for all locales.
660
+ * A strongly typed VitePress configuration where specific keys are required.
1911
661
  *
1912
662
  * @remarks
1913
- * - Retrieves normalized navigation items using {@link normalizeNavs}.
1914
- * - Iterates through all locales defined in `vitepressConfig.locales`.
1915
- * - For each locale:
1916
- * - Falls back to global navigation (`navs.root`) if locale-specific navigation is not defined.
1917
- * - Ensures the locale’s `themeConfig` exists.
1918
- * - Populates the locale’s `themeConfig.nav` using {@link populateNav}, applying versioning where applicable.
663
+ * This type uses {@link RequireKeysType} to ensure that the following properties
664
+ * of `UserConfig<DefaultTheme.Config>` are always present:
665
+ * - `locales`
666
+ * - `rewrites`
667
+ * - `themeConfig`
1919
668
  *
1920
- * This function ensures that all locales have a fully initialized and version-aware navigation structure.
669
+ * All other properties remain optional, preserving the flexibility of the standard
670
+ * VitePress configuration type.
1921
671
  *
1922
672
  * @example
1923
673
  * ```ts
1924
- * parseNavs();
1925
- * // state.vitepressConfig.locales → each locale has `themeConfig.nav` populated
674
+ * const config: VitepressConfigType = {
675
+ * locales: { en: { link: "/en/", label: "English" } },
676
+ * rewrites: { "/old-path": "/new-path" },
677
+ * themeConfig: { nav: [], sidebar: {} }
678
+ * };
1926
679
  * ```
1927
680
  *
1928
681
  * @since 2.0.0
1929
682
  */
1930
- declare function parseNavs(): void;
1931
-
1932
- /**
1933
- * Imports
1934
- */
683
+ type VitepressConfigType = RequireKeysType<UserConfig<DefaultTheme.Config>, 'locales' | 'rewrites' | 'themeConfig'>;
1935
684
  /**
1936
- * Builds a version switcher navigation item for the documentation site.
1937
- *
1938
- * @param themeConfig - The {@link VersionsConfigInterface} configuration object.
1939
- * @param versions - An array of available version strings.
1940
- * @param current - The current version label, defaults to `"Latest"`.
1941
- *
1942
- * @returns A {@link NavItemWithChildrenType} representing the version switcher,
1943
- * or `undefined` if the switcher is disabled in the configuration.
685
+ * Strongly typed VitePress configuration interface with custom locales support.
1944
686
  *
1945
687
  * @remarks
1946
- * - If `themeConfig.versionSwitcher === false`, no switcher is created.
1947
- * - The returned navigation item contains child links for each version in `versions`.
1948
- * - If `includeCurrentVersion` is enabled, adds a link to the root (`"/"`)
1949
- * for the currently active version, displayed as `"Latest"` or
1950
- * `"vX.Y.Z (latest)"`.
1951
- * - All version links have `skipVersioning: true` to prevent further prefixing.
688
+ * Extends {@link VitepressConfigType} but overrides the `locales` property
689
+ * to use a strongly typed {@link LocalesInterface}.
1952
690
  *
1953
- * This utility allows users to quickly switch between documentation versions
1954
- * from the navigation bar.
691
+ * This ensures:
692
+ * - `locales` are fully typed with per-locale configurations.
693
+ * - Other required properties from `VitepressConfigType` (`rewrites`, `themeConfig`) remain enforced.
694
+ * - Remaining properties from `UserConfig<DefaultTheme.Config>` retain their optionality.
1955
695
  *
1956
696
  * @example
1957
697
  * ```ts
1958
- * const themeConfig: VersionsConfigInterface = {
1959
- * versionSwitcher: { text: "Versions", includeCurrentVersion: true }
698
+ * const config: VitepressConfigInterface = {
699
+ * locales: {
700
+ * en: { link: "/en/", label: "English" },
701
+ * de: { link: "/de/", label: "Deutsch" }
702
+ * },
703
+ * rewrites: { "/old-path": "/new-path" },
704
+ * themeConfig: { nav: [], sidebar: {} }
1960
705
  * };
1961
- *
1962
- * const versions = ["v2.0.0", "v1.5.0"];
1963
- * const navItem = versionSwitcher(themeConfig, versions, "v2.0.0");
1964
- *
1965
- * // → {
1966
- * // text: "Versions",
1967
- * // items: [
1968
- * // { link: "/", text: "v2.0.0 (latest)", skipVersioning: true },
1969
- * // { link: "/v2.0.0/", text: "v2.0.0", skipVersioning: true },
1970
- * // { link: "/v1.5.0/", text: "v1.5.0", skipVersioning: true }
1971
- * // ]
1972
- * // }
1973
706
  * ```
1974
707
  *
1975
708
  * @since 2.0.0
1976
709
  */
1977
- declare function versionSwitcher(themeConfig: VersionsConfigInterface, versions: Array<string>, current?: string): undefined | NavItemWithChildrenType;
1978
-
1979
- /**
1980
- * Imports
1981
- */
710
+ interface VitepressConfigInterface extends Omit<VitepressConfigType, 'locales'> {
711
+ /**
712
+ * Locale-specific configuration for the site.
713
+ *
714
+ * @remarks
715
+ * Uses {@link LocalesInterface} to strongly type each locale's settings.
716
+ *
717
+ * @since 2.0.0
718
+ */
719
+ locales: LocalesInterface;
720
+ }
1982
721
  /**
1983
- * Deeply merges two object types into a single object.
1984
- *
1985
- * @typeParam T - The type of the first object.
1986
- * @typeParam U - The type of the second object.
1987
- *
1988
- * @param obj1 - The base object whose properties will be merged.
1989
- * @param obj2 - The object whose properties will overwrite or merge into `obj1`.
1990
- * @returns A new object containing the deeply merged properties of both `obj1` and `obj2`.
722
+ * A generic type representing a function with any arguments and any return type.
1991
723
  *
1992
724
  * @remarks
1993
- * - This function performs a deep merge, recursively merging nested objects.
1994
- * - If a property exists in both `obj1` and `obj2`:
1995
- * - If both values are plain objects, they are merged recursively.
1996
- * - Otherwise, the value from `obj2` overwrites the value from `obj1`.
1997
- * - Arrays are **not** merged; if a property is an array in `obj2`, it will replace
1998
- * the corresponding property in `obj1`.
725
+ * This type is a very flexible function type, allowing any arguments of any type
726
+ * and returning any type. Use with caution, as it bypasses TypeScript's type safety.
1999
727
  *
2000
728
  * @example
2001
729
  * ```ts
2002
- * const obj1 = { a: 1, b: { c: 2, d: 3 } };
2003
- * const obj2 = { b: { c: 42 }, e: 99 };
730
+ * const exampleFn: FunctionType = (a, b, c) => a + b + c;
2004
731
  *
2005
- * const merged = deepMerge(obj1, obj2);
2006
- * // Result: { a: 1, b: { c: 42, d: 3 }, e: 99 }
732
+ * const anotherFn: FunctionType = (...args) => args.length;
2007
733
  * ```
2008
734
  *
2009
735
  * @since 2.0.0
2010
736
  */
2011
- declare function deepMerge<T extends object, U extends object>(obj1: T, obj2: U): T & U;
737
+ type FunctionType = (...args: Array<any>) => any;
2012
738
  /**
2013
- * Recursively collects all Markdown (`.md`) files within a given directory,
2014
- * returning their paths relative to a specified root directory.
2015
- *
2016
- * @param rootDir - The root directory used as the base for relative paths.
2017
- * @param currentDir - The current directory to scan. Defaults to `rootDir`.
2018
- * @returns An array of relative file paths to Markdown files.
739
+ * Represents a generic constructor type.
2019
740
  *
2020
741
  * @remarks
2021
- * - This function traverses directories recursively.
2022
- * - Only files with a `.md` extension are included in the results.
2023
- * - Returned paths are **relative to `rootDir`**, regardless of how deep the files are nested.
2024
- * - Uses Node.js `fs.readdirSync` with `withFileTypes: true` for efficient directory traversal.
742
+ * This utility type describes a class constructor that accepts any number of arguments
743
+ * and returns any instance type. Useful for mixins or generic factory functions.
2025
744
  *
2026
745
  * @example
2027
746
  * ```ts
2028
- * const markdownFiles = getAllMarkdownFilesRelative("/project/docs");
2029
- *
2030
- * console.log(markdownFiles);
2031
- * // Example output:
2032
- * // [
2033
- * // "README.md",
2034
- * // "guide/intro.md",
2035
- * // "tutorial/setup.md"
2036
- * // ]
747
+ * function WithTimestamp<TBase extends ConstructorType>(Base: TBase) {
748
+ * return class extends Base {
749
+ * timestamp = Date.now();
750
+ * };
751
+ * }
2037
752
  * ```
2038
753
  *
2039
754
  * @since 2.0.0
2040
755
  */
2041
- declare function getAllMarkdownFilesRelative(rootDir: string, currentDir?: string): Array<string>;
2042
-
2043
- /**
2044
- * Import will remove at compile time
2045
- */
756
+ type ConstructorType = new (...args: Array<any>) => any;
2046
757
  /**
2047
- * Populates sidebar items with version-specific base paths.
758
+ * A type representing a function with a specific return type, arguments, and optional context.
2048
759
  *
2049
- * @param sidebar - Array of sidebar items to process {@link SidebarItemType}.
2050
- * @param version - The version string to apply to base paths, or 'root' for the default version.
2051
- * @returns A new array of sidebar items with updated base paths.
760
+ * @typeParam Return - The type returned by the function. Defaults to `unknown`.
761
+ * @typeParam Args - A tuple of argument types for the function. Defaults to an empty array `[]`.
762
+ * @typeParam Context - The type of `this` context for the function. Defaults to `unknown`.
2052
763
  *
2053
764
  * @remarks
2054
- * This function transforms sidebar items by adding version-specific base paths to enable
2055
- * multi-version documentation navigation. It processes each sidebar item according to
2056
- * specific rules:
2057
- *
2058
- * **Skipped items** (returned unchanged):
2059
- * - Items with `skipVersioning: true` flag
2060
- * - Items with external links (starting with 'http')
2061
- * - Items without links or nested items
2062
- * - Items when a version is empty or 'root'
2063
- *
2064
- * **Processed items**:
2065
- * - The base path is prepended with a version: `/{version}/{base}/`
2066
- * - Original item properties are preserved via spread operator
2067
- * - The normalized version replaces 'root' with empty string
2068
- *
2069
- * The base path structure follows the pattern: `/{version}/{originalBase}/`
2070
- * using {@link join} from path/posix for consistent URL formatting across platforms.
765
+ * This type allows you to strongly type functions with a specific `this` context and arguments.
2071
766
  *
2072
767
  * @example
2073
768
  * ```ts
2074
- * const sidebar: Array<SidebarItemType> = [
2075
- * { text: 'Guide', link: '/guide/', base: '/docs' },
2076
- * { text: 'API', link: '/api/', base: '/reference' },
2077
- * { text: 'External', link: 'https://example.com' },
2078
- * { text: 'Skip', link: '/skip/', skipVersioning: true }
2079
- * ];
2080
- *
2081
- * const versioned = populateSidebar(sidebar, 'v2.0');
2082
- * // [
2083
- * // { text: 'Guide', link: '/guide/', base: '/v2.0/docs/' },
2084
- * // { text: 'API', link: '/api/', base: '/v2.0/reference/' },
2085
- * // { text: 'External', link: 'https://example.com' },
2086
- * // { text: 'Skip', link: '/skip/', skipVersioning: true }
2087
- * // ]
2088
- *
2089
- * // Root version (no prefix)
2090
- * const rootVersioned = populateSidebar(sidebar, 'root');
2091
- * // Base paths remain unchanged
2092
- *
2093
- * // Use case: Version-specific sidebar configuration
2094
- * const versions = ['v1.0', 'v2.0', 'latest'];
2095
- * const sidebarConfigs = versions.map(version => ({
2096
- * version,
2097
- * items: populateSidebar(baseSidebar, version)
2098
- * }));
769
+ * const fn: FunctionLikeType<number, [string, string], { prefix: string }> = function(this, a, b) {
770
+ * return (this.prefix + a + b).length;
771
+ * }
2099
772
  * ```
2100
773
  *
2101
- * @see SidebarItemType
2102
- * @since 2.0.5
774
+ * @since 2.0.0
2103
775
  */
2104
- declare function populateSidebar(sidebar: Array<SidebarItemType>, version: string): Array<SidebarItemType>;
776
+ type FunctionLikeType<Return = unknown, Args extends Array<unknown> = [
777
+ ], Context = unknown> = (this: Context, ...args: Args) => Return;
2105
778
  /**
2106
- * Extracts locale and version information from URL path segments.
779
+ * A type representing a constructor with specific arguments and return type.
2107
780
  *
2108
- * @param segments - Array of URL path segments to parse (will be modified by shifting elements).
2109
- * @param localesList - List of valid locale identifiers for matching.
2110
- * @param versionsList - List of valid version identifiers for matching.
2111
- * @returns An object containing extracted language and version {@link PathSegmentsInterface}.
781
+ * @typeParam Return - The instance type returned by the constructor. Defaults to `unknown`.
782
+ * @typeParam Args - A tuple of argument types for the constructor. Defaults to an empty array `[]`.
2112
783
  *
2113
784
  * @remarks
2114
- * This function parses URL path segments to identify and extract locale and version
2115
- * information, supporting both version-first and locale-first URL structures. The
2116
- * function operates on the segment array destructively, removing matched elements
2117
- * via {@link Array.shift}.
2118
- *
2119
- * **Parsing logic**:
2120
- * 1. If the first segment matches a version → return `{ lang: '', version }` (version-first pattern)
2121
- * 2. If the first segment matches a locale → extract it as `lang` (locale-first pattern)
2122
- * 3. If the second segment matches a version → extract it as `version`
2123
- * 4. Return both extracted values (empty strings if not found)
2124
- *
2125
- * **URL patterns supported**:
2126
- * - `/v2.0/guide/` → `{ lang: '', version: 'v2.0' }`
2127
- * - `/fr/v2.0/guide/` → `{ lang: 'fr', version: 'v2.0' }`
2128
- * - `/fr/guide/` → `{ lang: 'fr', version: '' }`
2129
- * - `/guide/` → `{ lang: '', version: '' }`
2130
- *
2131
- * The segment array is mutated during extraction, with matched segments removed
2132
- * from the beginning. This allows the following processing to work with the remaining
2133
- * path components.
785
+ * This type allows strong typing of class constructors with defined argument types.
2134
786
  *
2135
787
  * @example
2136
788
  * ```ts
2137
- * const localesList = ['en', 'fr', 'de'];
2138
- * const versionsList = ['v1.0', 'v2.0', 'latest'];
2139
- *
2140
- * // Version-first pattern
2141
- * const segments1 = ['v2.0', 'guide', 'intro'];
2142
- * const result1 = extractLocale(segments1, localesList, versionsList);
2143
- * console.log(result1); // { lang: '', version: 'v2.0' }
2144
- * console.log(segments1); // ['guide', 'intro']
2145
- *
2146
- * // Locale-first pattern
2147
- * const segments2 = ['fr', 'v2.0', 'api', 'reference'];
2148
- * const result2 = extractLocale(segments2, localesList, versionsList);
2149
- * console.log(result2); // { lang: 'fr', version: 'v2.0' }
2150
- * console.log(segments2); // ['api', 'reference']
2151
- *
2152
- * // No locale or version
2153
- * const segments3 = ['docs', 'getting-started'];
2154
- * const result3 = extractLocale(segments3, localesList, versionsList);
2155
- * console.log(result3); // { lang: '', version: '' }
2156
- * console.log(segments3); // ['docs', 'getting-started']
2157
- *
2158
- * // Use case: URL parsing for routing
2159
- * const url = '/de/latest/guide/installation';
2160
- * const segments = url.split('/').filter(Boolean);
2161
- * const { lang, version } = extractLocale(
2162
- * segments,
2163
- * ['en', 'de', 'fr'],
2164
- * ['latest', 'v1', 'v2']
2165
- * );
2166
- * const route = segments.join('/');
2167
- * console.log({ lang, version, route });
2168
- * // { lang: 'de', version: 'latest', route: 'guide/installation' }
2169
- * ```
2170
- *
2171
- * @see PathSegmentsInterface
2172
- * @since 2.0.5
2173
- */
2174
- declare function extractLocale(segments: Array<string>, localesList: Array<string>, versionsList: Array<string>): PathSegmentsInterface;
2175
- /**
2176
- * Normalizes sidebar configuration into a structured format for multi-version documentation.
2177
- *
2178
- * @param state - The state model containing configuration data {@link StateModel}.
2179
- * @param results - Accumulator object to store normalized sidebar entries {@link SidebarObjectType}.
2180
- * @param sidebar - The sidebar configuration to normalize {@link SidebarType}.
2181
- * @param prefix - Locale prefix for the sidebar (e.g., 'root', 'fr', 'de').
2182
- *
2183
- * @remarks
2184
- * This function transforms sidebar configurations from various input formats into a
2185
- * normalized structure that supports multi-version, multi-locale documentation. It
2186
- * handles both array-based and object-based sidebar definitions.
2187
- *
2188
- * **Input formats supported**:
2189
- * - **Array format**: Simple list of sidebar items for a single path
2190
- * - **Object format**: Key-value pairs where keys are paths and values are sidebar items
2191
- * - **Undefined**: Gracefully handles missing sidebar configuration
2192
- *
2193
- * **Normalization process**:
2194
- * 1. Early return if the sidebar is undefined
2195
- * 2. Convert the 'root' prefix to an empty string for URL normalization
2196
- * 3. For array format: Store items under the normalized path
2197
- * 4. For object format: Parse each key to extract locale/version using {@link extractLocale}
2198
- * 5. Filter entries that don't match the current locale prefix
2199
- * 6. Construct versioned paths and store items in the result accumulator
2200
- *
2201
- * **Results structure**:
2202
- * ```ts
2203
- * {
2204
- * 'root': { '/': [...items], '/guide/': [...items] },
2205
- * 'fr': { '/fr/': [...items], '/fr/guide/': [...items] },
2206
- * 'fr/v2.0': { '/fr/v2.0/': [...items] }
789
+ * class MyClass {
790
+ * constructor(public name: string) {}
2207
791
  * }
2208
- * ```
2209
792
  *
2210
- * The function uses state data to access:
2211
- * - {@link StateModel.localesMap} for valid locale identifiers
2212
- * - {@link StateModel.versionsList} for valid version identifiers
2213
- *
2214
- * @example
2215
- * ```ts
2216
- * const state = new StateModel(config).init();
2217
- * const results: Record<string, SidebarObjectType> = {};
2218
- *
2219
- * // Array format sidebar
2220
- * const arraySidebar = [
2221
- * { text: 'Guide', link: '/guide/' },
2222
- * { text: 'API', link: '/api/' }
2223
- * ];
2224
- * normalizeSidebar(state, results, arraySidebar, 'root');
2225
- * // results = { 'root': { '/': [{ text: 'Guide', ... }, { text: 'API', ... }] } }
2226
- *
2227
- * // Object format sidebar
2228
- * const objectSidebar = {
2229
- * '/': [{ text: 'Home', link: '/' }],
2230
- * '/guide/': [{ text: 'Getting Started', link: '/guide/start' }],
2231
- * '/fr/guide/': [{ text: 'Commencer', link: '/fr/guide/start' }]
2232
- * };
2233
- * normalizeSidebar(state, results, objectSidebar, 'root');
2234
- *
2235
- * // With locale prefix
2236
- * normalizeSidebar(state, results, objectSidebar, 'fr');
2237
- * // Only '/fr/guide/' entries are processed
2238
- *
2239
- * // Use case: Multi-locale sidebar processing
2240
- * const results = {};
2241
- * const locales = ['root', 'fr', 'de'];
2242
- * for (const locale of locales) {
2243
- * const sidebar = getLocaleSidebar(locale);
2244
- * normalizeSidebar(state, results, sidebar, locale);
2245
- * }
793
+ * const ctor: ConstructorLikeType<MyClass, [string]> = MyClass;
794
+ * const instance = new ctor("Hello");
2246
795
  * ```
2247
796
  *
2248
- * @see StateModel
2249
- * @see SidebarType
2250
- * @see extractLocale
2251
- * @see SidebarObjectType
2252
- *
2253
- * @since 2.0.5
797
+ * @since 2.0.0
2254
798
  */
2255
- declare function normalizeSidebar(state: StateModel, results: Record<string, SidebarObjectType>, sidebar?: SidebarType, prefix?: string): void;
799
+ type ConstructorLikeType<Return = unknown, Args extends Array<unknown> = [
800
+ ]> = new (...args: Args) => Return;
2256
801
  /**
2257
- * Normalizes all sidebar configurations across locales and versions.
802
+ * Recursively makes all properties of a type optional.
2258
803
  *
2259
- * @param state - The state model containing configuration data {@link StateModel}.
2260
- * @returns A normalized sidebar structure organized by locale and path {@link SidebarObjectType}.
804
+ * @typeParam T - The type to transform into a deeply partial type.
2261
805
  *
2262
806
  * @remarks
2263
- * This function orchestrates the complete normalization of all sidebar configurations
2264
- * in a multi-version, multi-locale documentation site. It processes sidebars from both
2265
- * global theme configuration and locale-specific settings, then propagates them to all
2266
- * versioned locale entries.
2267
- *
2268
- * **Processing stages**:
2269
- * 1. **Initial Normalization**: Process sidebars from global theme config and each locale's
2270
- * theme config using {@link normalizeSidebar}
2271
- * 2. **Version Propagation**: For each locale entry in {@link StateModel.vitepressConfig},
2272
- * if it lacks a normalized sidebar, inherit from its parent locale
2273
- * 3. **Path Adjustment**: Adjust inherited paths to include the version/locale prefix
2274
- *
2275
- * **Data sources processed**:
2276
- * - {@link StateModel.configuration.themeConfig.sidebar}: Global sidebar configuration
2277
- * - Each locale's `themeConfig.sidebar`: Locale-specific sidebar configuration
2278
- *
2279
- * **Output structure**:
2280
- * ```ts
2281
- * {
2282
- * 'root': { '/': [...], '/guide/': [...] },
2283
- * 'v2.0': { '/v2.0/': [...], '/v2.0/guide/': [...] },
2284
- * 'fr': { '/fr/': [...], '/fr/guide/': [...] },
2285
- * 'fr/v2.0': { '/fr/v2.0/': [...], '/fr/v2.0/guide/': [...] }
2286
- * }
2287
- * ```
807
+ * This type is similar to TypeScript's built-in `Partial<T>`, but it applies recursively
808
+ * to all nested objects. Arrays and other non-object types are left unchanged.
2288
809
  *
2289
- * The function ensures that every locale entry in the VitePress configuration has
2290
- * appropriate sidebar items, either directly defined or inherited from parent locales.
2291
- * This enables consistent navigation across all versions and locales.
810
+ * Use `DeepPartialType` when you need to work with objects where only some properties,
811
+ * including nested properties, may be provided.
2292
812
  *
2293
813
  * @example
2294
814
  * ```ts
2295
- * const state = new StateModel({
2296
- * themeConfig: {
2297
- * sidebar: {
2298
- * '/': [{ text: 'Home', link: '/' }],
2299
- * '/guide/': [{ text: 'Guide', link: '/guide/' }]
2300
- * }
2301
- * },
2302
- * locales: {
2303
- * root: { lang: 'en-US' },
2304
- * '/fr/': {
2305
- * lang: 'fr-FR',
2306
- * themeConfig: {
2307
- * sidebar: {
2308
- * '/fr/guide/': [{ text: 'Guide', link: '/fr/guide/' }]
2309
- * }
2310
- * }
2311
- * }
2312
- * },
2313
- * versionsConfig: {
2314
- * sources: 'src',
2315
- * archive: 'versions'
2316
- * }
2317
- * }).init();
2318
- *
2319
- * const normalized = normalizeSidebars(state);
2320
- *
2321
- * console.log(Object.keys(normalized));
2322
- * // ['root', 'v1.0', 'v2.0', 'fr', 'fr/v1.0', 'fr/v2.0']
2323
- *
2324
- * console.log(normalized['v2.0']);
2325
- * // { '/v2.0/': [...], '/v2.0/guide/': [...] }
2326
- *
2327
- * console.log(normalized['fr/v2.0']);
2328
- * // { '/fr/v2.0/': [...], '/fr/v2.0/guide/': [...] }
2329
- *
2330
- * // Use case: Building a complete sidebar structure
2331
- * const state = inject(StateModel);
2332
- * const sidebars = normalizeSidebars(state);
2333
- *
2334
- * // Apply to VitePress config
2335
- * for (const [locale, paths] of Object.entries(sidebars)) {
2336
- * vitepressConfig.locales[locale].themeConfig.sidebar = paths;
815
+ * interface User {
816
+ * name: string;
817
+ * address: {
818
+ * street: string;
819
+ * city: string;
820
+ * };
2337
821
  * }
2338
- * ```
2339
- *
2340
- * @see StateModel
2341
- * @see extractLocale
2342
- * @see normalizeSidebar
2343
- * @see SidebarObjectType
2344
- *
2345
- * @since 2.0.5
2346
- */
2347
- declare function normalizeSidebars(state: StateModel): Record<string, SidebarObjectType>;
2348
- /**
2349
- * Parses and applies sidebar configurations to all locales in the VitePress configuration.
2350
- *
2351
- * @remarks
2352
- * This function is the main entry point for sidebar processing in a multi-version,
2353
- * multi-locale documentation system. It coordinates the complete sidebar normalization
2354
- * and population workflow by:
2355
- *
2356
- * 1. **Injecting State**: Retrieves the {@link StateModel} singleton instance
2357
- * 2. **Normalizing**: Calls {@link normalizeSidebars} to process all sidebar configurations
2358
- * 3. **Applying**: Iterates through each locale in {@link StateModel.vitepressConfig.locales}
2359
- * 4. **Populating**: Uses {@link populateSidebar} to add version-specific base paths
2360
- * 5. **Merging**: Assigns processed sidebars to each locale's theme configuration
2361
- *
2362
- * **Sidebar structure handling**:
2363
- * - Initializes `themeConfig` if it doesn't exist
2364
- * - Converts array-based sidebars to object format for consistent processing
2365
- * - Preserves existing sidebar structure when no normalized version exists
2366
- * - Ensures sidebar is always in object format after processing
2367
- *
2368
- * The function modifies the VitePress configuration in place, updating each locale's
2369
- * `themeConfig.sidebar` with the normalized and versioned sidebar items. This ensures
2370
- * that all routes have appropriate navigation structures.
2371
- *
2372
- * **Processing flow**:
2373
- * ```
2374
- * User Config → normalizeSidebars() → Normalized Structure
2375
- * ↓
2376
- * VitePress Config ← populateSidebar() ← Per-Locale Items
2377
- * ```
2378
822
  *
2379
- * @example
2380
- * ```ts
2381
- * // Setup configuration
2382
- * const config = {
2383
- * themeConfig: {
2384
- * sidebar: {
2385
- * '/': [{ text: 'Home', link: '/' }],
2386
- * '/guide/': [{ text: 'Getting Started', link: '/guide/start' }]
2387
- * }
2388
- * },
2389
- * locales: {
2390
- * root: { lang: 'en-US', label: 'English' },
2391
- * '/fr/': {
2392
- * lang: 'fr-FR',
2393
- * label: 'Français',
2394
- * themeConfig: {
2395
- * sidebar: {
2396
- * '/fr/guide/': [{ text: 'Commencer', link: '/fr/guide/start' }]
2397
- * }
2398
- * }
2399
- * }
2400
- * }
823
+ * const partialUser: DeepPartialType<User> = {
824
+ * name: "Alice",
825
+ * address: { city: "Wonderland" }
2401
826
  * };
2402
- *
2403
- * const state = new StateModel(config).init();
2404
- * provide(StateModel, state);
2405
- *
2406
- * // Parse and apply sidebars
2407
- * parseSidebars();
2408
- *
2409
- * // Result: Each locale now has versioned sidebars
2410
- * console.log(state.vitepressConfig.locales['v2.0'].themeConfig.sidebar);
2411
- * // {
2412
- * // '/v2.0/': [{ text: 'Home', link: '/', base: '/v2.0/' }],
2413
- * // '/v2.0/guide/': [{ text: 'Getting Started', link: '/guide/start', base: '/v2.0/guide/' }]
2414
- * // }
2415
- *
2416
- * console.log(state.vitepressConfig.locales['fr/v2.0'].themeConfig.sidebar);
2417
- * // {
2418
- * // '/fr/v2.0/guide/': [{ text: 'Commencer', link: '/fr/guide/start', base: '/fr/v2.0/guide/' }]
2419
- * // }
2420
- *
2421
- * // Use case: Integration in VitePress config hook
2422
- * export default defineConfig({
2423
- * async buildStart() {
2424
- * parseSidebars();
2425
- * },
2426
- * // ... rest of config
2427
- * });
2428
827
  * ```
2429
828
  *
2430
- * @see StateModel
2431
- * @see populateSidebar
2432
- * @see normalizeSidebars
2433
- *
2434
- * @since 2.0.5
829
+ * @since 2.0.0
2435
830
  */
2436
- declare function parseSidebars(): void;
2437
-
831
+ type DeepPartialType<T> = T extends object ? {
832
+ [P in keyof T]?: DeepPartialType<T[P]>;
833
+ } : T;
2438
834
  /**
2439
- * Represents extracted locale and version information from URL path segments.
835
+ * Makes specific keys of a type required while leaving the rest unchanged.
836
+ *
837
+ * @typeParam T - The base type.
838
+ * @typeParam K - The subset of keys from `T` that should be required.
2440
839
  *
2441
840
  * @remarks
2442
- * This interface defines the structure returned by {@link extractLocale} when parsing
2443
- * URL paths in a multi-version, multi-locale documentation system. It separates the
2444
- * locale identifier from the version identifier, enabling proper routing and content
2445
- * resolution.
2446
- *
2447
- * Both properties use empty strings as sentinel values to indicate absence, rather
2448
- * than undefined or null, simplifying string concatenation and path construction
2449
- * operations.
2450
- *
2451
- * Common usage patterns:
2452
- * - Route parsing and URL analysis
2453
- * - Content path resolution
2454
- * - Locale and version detection from request URLs
2455
- * - Sidebar and navigation path construction
2456
- * - Determining which content variant to serve
2457
- *
2458
- * The interface supports various URL structures:
2459
- * - Root locale, no version: `{ lang: '', version: '' }` → `/guide/`
2460
- * - Root locale with version: `{ lang: '', version: 'v2.0' }` → `/v2.0/guide/`
2461
- * - Specific locale, no version: `{ lang: 'fr', version: '' }` → `/fr/guide/`
2462
- * - Specific locale with version: `{ lang: 'fr', version: 'v2.0' }` → `/fr/v2.0/guide/`
841
+ * This utility type is useful when you want to enforce that certain properties
842
+ * of a type are mandatory, without affecting the optionality of other properties.
843
+ * It works by combining:
844
+ * - `Omit<T, K>` to remove the keys that will become required.
845
+ * - `Required<Pick<T, K>>` to mark the specified keys as required.
2463
846
  *
2464
847
  * @example
2465
848
  * ```ts
2466
- * // Parse URL segments
2467
- * const segments = ['fr', 'v2.0', 'guide', 'intro'];
2468
- * const result: PathSegmentsInterface = extractLocale(
2469
- * segments,
2470
- * ['en', 'fr', 'de'],
2471
- * ['v1.0', 'v2.0', 'latest']
2472
- * );
2473
- * console.log(result);
2474
- * // { lang: 'fr', version: 'v2.0' }
2475
- *
2476
- * // Handle missing locale/version
2477
- * const segments2 = ['docs', 'api'];
2478
- * const result2: PathSegmentsInterface = extractLocale(segments2, locales, versions);
2479
- * console.log(result2);
2480
- * // { lang: '', version: '' }
2481
- *
2482
- * // Use in routing logic
2483
- * function resolveContent(path: string): string {
2484
- * const segments = path.split('/').filter(Boolean);
2485
- * const { lang, version }: PathSegmentsInterface = extractLocale(
2486
- * segments,
2487
- * availableLocales,
2488
- * availableVersions
2489
- * );
2490
- *
2491
- * const contentPath = [
2492
- * lang || 'en',
2493
- * version || 'latest',
2494
- * ...segments
2495
- * ].join('/');
2496
- *
2497
- * return loadContent(contentPath);
849
+ * interface User {
850
+ * id?: number;
851
+ * name?: string;
852
+ * email?: string;
2498
853
  * }
2499
854
  *
2500
- * // Use in path construction
2501
- * function buildPath(info: PathSegmentsInterface, ...segments: string[]): string {
2502
- * const parts = [
2503
- * info.lang,
2504
- * info.version,
2505
- * ...segments
2506
- * ].filter(Boolean);
2507
- *
2508
- * return '/' + parts.join('/');
2509
- * }
855
+ * // Make 'id' and 'name' required, 'email' remains optional
856
+ * type UserWithRequiredIdName = RequireKeysType<User, 'id' | 'name'>;
2510
857
  *
2511
- * const pathInfo: PathSegmentsInterface = { lang: 'de', version: 'v3.0' };
2512
- * console.log(buildPath(pathInfo, 'guide', 'intro'));
2513
- * // '/de/v3.0/guide/intro'
858
+ * const user: UserWithRequiredIdName = {
859
+ * id: 1,
860
+ * name: "Alice"
861
+ * };
2514
862
  * ```
2515
863
  *
2516
- * @see extractLocale
2517
- * @since 2.0.5
864
+ * @since 2.0.0
2518
865
  */
2519
- interface PathSegmentsInterface {
2520
- lang: string;
2521
- version: string;
2522
- }
866
+ type RequireKeysType<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
867
+ declare function defineVersionedConfig(userConfiguration: PartialConfigurationType): UserConfig;
868
+
869
+ export {
870
+ ConfigurationInterface,
871
+ LocaleInterface,
872
+ LocalesInterface,
873
+ NavItemComponentType,
874
+ NavItemType,
875
+ NavItemWithChildrenType,
876
+ NavItemWithLinkType,
877
+ NavObjectType,
878
+ NavType,
879
+ PartialConfigurationType,
880
+ PathSidebarInterface,
881
+ SidebarGroupInterface,
882
+ SidebarItemType,
883
+ SidebarObjectType,
884
+ SidebarType,
885
+ ThemeInterface,
886
+ VersionsConfigInterface,
887
+ VersionsHooksInterface,
888
+ VersionsSwitcherInterface,
889
+ VitepressConfigInterface,
890
+ VitepressConfigType,
891
+ defineVersionedConfig
892
+ };