@viteplus/versions 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +141 -147
- package/components/version-switcher.component.vue +27 -26
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -6,184 +6,178 @@
|
|
|
6
6
|
[](https://github.com/viteplus/versions/actions/workflows/node.js.yml)
|
|
7
7
|
[](https://deepwiki.com/viteplus/versions)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
@viteplus/versions is a powerful VitePress plugin that enables versioned documentation with built-in localization support,
|
|
10
|
+
seamless navigation between versions, and intelligent URL routing.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
- Sidebar & navigation per version
|
|
13
|
-
- Version switcher component
|
|
14
|
-
- support 2.0.0-alpha.12
|
|
12
|
+
## ✨ Features
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
- **Version Management**: Effortlessly manage multiple documentation versions
|
|
15
|
+
- **Localization**: Full multi-language support with version-aware localization
|
|
16
|
+
- **Smart URL Routing**: Automatic path rewriting for clean, predictable URLs
|
|
17
|
+
- **Version Switcher**: Built-in component for navigating between versions
|
|
18
|
+
- **Flexible Configuration**: Customize navigation, sidebar, and URL structures per version/locale
|
|
19
|
+
- **VitePress**: support 2.0.0-alpha.12
|
|
17
20
|
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
Install via your preferred package manager:
|
|
21
|
+
## 📦 Installation
|
|
21
22
|
|
|
22
23
|
```bash
|
|
23
|
-
pnpm add @viteplus/versions
|
|
24
|
-
# or
|
|
25
24
|
npm install @viteplus/versions
|
|
26
25
|
# or
|
|
27
26
|
yarn add @viteplus/versions
|
|
27
|
+
# or
|
|
28
|
+
pnpm add @viteplus/versions
|
|
28
29
|
```
|
|
29
30
|
|
|
30
|
-
## Quick Start
|
|
31
|
-
|
|
32
|
-
1.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
root: [ /* Global navigation */ ],
|
|
51
|
-
'v1.0': [ /* Navigation for version 1.0 */ ],
|
|
52
|
-
'v2.0': [ /* Navigation for version 2.0 */ ]
|
|
53
|
-
},
|
|
54
|
-
sidebar: {
|
|
55
|
-
root: [ /* Global sidebar */ ],
|
|
56
|
-
'v1.0': [ /* Sidebar for version 1.0 */ ],
|
|
57
|
-
'v2.0': [ /* Sidebar for version 2.0 */ ]
|
|
58
|
-
}
|
|
31
|
+
## 🚀 Quick Start
|
|
32
|
+
|
|
33
|
+
1. Create a VitePress project
|
|
34
|
+
2. Install @viteplus/versions
|
|
35
|
+
3. Configure your documentation using `defineVersionedConfig`
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// .vitepress/config.ts
|
|
39
|
+
import { defineVersionedConfig } from '@viteplus/versions';
|
|
40
|
+
|
|
41
|
+
export default defineVersionedConfig({
|
|
42
|
+
title: 'My Project Documentation',
|
|
43
|
+
description: 'Documentation with version control',
|
|
44
|
+
|
|
45
|
+
// Version configuration
|
|
46
|
+
versionsConfig: {
|
|
47
|
+
current: 'v2.0.0',
|
|
48
|
+
versionSwitcher: {
|
|
49
|
+
text: 'Version',
|
|
50
|
+
includeCurrentVersion: true
|
|
59
51
|
}
|
|
60
|
-
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
// Standard VitePress configuration
|
|
55
|
+
themeConfig: {
|
|
56
|
+
nav: [
|
|
57
|
+
{ text: 'Guide', link: '/guide/' },
|
|
58
|
+
{ component: 'VersionSwitcher' }
|
|
59
|
+
],
|
|
60
|
+
// ...
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
```
|
|
61
64
|
|
|
62
|
-
##
|
|
65
|
+
## 📂 Project Structure
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
docs/
|
|
69
|
+
├── .vitepress/
|
|
70
|
+
│ └── config.ts
|
|
71
|
+
├── src/ // Current version docs
|
|
72
|
+
│ ├── en/ // English (default locale)
|
|
73
|
+
│ │ ├── index.md
|
|
74
|
+
│ │ └── guide/
|
|
75
|
+
│ └── de/ // German locale
|
|
76
|
+
│ ├── index.md
|
|
77
|
+
│ └── guide/
|
|
78
|
+
└── archive/ // Archived versions
|
|
79
|
+
└── v1.0/
|
|
80
|
+
├── en/
|
|
81
|
+
│ ├── index.md
|
|
82
|
+
│ └── guide/
|
|
83
|
+
└── de/
|
|
84
|
+
├── index.md
|
|
85
|
+
└── guide/
|
|
63
86
|
|
|
64
|
-
|
|
87
|
+
```
|
|
65
88
|
|
|
66
|
-
|
|
89
|
+
## 🌐 Localization Support
|
|
67
90
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
```ts
|
|
92
|
+
export default defineVersionedConfig({
|
|
93
|
+
// ...
|
|
94
|
+
locales: {
|
|
95
|
+
root: {
|
|
96
|
+
lang: 'en',
|
|
97
|
+
label: 'English',
|
|
98
|
+
themeConfig: {
|
|
99
|
+
nav: [
|
|
100
|
+
{ text: 'Home', link: '/' },
|
|
101
|
+
{ text: 'Guide', link: '/guide/' }
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
de: {
|
|
106
|
+
lang: 'de',
|
|
107
|
+
label: 'Deutsch',
|
|
108
|
+
themeConfig: {
|
|
109
|
+
nav: [
|
|
110
|
+
{ text: 'Startseite', link: '/' },
|
|
111
|
+
{ text: 'Anleitung', link: '/guide/' }
|
|
112
|
+
]
|
|
113
|
+
}
|
|
87
114
|
}
|
|
88
|
-
|
|
115
|
+
}
|
|
116
|
+
});
|
|
89
117
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
You can fully customize your documentation's navigation (`nav`) and sidebar (`sidebar`) according to your needs:
|
|
118
|
+
```
|
|
93
119
|
|
|
94
|
-
-
|
|
95
|
-
Use an array to apply a navigation or sidebar structure for all locales and all versions.
|
|
120
|
+
## 🔄 Version-Specific Navigation
|
|
96
121
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
122
|
+
```ts
|
|
123
|
+
export default defineVersionedConfig({
|
|
124
|
+
themeConfig: {
|
|
125
|
+
nav: {
|
|
126
|
+
// Default navigation for all versions
|
|
127
|
+
root: [
|
|
128
|
+
{ text: 'Home', link: '/' },
|
|
129
|
+
{ text: 'Guide', link: '/guide/' }
|
|
130
|
+
],
|
|
131
|
+
|
|
132
|
+
// Navigation only for v1.0
|
|
133
|
+
'v1.0': [
|
|
134
|
+
{ text: 'Home', link: '/' },
|
|
135
|
+
{ text: 'Legacy API', link: '/legacy-api/' }
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
100
140
|
|
|
101
|
-
|
|
102
|
-
Use the `locales` property to define locale-specific structure.
|
|
103
|
-
Each locale can individually specify its own nav and sidebar
|
|
104
|
-
as either an array (for that locale) or as a mapping of versions.
|
|
141
|
+
```
|
|
105
142
|
|
|
106
|
-
|
|
143
|
+
## 🛠️ Custom URL Structure
|
|
107
144
|
|
|
108
145
|
```ts
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
],
|
|
118
|
-
sidebar: [
|
|
119
|
-
{
|
|
120
|
-
text: 'Examples',
|
|
121
|
-
items: [
|
|
122
|
-
{ text: 'Markdown Examples', link: '/guide' },
|
|
123
|
-
{ text: 'Runtime API Examples', link: '/guide/getting-started' },
|
|
124
|
-
]
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
'fr': {
|
|
130
|
-
label: 'fr',
|
|
131
|
-
lang: 'fr',
|
|
132
|
-
themeConfig: {
|
|
133
|
-
nav: [
|
|
134
|
-
{ text: 'Sākums', link: '/' },
|
|
135
|
-
{ text: 'Piemēri', link: '/api' }
|
|
136
|
-
],
|
|
137
|
-
sidebar: [
|
|
138
|
-
{
|
|
139
|
-
text: 'Examples',
|
|
140
|
-
items: [
|
|
141
|
-
{ text: 'fr - Markdown Examples', link: '/guide' },
|
|
142
|
-
{ text: 'fr - Runtime API Examples', link: '/guide/getting-started' },
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
]
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
'fr/xs': {
|
|
149
|
-
label: 'fr-xs',
|
|
150
|
-
lang: 'fr-xs',
|
|
151
|
-
base: 'fr',
|
|
152
|
-
themeConfig: {
|
|
153
|
-
nav: [
|
|
154
|
-
{ text: 'Sākums', link: '/' },
|
|
155
|
-
{ text: 'Piemēri', link: '/api' }
|
|
156
|
-
],
|
|
157
|
-
sidebar: [
|
|
158
|
-
{
|
|
159
|
-
text: 'Examples',
|
|
160
|
-
items: [
|
|
161
|
-
{ text: 'fr - Markdown Examples', link: '/guide' },
|
|
162
|
-
{ text: 'fr - Runtime API Examples', link: '/guide/getting-started' },
|
|
163
|
-
]
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
}
|
|
167
|
-
}
|
|
146
|
+
export default defineVersionedConfig({
|
|
147
|
+
versionsConfig: {
|
|
148
|
+
// ...
|
|
149
|
+
hooks: {
|
|
150
|
+
rewritesHook: (source, version, locale) => {
|
|
151
|
+
// Custom URL structure (version first, then locale)
|
|
152
|
+
return `${version}/${locale}/${source}`;
|
|
153
|
+
}
|
|
168
154
|
}
|
|
169
|
-
|
|
155
|
+
}
|
|
156
|
+
});
|
|
170
157
|
```
|
|
171
158
|
|
|
172
|
-
##
|
|
159
|
+
## 📚 Documentation
|
|
160
|
+
|
|
161
|
+
For comprehensive guides and reference, check our [documentation](https://viteplus.github.io/versions/).
|
|
173
162
|
|
|
174
|
-
|
|
163
|
+
- [Localization](https://viteplus.github.io/versions//guide/locales.html)
|
|
164
|
+
- [URL Path Rewrites](https://viteplus.github.io/versions//guide/rewrites.html)
|
|
165
|
+
- [Version Switcher](https://viteplus.github.io/versions//guide/switcher.html)
|
|
166
|
+
- [Configuration Guide](https://viteplus.github.io/versions//guide/configuration.html)
|
|
175
167
|
|
|
176
|
-
|
|
168
|
+
## 🤝 Contributing
|
|
177
169
|
|
|
178
|
-
|
|
170
|
+
We welcome contributions! Please see our [contributing guidelines](CONTRIBUTING.md) for details.
|
|
179
171
|
|
|
180
|
-
|
|
172
|
+
## 📄 License
|
|
181
173
|
|
|
182
|
-
|
|
174
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
183
175
|
|
|
184
|
-
|
|
185
|
-
Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
176
|
+
## 💖 Acknowledgements
|
|
186
177
|
|
|
187
|
-
|
|
178
|
+
- [VitePress](https://vitepress.dev/) - The amazing static site generator this plugin extends
|
|
179
|
+
- [Vue.js](https://vuejs.org/) - The progressive JavaScript framework
|
|
180
|
+
- [Vite](https://vitejs.dev/) - Next generation frontend tooling
|
|
181
|
+
- `@IMB11` - for the original vitepress-versioning-plugin
|
|
188
182
|
|
|
189
|
-
|
|
183
|
+
Made with ❤️ by the @viteplus team
|
|
@@ -18,7 +18,7 @@ import VPMenuLink from 'vitepress/dist/client/theme-default/components/VPMenuLin
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
interface VersioningPlugin {
|
|
21
|
-
versions:
|
|
21
|
+
versions: Set<string>;
|
|
22
22
|
currentVersion: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -34,36 +34,37 @@ const props = defineProps<{
|
|
|
34
34
|
screenMenu?: boolean
|
|
35
35
|
}>();
|
|
36
36
|
|
|
37
|
+
const versionSet = computed(() => new Set([ ...props.versioningPlugin.versions ]));
|
|
38
|
+
|
|
39
|
+
function getPathSegments(): string[] {
|
|
40
|
+
return router.route.data.relativePath.split('/');
|
|
41
|
+
}
|
|
42
|
+
|
|
37
43
|
const getActiveVersion = computed(() => {
|
|
38
|
-
const
|
|
39
|
-
const {
|
|
40
|
-
const
|
|
44
|
+
const segments = getPathSegments();
|
|
45
|
+
const { currentVersion } = props.versioningPlugin;
|
|
46
|
+
const first = segments[0];
|
|
47
|
+
const second = segments[1];
|
|
48
|
+
const candidate = site.value.lang === first ? second : first;
|
|
41
49
|
|
|
42
|
-
return (
|
|
50
|
+
return versionSet.value.has(candidate) ? candidate : currentVersion;
|
|
43
51
|
})
|
|
44
52
|
|
|
45
53
|
function createVersionMenuItem(version: string): { text: string, link: string } {
|
|
46
|
-
const {
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
newPathSegments = [...pathSegments.slice(0, 1), ...pathSegments.slice(2)]
|
|
61
|
-
} else {
|
|
62
|
-
newPathSegments = [...pathSegments]
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return { text: version, link: `/${ newPathSegments.join('/') }` }
|
|
54
|
+
const { currentVersion } = props.versioningPlugin;
|
|
55
|
+
const segments = getPathSegments();
|
|
56
|
+
const baseSegments = segments.filter(seg => !versionSet.value.has(seg));
|
|
57
|
+
|
|
58
|
+
// Determine if the first segment is a language code
|
|
59
|
+
const [ first ] = baseSegments;
|
|
60
|
+
const langIsFirst = first === site.value.lang;
|
|
61
|
+
|
|
62
|
+
let newSegments: Array<string>;
|
|
63
|
+
if (version === currentVersion) newSegments = baseSegments;
|
|
64
|
+
else if (langIsFirst) newSegments = [ first, version, ...baseSegments.slice(1) ];
|
|
65
|
+
else newSegments = [ version, ...baseSegments ];
|
|
66
|
+
|
|
67
|
+
return { text: version, link: `/${ newSegments.join('/') }` };
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
function toggle() {
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
var b=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var s=(e,o)=>b(e,"name",{value:o,configurable:!0});var T=(e,o,r,t)=>{for(var n=t>1?void 0:t?W(o,r):o,i=e.length-1,a;i>=0;i--)(a=e[i])&&(n=(t?a(o,r,n):a(n))||n);return t&&n&&b(o,r,n),n};import{join as m,posix as B}from"path";import{xterm as G}from"@remotex-labs/xansi/xterm.component";var y=new Map,k=new Map;function $(e){return typeof e=="object"&&e!==null&&"useClass"in e}s($,"isProviderUseClass");function E(e){return typeof e=="object"&&e!==null&&"useFactory"in e}s(E,"isProviderUseFactory");function z(e){return typeof e=="object"&&e!==null&&"useValue"in e}s(z,"isProviderUseValue");function I(e){return function(o){k.set(o,e||{})}}s(I,"Injectable");function v(e,o=[]){if(!e)return o;let r=o;for(let t of e.slice(r.length))if($(t))r.push(p(t.useClass,...v(t.providers)));else if(E(t))r.push(t.useFactory(...v(t.providers)));else if(z(t))r.push(t.useValue);else if(typeof t=="function")r.push(p(t));else throw new Error(`Unknown provider type: ${typeof t}`);return r}s(v,"providersIntoArgs");function p(e,...o){if(y.has(e))return y.get(e);let r=k.get(e);if(!r)throw new Error(`Cannot inject ${e.name} \u2013 not marked @Injectable`);let t=v(r.providers,o),n=r.factory?r.factory(...t):new e(...t);return r?.scope==="singleton"&&y.set(e,n),n}s(p,"inject");function j(e,...o){return y.has(e)&&y.delete(e),p(e,...o)}s(j,"forceInject");import{existsSync as S,mkdirSync as J,readdirSync as q,writeFileSync as Q}from"fs";import{join as x}from"path/posix";function A(e,o,r){return x(r,o,e)}s(A,"rewritesHook");function w(){let e={},o=p(f),r=Object.keys(o.localesMap);for(let[t,n]of Object.entries(o.fileMap)){let i=t===""?o.sources:o.archive;for(let a of n){let c=r[r.findIndex(g=>a.startsWith(g))],l=o.localesMap[c]==="root"?"":c??"";e[x(i,t,a)]=o.versionsConfig.hooks.rewritesHook(a.replace(c+"/",""),t,l)}}o.vitepressConfig.rewrites=e}s(w,"parseRoutesComponent");var h={locales:{},rewrites:{},versionsConfig:{current:"latest",sources:"src",archive:"archive",hooks:{rewritesHook:A},versionSwitcher:{text:"Switch Version",includeCurrentVersion:!0}}};import{readdirSync as D}from"fs";import{join as H,relative as K}from"path/posix";function C(e,o){let r={...e};for(let t in o)if(Object.prototype.hasOwnProperty.call(o,t)){let n=o[t],i=e[t];i&&typeof i=="object"&&n&&typeof n=="object"&&!Array.isArray(n)&&!Array.isArray(n)?r[t]=C(i,n):r[t]=n}return r}s(C,"deepMerge");function d(e,o=e){let r=[],t=D(o,{withFileTypes:!0});for(let n of t){let i=H(o,n.name);if(n.isDirectory())r=r.concat(d(e,i));else if(n.isFile()&&n.name.endsWith(".md")){let a=K(e,i);r.push(a)}}return r}s(d,"getAllMarkdownFilesRelative");var f=class{constructor(o=h){this.configuration=o;let{sources:r,archive:t}=o.versionsConfig;if(this.sources=r,this.archive=t,this.versionsConfig=o.versionsConfig,this.root=m(process.cwd(),process.argv[3]??"",o.srcDir??""),this.sourcesPath=m(this.root,this.sources),this.archivePath=m(this.root,this.archive),!S(this.sourcesPath))throw console.error(G.red("[ viteplus ]"),`Source directory ${this.sourcesPath} does not exist
|
|
2
|
-
`),new Error(`Source directory ${this.sourcesPath} does not exist`);this.makeArchiveDirectory(this.archivePath),this.vitepressConfig=this.createVitepressConfig()}root;sources;archive;sourcesPath;archivePath;versionsConfig;vitepressConfig;versionsList=[];localesMap={};fileMap={};init(){let o=q(this.archivePath,{withFileTypes:!0}).filter(r=>r.isDirectory());this.fileMap[""]=d(this.sourcesPath),this.vitepressConfig.locales.root={themeConfig:{}};for(let r of o){let t=m(r.parentPath,r.name);this.fileMap[r.name]=d(t)}return this.initializeLocalesMap(),this}initializeLocalesMap(){let o=this.vitepressConfig.locales,r=this.configuration.locales;if(this.versionsList.push(...Object.keys(this.fileMap).filter(Boolean)),o.root={},Object.keys(r).length>0){let t=Object.keys(r),n="root"in r?"root":t[0];for(let i of t){let a=r[i].lang??i;for(let c of this.versionsList){if(i===n)continue;let l=B.join(a,c);o[l]={}}i===n?this.localesMap[r[i].link??a]="root":(o[i]={},this.localesMap[r[i].link??a]=i)}}for(let t of this.versionsList)o[t]={}}makeArchiveDirectory(o){o&&(S(o)||(J(o),Q(m(o,".gitkeep"),"")))}createVitepressConfig(){let o={},r=["locales","rewrites","themeConfig","versionsConfig"];for(let t of Object.keys(this.configuration))if(!r.includes(t))o[t]=this.configuration[t];else if(t==="themeConfig"){let n=this.configuration.themeConfig??{};o.themeConfig=Object.fromEntries(Object.entries(n).filter(([i])=>i!=="nav"&&i!=="sidebar"))}else t!=="versionsConfig"&&(o[t]={});return o}};s(f,"StateModel"),f=T([I({scope:"singleton"})],f);import{join as P}from"path/posix";function O(e,o,r="Latest"){if(e.versionSwitcher===!1)return;let{text:t,includeCurrentVersion:n}=e.versionSwitcher,i=[];n&&i.push({link:"/",text:r==="Latest"?r:`${r} (latest)`,skipVersioning:!0});for(let a of o)i.push({text:a,link:`/${a}/`,skipVersioning:!0});return{text:t,items:i}}s(O,"versionSwitcher");function X(e){return"items"in e&&Array.isArray(e.items)}s(X,"isNavItemWithChildren");function Y(e){return"link"in e&&!!e.link}s(Y,"isNavItemWithLink");function L(e,o){return X(o)&&!o.skipVersioning?{...o,items:o.items.map(r=>L(e,r))}:Y(o)&&!o.skipVersioning?{...o,link:P("/",e,o.link)}:o}s(L,"replaceLinksRecursive");function Z(e,o){let r=p(f);return o==="root"&&(o=""),e.map(t=>"component"in t&&t.component?{...t,props:{...t.props,versioningPlugin:{versions:r.versionsList,currentVersion:r.versionsConfig.current}}}:L(o,t))}s(Z,"populateNav");function N(e,o,r="",t={}){if(Array.isArray(o)){let n=r||"root";e[n]??=[],e[n].push(...o),t[n]?e[n].push(...t[n]):t.root&&e[n].push(...t.root);return}for(let[n,i]of Object.entries(o)){let c=n==="root"?n==="root"&&r===""?"root":r:P(r,n);e[c]??=[],e[c].push(...i),t[n]?e[c].push(...t[n]):t.root&&e[c].push(...t.root)}}s(N,"normalizeNav");function _(e){let o=e.configuration.locales,r=Object.keys(o),t={root:[]},n=O(e.versionsConfig,e.versionsList,e.versionsConfig.current);if(n&&t.root.push(n)
|
|
2
|
+
`),new Error(`Source directory ${this.sourcesPath} does not exist`);this.makeArchiveDirectory(this.archivePath),this.vitepressConfig=this.createVitepressConfig()}root;sources;archive;sourcesPath;archivePath;versionsConfig;vitepressConfig;versionsList=[];localesMap={};fileMap={};init(){let o=q(this.archivePath,{withFileTypes:!0}).filter(r=>r.isDirectory());this.fileMap[""]=d(this.sourcesPath),this.vitepressConfig.locales.root={themeConfig:{}};for(let r of o){let t=m(r.parentPath,r.name);this.fileMap[r.name]=d(t)}return this.initializeLocalesMap(),this}initializeLocalesMap(){let o=this.vitepressConfig.locales,r=this.configuration.locales;if(this.versionsList.push(...Object.keys(this.fileMap).filter(Boolean)),o.root={},Object.keys(r).length>0){let t=Object.keys(r),n="root"in r?"root":t[0];for(let i of t){let a=r[i].lang??i;for(let c of this.versionsList){if(i===n)continue;let l=B.join(a,c);o[l]={}}i===n?this.localesMap[r[i].link??a]="root":(o[i]={},this.localesMap[r[i].link??a]=i)}}for(let t of this.versionsList)o[t]={}}makeArchiveDirectory(o){o&&(S(o)||(J(o),Q(m(o,".gitkeep"),"")))}createVitepressConfig(){let o={},r=["locales","rewrites","themeConfig","versionsConfig"];for(let t of Object.keys(this.configuration))if(!r.includes(t))o[t]=this.configuration[t];else if(t==="themeConfig"){let n=this.configuration.themeConfig??{};o.themeConfig=Object.fromEntries(Object.entries(n).filter(([i])=>i!=="nav"&&i!=="sidebar"))}else t!=="versionsConfig"&&(o[t]={});return o}};s(f,"StateModel"),f=T([I({scope:"singleton"})],f);import{join as P}from"path/posix";function O(e,o,r="Latest"){if(e.versionSwitcher===!1)return;let{text:t,includeCurrentVersion:n}=e.versionSwitcher,i=[];n&&i.push({link:"/",text:r==="Latest"?r:`${r} (latest)`,skipVersioning:!0});for(let a of o)i.push({text:a,link:`/${a}/`,skipVersioning:!0});return{text:t,items:i}}s(O,"versionSwitcher");function X(e){return"items"in e&&Array.isArray(e.items)}s(X,"isNavItemWithChildren");function Y(e){return"link"in e&&!!e.link}s(Y,"isNavItemWithLink");function L(e,o){return X(o)&&!o.skipVersioning?{...o,items:o.items.map(r=>L(e,r))}:Y(o)&&!o.skipVersioning?{...o,link:P("/",e,o.link)}:o}s(L,"replaceLinksRecursive");function Z(e,o){let r=p(f);return o==="root"&&(o=""),e.map(t=>"component"in t&&t.component?{...t,props:{...t.props,versioningPlugin:{versions:r.versionsList,currentVersion:r.versionsConfig.current}}}:L(o,t))}s(Z,"populateNav");function N(e,o,r="",t={}){if(Array.isArray(o)){let n=r||"root";e[n]??=[],e[n].push(...o),t[n]?e[n].push(...t[n]):t.root&&e[n].push(...t.root);return}for(let[n,i]of Object.entries(o)){let c=n==="root"?n==="root"&&r===""?"root":r:P(r,n);e[c]??=[],e[c].push(...i),t[n]?e[c].push(...t[n]):t.root&&e[c].push(...t.root)}}s(N,"normalizeNav");function _(e){let o=e.configuration.locales,r=Object.keys(o),t={root:[]};e.configuration.themeConfig?.nav&&N(t,e.configuration.themeConfig.nav);let n=O(e.versionsConfig,e.versionsList,e.versionsConfig.current);if(n&&t.root.push(n),!r.length)return t;let i={root:[]};for(let a of r){let c=a==="root"||e.localesMap[a]==="root"?"root":a;N(i,o[a].themeConfig?.nav??[],c,t)}return i}s(_,"normalizeNavs");function V(){let e=p(f),{vitepressConfig:{locales:o}}=e,r=_(e);for(let[t,n]of Object.entries(o)){let i=r[t]??r.root;n.themeConfig??={},n.themeConfig.nav=Z(i,t)}}s(V,"parseNavs");import{join as ee}from"path/posix";function M(){let e=p(f),o=e.versionsList,r=e.vitepressConfig.locales,t=e.configuration.locales;for(let n of Object.keys(e.localesMap)){let i=e.localesMap[n],a=i==="root",l={..."root"in t?t[i]:t[n],themeConfig:void 0};r[i]??={},Object.assign(r[i],l),a?r[i].link="/":r[i].link=`/${r[i].lang}/`;for(let g of o){let u=a?g:ee(n,g);r[u]??={},Object.assign(r[u],{...l}),r[u].label=" ",a?r[u].link="/":r[u].link=`/${r[u].lang}/`}}}s(M,"parseLocale");import{join as U}from"path/posix";function re(e,o){return o==="root"&&(o=""),e.map(r=>(r.skipVersioning||(r={...r},(r.link||r.items)&&o!==""&&(r.base??="",r.base=U("/",o,r.base,"/"))),r))}s(re,"populateSidebar");function R(e,o,r="",t={}){if(Array.isArray(o)){let n=r||"root";e[n]??=[],t[n]?e[n].push(...t[n]):t.root&&e[n].push(...t.root),e[n].push(...o);return}for(let[n,i]of Object.entries(o)){let c=n==="root"?n==="root"&&r===""?"root":r:U(r,n),l=Array.isArray(i)?i:[i];e[c]??=[],t[n]?e[c].push(...t[n]):t.root&&e[c].push(...t.root),e[c].push(...l)}}s(R,"normalizeSidebar");function oe(e){let o=e.configuration.locales,r=Object.keys(o),t={root:[]};if(e.configuration.themeConfig?.sidebar&&R(t,e.configuration.themeConfig.sidebar),!r.length)return t;let n={root:[]};for(let i of r){let a=i==="root"||e.localesMap[i]==="root"?"root":i;R(n,o[i].themeConfig?.sidebar??[],a,t)}return n}s(oe,"normalizeSidebars");function F(){let e=p(f),{vitepressConfig:{locales:o}}=e,r=oe(e);for(let[t,n]of Object.entries(o)){let i=r[t]??r.root;n.themeConfig??={},n.themeConfig.sidebar=re(i,t)}}s(F,"parseSidebar");function Ye(e){let o=C(h,e),r=j(f,o).init();return M(),V(),F(),w(),r.vitepressConfig}s(Ye,"defineVersionedConfig");export{Ye as defineVersionedConfig};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/models/state.model.ts", "../src/modules/symlinks/services/inject.service.ts", "../src/components/rewrites.component.ts", "../src/constants/configuration.constant.ts", "../src/components/object.component.ts", "../src/components/nav.component.ts", "../src/components/switcher.component.ts", "../src/components/locale.component.ts", "../src/components/sidebar.component.ts", "../src/index.ts"],
|
|
4
|
-
"sourceRoot": "https://github.com/viteplus/versions/tree/v2.0.
|
|
5
|
-
"sourcesContent": ["/**\n * Import will remove at compile time\n */\n\nimport type { Dirent } from 'fs';\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\nimport type { VersionsConfigInterface, VitepressConfigInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { join, posix } from 'path';\nimport { xterm } from '@remotex-labs/xansi/xterm.component';\nimport { Injectable } from '@symlinks/services/inject.service';\nimport { existsSync, mkdirSync, readdirSync, writeFileSync } from 'fs';\nimport { defaultConfiguration } from '@constants/configuration.constant';\nimport { getAllMarkdownFilesRelative } from '@components/object.component';\n\n/**\n * Manages the state of a versioned VitePress documentation project.\n *\n * @remarks\n * The `StateModel` class is responsible for:\n * - Managing source and archive directories for versioned documentation.\n * - Initializing the VitePress configuration (`VitepressConfigInterface`) from\n * a provided {@link ConfigurationInterface}.\n * - Maintaining a list of documentation versions and a map of Markdown files per version.\n * - Ensuring the necessary directories exist and are initialized.\n *\n * This service is designed as a singleton, making it safe to inject across\n * your application using `@Injectable({ scope: 'singleton' })`.\n *\n * @example\n * ```ts\n * import { StateModel } from \"@models/state.model\";\n *\n * const state = new StateModel(config).init();\n * console.log(state.versionsList);\n * console.log(state.fileMap);\n * ```\n *\n * @since 2.0.0\n */\n\n@Injectable({\n scope: 'singleton'\n})\nexport class StateModel {\n /**\n * The root path of the documentation project,\n * based on the current working directory and optional srcDir.\n *\n * @since 2.0.0\n */\n\n readonly root: string;\n\n /**\n * The name of the sources directory from which current content.\n *\n * @default `src`\n * @since 2.0.0\n */\n\n readonly sources: string;\n\n /**\n * The name of the archive directory where old versions are stored.\n *\n * @default `archive`\n * @since 2.0.0\n */\n\n readonly archive: string;\n\n /**\n * Full path to the `sources` directory.\n *\n * @since 2.0.0\n */\n\n readonly sourcesPath: string;\n\n /**\n * Full path to the `archive` directory.\n *\n * @since 2.0.0\n */\n\n readonly archivePath: string;\n\n /**\n * The `versions` configuration object for the plugin.\n *\n * @remarks\n * This property holds the currently active versions configuration\n * as defined in {@link VersionsConfigInterface}. It includes settings\n * like the current version, sources, archive, hooks, and version switcher.\n *\n * @see VersionsConfigInterface\n * @since 2.0.0\n */\n\n readonly versionsConfig: VersionsConfigInterface;\n\n /**\n * The VitePress configuration object crafted from the user-provided configuration,\n * with versioning support added.\n *\n * @remarks\n * This object is based on the user configuration and extended to include\n * locales, rewrites, and versioning-aware settings. It is typed as\n * {@link VitepressConfigInterface}.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n readonly vitepressConfig: VitepressConfigInterface;\n\n /**\n * List of all available documentation versions.\n *\n * @remarks\n * This array is populated during initialization (`init()`) by reading the archive\n * and sources directories. Each element is a version string (e.g., `\"1.0\"`, `\"2.0\"`).\n *\n * @since 2.0.0\n */\n\n readonly versionsList: Array<string> = [];\n\n /**\n * Maps locale keys to their effective base paths.\n *\n * @remarks\n * - Keys are the locale identifiers as defined in the user configuration\n * (e.g., `\"de\"`, `\"root\"`).\n * - Values are the corresponding effective base paths or link prefixes\n * used inside the generated VitePress config.\n * - The `\"root\"` locale always maps to the default language of the site.\n *\n * This mapping is used internally to resolve and normalize locale-based\n * routing for both source files and versioned archives.\n *\n * @example\n * ```ts\n * localesMap = {\n * en: \"root\",\n * de: \"de\"\n * };\n * ```\n *\n * @since 2.0.0\n */\n\n readonly localesMap: Record<string, string> = {};\n\n /**\n * A map of version names to arrays of Markdown file paths relative to the sources directory.\n *\n * @remarks\n * - The key is the version name (or `''` for the root/source version).\n * - The value is an array of file paths (strings) for that version.\n *\n * This structure is built during initialization to facilitate generating versioned\n * documentation and navigation.\n *\n * @since 2.0.0\n */\n\n readonly fileMap: Record<string, Array<string>> = {};\n\n /**\n * Creates an instance of `StateModel`.\n *\n * @param configuration - Optional configuration object; defaults to {@link defaultConfiguration}.\n *\n * @throws Will throw an error if the sources directory does not exist.\n *\n * @remarks\n * Initializes the state of the documentation project by:\n * - Extracting `sources` and `archive` from the provided configuration.\n * - Constructing full paths for `root`, `sourcesPath`, and `archivePath`.\n * - Validating that the sources directory exists.\n * - Ensuring the archive directory exists and creating a `.gitkeep` file if necessary.\n * - Creating a VitePress configuration object with versioning support.\n *\n * @since 2.0.0\n */\n\n constructor(readonly configuration: ConfigurationInterface = defaultConfiguration) {\n const { sources, archive } = configuration.versionsConfig;\n\n this.sources = sources;\n this.archive = archive;\n this.versionsConfig = configuration.versionsConfig;\n\n this.root = join(process.cwd(), process.argv[3] ?? '', configuration.srcDir ?? '');\n this.sourcesPath = join(this.root, this.sources);\n this.archivePath = join(this.root, this.archive);\n\n if (!existsSync(this.sourcesPath)) {\n console.error(xterm.red('[ viteplus ]'), `Source directory ${ this.sourcesPath } does not exist\\n`);\n throw new Error(`Source directory ${ this.sourcesPath } does not exist`);\n }\n\n this.makeArchiveDirectory(this.archivePath);\n this.vitepressConfig = this.createVitepressConfig();\n }\n\n /**\n * Initializes the state by reading archive subfolders and building file maps.\n *\n * @returns The instance itself (`this`) to allow method chaining.\n *\n * @remarks\n * This method performs the following steps:\n * - Reads all subdirectories in the archive directory.\n * - Populates `fileMap` with all Markdown files relative to the sources directory.\n * - The root source files are stored under the `''` key.\n * - Archive subfolders are stored under their folder names.\n * - Initializes `vitepressConfig.locales` for each folder with an empty `themeConfig`.\n * - Populates `versionsList` with all version keys derived from `fileMap`.\n *\n * @since 2.0.0\n */\n\n init(): this {\n const subFolders = readdirSync(this.archivePath, { withFileTypes: true })\n .filter((entry: Dirent) => entry.isDirectory());\n\n this.fileMap[''] = getAllMarkdownFilesRelative(this.sourcesPath);\n this.vitepressConfig.locales['root'] = {\n themeConfig: {}\n };\n\n for (const folder of subFolders) {\n const path = join(folder.parentPath, folder.name);\n this.fileMap[folder.name] = getAllMarkdownFilesRelative(path);\n }\n\n this.initializeLocalesMap();\n\n return this;\n }\n\n /**\n * Initializes the locale entries in the VitePress configuration and builds a mapping\n * of locales to their links for all versions.\n *\n * @remarks\n * - Adds a `root` locale entry.\n * - Copies all user-defined locales into the VitePress config.\n * - Populates `localesMap` with locale keys and their corresponding links (or folder names).\n * - Ensures that for each documentation version, a locale entry exists in the VitePress config.\n * - Handles both root and non-root locales, creating versioned paths automatically.\n *\n * @since 2.0.0\n */\n\n private initializeLocalesMap(): void {\n const locales = this.vitepressConfig.locales;\n const userLocales = this.configuration.locales;\n this.versionsList.push(...Object.keys(this.fileMap).filter(Boolean));\n\n locales['root'] = {};\n if (Object.keys(userLocales).length > 0) {\n const keys = Object.keys(userLocales);\n const rootLocaleKey = 'root' in userLocales ? 'root' : keys[0];\n\n for (const key of keys) {\n const index = userLocales[key].lang ?? key;\n for (const version of this.versionsList) {\n if(key === rootLocaleKey) continue;\n const versionPath = posix.join(index, version);\n locales[versionPath] = {};\n }\n\n if (key === rootLocaleKey) {\n this.localesMap[userLocales[key].link ?? index] = 'root';\n } else {\n locales[key] = {};\n this.localesMap[userLocales[key].link ?? index] = key;\n }\n }\n }\n\n for (const version of this.versionsList) {\n locales[version] = {};\n }\n }\n\n /**\n * Ensures that the archive directory exists.\n *\n * @param path - The path to the archive directory.\n *\n * @remarks\n * - If the directory does not exist, it is created.\n * - A `.gitkeep` file is also added to ensure the directory is tracked by Git.\n *\n * @since 2.0.0\n */\n\n private makeArchiveDirectory(path: string): void {\n if (!path) return;\n\n if (!existsSync(path)) {\n mkdirSync(path);\n writeFileSync(join(path, '.gitkeep'), '');\n }\n }\n\n /**\n * Creates a VitePress configuration object from the user-provided configuration.\n *\n * @returns A `VitepressConfigInterface` object with versioning support added.\n *\n * @remarks\n * - Copies all configuration properties except for `locales`, `rewrites`, `themeConfig`, and `versionsConfig`.\n * - Initializes excluded properties (except `versionsConfig`) with empty objects.\n * - Returns a configuration object typed as {@link VitepressConfigInterface}, ready for VitePress usage.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n private createVitepressConfig(): VitepressConfigInterface {\n const result: Record<string, unknown> = {};\n const exclude: Array<keyof ConfigurationInterface> = [\n 'locales',\n 'rewrites',\n 'themeConfig',\n 'versionsConfig'\n ];\n\n for (const key of Object.keys(this.configuration) as Array<keyof ConfigurationInterface>) {\n if (!exclude.includes(key)) {\n result[key] = this.configuration[key];\n } else if (key === 'themeConfig') {\n const themeConfig = this.configuration.themeConfig ?? {};\n result.themeConfig = Object.fromEntries(\n Object.entries(themeConfig).filter(\n ([ prop ]) => prop !== 'nav' && prop !== 'sidebar'\n )\n );\n } else if (key !== 'versionsConfig') {\n result[key] = {};\n }\n }\n\n return <VitepressConfigInterface><unknown>result;\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ProviderUseClassInterface } from '@symlinks/interfaces/symlinks.interface';\nimport type { ConstructorLikeType, ConstructorType } from '@interfaces/function.interface';\nimport type { InjectableOptionsInterface, ProvidersType } from '@symlinks/interfaces/symlinks.interface';\nimport type { ProviderUseFactoryInterface, ProviderUseValueInterface } from '@symlinks/interfaces/symlinks.interface';\n\n/**\n * A collection of singleton instances for injectable classes.\n *\n * @remarks\n * This map stores instances of classes marked as `singleton` in `@Injectable` metadata.\n * It ensures that only one instance exists for the lifetime of the application.\n *\n * @see ConstructorType\n * @since 2.0.0\n */\n\nexport const SINGLETONS = new Map<ConstructorType, unknown>();\n\n/**\n * Stores metadata for all classes marked with the `@Injectable` decorator.\n *\n * @remarks\n * The metadata includes scope, factory function, and provider dependencies.\n *\n * @see Injectable\n * @since 2.0.0\n */\n\nexport const INJECTABLES = new Map<ConstructorType, InjectableOptionsInterface>();\n\n/**\n * Type guard to check if a provider uses a class.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseClassInterface}.\n *\n * @see ProviderUseClassInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseClass(provider: unknown): provider is ProviderUseClassInterface {\n return typeof provider === 'object' && provider !== null && 'useClass' in provider;\n}\n\n/**\n * Type guard to check if a provider uses a factory function.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseFactoryInterface}.\n *\n * @see ProviderUseFactoryInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseFactory(provider: unknown): provider is ProviderUseFactoryInterface {\n return typeof provider === 'object' && provider !== null && 'useFactory' in provider;\n}\n\n/**\n * Type guard to check if a provider uses a value.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseValueInterface}.\n *\n * @see ProviderUseValueInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseValue(provider: unknown): provider is ProviderUseValueInterface {\n return typeof provider === 'object' && provider !== null && 'useValue' in provider;\n}\n\n/**\n * Marks a class as injectable, optionally providing metadata.\n *\n * @param options - Optional configuration for the injectable class.\n *\n * @remarks\n * The `@Injectable` decorator allows classes to be automatically instantiated\n * and injected with dependencies using the `inject` function.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const instance = inject(MyService);\n * ```\n *\n * @see InjectableOptionsInterface\n * @since 2.0.0\n */\n\nexport function Injectable<T extends ConstructorType = ConstructorType>(options?: InjectableOptionsInterface<T>) {\n return function (target: T): void {\n INJECTABLES.set(target, <InjectableOptionsInterface>options || {});\n };\n}\n\n/**\n * Converts an array of providers into constructor arguments for injection.\n *\n * @param providers - An optional array of providers to resolve.\n * @param args - Optional initial arguments to prepend before resolving providers.\n * @returns An array of resolved arguments including the results from providers.\n *\n * @remarks\n * This function iterates over the provided `ProvidersType` array and converts each provider\n * into its resolved value. It supports class providers, factory providers, value providers,\n * and direct constructor functions. The returned array can be used to construct instances\n * with dependencies injected in the correct order.\n *\n * @example\n * ```ts\n * const args = providersIntoArgs([{ useValue: 42 }, { useFactory: () => 'hello' }]);\n * // args = [42, 'hello']\n * ```\n *\n * @see isProviderUseClass\n * @see isProviderUseValue\n * @see isProviderUseFactory\n *\n * @since 2.0.0\n */\n\nexport function providersIntoArgs(providers?: ProvidersType, args: Array<unknown> = []): Array<unknown> {\n if (!providers) return args;\n\n const scopeAgs: Array<unknown> = args;\n for (const provider of providers.slice(scopeAgs.length)) {\n if (isProviderUseClass(provider)) {\n scopeAgs.push(inject(provider.useClass, ...providersIntoArgs(provider.providers)));\n } else if (isProviderUseFactory(provider)) {\n scopeAgs.push(provider.useFactory(...providersIntoArgs(provider.providers)));\n } else if (isProviderUseValue(provider)) {\n scopeAgs.push(provider.useValue);\n } else if (typeof provider === 'function') {\n scopeAgs.push(inject(provider));\n } else {\n throw new Error(`Unknown provider type: ${ typeof provider }`);\n }\n }\n\n return scopeAgs;\n}\n\n/**\n * Resolves and instantiates a class with its dependencies.\n *\n * @param token - The constructor function or class to instantiate.\n * @param args - Optional arguments to pass to the constructor, which can override\n * or supplement provider-resolved values.\n * @returns An instance of the class with all dependencies injected.\n *\n * @remarks\n * The `inject` function looks up metadata for the class marked with `@Injectable`.\n * It resolves all providers recursively using `providersIntoArgs`. If the class is\n * marked as a `singleton`, the same instance will be returned on further calls.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const instance = inject(MyService);\n * ```\n *\n * @see Injectable\n * @see providersIntoArgs\n *\n * @since 2.0.0\n */\n\nexport function inject<T, Args extends Array<unknown>>(token: ConstructorLikeType<T, Args>, ...args: Partial<Args>): T {\n if (SINGLETONS.has(token)) return <T>SINGLETONS.get(token);\n\n const metadata = INJECTABLES.get(token)!;\n if (!metadata) throw new Error(`Cannot inject ${ token.name } \u2013 not marked @Injectable`);\n\n const scopeAgs = providersIntoArgs(metadata.providers, args);\n const instance: T = metadata.factory\n ? <T>metadata.factory(...scopeAgs)\n : new token(...scopeAgs as Args);\n\n if (metadata?.scope === 'singleton') {\n SINGLETONS.set(token, instance);\n }\n\n return instance;\n}\n\n/**\n * Forces the instantiation of a class, bypassing any existing singleton instance.\n *\n * @param token - The constructor function or class to instantiate.\n * @param args - Optional arguments to pass to the constructor, which can override\n * or supplement provider-resolved values.\n * @returns A new instance of the class, even if a singleton instance already exists.\n *\n * @remarks\n * Unlike the `inject` function, `forceInject` will delete any existing singleton\n * instance for the given class before creating a new one. This is useful when you\n * need a fresh instance regardless of the singleton scope.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const freshInstance = forceInject(MyService);\n * ```\n *\n * @see inject\n * @since 2.0.0\n */\n\nexport function forceInject<T, Args extends Array<unknown>>(token: ConstructorLikeType<T, Args>, ...args: Partial<Args>): T {\n if (SINGLETONS.has(token)) SINGLETONS.delete(token);\n\n return inject<T, Args>(token, ...args);\n}\n", "/**\n * imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Rewrites a documentation source path using version and locale.\n *\n * @remarks\n * This implementation joins the `version`, `locale`, and original `source`\n * into a normalized POSIX-style path. It is commonly used to generate\n * consistent URLs or filesystem paths for versioned and localized docs.\n *\n * @param source - The original file path or content identifier.\n * @param version - The version string of the documentation (e.g., `\"1.2.0\"`).\n * @param locale - The locale code (e.g., `\"en\"`, `\"de\"`).\n *\n * @returns The rewritten path string in the format `version/locale/source`.\n *\n * @example\n * ```ts\n * rewritesHook(\"guide/intro.md\", \"v2.0.0\", \"en\");\n * // \u2192 \"en/v2.0.0/guide/intro.md\"\n * ```\n *\n * @since 2.0.0\n */\n\nexport function rewritesHook(source: string, version: string, locale: string): string {\n return join(locale, version, source);\n}\n\n/**\n * Parses all documentation routes and generates rewritten paths for versioned and localized files.\n *\n * @remarks\n * - Iterates through the `fileMap` of the `StateModel` to process all Markdown files.\n * - Determines the correct locale for each file using `localesMap`.\n * - Uses the `rewritesHook` from `versionsConfig.hooks` to generate the versioned and localized path.\n * - Populates the `vitepressConfig.rewrites` object with the mapping of original paths to rewritten paths.\n *\n * @example\n * ```ts\n * parseRoutesComponent();\n * console.log(state.vitepressConfig.rewrites);\n * // \u2192 {\n * \"src/en/index.md\": \"en/index.md\",\n * \"src/de/index.md\": \"index.md\",\n * \"archive/x0.0.1/en/index.md\": \"x0.0.1/en/index.md\"\n * ...\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseRoutesComponent(): void {\n const result: Record<string, string> = {};\n const state = inject(StateModel);\n const localesPrefix = Object.keys(state.localesMap);\n\n for (const [ folder, fileList ] of Object.entries(state.fileMap)) {\n const prefix = folder === '' ? state.sources : state.archive;\n\n for (const file of fileList) {\n const localeKey = localesPrefix[localesPrefix.findIndex(item => file.startsWith(item))];\n const locale = state.localesMap[localeKey] === 'root' ? '' : localeKey ?? '';\n\n result[join(prefix, folder, file)] = state.versionsConfig.hooks.rewritesHook(\n file.replace(localeKey + '/', ''), folder, locale\n );\n }\n }\n\n state.vitepressConfig.rewrites = result;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { rewritesHook } from '@components/rewrites.component';\n\n/**\n * Default configuration object for the `versions` system.\n *\n * @remarks\n * Provides a baseline implementation of {@link ConfigurationInterface}.\n * This includes:\n * - Empty `locales` and `rewrites` mappings.\n * - A `versionsConfig` with:\n * - `current` set to `\"latest\"`.\n * - `sources` pointing to `\"src\"`.\n * - `archive` pointing to `\"archive\"`.\n * - `hooks.rewritesHook` bound to the default {@link rewritesHook}.\n * - A `versionSwitcher` enabled with label `\"Switch Version\"` and\n * `includeCurrentVersion` set to `true`.\n *\n * This default setup can be extended or overridden as needed when\n * customizing your documentation site.\n *\n * @example\n * ```ts\n * import { defaultConfiguration } from \"@config/default.configuration\";\n *\n * export default {\n * ...defaultConfiguration,\n * locales: {\n * en: { link: \"/en/\", label: \"English\" }\n * }\n * };\n * ```\n *\n * @since 2.0.0\n */\n\nexport const defaultConfiguration: ConfigurationInterface = {\n locales: {},\n rewrites: {},\n versionsConfig: {\n current: 'latest',\n sources: 'src',\n archive: 'archive',\n hooks: {\n rewritesHook: rewritesHook\n },\n versionSwitcher: {\n text: 'Switch Version',\n includeCurrentVersion: true\n }\n }\n};\n", "/**\n * Imports\n */\n\nimport { readdirSync } from 'fs';\nimport { join, relative } from 'path/posix';\n\n/**\n * Deeply merges two object types into a single object.\n *\n * @typeParam T - The type of the first object.\n * @typeParam U - The type of the second object.\n *\n * @param obj1 - The base object whose properties will be merged.\n * @param obj2 - The object whose properties will overwrite or merge into `obj1`.\n * @returns A new object containing the deeply merged properties of both `obj1` and `obj2`.\n *\n * @remarks\n * - This function performs a deep merge, recursively merging nested objects.\n * - If a property exists in both `obj1` and `obj2`:\n * - If both values are plain objects, they are merged recursively.\n * - Otherwise, the value from `obj2` overwrites the value from `obj1`.\n * - Arrays are **not** merged; if a property is an array in `obj2`, it will replace\n * the corresponding property in `obj1`.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { c: 2, d: 3 } };\n * const obj2 = { b: { c: 42 }, e: 99 };\n *\n * const merged = deepMerge(obj1, obj2);\n * // Result: { a: 1, b: { c: 42, d: 3 }, e: 99 }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function deepMerge<T extends object, U extends object>(obj1: T, obj2: U): T & U {\n const result = <Record<string, unknown>> { ...obj1 };\n\n for (const key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n const val2 = (obj2 as T & U)[key];\n const val1 = (obj1 as T & U)[key];\n\n if (\n val1 && typeof val1 === 'object' &&\n val2 && typeof val2 === 'object' &&\n !Array.isArray(val2) && !Array.isArray(val2)\n ) {\n result[key] = deepMerge(val1 as object, val2 as object);\n } else {\n result[key] = val2;\n }\n }\n }\n\n return result as T & U;\n}\n\n/**\n * Recursively collects all Markdown (`.md`) files within a given directory,\n * returning their paths relative to a specified root directory.\n *\n * @param rootDir - The root directory used as the base for relative paths.\n * @param currentDir - The current directory to scan. Defaults to `rootDir`.\n * @returns An array of relative file paths to Markdown files.\n *\n * @remarks\n * - This function traverses directories recursively.\n * - Only files with a `.md` extension are included in the results.\n * - Returned paths are **relative to `rootDir`**, regardless of how deep the files are nested.\n * - Uses Node.js `fs.readdirSync` with `withFileTypes: true` for efficient directory traversal.\n *\n * @example\n * ```ts\n * const markdownFiles = getAllMarkdownFilesRelative(\"/project/docs\");\n *\n * console.log(markdownFiles);\n * // Example output:\n * // [\n * // \"README.md\",\n * // \"guide/intro.md\",\n * // \"tutorial/setup.md\"\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function getAllMarkdownFilesRelative(rootDir: string, currentDir: string = rootDir): Array<string> {\n let results: Array<string> = [];\n const entries = readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(currentDir, entry.name);\n\n if (entry.isDirectory()) {\n results = results.concat(getAllMarkdownFilesRelative(rootDir, fullPath));\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n const relativePath = relative(rootDir, fullPath);\n results.push(relativePath);\n }\n }\n\n return results;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { NavItemType, NavItemWithChildrenType } from '@interfaces/nav.interface';\nimport type { NavItemWithLinkType, NavObjectType, NavType } from '@interfaces/nav.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\nimport { versionSwitcher } from '@components/switcher.component';\n\n/**\n * Type guard to check if a navigation item has children.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithChildrenType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of an `item` property that is an array.\n * - Use this type guard to safely access child navigation items when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Docs\", items: [{ text: \"Guide\", link: \"/guide/\" }] };\n * if (isNavItemWithChildren(item)) {\n * console.log(item.items); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithChildren(item: NavItemType): item is NavItemWithChildrenType {\n return 'items' in item && Array.isArray(item.items);\n}\n\n/**\n * Type guard to check if a navigation item has a link.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithLinkType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of a `link` property.\n * - Use this type guard to safely access the `link` property when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Home\", link: \"/\" };\n * if (isNavItemWithLink(item)) {\n * console.log(item.link); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithLink(item: NavItemType): item is NavItemWithLinkType {\n return 'link' in item && !!item.link;\n}\n\n/**\n * Recursively prepends a version prefix to navigation item links.\n *\n * @param version - The version string to prefix (e.g., `\"v2.0.0\"`).\n * @param item - The navigation item to process, which can be a link, a group with children, or a component.\n * @returns A new navigation item with updated `link` values where applicable.\n *\n * @remarks\n * - For {@link NavItemWithLinkType}, prepends the given `version` to the `link`\n * unless `skipVersioning` is `true`.\n * - For {@link NavItemWithChildrenType}, recursively traverses all children and applies\n * the same transformation.\n * - Component-based navigation items ({@link NavItemComponentType}) are returned as-is.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItem: NavItemWithLinkType = { text: \"Guide\", link: \"/guide/\" };\n * const result = replaceLinksRecursive(\"v2.0.0\", navItem);\n * // \u2192 { text: \"Guide\", link: \"/v2.0.0/guide/\" }\n *\n * const navGroup: NavItemWithChildrenType = {\n * text: \"Docs\",\n * items: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const groupResult = replaceLinksRecursive(\"v2.0.0\", navGroup);\n * // \u2192 { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function replaceLinksRecursive(version: string, item: NavItemType): NavItemType {\n if (isNavItemWithChildren(item) && !item.skipVersioning) {\n return {\n ...item,\n items: item.items.map(child => replaceLinksRecursive(version, child))\n };\n }\n\n if (isNavItemWithLink(item) && !item.skipVersioning) {\n return {\n ...item,\n link: join('/', version, item.link)\n };\n }\n\n return item;\n}\n\n/**\n * Applies version prefixes to an array of navigation items.\n *\n * @param items - An array of navigation items to process.\n * @param version - The version string to prepend to links (e.g., `\"v2.0.0\"`).\n * - If `\"root\"` is provided, no version prefix is added.\n * @returns A new array of navigation items with versioned links applied.\n *\n * @remarks\n * - Uses {@link replaceLinksRecursive} to traverse each navigation item.\n * - Only items that are link-based or have children are modified; component items remain unchanged.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItems: NavItemType[] = [\n * { text: \"Guide\", link: \"/guide/\" },\n * { text: \"Docs\", items: [{ text: \"Intro\", link: \"/intro/\" }] }\n * ];\n * const versionedNav = populateNav(navItems, \"v2.0.0\");\n * // \u2192 [\n * // { text: \"Guide\", link: \"/v2.0.0/guide/\" },\n * // { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function populateNav(items: Array<NavItemType>, version: string): Array<NavItemType> {\n const state = inject(StateModel);\n if (version === 'root') version = '';\n\n return items.map(item => {\n if ('component' in item && item.component) {\n return {\n ...item,\n props: {\n ...item.props,\n versioningPlugin: {\n versions: state.versionsList,\n currentVersion: state.versionsConfig.current\n }\n }\n };\n }\n\n return replaceLinksRecursive(version, item);\n });\n}\n\n/**\n * Normalizes a navigation structure into a flat, prefixed record.\n *\n * @param results - The target {@link NavObjectType} to populate with normalized items.\n * @param nav - The navigation structure to normalize. Can be:\n * - An array of navigation items (`NavItemType[]`), or\n * - A record mapping strings to arrays of navigation items (`NavObjectType`).\n * @param prefix - Optional prefix for keys when processing nested navigation objects.\n * Defaults to an empty string.\n * @param root - Optional root-level navigation items to include in all normalized entries.\n *\n * @remarks\n * - If `nav` is an array, it merges it with the root items (if any) and appends to `results.root`.\n * - If `nav` is a record:\n * - Each key is prefixed with `prefix` unless it is `'root'`.\n * - Items from `root` or `root.root` are merged into each key.\n * - All items are accumulated in the `results` object, preserving the hierarchy as flat keys.\n *\n * @example\n * ```ts\n * const nav: NavObjectType = {\n * root: [{ text: \"Home\", link: \"/\" }],\n * guide: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const results: NavObjectType = { root: [] };\n * normalizeNav(results, nav, \"v2.0.0\");\n * // results \u2192 {\n * // root: [{ text: \"Home\", link: \"/\" }],\n * // \"v2.0.0/guide\": [{ text: \"Intro\", link: \"/intro/\" }]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNav(results: NavObjectType, nav: NavType, prefix: string = '', root: NavObjectType = {}): void {\n if (Array.isArray(nav)) {\n const index = prefix ? prefix : 'root';\n\n results[index] ??= [];\n results[index].push(...nav);\n if (root[index]) results[index].push(...root[index]);\n else if (root.root) results[index].push(...root.root);\n\n return;\n }\n\n for (const [ key, items ] of Object.entries(nav)) {\n const subRoot = key === 'root' && prefix === '' ? 'root' : prefix;\n const index = key === 'root' ? subRoot : join(prefix, key);\n\n results[index] ??= [];\n results[index].push(...items);\n if (root[key]) results[index].push(...root[key]);\n else if (root.root) results[index].push(...root.root);\n }\n}\n\n/**\n * Normalizes all navigation structures across the global and locale-specific configurations.\n *\n * @param state - The current {@link StateModel} providing configuration data:\n * - `configuration.themeConfig.nav` \u2014 global navigation configuration.\n * - `configuration.locales` \u2014 locale-specific configurations with optional `nav`.\n *\n * @returns A flat record of navigation items keyed by locale or `'root'`, suitable for further processing.\n *\n * @remarks\n * - First, global navigation items are normalized into `globalResults`.\n * - If no locales are defined, `globalResults` is returned directly.\n * - Otherwise, iterates through all locale keys:\n * - Normalizes each locale\u2019s `nav` configuration.\n * - Merges in global navigation items as fallback where necessary.\n * - Ensures that all navigation entries are flattened and ready for versioning or rendering.\n *\n * @example\n * ```ts\n * const state = inject(StateModel);\n * const normalizedNavs = normalizeNavs(state);\n * // normalizedNavs \u2192 {\n * // root: [...global items],\n * // en: [...English locale items including global fallback],\n * // de: [...German locale items including global fallback]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNavs(state: StateModel): Record<string, Array<NavItemType>> {\n const locales = state.configuration.locales;\n const localesKeys = Object.keys(locales);\n const globalResults: Record<string, Array<NavItemType>> = { root: [] };\n const switcher = versionSwitcher(state.versionsConfig, state.versionsList, state.versionsConfig.current);\n if(switcher) globalResults.root.push(switcher);\n\n if (state.configuration.themeConfig?.nav) {\n normalizeNav(globalResults, state.configuration.themeConfig.nav as NavType);\n }\n\n if (!localesKeys.length) return globalResults;\n const results: Record<string, Array<NavItemType>> = { root: [] };\n\n for (const locale of localesKeys) {\n const prefix = locale === 'root' || state.localesMap[locale] === 'root' ? 'root' : locale;\n normalizeNav(results, (locales[locale].themeConfig?.nav ?? []) as NavType, prefix, globalResults);\n }\n\n return results;\n}\n\n/**\n * Parses and populates the navigation structure for all locales.\n *\n * @remarks\n * - Retrieves normalized navigation items using {@link normalizeNavs}.\n * - Iterates through all locales defined in `vitepressConfig.locales`.\n * - For each locale:\n * - Falls back to global navigation (`navs.root`) if locale-specific navigation is not defined.\n * - Ensures the locale\u2019s `themeConfig` exists.\n * - Populates the locale\u2019s `themeConfig.nav` using {@link populateNav}, applying versioning where applicable.\n *\n * This function ensures that all locales have a fully initialized and version-aware navigation structure.\n *\n * @example\n * ```ts\n * parseNavs();\n * // state.vitepressConfig.locales \u2192 each locale has `themeConfig.nav` populated\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseNavs(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const navs = normalizeNavs(state);\n\n for (const [ key, locale ] of Object.entries(locales)) {\n const nav = navs[key] ?? navs.root;\n\n locale.themeConfig ??= {};\n locale.themeConfig.nav = populateNav(nav, key);\n }\n}\n", "/**\n * Imports\n */\n\nimport type { NavItemWithChildrenType } from '@interfaces/nav.interface';\nimport type { VersionsConfigInterface } from '@interfaces/configuration.interface';\n\n/**\n * Builds a version switcher navigation item for the documentation site.\n *\n * @param themeConfig - The {@link VersionsConfigInterface} configuration object.\n * @param versions - An array of available version strings.\n * @param current - The current version label, defaults to `\"Latest\"`.\n *\n * @returns A {@link NavItemWithChildrenType} representing the version switcher,\n * or `undefined` if the switcher is disabled in the configuration.\n *\n * @remarks\n * - If `themeConfig.versionSwitcher === false`, no switcher is created.\n * - The returned navigation item contains child links for each version in `versions`.\n * - If `includeCurrentVersion` is enabled, adds a link to the root (`\"/\"`)\n * for the currently active version, displayed as `\"Latest\"` or\n * `\"vX.Y.Z (latest)\"`.\n * - All version links have `skipVersioning: true` to prevent further prefixing.\n *\n * This utility allows users to quickly switch between documentation versions\n * from the navigation bar.\n *\n * @example\n * ```ts\n * const themeConfig: VersionsConfigInterface = {\n * versionSwitcher: { text: \"Versions\", includeCurrentVersion: true }\n * };\n *\n * const versions = [\"v2.0.0\", \"v1.5.0\"];\n * const navItem = versionSwitcher(themeConfig, versions, \"v2.0.0\");\n *\n * // \u2192 {\n * // text: \"Versions\",\n * // items: [\n * // { link: \"/\", text: \"v2.0.0 (latest)\", skipVersioning: true },\n * // { link: \"/v2.0.0/\", text: \"v2.0.0\", skipVersioning: true },\n * // { link: \"/v1.5.0/\", text: \"v1.5.0\", skipVersioning: true }\n * // ]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function versionSwitcher(themeConfig: VersionsConfigInterface, versions: Array<string>, current: string = 'Latest'): undefined | NavItemWithChildrenType {\n if (themeConfig.versionSwitcher === false) return;\n\n const { text, includeCurrentVersion } = themeConfig.versionSwitcher;\n const items = [];\n if (includeCurrentVersion) {\n items.push({\n link: '/',\n text: current === 'Latest' ? current : `${ current } (latest)`,\n skipVersioning: true\n });\n }\n\n for (const version of versions) {\n items.push({ text: version, link: `/${ version }/`, skipVersioning: true });\n }\n\n return { text, items };\n}\n", "/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Populates locale information in the VitePress configuration for all versions.\n *\n * @remarks\n * - Reads the `localesMap` from the `StateModel` to identify each user-defined locale.\n * - Copies `lang` and `label` from the user configuration into `vitepressConfig.locales`.\n * - For each version in `versionsList`, creates a versioned locale entry in `vitepressConfig.locales`.\n * - Ensures that both the root locale and versioned locales have proper `lang` and `label` settings.\n *\n * @example\n * ```ts\n * parseLocale();\n * console.log(state.vitepressConfig.locales);\n * // \u2192 { root: { lang: \"en\", label: \"English\" }, \"1.0/en\": { lang: \"en\" }, ... }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseLocale(): void {\n const state = inject(StateModel);\n const versions = state.versionsList;\n const locales = state.vitepressConfig.locales;\n const userLocales = state.configuration.locales;\n\n for (const key of Object.keys(state.localesMap)) {\n const index = state.localesMap[key];\n const isRoot = index === 'root';\n const localeObject = 'root' in userLocales ? userLocales[index] : userLocales[key];\n const localeItems = { ...localeObject, themeConfig: undefined };\n\n locales[index] ??= {};\n Object.assign(locales[index], localeItems);\n\n if(isRoot) locales[index].link = '/';\n else locales[index].link = `/${ locales[index].lang }/`;\n\n for (const version of versions) {\n const subIndex = isRoot ? version : join(key, version);\n locales[subIndex] ??= {};\n Object.assign(locales[subIndex], { ...localeItems });\n\n locales[subIndex].label = ' ';\n if(isRoot) locales[subIndex].link = '/';\n else locales[subIndex].link = `/${ locales[subIndex].lang }/`;\n }\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { SidebarItemType, SidebarObjectType, SidebarType } from '@interfaces/sidebar.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Populates sidebar items with versioned base paths.\n *\n * @param sidebar - The list of sidebar {@link SidebarItemType} items to transform.\n * @param version - The version key (e.g., `\"en\"`, `\"v1.0\"`, `\"root\"`).\n *\n * @returns A new sidebar array with versioned `base` properties applied.\n *\n * @remarks\n * - If the provided `version` is `\"root\"`, it is normalized to an empty prefix (`\"\"`).\n * - Items marked with `skipVersioning` are returned unchanged.\n * - When an item has a `link` or nested `items`, its `base` property is updated with the version prefix.\n * - Recursively processes child `items` to ensure consistent versioning throughout the sidebar tree.\n *\n * @example\n * ```ts\n * const sidebar: SidebarItemType[] = [\n * { text: \"Introduction\", link: \"/intro\" },\n * {\n * text: \"Guide\",\n * items: [\n * { text: \"Setup\", link: \"/setup\" }\n * ]\n * }\n * ];\n *\n * // Applying version \"v1\"\n * const result = populateSidebar(sidebar, \"v1\");\n *\n * // Result:\n * [\n * { text: \"Introduction\", link: \"/intro\", base: \"/v1/\" },\n * {\n * text: \"Guide\",\n * base: \"/v1/\",\n * items: [\n * { text: \"Setup\", link: \"/setup\", base: \"/v1/\" }\n * ]\n * }\n * ]\n * ```\n *\n * @see SidebarItemType\n * @since 2.0.0\n */\n\nexport function populateSidebar(sidebar: Array<SidebarItemType>, version: string): Array<SidebarItemType> {\n if (version === 'root') version = '';\n\n return sidebar.map(item => {\n if(item.skipVersioning) return item;\n item = { ...item };\n\n if((item.link || item.items) && version !== '') {\n item.base ??= '';\n item.base = join('/', version, item.base, '/');\n }\n\n return item;\n });\n}\n\n/**\n * Normalizes a sidebar definition into a flat {@link SidebarObjectType} structure.\n *\n * @param results - The target results object where normalized sidebar items will be accumulated.\n * @param sidebar - The sidebar definition to normalize, which can be an array of items or a path-based mapping.\n * @param prefix - The optional path prefix used for nested sidebar entries (defaults to `\"\"`).\n * @param root - A root-level sidebar object used as a fallback when merging items (defaults to `{}`).\n *\n * @returns void \u2014 Mutates the `results` object directly by appending normalized sidebar items.\n *\n * @remarks\n * - If the `sidebar` is an array, it is stored under the `prefix` key (or `\"root\"` if no prefix is given).\n * - If the `sidebar` is an object, each key is resolved into a full index path using the `prefix`.\n * - When merging items, entries from `root` (matching key or `\"root\"`) are prepended to the results.\n * - Ensures all sidebar values are normalized into arrays, even if a single item is provided.\n *\n * @example\n * ```ts\n * const results: SidebarObjectType = {};\n * normalizeSidebar(results, [\n * { text: \"Intro\", link: \"/intro\" }\n * ]);\n *\n * // Result:\n * {\n * root: [\n * { text: \"Intro\", link: \"/intro\" }\n * ]\n * }\n * ```\n *\n * @example\n * ```ts\n * const results: SidebarObjectType = {};\n * normalizeSidebar(results, {\n * guide: [\n * { text: \"Getting Started\", link: \"/guide/start\" }\n * ]\n * }, \"en\");\n *\n * // Result:\n * {\n * \"en/guide\": [\n * { text: \"Getting Started\", link: \"/guide/start\" }\n * ]\n * }\n * ```\n *\n * @see SidebarType\n * @see SidebarObjectType\n *\n * @since 2.0.0\n */\n\nexport function normalizeSidebar(results: SidebarObjectType, sidebar: SidebarType, prefix: string = '', root: SidebarObjectType = {}): void {\n if (Array.isArray(sidebar)) {\n const index = prefix ? prefix : 'root';\n results[index] ??= [];\n\n if (root[index]) results[index].push(...root[index]);\n else if (root.root) results[index].push(...root.root);\n results[index].push(...sidebar);\n\n return;\n }\n\n for (const [ key, items ] of Object.entries(sidebar)) {\n const subRoot = key === 'root' && prefix === '' ? 'root' : prefix;\n const index = key === 'root' ? subRoot : join(prefix, key);\n const itemsArray = Array.isArray(items) ? items : [ items ];\n results[index] ??= [];\n\n if (root[key]) results[index].push(...root[key]);\n else if (root.root) results[index].push(...root.root);\n results[index].push(...itemsArray);\n }\n}\n\n/**\n * Normalizes all sidebar structures across global and locale-specific configurations.\n *\n * @param state - The current {@link StateModel} providing configuration data:\n * - `configuration.themeConfig.sidebar` \u2014 global sidebar configuration.\n * - `configuration.locales` \u2014 locale-specific configurations with optional `sidebar`.\n * - `localesMap` \u2014 maps locale keys to normalized paths for root fallback.\n *\n * @returns A flat {@link SidebarObjectType} where each key corresponds to a locale\n * or `\"root\"` and contains an array of normalized sidebar items.\n *\n * @remarks\n * - Global sidebar items are first normalized into `globalResults`.\n * - If no locales are defined, `globalResults` is returned directly.\n * - For each locale:\n * - Computes a `prefix` key for the locale (falling back to `\"root\"` if necessary).\n * - Normalizes the locale\u2019s sidebar using {@link normalizeSidebar}, merging in global items as fallback.\n * - Ensures that all sidebar entries are flattened and ready for versioning or rendering.\n *\n * @example\n * ```ts\n * const state = inject(StateModel);\n * const sidebars = normalizeSidebars(state);\n * // sidebars \u2192 {\n * // root: [...global items],\n * // en: [...English locale items including global fallback],\n * // fr: [...French locale items including global fallback]\n * // }\n * ```\n *\n * @see SidebarType\n * @see normalizeSidebar\n * @see SidebarObjectType\n *\n * @since 2.0.0\n */\n\nexport function normalizeSidebars(state: StateModel): SidebarObjectType {\n const locales = state.configuration.locales;\n const localesKeys = Object.keys(locales);\n const globalResults: SidebarObjectType = { root: [] };\n\n if (state.configuration.themeConfig?.sidebar) {\n normalizeSidebar(globalResults, state.configuration.themeConfig.sidebar as SidebarType);\n }\n\n if (!localesKeys.length) return globalResults;\n const results: SidebarObjectType = { root: [] };\n\n for (const locale of localesKeys) {\n const prefix = locale === 'root' || state.localesMap[locale] === 'root' ? 'root' : locale;\n normalizeSidebar(results, (locales[locale].themeConfig?.sidebar ?? []) as SidebarType, prefix, globalResults);\n }\n\n return results;\n}\n\n/**\n * Parses and populates the sidebar structure for all locales.\n *\n * @remarks\n * - Retrieves normalized sidebar items using {@link normalizeSidebars}.\n * - Iterates through all locales defined in `vitepressConfig.locales`.\n * - For each locale:\n * - Falls back to global sidebar (`sidebars.root`) if locale-specific sidebar is not defined.\n * - Ensures the locale\u2019s `themeConfig` exists.\n * - Populates the locale\u2019s `themeConfig.sidebar` using {@link populateSidebar}, applying versioning where applicable.\n *\n * This function ensures that all locales have a fully initialized and version-aware sidebar structure.\n *\n * @example\n * ```ts\n * parseSidebar();\n * // state.vitepressConfig.locales \u2192 each locale has `themeConfig.sidebar` populated\n * ```\n *\n * @see SidebarType\n * @see populateSidebar\n * @see SidebarObjectType\n * @see normalizeSidebars\n *\n * @since 2.0.0\n */\n\nexport function parseSidebar(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const sidebars = normalizeSidebars(state);\n\n for (const [ key, locale ] of Object.entries(locales)) {\n const sidebar = sidebars[key] ?? sidebars.root;\n\n locale.themeConfig ??= {};\n locale.themeConfig.sidebar = populateSidebar(sidebar, key);\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { UserConfig } from 'vitepress';\nimport type { PartialConfigurationType } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { StateModel } from '@models/state.model';\nimport { parseNavs } from '@components/nav.component';\nimport { deepMerge } from '@components/object.component';\nimport { parseLocale } from '@components/locale.component';\nimport { parseSidebar } from '@components/sidebar.component';\nimport { forceInject } from '@symlinks/services/inject.service';\nimport { parseRoutesComponent } from '@components/rewrites.component';\nimport { defaultConfiguration } from '@constants/configuration.constant';\n\n/**\n * Export interfaces\n */\n\nexport type * from 'vitepress';\nexport type * from '@interfaces/nav.interface';\nexport type * from '@interfaces/theme.interface';\nexport type * from '@interfaces/locale.interface';\nexport type * from '@interfaces/sidebar.interface';\nexport type * from '@interfaces/configuration.interface';\n\nexport function defineVersionedConfig(userConfiguration: PartialConfigurationType): UserConfig {\n const config = deepMerge(defaultConfiguration, userConfiguration);\n const state = forceInject(StateModel, config).init();\n parseLocale();\n\n /**\n * Parse components\n */\n\n parseNavs();\n parseSidebar();\n parseRoutesComponent();\n\n return <UserConfig> state.vitepressConfig;\n}\n"],
|
|
6
|
-
"mappings": "2PAYA,OAAS,QAAAA,EAAM,SAAAC,MAAa,OAC5B,OAAS,SAAAC,MAAa,sCCOf,IAAMC,EAAa,IAAI,IAYjBC,EAAc,IAAI,IAYxB,SAASC,EAAmBC,EAA0D,CACzF,OAAO,OAAOA,GAAa,UAAYA,IAAa,MAAQ,aAAcA,CAC9E,CAFgBC,EAAAF,EAAA,sBAcT,SAASG,EAAqBF,EAA4D,CAC7F,OAAO,OAAOA,GAAa,UAAYA,IAAa,MAAQ,eAAgBA,CAChF,CAFgBC,EAAAC,EAAA,wBAcT,SAASC,EAAmBH,EAA0D,CACzF,OAAO,OAAOA,GA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AM,eAC9B,CAdgBO,EAAAZ,GAAA",
|
|
4
|
+
"sourceRoot": "https://github.com/viteplus/versions/tree/v2.0.2/",
|
|
5
|
+
"sourcesContent": ["/**\n * Import will remove at compile time\n */\n\nimport type { Dirent } from 'fs';\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\nimport type { VersionsConfigInterface, VitepressConfigInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { join, posix } from 'path';\nimport { xterm } from '@remotex-labs/xansi/xterm.component';\nimport { Injectable } from '@symlinks/services/inject.service';\nimport { existsSync, mkdirSync, readdirSync, writeFileSync } from 'fs';\nimport { defaultConfiguration } from '@constants/configuration.constant';\nimport { getAllMarkdownFilesRelative } from '@components/object.component';\n\n/**\n * Manages the state of a versioned VitePress documentation project.\n *\n * @remarks\n * The `StateModel` class is responsible for:\n * - Managing source and archive directories for versioned documentation.\n * - Initializing the VitePress configuration (`VitepressConfigInterface`) from\n * a provided {@link ConfigurationInterface}.\n * - Maintaining a list of documentation versions and a map of Markdown files per version.\n * - Ensuring the necessary directories exist and are initialized.\n *\n * This service is designed as a singleton, making it safe to inject across\n * your application using `@Injectable({ scope: 'singleton' })`.\n *\n * @example\n * ```ts\n * import { StateModel } from \"@models/state.model\";\n *\n * const state = new StateModel(config).init();\n * console.log(state.versionsList);\n * console.log(state.fileMap);\n * ```\n *\n * @since 2.0.0\n */\n\n@Injectable({\n scope: 'singleton'\n})\nexport class StateModel {\n /**\n * The root path of the documentation project,\n * based on the current working directory and optional srcDir.\n *\n * @since 2.0.0\n */\n\n readonly root: string;\n\n /**\n * The name of the sources directory from which current content.\n *\n * @default `src`\n * @since 2.0.0\n */\n\n readonly sources: string;\n\n /**\n * The name of the archive directory where old versions are stored.\n *\n * @default `archive`\n * @since 2.0.0\n */\n\n readonly archive: string;\n\n /**\n * Full path to the `sources` directory.\n *\n * @since 2.0.0\n */\n\n readonly sourcesPath: string;\n\n /**\n * Full path to the `archive` directory.\n *\n * @since 2.0.0\n */\n\n readonly archivePath: string;\n\n /**\n * The `versions` configuration object for the plugin.\n *\n * @remarks\n * This property holds the currently active versions configuration\n * as defined in {@link VersionsConfigInterface}. It includes settings\n * like the current version, sources, archive, hooks, and version switcher.\n *\n * @see VersionsConfigInterface\n * @since 2.0.0\n */\n\n readonly versionsConfig: VersionsConfigInterface;\n\n /**\n * The VitePress configuration object crafted from the user-provided configuration,\n * with versioning support added.\n *\n * @remarks\n * This object is based on the user configuration and extended to include\n * locales, rewrites, and versioning-aware settings. It is typed as\n * {@link VitepressConfigInterface}.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n readonly vitepressConfig: VitepressConfigInterface;\n\n /**\n * List of all available documentation versions.\n *\n * @remarks\n * This array is populated during initialization (`init()`) by reading the archive\n * and sources directories. Each element is a version string (e.g., `\"1.0\"`, `\"2.0\"`).\n *\n * @since 2.0.0\n */\n\n readonly versionsList: Array<string> = [];\n\n /**\n * Maps locale keys to their effective base paths.\n *\n * @remarks\n * - Keys are the locale identifiers as defined in the user configuration\n * (e.g., `\"de\"`, `\"root\"`).\n * - Values are the corresponding effective base paths or link prefixes\n * used inside the generated VitePress config.\n * - The `\"root\"` locale always maps to the default language of the site.\n *\n * This mapping is used internally to resolve and normalize locale-based\n * routing for both source files and versioned archives.\n *\n * @example\n * ```ts\n * localesMap = {\n * en: \"root\",\n * de: \"de\"\n * };\n * ```\n *\n * @since 2.0.0\n */\n\n readonly localesMap: Record<string, string> = {};\n\n /**\n * A map of version names to arrays of Markdown file paths relative to the sources directory.\n *\n * @remarks\n * - The key is the version name (or `''` for the root/source version).\n * - The value is an array of file paths (strings) for that version.\n *\n * This structure is built during initialization to facilitate generating versioned\n * documentation and navigation.\n *\n * @since 2.0.0\n */\n\n readonly fileMap: Record<string, Array<string>> = {};\n\n /**\n * Creates an instance of `StateModel`.\n *\n * @param configuration - Optional configuration object; defaults to {@link defaultConfiguration}.\n *\n * @throws Will throw an error if the sources directory does not exist.\n *\n * @remarks\n * Initializes the state of the documentation project by:\n * - Extracting `sources` and `archive` from the provided configuration.\n * - Constructing full paths for `root`, `sourcesPath`, and `archivePath`.\n * - Validating that the sources directory exists.\n * - Ensuring the archive directory exists and creating a `.gitkeep` file if necessary.\n * - Creating a VitePress configuration object with versioning support.\n *\n * @since 2.0.0\n */\n\n constructor(readonly configuration: ConfigurationInterface = defaultConfiguration) {\n const { sources, archive } = configuration.versionsConfig;\n\n this.sources = sources;\n this.archive = archive;\n this.versionsConfig = configuration.versionsConfig;\n\n this.root = join(process.cwd(), process.argv[3] ?? '', configuration.srcDir ?? '');\n this.sourcesPath = join(this.root, this.sources);\n this.archivePath = join(this.root, this.archive);\n\n if (!existsSync(this.sourcesPath)) {\n console.error(xterm.red('[ viteplus ]'), `Source directory ${ this.sourcesPath } does not exist\\n`);\n throw new Error(`Source directory ${ this.sourcesPath } does not exist`);\n }\n\n this.makeArchiveDirectory(this.archivePath);\n this.vitepressConfig = this.createVitepressConfig();\n }\n\n /**\n * Initializes the state by reading archive subfolders and building file maps.\n *\n * @returns The instance itself (`this`) to allow method chaining.\n *\n * @remarks\n * This method performs the following steps:\n * - Reads all subdirectories in the archive directory.\n * - Populates `fileMap` with all Markdown files relative to the sources directory.\n * - The root source files are stored under the `''` key.\n * - Archive subfolders are stored under their folder names.\n * - Initializes `vitepressConfig.locales` for each folder with an empty `themeConfig`.\n * - Populates `versionsList` with all version keys derived from `fileMap`.\n *\n * @since 2.0.0\n */\n\n init(): this {\n const subFolders = readdirSync(this.archivePath, { withFileTypes: true })\n .filter((entry: Dirent) => entry.isDirectory());\n\n this.fileMap[''] = getAllMarkdownFilesRelative(this.sourcesPath);\n this.vitepressConfig.locales['root'] = {\n themeConfig: {}\n };\n\n for (const folder of subFolders) {\n const path = join(folder.parentPath, folder.name);\n this.fileMap[folder.name] = getAllMarkdownFilesRelative(path);\n }\n\n this.initializeLocalesMap();\n\n return this;\n }\n\n /**\n * Initializes the locale entries in the VitePress configuration and builds a mapping\n * of locales to their links for all versions.\n *\n * @remarks\n * - Adds a `root` locale entry.\n * - Copies all user-defined locales into the VitePress config.\n * - Populates `localesMap` with locale keys and their corresponding links (or folder names).\n * - Ensures that for each documentation version, a locale entry exists in the VitePress config.\n * - Handles both root and non-root locales, creating versioned paths automatically.\n *\n * @since 2.0.0\n */\n\n private initializeLocalesMap(): void {\n const locales = this.vitepressConfig.locales;\n const userLocales = this.configuration.locales;\n this.versionsList.push(...Object.keys(this.fileMap).filter(Boolean));\n\n locales['root'] = {};\n if (Object.keys(userLocales).length > 0) {\n const keys = Object.keys(userLocales);\n const rootLocaleKey = 'root' in userLocales ? 'root' : keys[0];\n\n for (const key of keys) {\n const index = userLocales[key].lang ?? key;\n for (const version of this.versionsList) {\n if(key === rootLocaleKey) continue;\n const versionPath = posix.join(index, version);\n locales[versionPath] = {};\n }\n\n if (key === rootLocaleKey) {\n this.localesMap[userLocales[key].link ?? index] = 'root';\n } else {\n locales[key] = {};\n this.localesMap[userLocales[key].link ?? index] = key;\n }\n }\n }\n\n for (const version of this.versionsList) {\n locales[version] = {};\n }\n }\n\n /**\n * Ensures that the archive directory exists.\n *\n * @param path - The path to the archive directory.\n *\n * @remarks\n * - If the directory does not exist, it is created.\n * - A `.gitkeep` file is also added to ensure the directory is tracked by Git.\n *\n * @since 2.0.0\n */\n\n private makeArchiveDirectory(path: string): void {\n if (!path) return;\n\n if (!existsSync(path)) {\n mkdirSync(path);\n writeFileSync(join(path, '.gitkeep'), '');\n }\n }\n\n /**\n * Creates a VitePress configuration object from the user-provided configuration.\n *\n * @returns A `VitepressConfigInterface` object with versioning support added.\n *\n * @remarks\n * - Copies all configuration properties except for `locales`, `rewrites`, `themeConfig`, and `versionsConfig`.\n * - Initializes excluded properties (except `versionsConfig`) with empty objects.\n * - Returns a configuration object typed as {@link VitepressConfigInterface}, ready for VitePress usage.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n private createVitepressConfig(): VitepressConfigInterface {\n const result: Record<string, unknown> = {};\n const exclude: Array<keyof ConfigurationInterface> = [\n 'locales',\n 'rewrites',\n 'themeConfig',\n 'versionsConfig'\n ];\n\n for (const key of Object.keys(this.configuration) as Array<keyof ConfigurationInterface>) {\n if (!exclude.includes(key)) {\n result[key] = this.configuration[key];\n } else if (key === 'themeConfig') {\n const themeConfig = this.configuration.themeConfig ?? {};\n result.themeConfig = Object.fromEntries(\n Object.entries(themeConfig).filter(\n ([ prop ]) => prop !== 'nav' && prop !== 'sidebar'\n )\n );\n } else if (key !== 'versionsConfig') {\n result[key] = {};\n }\n }\n\n return <VitepressConfigInterface><unknown>result;\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ProviderUseClassInterface } from '@symlinks/interfaces/symlinks.interface';\nimport type { ConstructorLikeType, ConstructorType } from '@interfaces/function.interface';\nimport type { InjectableOptionsInterface, ProvidersType } from '@symlinks/interfaces/symlinks.interface';\nimport type { ProviderUseFactoryInterface, ProviderUseValueInterface } from '@symlinks/interfaces/symlinks.interface';\n\n/**\n * A collection of singleton instances for injectable classes.\n *\n * @remarks\n * This map stores instances of classes marked as `singleton` in `@Injectable` metadata.\n * It ensures that only one instance exists for the lifetime of the application.\n *\n * @see ConstructorType\n * @since 2.0.0\n */\n\nexport const SINGLETONS = new Map<ConstructorType, unknown>();\n\n/**\n * Stores metadata for all classes marked with the `@Injectable` decorator.\n *\n * @remarks\n * The metadata includes scope, factory function, and provider dependencies.\n *\n * @see Injectable\n * @since 2.0.0\n */\n\nexport const INJECTABLES = new Map<ConstructorType, InjectableOptionsInterface>();\n\n/**\n * Type guard to check if a provider uses a class.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseClassInterface}.\n *\n * @see ProviderUseClassInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseClass(provider: unknown): provider is ProviderUseClassInterface {\n return typeof provider === 'object' && provider !== null && 'useClass' in provider;\n}\n\n/**\n * Type guard to check if a provider uses a factory function.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseFactoryInterface}.\n *\n * @see ProviderUseFactoryInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseFactory(provider: unknown): provider is ProviderUseFactoryInterface {\n return typeof provider === 'object' && provider !== null && 'useFactory' in provider;\n}\n\n/**\n * Type guard to check if a provider uses a value.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseValueInterface}.\n *\n * @see ProviderUseValueInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseValue(provider: unknown): provider is ProviderUseValueInterface {\n return typeof provider === 'object' && provider !== null && 'useValue' in provider;\n}\n\n/**\n * Marks a class as injectable, optionally providing metadata.\n *\n * @param options - Optional configuration for the injectable class.\n *\n * @remarks\n * The `@Injectable` decorator allows classes to be automatically instantiated\n * and injected with dependencies using the `inject` function.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const instance = inject(MyService);\n * ```\n *\n * @see InjectableOptionsInterface\n * @since 2.0.0\n */\n\nexport function Injectable<T extends ConstructorType = ConstructorType>(options?: InjectableOptionsInterface<T>) {\n return function (target: T): void {\n INJECTABLES.set(target, <InjectableOptionsInterface>options || {});\n };\n}\n\n/**\n * Converts an array of providers into constructor arguments for injection.\n *\n * @param providers - An optional array of providers to resolve.\n * @param args - Optional initial arguments to prepend before resolving providers.\n * @returns An array of resolved arguments including the results from providers.\n *\n * @remarks\n * This function iterates over the provided `ProvidersType` array and converts each provider\n * into its resolved value. It supports class providers, factory providers, value providers,\n * and direct constructor functions. The returned array can be used to construct instances\n * with dependencies injected in the correct order.\n *\n * @example\n * ```ts\n * const args = providersIntoArgs([{ useValue: 42 }, { useFactory: () => 'hello' }]);\n * // args = [42, 'hello']\n * ```\n *\n * @see isProviderUseClass\n * @see isProviderUseValue\n * @see isProviderUseFactory\n *\n * @since 2.0.0\n */\n\nexport function providersIntoArgs(providers?: ProvidersType, args: Array<unknown> = []): Array<unknown> {\n if (!providers) return args;\n\n const scopeAgs: Array<unknown> = args;\n for (const provider of providers.slice(scopeAgs.length)) {\n if (isProviderUseClass(provider)) {\n scopeAgs.push(inject(provider.useClass, ...providersIntoArgs(provider.providers)));\n } else if (isProviderUseFactory(provider)) {\n scopeAgs.push(provider.useFactory(...providersIntoArgs(provider.providers)));\n } else if (isProviderUseValue(provider)) {\n scopeAgs.push(provider.useValue);\n } else if (typeof provider === 'function') {\n scopeAgs.push(inject(provider));\n } else {\n throw new Error(`Unknown provider type: ${ typeof provider }`);\n }\n }\n\n return scopeAgs;\n}\n\n/**\n * Resolves and instantiates a class with its dependencies.\n *\n * @param token - The constructor function or class to instantiate.\n * @param args - Optional arguments to pass to the constructor, which can override\n * or supplement provider-resolved values.\n * @returns An instance of the class with all dependencies injected.\n *\n * @remarks\n * The `inject` function looks up metadata for the class marked with `@Injectable`.\n * It resolves all providers recursively using `providersIntoArgs`. If the class is\n * marked as a `singleton`, the same instance will be returned on further calls.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const instance = inject(MyService);\n * ```\n *\n * @see Injectable\n * @see providersIntoArgs\n *\n * @since 2.0.0\n */\n\nexport function inject<T, Args extends Array<unknown>>(token: ConstructorLikeType<T, Args>, ...args: Partial<Args>): T {\n if (SINGLETONS.has(token)) return <T>SINGLETONS.get(token);\n\n const metadata = INJECTABLES.get(token)!;\n if (!metadata) throw new Error(`Cannot inject ${ token.name } \u2013 not marked @Injectable`);\n\n const scopeAgs = providersIntoArgs(metadata.providers, args);\n const instance: T = metadata.factory\n ? <T>metadata.factory(...scopeAgs)\n : new token(...scopeAgs as Args);\n\n if (metadata?.scope === 'singleton') {\n SINGLETONS.set(token, instance);\n }\n\n return instance;\n}\n\n/**\n * Forces the instantiation of a class, bypassing any existing singleton instance.\n *\n * @param token - The constructor function or class to instantiate.\n * @param args - Optional arguments to pass to the constructor, which can override\n * or supplement provider-resolved values.\n * @returns A new instance of the class, even if a singleton instance already exists.\n *\n * @remarks\n * Unlike the `inject` function, `forceInject` will delete any existing singleton\n * instance for the given class before creating a new one. This is useful when you\n * need a fresh instance regardless of the singleton scope.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const freshInstance = forceInject(MyService);\n * ```\n *\n * @see inject\n * @since 2.0.0\n */\n\nexport function forceInject<T, Args extends Array<unknown>>(token: ConstructorLikeType<T, Args>, ...args: Partial<Args>): T {\n if (SINGLETONS.has(token)) SINGLETONS.delete(token);\n\n return inject<T, Args>(token, ...args);\n}\n", "/**\n * imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Rewrites a documentation source path using version and locale.\n *\n * @remarks\n * This implementation joins the `version`, `locale`, and original `source`\n * into a normalized POSIX-style path. It is commonly used to generate\n * consistent URLs or filesystem paths for versioned and localized docs.\n *\n * @param source - The original file path or content identifier.\n * @param version - The version string of the documentation (e.g., `\"1.2.0\"`).\n * @param locale - The locale code (e.g., `\"en\"`, `\"de\"`).\n *\n * @returns The rewritten path string in the format `version/locale/source`.\n *\n * @example\n * ```ts\n * rewritesHook(\"guide/intro.md\", \"v2.0.0\", \"en\");\n * // \u2192 \"en/v2.0.0/guide/intro.md\"\n * ```\n *\n * @since 2.0.0\n */\n\nexport function rewritesHook(source: string, version: string, locale: string): string {\n return join(locale, version, source);\n}\n\n/**\n * Parses all documentation routes and generates rewritten paths for versioned and localized files.\n *\n * @remarks\n * - Iterates through the `fileMap` of the `StateModel` to process all Markdown files.\n * - Determines the correct locale for each file using `localesMap`.\n * - Uses the `rewritesHook` from `versionsConfig.hooks` to generate the versioned and localized path.\n * - Populates the `vitepressConfig.rewrites` object with the mapping of original paths to rewritten paths.\n *\n * @example\n * ```ts\n * parseRoutesComponent();\n * console.log(state.vitepressConfig.rewrites);\n * // \u2192 {\n * \"src/en/index.md\": \"en/index.md\",\n * \"src/de/index.md\": \"index.md\",\n * \"archive/x0.0.1/en/index.md\": \"x0.0.1/en/index.md\"\n * ...\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseRoutesComponent(): void {\n const result: Record<string, string> = {};\n const state = inject(StateModel);\n const localesPrefix = Object.keys(state.localesMap);\n\n for (const [ folder, fileList ] of Object.entries(state.fileMap)) {\n const prefix = folder === '' ? state.sources : state.archive;\n\n for (const file of fileList) {\n const localeKey = localesPrefix[localesPrefix.findIndex(item => file.startsWith(item))];\n const locale = state.localesMap[localeKey] === 'root' ? '' : localeKey ?? '';\n\n result[join(prefix, folder, file)] = state.versionsConfig.hooks.rewritesHook(\n file.replace(localeKey + '/', ''), folder, locale\n );\n }\n }\n\n state.vitepressConfig.rewrites = result;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { rewritesHook } from '@components/rewrites.component';\n\n/**\n * Default configuration object for the `versions` system.\n *\n * @remarks\n * Provides a baseline implementation of {@link ConfigurationInterface}.\n * This includes:\n * - Empty `locales` and `rewrites` mappings.\n * - A `versionsConfig` with:\n * - `current` set to `\"latest\"`.\n * - `sources` pointing to `\"src\"`.\n * - `archive` pointing to `\"archive\"`.\n * - `hooks.rewritesHook` bound to the default {@link rewritesHook}.\n * - A `versionSwitcher` enabled with label `\"Switch Version\"` and\n * `includeCurrentVersion` set to `true`.\n *\n * This default setup can be extended or overridden as needed when\n * customizing your documentation site.\n *\n * @example\n * ```ts\n * import { defaultConfiguration } from \"@config/default.configuration\";\n *\n * export default {\n * ...defaultConfiguration,\n * locales: {\n * en: { link: \"/en/\", label: \"English\" }\n * }\n * };\n * ```\n *\n * @since 2.0.0\n */\n\nexport const defaultConfiguration: ConfigurationInterface = {\n locales: {},\n rewrites: {},\n versionsConfig: {\n current: 'latest',\n sources: 'src',\n archive: 'archive',\n hooks: {\n rewritesHook: rewritesHook\n },\n versionSwitcher: {\n text: 'Switch Version',\n includeCurrentVersion: true\n }\n }\n};\n", "/**\n * Imports\n */\n\nimport { readdirSync } from 'fs';\nimport { join, relative } from 'path/posix';\n\n/**\n * Deeply merges two object types into a single object.\n *\n * @typeParam T - The type of the first object.\n * @typeParam U - The type of the second object.\n *\n * @param obj1 - The base object whose properties will be merged.\n * @param obj2 - The object whose properties will overwrite or merge into `obj1`.\n * @returns A new object containing the deeply merged properties of both `obj1` and `obj2`.\n *\n * @remarks\n * - This function performs a deep merge, recursively merging nested objects.\n * - If a property exists in both `obj1` and `obj2`:\n * - If both values are plain objects, they are merged recursively.\n * - Otherwise, the value from `obj2` overwrites the value from `obj1`.\n * - Arrays are **not** merged; if a property is an array in `obj2`, it will replace\n * the corresponding property in `obj1`.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { c: 2, d: 3 } };\n * const obj2 = { b: { c: 42 }, e: 99 };\n *\n * const merged = deepMerge(obj1, obj2);\n * // Result: { a: 1, b: { c: 42, d: 3 }, e: 99 }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function deepMerge<T extends object, U extends object>(obj1: T, obj2: U): T & U {\n const result = <Record<string, unknown>> { ...obj1 };\n\n for (const key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n const val2 = (obj2 as T & U)[key];\n const val1 = (obj1 as T & U)[key];\n\n if (\n val1 && typeof val1 === 'object' &&\n val2 && typeof val2 === 'object' &&\n !Array.isArray(val2) && !Array.isArray(val2)\n ) {\n result[key] = deepMerge(val1 as object, val2 as object);\n } else {\n result[key] = val2;\n }\n }\n }\n\n return result as T & U;\n}\n\n/**\n * Recursively collects all Markdown (`.md`) files within a given directory,\n * returning their paths relative to a specified root directory.\n *\n * @param rootDir - The root directory used as the base for relative paths.\n * @param currentDir - The current directory to scan. Defaults to `rootDir`.\n * @returns An array of relative file paths to Markdown files.\n *\n * @remarks\n * - This function traverses directories recursively.\n * - Only files with a `.md` extension are included in the results.\n * - Returned paths are **relative to `rootDir`**, regardless of how deep the files are nested.\n * - Uses Node.js `fs.readdirSync` with `withFileTypes: true` for efficient directory traversal.\n *\n * @example\n * ```ts\n * const markdownFiles = getAllMarkdownFilesRelative(\"/project/docs\");\n *\n * console.log(markdownFiles);\n * // Example output:\n * // [\n * // \"README.md\",\n * // \"guide/intro.md\",\n * // \"tutorial/setup.md\"\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function getAllMarkdownFilesRelative(rootDir: string, currentDir: string = rootDir): Array<string> {\n let results: Array<string> = [];\n const entries = readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(currentDir, entry.name);\n\n if (entry.isDirectory()) {\n results = results.concat(getAllMarkdownFilesRelative(rootDir, fullPath));\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n const relativePath = relative(rootDir, fullPath);\n results.push(relativePath);\n }\n }\n\n return results;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { NavItemType, NavItemWithChildrenType } from '@interfaces/nav.interface';\nimport type { NavItemWithLinkType, NavObjectType, NavType } from '@interfaces/nav.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\nimport { versionSwitcher } from '@components/switcher.component';\n\n/**\n * Type guard to check if a navigation item has children.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithChildrenType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of an `item` property that is an array.\n * - Use this type guard to safely access child navigation items when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Docs\", items: [{ text: \"Guide\", link: \"/guide/\" }] };\n * if (isNavItemWithChildren(item)) {\n * console.log(item.items); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithChildren(item: NavItemType): item is NavItemWithChildrenType {\n return 'items' in item && Array.isArray(item.items);\n}\n\n/**\n * Type guard to check if a navigation item has a link.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithLinkType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of a `link` property.\n * - Use this type guard to safely access the `link` property when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Home\", link: \"/\" };\n * if (isNavItemWithLink(item)) {\n * console.log(item.link); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithLink(item: NavItemType): item is NavItemWithLinkType {\n return 'link' in item && !!item.link;\n}\n\n/**\n * Recursively prepends a version prefix to navigation item links.\n *\n * @param version - The version string to prefix (e.g., `\"v2.0.0\"`).\n * @param item - The navigation item to process, which can be a link, a group with children, or a component.\n * @returns A new navigation item with updated `link` values where applicable.\n *\n * @remarks\n * - For {@link NavItemWithLinkType}, prepends the given `version` to the `link`\n * unless `skipVersioning` is `true`.\n * - For {@link NavItemWithChildrenType}, recursively traverses all children and applies\n * the same transformation.\n * - Component-based navigation items ({@link NavItemComponentType}) are returned as-is.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItem: NavItemWithLinkType = { text: \"Guide\", link: \"/guide/\" };\n * const result = replaceLinksRecursive(\"v2.0.0\", navItem);\n * // \u2192 { text: \"Guide\", link: \"/v2.0.0/guide/\" }\n *\n * const navGroup: NavItemWithChildrenType = {\n * text: \"Docs\",\n * items: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const groupResult = replaceLinksRecursive(\"v2.0.0\", navGroup);\n * // \u2192 { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function replaceLinksRecursive(version: string, item: NavItemType): NavItemType {\n if (isNavItemWithChildren(item) && !item.skipVersioning) {\n return {\n ...item,\n items: item.items.map(child => replaceLinksRecursive(version, child))\n };\n }\n\n if (isNavItemWithLink(item) && !item.skipVersioning) {\n return {\n ...item,\n link: join('/', version, item.link)\n };\n }\n\n return item;\n}\n\n/**\n * Applies version prefixes to an array of navigation items.\n *\n * @param items - An array of navigation items to process.\n * @param version - The version string to prepend to links (e.g., `\"v2.0.0\"`).\n * - If `\"root\"` is provided, no version prefix is added.\n * @returns A new array of navigation items with versioned links applied.\n *\n * @remarks\n * - Uses {@link replaceLinksRecursive} to traverse each navigation item.\n * - Only items that are link-based or have children are modified; component items remain unchanged.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItems: NavItemType[] = [\n * { text: \"Guide\", link: \"/guide/\" },\n * { text: \"Docs\", items: [{ text: \"Intro\", link: \"/intro/\" }] }\n * ];\n * const versionedNav = populateNav(navItems, \"v2.0.0\");\n * // \u2192 [\n * // { text: \"Guide\", link: \"/v2.0.0/guide/\" },\n * // { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function populateNav(items: Array<NavItemType>, version: string): Array<NavItemType> {\n const state = inject(StateModel);\n if (version === 'root') version = '';\n\n return items.map(item => {\n if ('component' in item && item.component) {\n return {\n ...item,\n props: {\n ...item.props,\n versioningPlugin: {\n versions: state.versionsList,\n currentVersion: state.versionsConfig.current\n }\n }\n };\n }\n\n return replaceLinksRecursive(version, item);\n });\n}\n\n/**\n * Normalizes a navigation structure into a flat, prefixed record.\n *\n * @param results - The target {@link NavObjectType} to populate with normalized items.\n * @param nav - The navigation structure to normalize. Can be:\n * - An array of navigation items (`NavItemType[]`), or\n * - A record mapping strings to arrays of navigation items (`NavObjectType`).\n * @param prefix - Optional prefix for keys when processing nested navigation objects.\n * Defaults to an empty string.\n * @param root - Optional root-level navigation items to include in all normalized entries.\n *\n * @remarks\n * - If `nav` is an array, it merges it with the root items (if any) and appends to `results.root`.\n * - If `nav` is a record:\n * - Each key is prefixed with `prefix` unless it is `'root'`.\n * - Items from `root` or `root.root` are merged into each key.\n * - All items are accumulated in the `results` object, preserving the hierarchy as flat keys.\n *\n * @example\n * ```ts\n * const nav: NavObjectType = {\n * root: [{ text: \"Home\", link: \"/\" }],\n * guide: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const results: NavObjectType = { root: [] };\n * normalizeNav(results, nav, \"v2.0.0\");\n * // results \u2192 {\n * // root: [{ text: \"Home\", link: \"/\" }],\n * // \"v2.0.0/guide\": [{ text: \"Intro\", link: \"/intro/\" }]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNav(results: NavObjectType, nav: NavType, prefix: string = '', root: NavObjectType = {}): void {\n if (Array.isArray(nav)) {\n const index = prefix ? prefix : 'root';\n\n results[index] ??= [];\n results[index].push(...nav);\n if (root[index]) results[index].push(...root[index]);\n else if (root.root) results[index].push(...root.root);\n\n return;\n }\n\n for (const [ key, items ] of Object.entries(nav)) {\n const subRoot = key === 'root' && prefix === '' ? 'root' : prefix;\n const index = key === 'root' ? subRoot : join(prefix, key);\n\n results[index] ??= [];\n results[index].push(...items);\n if (root[key]) results[index].push(...root[key]);\n else if (root.root) results[index].push(...root.root);\n }\n}\n\n/**\n * Normalizes all navigation structures across the global and locale-specific configurations.\n *\n * @param state - The current {@link StateModel} providing configuration data:\n * - `configuration.themeConfig.nav` \u2014 global navigation configuration.\n * - `configuration.locales` \u2014 locale-specific configurations with optional `nav`.\n *\n * @returns A flat record of navigation items keyed by locale or `'root'`, suitable for further processing.\n *\n * @remarks\n * - First, global navigation items are normalized into `globalResults`.\n * - If no locales are defined, `globalResults` is returned directly.\n * - Otherwise, iterates through all locale keys:\n * - Normalizes each locale\u2019s `nav` configuration.\n * - Merges in global navigation items as fallback where necessary.\n * - Ensures that all navigation entries are flattened and ready for versioning or rendering.\n *\n * @example\n * ```ts\n * const state = inject(StateModel);\n * const normalizedNavs = normalizeNavs(state);\n * // normalizedNavs \u2192 {\n * // root: [...global items],\n * // en: [...English locale items including global fallback],\n * // de: [...German locale items including global fallback]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNavs(state: StateModel): Record<string, Array<NavItemType>> {\n const locales = state.configuration.locales;\n const localesKeys = Object.keys(locales);\n const globalResults: Record<string, Array<NavItemType>> = { root: [] };\n\n if (state.configuration.themeConfig?.nav) {\n normalizeNav(globalResults, state.configuration.themeConfig.nav as NavType);\n }\n\n const switcher = versionSwitcher(state.versionsConfig, state.versionsList, state.versionsConfig.current);\n if(switcher) globalResults.root.push(switcher);\n\n if (!localesKeys.length) return globalResults;\n const results: Record<string, Array<NavItemType>> = { root: [] };\n\n for (const locale of localesKeys) {\n const prefix = locale === 'root' || state.localesMap[locale] === 'root' ? 'root' : locale;\n normalizeNav(results, (locales[locale].themeConfig?.nav ?? []) as NavType, prefix, globalResults);\n }\n\n return results;\n}\n\n/**\n * Parses and populates the navigation structure for all locales.\n *\n * @remarks\n * - Retrieves normalized navigation items using {@link normalizeNavs}.\n * - Iterates through all locales defined in `vitepressConfig.locales`.\n * - For each locale:\n * - Falls back to global navigation (`navs.root`) if locale-specific navigation is not defined.\n * - Ensures the locale\u2019s `themeConfig` exists.\n * - Populates the locale\u2019s `themeConfig.nav` using {@link populateNav}, applying versioning where applicable.\n *\n * This function ensures that all locales have a fully initialized and version-aware navigation structure.\n *\n * @example\n * ```ts\n * parseNavs();\n * // state.vitepressConfig.locales \u2192 each locale has `themeConfig.nav` populated\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseNavs(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const navs = normalizeNavs(state);\n\n for (const [ key, locale ] of Object.entries(locales)) {\n const nav = navs[key] ?? navs.root;\n\n locale.themeConfig ??= {};\n locale.themeConfig.nav = populateNav(nav, key);\n }\n}\n", "/**\n * Imports\n */\n\nimport type { NavItemWithChildrenType } from '@interfaces/nav.interface';\nimport type { VersionsConfigInterface } from '@interfaces/configuration.interface';\n\n/**\n * Builds a version switcher navigation item for the documentation site.\n *\n * @param themeConfig - The {@link VersionsConfigInterface} configuration object.\n * @param versions - An array of available version strings.\n * @param current - The current version label, defaults to `\"Latest\"`.\n *\n * @returns A {@link NavItemWithChildrenType} representing the version switcher,\n * or `undefined` if the switcher is disabled in the configuration.\n *\n * @remarks\n * - If `themeConfig.versionSwitcher === false`, no switcher is created.\n * - The returned navigation item contains child links for each version in `versions`.\n * - If `includeCurrentVersion` is enabled, adds a link to the root (`\"/\"`)\n * for the currently active version, displayed as `\"Latest\"` or\n * `\"vX.Y.Z (latest)\"`.\n * - All version links have `skipVersioning: true` to prevent further prefixing.\n *\n * This utility allows users to quickly switch between documentation versions\n * from the navigation bar.\n *\n * @example\n * ```ts\n * const themeConfig: VersionsConfigInterface = {\n * versionSwitcher: { text: \"Versions\", includeCurrentVersion: true }\n * };\n *\n * const versions = [\"v2.0.0\", \"v1.5.0\"];\n * const navItem = versionSwitcher(themeConfig, versions, \"v2.0.0\");\n *\n * // \u2192 {\n * // text: \"Versions\",\n * // items: [\n * // { link: \"/\", text: \"v2.0.0 (latest)\", skipVersioning: true },\n * // { link: \"/v2.0.0/\", text: \"v2.0.0\", skipVersioning: true },\n * // { link: \"/v1.5.0/\", text: \"v1.5.0\", skipVersioning: true }\n * // ]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function versionSwitcher(themeConfig: VersionsConfigInterface, versions: Array<string>, current: string = 'Latest'): undefined | NavItemWithChildrenType {\n if (themeConfig.versionSwitcher === false) return;\n\n const { text, includeCurrentVersion } = themeConfig.versionSwitcher;\n const items = [];\n if (includeCurrentVersion) {\n items.push({\n link: '/',\n text: current === 'Latest' ? current : `${ current } (latest)`,\n skipVersioning: true\n });\n }\n\n for (const version of versions) {\n items.push({ text: version, link: `/${ version }/`, skipVersioning: true });\n }\n\n return { text, items };\n}\n", "/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Populates locale information in the VitePress configuration for all versions.\n *\n * @remarks\n * - Reads the `localesMap` from the `StateModel` to identify each user-defined locale.\n * - Copies `lang` and `label` from the user configuration into `vitepressConfig.locales`.\n * - For each version in `versionsList`, creates a versioned locale entry in `vitepressConfig.locales`.\n * - Ensures that both the root locale and versioned locales have proper `lang` and `label` settings.\n *\n * @example\n * ```ts\n * parseLocale();\n * console.log(state.vitepressConfig.locales);\n * // \u2192 { root: { lang: \"en\", label: \"English\" }, \"1.0/en\": { lang: \"en\" }, ... }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseLocale(): void {\n const state = inject(StateModel);\n const versions = state.versionsList;\n const locales = state.vitepressConfig.locales;\n const userLocales = state.configuration.locales;\n\n for (const key of Object.keys(state.localesMap)) {\n const index = state.localesMap[key];\n const isRoot = index === 'root';\n const localeObject = 'root' in userLocales ? userLocales[index] : userLocales[key];\n const localeItems = { ...localeObject, themeConfig: undefined };\n\n locales[index] ??= {};\n Object.assign(locales[index], localeItems);\n\n if(isRoot) locales[index].link = '/';\n else locales[index].link = `/${ locales[index].lang }/`;\n\n for (const version of versions) {\n const subIndex = isRoot ? version : join(key, version);\n locales[subIndex] ??= {};\n Object.assign(locales[subIndex], { ...localeItems });\n\n locales[subIndex].label = ' ';\n if(isRoot) locales[subIndex].link = '/';\n else locales[subIndex].link = `/${ locales[subIndex].lang }/`;\n }\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { SidebarItemType, SidebarObjectType, SidebarType } from '@interfaces/sidebar.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Populates sidebar items with versioned base paths.\n *\n * @param sidebar - The list of sidebar {@link SidebarItemType} items to transform.\n * @param version - The version key (e.g., `\"en\"`, `\"v1.0\"`, `\"root\"`).\n *\n * @returns A new sidebar array with versioned `base` properties applied.\n *\n * @remarks\n * - If the provided `version` is `\"root\"`, it is normalized to an empty prefix (`\"\"`).\n * - Items marked with `skipVersioning` are returned unchanged.\n * - When an item has a `link` or nested `items`, its `base` property is updated with the version prefix.\n * - Recursively processes child `items` to ensure consistent versioning throughout the sidebar tree.\n *\n * @example\n * ```ts\n * const sidebar: SidebarItemType[] = [\n * { text: \"Introduction\", link: \"/intro\" },\n * {\n * text: \"Guide\",\n * items: [\n * { text: \"Setup\", link: \"/setup\" }\n * ]\n * }\n * ];\n *\n * // Applying version \"v1\"\n * const result = populateSidebar(sidebar, \"v1\");\n *\n * // Result:\n * [\n * { text: \"Introduction\", link: \"/intro\", base: \"/v1/\" },\n * {\n * text: \"Guide\",\n * base: \"/v1/\",\n * items: [\n * { text: \"Setup\", link: \"/setup\", base: \"/v1/\" }\n * ]\n * }\n * ]\n * ```\n *\n * @see SidebarItemType\n * @since 2.0.0\n */\n\nexport function populateSidebar(sidebar: Array<SidebarItemType>, version: string): Array<SidebarItemType> {\n if (version === 'root') version = '';\n\n return sidebar.map(item => {\n if(item.skipVersioning) return item;\n item = { ...item };\n\n if((item.link || item.items) && version !== '') {\n item.base ??= '';\n item.base = join('/', version, item.base, '/');\n }\n\n return item;\n });\n}\n\n/**\n * Normalizes a sidebar definition into a flat {@link SidebarObjectType} structure.\n *\n * @param results - The target results object where normalized sidebar items will be accumulated.\n * @param sidebar - The sidebar definition to normalize, which can be an array of items or a path-based mapping.\n * @param prefix - The optional path prefix used for nested sidebar entries (defaults to `\"\"`).\n * @param root - A root-level sidebar object used as a fallback when merging items (defaults to `{}`).\n *\n * @returns void \u2014 Mutates the `results` object directly by appending normalized sidebar items.\n *\n * @remarks\n * - If the `sidebar` is an array, it is stored under the `prefix` key (or `\"root\"` if no prefix is given).\n * - If the `sidebar` is an object, each key is resolved into a full index path using the `prefix`.\n * - When merging items, entries from `root` (matching key or `\"root\"`) are prepended to the results.\n * - Ensures all sidebar values are normalized into arrays, even if a single item is provided.\n *\n * @example\n * ```ts\n * const results: SidebarObjectType = {};\n * normalizeSidebar(results, [\n * { text: \"Intro\", link: \"/intro\" }\n * ]);\n *\n * // Result:\n * {\n * root: [\n * { text: \"Intro\", link: \"/intro\" }\n * ]\n * }\n * ```\n *\n * @example\n * ```ts\n * const results: SidebarObjectType = {};\n * normalizeSidebar(results, {\n * guide: [\n * { text: \"Getting Started\", link: \"/guide/start\" }\n * ]\n * }, \"en\");\n *\n * // Result:\n * {\n * \"en/guide\": [\n * { text: \"Getting Started\", link: \"/guide/start\" }\n * ]\n * }\n * ```\n *\n * @see SidebarType\n * @see SidebarObjectType\n *\n * @since 2.0.0\n */\n\nexport function normalizeSidebar(results: SidebarObjectType, sidebar: SidebarType, prefix: string = '', root: SidebarObjectType = {}): void {\n if (Array.isArray(sidebar)) {\n const index = prefix ? prefix : 'root';\n results[index] ??= [];\n\n if (root[index]) results[index].push(...root[index]);\n else if (root.root) results[index].push(...root.root);\n results[index].push(...sidebar);\n\n return;\n }\n\n for (const [ key, items ] of Object.entries(sidebar)) {\n const subRoot = key === 'root' && prefix === '' ? 'root' : prefix;\n const index = key === 'root' ? subRoot : join(prefix, key);\n const itemsArray = Array.isArray(items) ? items : [ items ];\n results[index] ??= [];\n\n if (root[key]) results[index].push(...root[key]);\n else if (root.root) results[index].push(...root.root);\n results[index].push(...itemsArray);\n }\n}\n\n/**\n * Normalizes all sidebar structures across global and locale-specific configurations.\n *\n * @param state - The current {@link StateModel} providing configuration data:\n * - `configuration.themeConfig.sidebar` \u2014 global sidebar configuration.\n * - `configuration.locales` \u2014 locale-specific configurations with optional `sidebar`.\n * - `localesMap` \u2014 maps locale keys to normalized paths for root fallback.\n *\n * @returns A flat {@link SidebarObjectType} where each key corresponds to a locale\n * or `\"root\"` and contains an array of normalized sidebar items.\n *\n * @remarks\n * - Global sidebar items are first normalized into `globalResults`.\n * - If no locales are defined, `globalResults` is returned directly.\n * - For each locale:\n * - Computes a `prefix` key for the locale (falling back to `\"root\"` if necessary).\n * - Normalizes the locale\u2019s sidebar using {@link normalizeSidebar}, merging in global items as fallback.\n * - Ensures that all sidebar entries are flattened and ready for versioning or rendering.\n *\n * @example\n * ```ts\n * const state = inject(StateModel);\n * const sidebars = normalizeSidebars(state);\n * // sidebars \u2192 {\n * // root: [...global items],\n * // en: [...English locale items including global fallback],\n * // fr: [...French locale items including global fallback]\n * // }\n * ```\n *\n * @see SidebarType\n * @see normalizeSidebar\n * @see SidebarObjectType\n *\n * @since 2.0.0\n */\n\nexport function normalizeSidebars(state: StateModel): SidebarObjectType {\n const locales = state.configuration.locales;\n const localesKeys = Object.keys(locales);\n const globalResults: SidebarObjectType = { root: [] };\n\n if (state.configuration.themeConfig?.sidebar) {\n normalizeSidebar(globalResults, state.configuration.themeConfig.sidebar as SidebarType);\n }\n\n if (!localesKeys.length) return globalResults;\n const results: SidebarObjectType = { root: [] };\n\n for (const locale of localesKeys) {\n const prefix = locale === 'root' || state.localesMap[locale] === 'root' ? 'root' : locale;\n normalizeSidebar(results, (locales[locale].themeConfig?.sidebar ?? []) as SidebarType, prefix, globalResults);\n }\n\n return results;\n}\n\n/**\n * Parses and populates the sidebar structure for all locales.\n *\n * @remarks\n * - Retrieves normalized sidebar items using {@link normalizeSidebars}.\n * - Iterates through all locales defined in `vitepressConfig.locales`.\n * - For each locale:\n * - Falls back to global sidebar (`sidebars.root`) if locale-specific sidebar is not defined.\n * - Ensures the locale\u2019s `themeConfig` exists.\n * - Populates the locale\u2019s `themeConfig.sidebar` using {@link populateSidebar}, applying versioning where applicable.\n *\n * This function ensures that all locales have a fully initialized and version-aware sidebar structure.\n *\n * @example\n * ```ts\n * parseSidebar();\n * // state.vitepressConfig.locales \u2192 each locale has `themeConfig.sidebar` populated\n * ```\n *\n * @see SidebarType\n * @see populateSidebar\n * @see SidebarObjectType\n * @see normalizeSidebars\n *\n * @since 2.0.0\n */\n\nexport function parseSidebar(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const sidebars = normalizeSidebars(state);\n\n for (const [ key, locale ] of Object.entries(locales)) {\n const sidebar = sidebars[key] ?? sidebars.root;\n\n locale.themeConfig ??= {};\n locale.themeConfig.sidebar = populateSidebar(sidebar, key);\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { UserConfig } from 'vitepress';\nimport type { PartialConfigurationType } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { StateModel } from '@models/state.model';\nimport { parseNavs } from '@components/nav.component';\nimport { deepMerge } from '@components/object.component';\nimport { parseLocale } from '@components/locale.component';\nimport { parseSidebar } from '@components/sidebar.component';\nimport { forceInject } from '@symlinks/services/inject.service';\nimport { parseRoutesComponent } from '@components/rewrites.component';\nimport { defaultConfiguration } from '@constants/configuration.constant';\n\n/**\n * Export interfaces\n */\n\nexport type * from 'vitepress';\nexport type * from '@interfaces/nav.interface';\nexport type * from '@interfaces/theme.interface';\nexport type * from '@interfaces/locale.interface';\nexport type * from '@interfaces/sidebar.interface';\nexport type * from '@interfaces/configuration.interface';\n\nexport function defineVersionedConfig(userConfiguration: PartialConfigurationType): UserConfig {\n const config = deepMerge(defaultConfiguration, userConfiguration);\n const state = forceInject(StateModel, config).init();\n parseLocale();\n\n /**\n * Parse components\n */\n\n parseNavs();\n parseSidebar();\n parseRoutesComponent();\n\n return <UserConfig> state.vitepressConfig;\n}\n"],
|
|
6
|
+
"mappings": "2PAYA,OAAS,QAAAA,EAAM,SAAAC,MAAa,OAC5B,OAAS,SAAAC,MAAa,sCCOf,IAAMC,EAAa,IAAI,IAYjBC,EAAc,IAAI,IAYxB,SAASC,EAAmBC,EAA0D,CACzF,OAAO,OAAOA,GAAa,UAAYA,IAAa,MAAQ,aAAcA,CAC9E,CAFgBC,EAAAF,EAAA,sBAcT,SAASG,EAAqBF,EAA4D,CAC7F,OAAO,OAAOA,GAAa,UAAYA,IAAa,MAAQ,eAAgBA,CAChF,CAFgBC,EAAAC,EAAA,wBAcT,SAASC,EAAmBH,EAA0D,CACzF,OAAO,OAAOA,GAAa,UAAYA,IAAa,MAAQ,aAAcA,CAC9E,CAFgBC,EAAAE,EAAA,sBAyBT,SAASC,EAAwDC,EAAyC,CAC7G,OAAO,SAAUC,EAAiB,CAC9BR,EAAY,IAAIQ,EAAoCD,GAAW,CAAC,CAAC,CACrE,CACJ,CAJgBJ,EAAAG,EAAA,cAgCT,SAASG,EAAk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,cAAc,QAC9BE,EAAc,OAAO,KAAKD,CAAO,EACjCE,EAAmC,CAAE,KAAM,CAAC,CAAE,EAMpD,GAJIH,EAAM,cAAc,aAAa,SACjCT,EAAiBY,EAAeH,EAAM,cAAc,YAAY,OAAsB,EAGtF,CAACE,EAAY,OAAQ,OAAOC,EAChC,IAAMX,EAA6B,CAAE,KAAM,CAAC,CAAE,EAE9C,QAAWY,KAAUF,EAAa,CAC9B,IAAMT,EAASW,IAAW,QAAUJ,EAAM,WAAWI,CAAM,IAAM,OAAS,OAASA,EACnFb,EAAiBC,EAAUS,EAAQG,CAAM,EAAE,aAAa,SAAW,CAAC,EAAmBX,EAAQU,CAAa,CAChH,CAEA,OAAOX,CACX,CAlBgBF,EAAAS,GAAA,qBA+CT,SAASM,GAAqB,CACjC,IAAML,EAAQM,EAAOC,CAAU,EACzB,CAAE,gBAAiB,CAAE,QAAAN,CAAQ,CAAE,EAAID,EACnCQ,EAAWT,GAAkBC,CAAK,EAExC,OAAW,CAAEJ,EAAKQ,CAAO,IAAK,OAAO,QAAQH,CAAO,EAAG,CACnD,IAAMf,EAAUsB,EAASZ,CAAG,GAAKY,EAAS,KAE1CJ,EAAO,cAAgB,CAAC,EACxBA,EAAO,YAAY,QAAUnB,GAAgBC,EAASU,CAAG,CAC7D,CACJ,CAXgBN,EAAAe,EAAA,gBC/MT,SAASI,GAAsBC,EAAyD,CAC3F,IAAMC,EAASC,EAAUC,EAAsBH,CAAiB,EAC1DI,EAAQC,EAAYC,EAAYL,CAAM,EAAE,KAAK,EACnD,OAAAM,EAAY,EAMZC,EAAU,EACVC,EAAa,EACbC,EAAqB,EAEDN,EAAM,eAC9B,CAdgBO,EAAAZ,GAAA",
|
|
7
7
|
"names": ["join", "posix", "xterm", "SINGLETONS", "INJECTABLES", "isProviderUseClass", "provider", "__name", "isProviderUseFactory", "isProviderUseValue", "Injectable", "options", "target", "providersIntoArgs", "providers", "args", "scopeAgs", "inject", "token", "metadata", "instance", "forceInject", "existsSync", "mkdirSync", "readdirSync", "writeFileSync", "join", "rewritesHook", "source", "version", "locale", "join", "__name", "parseRoutesComponent", "result", "state", "inject", "StateModel", "localesPrefix", "folder", "fileList", "prefix", "file", "localeKey", "item", "defaultConfiguration", "rewritesHook", "readdirSync", "join", "relative", "deepMerge", "obj1", "obj2", "result", "key", "val2", "val1", "__name", "getAllMarkdownFilesRelative", "rootDir", "currentDir", "results", "entries", "readdirSync", "entry", "fullPath", "join", "relativePath", "relative", "StateModel", "configuration", "defaultConfiguration", "sources", "archive", "join", "existsSync", "xterm", "subFolders", "readdirSync", "entry", "getAllMarkdownFilesRelative", "folder", "path", "locales", "userLocales", "keys", "rootLocaleKey", "key", "index", "version", "versionPath", "posix", "mkdirSync", "writeFileSync", "result", "exclude", "themeConfig", "prop", "__name", "__decorateClass", "Injectable", "join", "versionSwitcher", "themeConfig", "versions", "current", "text", "includeCurrentVersion", "items", "version", "__name", "isNavItemWithChildren", "item", "__name", "isNavItemWithLink", "replaceLinksRecursive", "version", "child", "join", "populateNav", "items", "state", "inject", "StateModel", "normalizeNav", "results", "nav", "prefix", "root", "index", "key", "normalizeNavs", "locales", "localesKeys", "globalResults", "switcher", "versionSwitcher", "locale", "parseNavs", "navs", "join", "parseLocale", "state", "inject", "StateModel", "versions", "locales", "userLocales", "key", "index", "isRoot", "localeItems", "version", "subIndex", "join", "__name", "join", "populateSidebar", "sidebar", "version", "item", "join", "__name", "normalizeSidebar", "results", "prefix", "root", "index", "key", "items", "itemsArray", "normalizeSidebars", "state", "locales", "localesKeys", "globalResults", "locale", "parseSidebar", "inject", "StateModel", "sidebars", "defineVersionedConfig", "userConfiguration", "config", "deepMerge", "defaultConfiguration", "state", "forceInject", "StateModel", "parseLocale", "parseNavs", "parseSidebar", "parseRoutesComponent", "__name"]
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"author": "Garefild",
|
|
8
|
-
"version": "2.0.
|
|
8
|
+
"version": "2.0.2",
|
|
9
9
|
"license": "Mozilla Public License Version 2.0",
|
|
10
10
|
"description": "A versioning plugin for VitePress",
|
|
11
11
|
"homepage": "https://viteplus.github.io/versions/",
|
|
@@ -60,7 +60,8 @@
|
|
|
60
60
|
"eslint-plugin-tsdoc": "^0.4.0",
|
|
61
61
|
"eslint-plugin-perfectionist": "^4.15.0",
|
|
62
62
|
"@types/node": "^24.5.0",
|
|
63
|
-
"@
|
|
63
|
+
"@viteplus/versions": "^2.0.0",
|
|
64
|
+
"@remotex-labs/xjet": "^1.1.1",
|
|
64
65
|
"@remotex-labs/xbuild": "1.6.0"
|
|
65
66
|
},
|
|
66
67
|
"peerDependencies": {
|