doccupine 0.0.158 → 0.0.159

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.
Files changed (149) hide show
  1. package/README.md +51 -1
  2. package/dist/generator/app-scaffolder.js +11 -3
  3. package/dist/generator/generated-page-publisher.d.ts +6 -6
  4. package/dist/generator/generated-page-publisher.js +7 -5
  5. package/dist/generator/mdx-pass-builder.d.ts +4 -4
  6. package/dist/generator/mdx-pass-builder.js +8 -1
  7. package/dist/generator/mdx-reconciliation-coordinator.d.ts +23 -9
  8. package/dist/generator/mdx-reconciliation-coordinator.js +63 -9
  9. package/dist/generator/page-catalog.d.ts +2 -4
  10. package/dist/generator/page-catalog.js +7 -2
  11. package/dist/generator/page-renderer.d.ts +15 -5
  12. package/dist/generator/page-renderer.js +38 -11
  13. package/dist/generator/project-config-repository.d.ts +4 -1
  14. package/dist/generator/project-config-repository.js +26 -0
  15. package/dist/generator/public-asset-manager.d.ts +10 -0
  16. package/dist/generator/public-asset-manager.js +63 -3
  17. package/dist/generator/section-index-generator.d.ts +10 -1
  18. package/dist/generator/section-index-generator.js +43 -15
  19. package/dist/generator/section-resolver.d.ts +8 -0
  20. package/dist/generator/site-artifacts.d.ts +4 -3
  21. package/dist/generator/site-artifacts.js +94 -9
  22. package/dist/generator/watch-coordinator.js +6 -1
  23. package/dist/lib/generated-artifacts.d.ts +3 -0
  24. package/dist/lib/generated-artifacts.js +36 -0
  25. package/dist/lib/layout.d.ts +6 -3
  26. package/dist/lib/layout.js +107 -4
  27. package/dist/lib/metadata.d.ts +7 -0
  28. package/dist/lib/metadata.js +33 -10
  29. package/dist/lib/structures.js +20 -0
  30. package/dist/lib/types.d.ts +28 -0
  31. package/dist/lib/ui-strings.d.ts +44 -0
  32. package/dist/lib/ui-strings.js +48 -0
  33. package/dist/lib/variants.d.ts +91 -0
  34. package/dist/lib/variants.js +411 -0
  35. package/dist/mdx-to-nextjs-generator.d.ts +22 -5
  36. package/dist/mdx-to-nextjs-generator.js +89 -10
  37. package/dist/templates/app/api/mcp/route.d.ts +1 -1
  38. package/dist/templates/app/api/mcp/route.js +14 -1
  39. package/dist/templates/app/api/rag/route.d.ts +1 -1
  40. package/dist/templates/app/api/rag/route.js +13 -2
  41. package/dist/templates/app/api/search/route.d.ts +1 -1
  42. package/dist/templates/app/api/search/route.js +16 -1
  43. package/dist/templates/app/sitemap.d.ts +2 -0
  44. package/dist/templates/app/sitemap.js +48 -3
  45. package/dist/templates/components/Chat.d.ts +1 -1
  46. package/dist/templates/components/Chat.js +40 -12
  47. package/dist/templates/components/Docs.d.ts +1 -1
  48. package/dist/templates/components/Docs.js +5 -2
  49. package/dist/templates/components/DocsSideBar.d.ts +1 -1
  50. package/dist/templates/components/DocsSideBar.js +3 -1
  51. package/dist/templates/components/SearchDocs.d.ts +1 -1
  52. package/dist/templates/components/SearchDocs.js +17 -3
  53. package/dist/templates/components/SearchModalContent.d.ts +1 -1
  54. package/dist/templates/components/SearchModalContent.js +22 -14
  55. package/dist/templates/components/SectionNavProvider.d.ts +1 -1
  56. package/dist/templates/components/SectionNavProvider.js +32 -20
  57. package/dist/templates/components/SideBar.d.ts +1 -1
  58. package/dist/templates/components/SideBar.js +26 -12
  59. package/dist/templates/components/layout/ActionBar.d.ts +1 -1
  60. package/dist/templates/components/layout/ActionBar.js +9 -7
  61. package/dist/templates/components/layout/Code.d.ts +1 -1
  62. package/dist/templates/components/layout/Code.js +6 -3
  63. package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
  64. package/dist/templates/components/layout/DocsComponents.js +38 -5
  65. package/dist/templates/components/layout/DocsNavigation.d.ts +1 -1
  66. package/dist/templates/components/layout/DocsNavigation.js +4 -2
  67. package/dist/templates/components/layout/Dropdown.d.ts +1 -0
  68. package/dist/templates/components/layout/Dropdown.js +308 -0
  69. package/dist/templates/components/layout/FocusModeToggle.d.ts +1 -1
  70. package/dist/templates/components/layout/FocusModeToggle.js +7 -4
  71. package/dist/templates/components/layout/Footer.d.ts +1 -1
  72. package/dist/templates/components/layout/Footer.js +4 -2
  73. package/dist/templates/components/layout/Header.d.ts +1 -1
  74. package/dist/templates/components/layout/Header.js +18 -8
  75. package/dist/templates/components/layout/SectionBar.d.ts +1 -1
  76. package/dist/templates/components/layout/SectionBar.js +16 -10
  77. package/dist/templates/components/layout/VariantSwitchers.d.ts +1 -0
  78. package/dist/templates/components/layout/VariantSwitchers.js +313 -0
  79. package/dist/templates/components/useStrings.d.ts +1 -0
  80. package/dist/templates/components/useStrings.js +10 -0
  81. package/dist/templates/components/useVariant.d.ts +1 -0
  82. package/dist/templates/components/useVariant.js +13 -0
  83. package/dist/templates/llms/llmsIndex.d.ts +13 -0
  84. package/dist/templates/llms/llmsIndex.js +18 -3
  85. package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
  86. package/dist/templates/mdx/ai-assistant.mdx.js +2 -0
  87. package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
  88. package/dist/templates/mdx/api-playground.mdx.js +2 -0
  89. package/dist/templates/mdx/commands.mdx.d.ts +1 -1
  90. package/dist/templates/mdx/commands.mdx.js +1 -1
  91. package/dist/templates/mdx/fonts.mdx.d.ts +1 -1
  92. package/dist/templates/mdx/fonts.mdx.js +1 -1
  93. package/dist/templates/mdx/footer-links.mdx.d.ts +1 -1
  94. package/dist/templates/mdx/footer-links.mdx.js +1 -1
  95. package/dist/templates/mdx/index.mdx.d.ts +1 -1
  96. package/dist/templates/mdx/index.mdx.js +2 -0
  97. package/dist/templates/mdx/languages.mdx.d.ts +1 -0
  98. package/dist/templates/mdx/languages.mdx.js +94 -0
  99. package/dist/templates/mdx/media-and-assets.mdx.d.ts +1 -1
  100. package/dist/templates/mdx/media-and-assets.mdx.js +1 -1
  101. package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
  102. package/dist/templates/mdx/model-context-protocol.mdx.js +6 -0
  103. package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
  104. package/dist/templates/mdx/navigation.mdx.js +2 -0
  105. package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
  106. package/dist/templates/mdx/platform/ai-assistant.mdx.js +2 -0
  107. package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -1
  108. package/dist/templates/mdx/platform/api-playground.mdx.js +2 -0
  109. package/dist/templates/mdx/platform/file-editor.mdx.d.ts +1 -1
  110. package/dist/templates/mdx/platform/file-editor.mdx.js +2 -0
  111. package/dist/templates/mdx/platform/index.mdx.d.ts +1 -1
  112. package/dist/templates/mdx/platform/index.mdx.js +1 -1
  113. package/dist/templates/mdx/platform/languages.mdx.d.ts +1 -0
  114. package/dist/templates/mdx/platform/languages.mdx.js +50 -0
  115. package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
  116. package/dist/templates/mdx/platform/mcp.mdx.js +2 -0
  117. package/dist/templates/mdx/platform/navigation-settings.mdx.d.ts +1 -1
  118. package/dist/templates/mdx/platform/navigation-settings.mdx.js +2 -0
  119. package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
  120. package/dist/templates/mdx/platform/publishing.mdx.js +4 -0
  121. package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -1
  122. package/dist/templates/mdx/platform/self-updating-docs.mdx.js +2 -0
  123. package/dist/templates/mdx/platform/versions.mdx.d.ts +1 -0
  124. package/dist/templates/mdx/platform/versions.mdx.js +33 -0
  125. package/dist/templates/mdx/sections.mdx.d.ts +1 -1
  126. package/dist/templates/mdx/sections.mdx.js +1 -1
  127. package/dist/templates/mdx/theme.mdx.d.ts +1 -1
  128. package/dist/templates/mdx/theme.mdx.js +1 -1
  129. package/dist/templates/mdx/versions.mdx.d.ts +1 -0
  130. package/dist/templates/mdx/versions.mdx.js +78 -0
  131. package/dist/templates/mdx/what-is-doccupine.mdx.d.ts +1 -1
  132. package/dist/templates/mdx/what-is-doccupine.mdx.js +1 -1
  133. package/dist/templates/prettierignore.d.ts +1 -1
  134. package/dist/templates/prettierignore.js +2 -0
  135. package/dist/templates/services/mcp/server.d.ts +1 -1
  136. package/dist/templates/services/mcp/server.js +54 -10
  137. package/dist/templates/services/mcp/tools.d.ts +1 -1
  138. package/dist/templates/services/mcp/tools.js +81 -6
  139. package/dist/templates/services/mcp/types.d.ts +1 -1
  140. package/dist/templates/services/mcp/types.js +10 -0
  141. package/dist/templates/services/search.d.ts +1 -1
  142. package/dist/templates/services/search.js +34 -4
  143. package/dist/templates/utils/orderNavItems.d.ts +1 -1
  144. package/dist/templates/utils/orderNavItems.js +2 -0
  145. package/dist/templates/utils/strings.d.ts +1 -0
  146. package/dist/templates/utils/strings.js +27 -0
  147. package/dist/templates/utils/variants.d.ts +1 -0
  148. package/dist/templates/utils/variants.js +170 -0
  149. package/package.json +1 -1
@@ -0,0 +1,170 @@
1
+ export const variantsUtilTemplate = `import rawLanguages from "@/languages.json";
2
+ import rawVersions from "@/versions.json";
3
+
4
+ // Languages (languages.json) and versions (versions.json) of this site. A
5
+ // variant's folder is its URL prefix - "de", "v1", "de/v1" - and the default
6
+ // language and version live at the docs root with no prefix. The CLI
7
+ // validated both files when it generated this app, so this module only has to
8
+ // read them. The resolver mirrors the CLI's src/lib/variants.ts; keep the two
9
+ // in step.
10
+
11
+ export interface LanguageConfig {
12
+ code: string;
13
+ label: string;
14
+ default?: boolean;
15
+ strings?: Record<string, string>;
16
+ }
17
+
18
+ export interface VersionConfig {
19
+ /** URL prefix and folder name; "" for the default version at the docs root. */
20
+ slug: string;
21
+ label: string;
22
+ default?: boolean;
23
+ }
24
+
25
+ export interface VariantResolution {
26
+ /** Language code; undefined when languages.json is not configured. */
27
+ locale?: string;
28
+ /** Version slug ("" for the default); undefined when not configured. */
29
+ version?: string;
30
+ /** URL prefix: "", "de", "v1", or "de/v1". */
31
+ prefix: string;
32
+ /** The slug with the variant prefix removed. */
33
+ rest: string;
34
+ }
35
+
36
+ function readLanguages(raw: unknown): LanguageConfig[] | null {
37
+ if (!Array.isArray(raw) || raw.length === 0) return null;
38
+ return raw as LanguageConfig[];
39
+ }
40
+
41
+ function readVersions(raw: unknown): VersionConfig[] | null {
42
+ if (!Array.isArray(raw) || raw.length === 0) return null;
43
+ return (raw as Partial<VersionConfig>[]).map((entry) => ({
44
+ slug: entry.default ? "" : (entry.slug ?? ""),
45
+ label: entry.label ?? "",
46
+ default: entry.default === true,
47
+ }));
48
+ }
49
+
50
+ export const languages = readLanguages(rawLanguages);
51
+ export const versions = readVersions(rawVersions);
52
+
53
+ export function isVariantsConfigured(): boolean {
54
+ return languages !== null || versions !== null;
55
+ }
56
+
57
+ export function defaultLanguage(): LanguageConfig | null {
58
+ return languages?.find((language) => language.default) ?? null;
59
+ }
60
+
61
+ export function defaultVersion(): VersionConfig | null {
62
+ return versions?.find((version) => version.default) ?? null;
63
+ }
64
+
65
+ export function joinVariantSlug(prefix: string, slug: string): string {
66
+ if (!prefix) return slug;
67
+ if (slug === "") return prefix;
68
+ return prefix + "/" + slug;
69
+ }
70
+
71
+ /**
72
+ * Resolves the variant of a URL slug: a leading declared language folder is
73
+ * consumed first, then a declared version folder. "de" alone is the German
74
+ * home, "de/v1" the German v1 home.
75
+ */
76
+ export function resolveVariantFromSlug(slug: string): VariantResolution {
77
+ const normalized = slug.replace(/^\\/+|\\/+$/g, "");
78
+ const segments = normalized === "" ? [] : normalized.split("/");
79
+ let locale = languages ? (defaultLanguage()?.code ?? "") : undefined;
80
+ let version = versions ? "" : undefined;
81
+ let consumed = 0;
82
+ const prefix: string[] = [];
83
+
84
+ const language = languages?.find(
85
+ (entry) => !entry.default && entry.code === segments[0],
86
+ );
87
+ if (language) {
88
+ locale = language.code;
89
+ prefix.push(language.code);
90
+ consumed = 1;
91
+ }
92
+ const versionEntry = versions?.find(
93
+ (entry) => !entry.default && entry.slug === segments[consumed],
94
+ );
95
+ if (versionEntry) {
96
+ version = versionEntry.slug;
97
+ prefix.push(versionEntry.slug);
98
+ consumed += 1;
99
+ }
100
+
101
+ return {
102
+ ...(locale !== undefined ? { locale } : {}),
103
+ ...(version !== undefined ? { version } : {}),
104
+ prefix: prefix.join("/"),
105
+ rest: segments.slice(consumed).join("/"),
106
+ };
107
+ }
108
+
109
+ /** Key of a navigation.json object entry: the URL prefix of the scope. */
110
+ export function navigationScopeKey(
111
+ prefix: string,
112
+ sectionSlug: string,
113
+ ): string {
114
+ return [prefix, sectionSlug].filter(Boolean).join("/");
115
+ }
116
+
117
+ /** URL prefix of a language/version pair; the default of either is "". */
118
+ export function variantPrefix(
119
+ locale: string | undefined,
120
+ version: string | undefined,
121
+ ): string {
122
+ const language =
123
+ languages && locale !== undefined
124
+ ? languages.find((entry) => entry.code === locale)
125
+ : undefined;
126
+ const versionEntry =
127
+ versions && version !== undefined
128
+ ? versions.find((entry) => entry.slug === version)
129
+ : undefined;
130
+ return joinVariantSlug(
131
+ language && !language.default ? language.code : "",
132
+ versionEntry && !versionEntry.default ? versionEntry.slug : "",
133
+ );
134
+ }
135
+
136
+ export function pageVariantPrefix(page: {
137
+ locale?: string;
138
+ version?: string;
139
+ }): string {
140
+ return variantPrefix(page.locale, page.version);
141
+ }
142
+
143
+ /** The slug without its language prefix: the same page in every language. */
144
+ export function stripLanguagePrefix(
145
+ slug: string,
146
+ locale: string | undefined,
147
+ ): string {
148
+ if (!languages || locale === undefined) return slug;
149
+ const language = languages.find((entry) => entry.code === locale);
150
+ if (!language || language.default) return slug;
151
+ if (slug === language.code) return "";
152
+ if (slug.startsWith(language.code + "/")) {
153
+ return slug.slice(language.code.length + 1);
154
+ }
155
+ return slug;
156
+ }
157
+
158
+ /** The slug without its whole variant prefix: the same page in every variant. */
159
+ export function stripVariantPrefix(
160
+ slug: string,
161
+ locale: string | undefined,
162
+ version: string | undefined,
163
+ ): string {
164
+ const prefix = variantPrefix(locale, version);
165
+ if (!prefix) return slug;
166
+ if (slug === prefix) return "";
167
+ if (slug.startsWith(prefix + "/")) return slug.slice(prefix.length + 1);
168
+ return slug;
169
+ }
170
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doccupine",
3
- "version": "0.0.158",
3
+ "version": "0.0.159",
4
4
  "description": "Free and open-source documentation platform. Write MDX, get a production-ready site with AI chat, built-in components, and an MCP server - in one command.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {