doccupine 0.0.143 → 0.0.145

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 (66) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.d.ts +6 -0
  3. package/dist/cli.js +130 -22
  4. package/dist/generator/api-reference-generator.d.ts +22 -0
  5. package/dist/generator/api-reference-generator.js +96 -0
  6. package/dist/generator/app-scaffolder.d.ts +18 -0
  7. package/dist/generator/app-scaffolder.js +49 -0
  8. package/dist/generator/generated-route-manager.d.ts +18 -0
  9. package/dist/generator/generated-route-manager.js +114 -0
  10. package/dist/generator/page-catalog.d.ts +21 -0
  11. package/dist/generator/page-catalog.js +75 -0
  12. package/dist/generator/page-renderer.d.ts +31 -0
  13. package/dist/generator/page-renderer.js +248 -0
  14. package/dist/generator/project-config-repository.d.ts +33 -0
  15. package/dist/generator/project-config-repository.js +191 -0
  16. package/dist/generator/public-asset-manager.d.ts +20 -0
  17. package/dist/generator/public-asset-manager.js +225 -0
  18. package/dist/generator/section-resolver.d.ts +13 -0
  19. package/dist/generator/section-resolver.js +150 -0
  20. package/dist/generator/secure-source-fs.d.ts +31 -0
  21. package/dist/generator/secure-source-fs.js +470 -0
  22. package/dist/generator/site-artifacts.d.ts +23 -0
  23. package/dist/generator/site-artifacts.js +156 -0
  24. package/dist/generator/watch-coordinator.d.ts +58 -0
  25. package/dist/generator/watch-coordinator.js +456 -0
  26. package/dist/lib/config-manager.d.ts +1 -0
  27. package/dist/lib/config-manager.js +194 -12
  28. package/dist/lib/generated-artifacts.d.ts +11 -2
  29. package/dist/lib/generated-artifacts.js +52 -7
  30. package/dist/lib/layout.d.ts +1 -17
  31. package/dist/lib/layout.js +5 -4
  32. package/dist/lib/openapi.d.ts +4 -0
  33. package/dist/lib/openapi.js +36 -4
  34. package/dist/lib/project-config.d.ts +3 -0
  35. package/dist/lib/project-config.js +110 -0
  36. package/dist/lib/types.d.ts +14 -1
  37. package/dist/mdx-to-nextjs-generator.d.ts +50 -34
  38. package/dist/mdx-to-nextjs-generator.js +760 -1740
  39. package/dist/templates/app/api/rag/route.d.ts +1 -1
  40. package/dist/templates/app/api/rag/route.js +2 -1
  41. package/dist/templates/components/Chat.d.ts +1 -1
  42. package/dist/templates/components/Chat.js +2 -1
  43. package/dist/templates/components/layout/Accordion.d.ts +1 -1
  44. package/dist/templates/components/layout/Accordion.js +2 -3
  45. package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
  46. package/dist/templates/mdx/api-playground.mdx.js +11 -2
  47. package/dist/templates/mdx/commands.mdx.d.ts +1 -1
  48. package/dist/templates/mdx/commands.mdx.js +26 -1
  49. package/dist/templates/mdx/media-and-assets.mdx.d.ts +1 -1
  50. package/dist/templates/mdx/media-and-assets.mdx.js +5 -0
  51. package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
  52. package/dist/templates/mdx/model-context-protocol.mdx.js +2 -1
  53. package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -1
  54. package/dist/templates/mdx/platform/api-playground.mdx.js +2 -2
  55. package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
  56. package/dist/templates/mdx/platform/publishing.mdx.js +3 -3
  57. package/dist/templates/mdx/space.mdx.d.ts +1 -1
  58. package/dist/templates/mdx/space.mdx.js +1 -5
  59. package/dist/templates/mdx/what-is-doccupine.mdx.d.ts +1 -1
  60. package/dist/templates/mdx/what-is-doccupine.mdx.js +8 -3
  61. package/dist/templates/next.config.js +2 -2
  62. package/dist/templates/package.js +3 -3
  63. package/dist/templates/proxy.js +1 -1
  64. package/dist/templates/services/mcp/server.d.ts +1 -1
  65. package/dist/templates/services/mcp/server.js +2 -12
  66. package/package.json +3 -3
@@ -0,0 +1,248 @@
1
+ import { generateJsonLdScript, generateMetadataBlock, generateRuntimeOnlyMetadataBlock, } from "../lib/metadata.js";
2
+ import { parseUpdateBlocks } from "../lib/rss.js";
3
+ import { escapeTemplateContent, toJsStringLiteral } from "../lib/utils.js";
4
+ import { rssRouteTemplate } from "../templates/app/rssRoute.js";
5
+ export function renderMdxPage(mdxFile, options) {
6
+ const fm = mdxFile.frontmatter;
7
+ const apiOperation = options?.apiOperation;
8
+ const isSynthetic = mdxFile.path.startsWith("@openapi/");
9
+ const updates = isSynthetic ? [] : parseUpdateBlocks(mdxFile.content);
10
+ const hasFeed = updates.length > 0;
11
+ const feedPath = `/${mdxFile.slug}/rss.xml`;
12
+ const metadataBlock = generateMetadataBlock({
13
+ title: fm.title,
14
+ titleFallback: "Generated with Doccupine",
15
+ name: fm.name,
16
+ titleOrder: "page-first",
17
+ description: fm.description,
18
+ icon: fm.icon,
19
+ image: fm.image,
20
+ canonicalPath: mdxFile.slug,
21
+ rssPath: hasFeed ? feedPath : undefined,
22
+ });
23
+ const jsonLd = generateJsonLdScript({
24
+ kind: "article",
25
+ canonicalPath: mdxFile.slug,
26
+ title: fm.title,
27
+ description: fm.description,
28
+ date: typeof fm.date === "string" ? fm.date : undefined,
29
+ updated: typeof fm.updated === "string"
30
+ ? fm.updated
31
+ : typeof fm.date === "string"
32
+ ? fm.date
33
+ : undefined,
34
+ image: fm.image,
35
+ });
36
+ const apiImport = apiOperation
37
+ ? `\nimport { ApiPlayground } from "@/components/layout/ApiPlayground";`
38
+ : "";
39
+ const apiConst = apiOperation
40
+ ? (() => {
41
+ const arg = toJsStringLiteral(JSON.stringify(apiOperation));
42
+ const inline = `const operation = JSON.parse(${arg});`;
43
+ const decl = inline.length <= 80
44
+ ? inline
45
+ : `const operation = JSON.parse(\n ${arg},\n);`;
46
+ return `\n${decl}\n`;
47
+ })()
48
+ : "";
49
+ const sourcePathLiteral = JSON.stringify(mdxFile.path);
50
+ const showRssButton = hasFeed && fm.rss === true && !apiOperation;
51
+ const docsAttrs = [
52
+ `content={content}`,
53
+ `sourcePath={${sourcePathLiteral}}`,
54
+ ...(showRssButton ? [`rssHref={${JSON.stringify(feedPath)}}`] : []),
55
+ ];
56
+ const inlineDocs = `<Docs ${docsAttrs.join(" ")} />`;
57
+ const docsElement = apiOperation
58
+ ? `<Docs content={content}>
59
+ <ApiPlayground operation={operation} />
60
+ </Docs>`
61
+ : inlineDocs.length + 6 <= 80
62
+ ? inlineDocs
63
+ : `<Docs\n${docsAttrs.map((attr) => ` ${attr}`).join("\n")}\n />`;
64
+ const pageContent = `import { Metadata } from "next";
65
+ import { Docs } from "@/components/Docs";
66
+ import { config } from "@/utils/config";${apiImport}
67
+
68
+ const content = \`${escapeTemplateContent(mdxFile.content)}\`;
69
+ ${apiConst}
70
+ ${metadataBlock}
71
+
72
+ // Doc pages have no per-request data: theme resolves client-side via the
73
+ // "dark" class on <html> (set before paint by the theme-init blocking
74
+ // script). Static rendering lets every response come from the edge cache.
75
+ export const dynamic = "force-static";
76
+ export const revalidate = false;
77
+
78
+ export default function Page() {
79
+ ${jsonLd.declarations}
80
+
81
+ return (
82
+ <>
83
+ ${jsonLd.element}
84
+ ${docsElement}
85
+ </>
86
+ );
87
+ }
88
+ `;
89
+ const rssRoute = isSynthetic
90
+ ? { action: "preserve" }
91
+ : hasFeed
92
+ ? {
93
+ action: "write",
94
+ content: rssRouteTemplate({
95
+ pagePath: mdxFile.slug,
96
+ title: typeof fm.title === "string" ? fm.title : null,
97
+ description: typeof fm.description === "string" ? fm.description : null,
98
+ items: updates.map((update) => ({
99
+ title: update.label,
100
+ anchor: update.anchor,
101
+ description: update.description,
102
+ })),
103
+ }),
104
+ }
105
+ : { action: "remove" };
106
+ return { pageContent, rssRoute };
107
+ }
108
+ export function renderHomepage(indexMDX, apiOperation) {
109
+ const updates = indexMDX ? parseUpdateBlocks(indexMDX.content) : [];
110
+ const hasFeed = updates.length > 0;
111
+ const feedPath = "/rss.xml";
112
+ const metadataBlock = indexMDX
113
+ ? generateMetadataBlock({
114
+ title: indexMDX.title,
115
+ titleFallback: "Welcome",
116
+ name: indexMDX.name,
117
+ titleOrder: "name-first",
118
+ description: indexMDX.description || undefined,
119
+ icon: indexMDX.icon,
120
+ image: indexMDX.image,
121
+ canonicalPath: "",
122
+ rssPath: hasFeed ? feedPath : undefined,
123
+ })
124
+ : generateRuntimeOnlyMetadataBlock();
125
+ const homeJsonLd = generateJsonLdScript({
126
+ kind: "homepage",
127
+ canonicalPath: "",
128
+ title: indexMDX?.title,
129
+ description: indexMDX?.description || undefined,
130
+ date: indexMDX?.date,
131
+ updated: indexMDX?.updated ?? indexMDX?.date,
132
+ image: indexMDX?.image,
133
+ });
134
+ const apiImport = apiOperation
135
+ ? `\nimport { ApiPlayground } from "@/components/layout/ApiPlayground";`
136
+ : "";
137
+ const apiConst = apiOperation
138
+ ? `\nconst operation = JSON.parse(${JSON.stringify(JSON.stringify(apiOperation))});\n`
139
+ : "";
140
+ const showRssButton = hasFeed && indexMDX?.rss === true && !apiOperation;
141
+ const docsElement = apiOperation
142
+ ? `<Docs content={content} sourcePath="index.mdx">
143
+ <ApiPlayground operation={operation} />
144
+ </Docs>`
145
+ : showRssButton
146
+ ? `<Docs content={content} sourcePath="index.mdx" rssHref={"/rss.xml"} />`
147
+ : `<Docs content={content} sourcePath="index.mdx" />`;
148
+ const pageContent = `import { Metadata } from "next";
149
+ import { Docs } from "@/components/Docs";
150
+ import { config } from "@/utils/config";${apiImport}
151
+
152
+ ${indexMDX ? `const content = \`${escapeTemplateContent(indexMDX.content)}\`;` : `const content = null;`}
153
+ ${apiConst}
154
+ ${metadataBlock}
155
+
156
+ export const dynamic = "force-static";
157
+ export const revalidate = false;
158
+
159
+ export default function Home() {
160
+ ${homeJsonLd.declarations}
161
+
162
+ return (
163
+ <>
164
+ ${homeJsonLd.element}
165
+ ${docsElement}
166
+ </>
167
+ );
168
+ }
169
+ `;
170
+ const rssRoute = hasFeed && indexMDX
171
+ ? {
172
+ action: "write",
173
+ content: rssRouteTemplate({
174
+ pagePath: "",
175
+ title: indexMDX.title,
176
+ description: indexMDX.description || null,
177
+ items: updates.map((update) => ({
178
+ title: update.label,
179
+ anchor: update.anchor,
180
+ description: update.description,
181
+ })),
182
+ }),
183
+ }
184
+ : { action: "remove" };
185
+ return { pageContent, rssRoute };
186
+ }
187
+ export function renderSectionPage(sectionSlug, frontmatter, mdxContent, sourcePath) {
188
+ const updates = parseUpdateBlocks(mdxContent);
189
+ const hasFeed = updates.length > 0;
190
+ const feedPath = `/${sectionSlug}/rss.xml`;
191
+ const showRssButton = hasFeed && frontmatter.rss === true;
192
+ const metadataBlock = generateMetadataBlock({
193
+ title: frontmatter.title,
194
+ titleFallback: "Section",
195
+ name: frontmatter.name,
196
+ titleOrder: "name-first",
197
+ description: frontmatter.description || undefined,
198
+ icon: frontmatter.icon,
199
+ image: frontmatter.image,
200
+ canonicalPath: sectionSlug,
201
+ rssPath: hasFeed ? feedPath : undefined,
202
+ });
203
+ const sectionJsonLd = generateJsonLdScript({
204
+ kind: "article",
205
+ canonicalPath: sectionSlug,
206
+ title: frontmatter.title,
207
+ description: frontmatter.description,
208
+ date: typeof frontmatter.date === "string" ? frontmatter.date : undefined,
209
+ updated: typeof frontmatter.updated === "string"
210
+ ? frontmatter.updated
211
+ : typeof frontmatter.date === "string"
212
+ ? frontmatter.date
213
+ : undefined,
214
+ image: frontmatter.image,
215
+ });
216
+ const docsAttrs = [
217
+ `content={content}`,
218
+ `sourcePath={${JSON.stringify(sourcePath ?? `${sectionSlug}/index.mdx`)}}`,
219
+ ...(showRssButton ? [`rssHref={${JSON.stringify(feedPath)}}`] : []),
220
+ ];
221
+ const inlineDocs = `<Docs ${docsAttrs.join(" ")} />`;
222
+ const docsElement = inlineDocs.length + 6 <= 80
223
+ ? inlineDocs
224
+ : `<Docs\n${docsAttrs.map((attr) => ` ${attr}`).join("\n")}\n />`;
225
+ const pageContent = `import { Metadata } from "next";
226
+ import { Docs } from "@/components/Docs";
227
+ import { config } from "@/utils/config";
228
+
229
+ const content = \`${escapeTemplateContent(mdxContent)}\`;
230
+
231
+ ${metadataBlock}
232
+
233
+ export const dynamic = "force-static";
234
+ export const revalidate = false;
235
+
236
+ export default function Page() {
237
+ ${sectionJsonLd.declarations}
238
+
239
+ return (
240
+ <>
241
+ ${sectionJsonLd.element}
242
+ ${docsElement}
243
+ </>
244
+ );
245
+ }
246
+ `;
247
+ return { pageContent, rssRoute: { action: "preserve" } };
248
+ }
@@ -0,0 +1,33 @@
1
+ import type { AnalyticsConfig, FontConfig, SectionConfig } from "../lib/types.js";
2
+ import { SecureSourceFs } from "./secure-source-fs.js";
3
+ export declare class ProjectConfigRepository {
4
+ private readonly rootDir;
5
+ private readonly outputDir;
6
+ private readonly sourceFs;
7
+ private readonly configFiles;
8
+ private readonly fontConfigFile;
9
+ private readonly analyticsConfigFile;
10
+ private sourceSnapshot;
11
+ constructor(rootDir: string, outputDir: string, sourceFs: SecureSourceFs, configFiles: readonly string[], fontConfigFile: string, analyticsConfigFile: string);
12
+ private outputPath;
13
+ private hasRootSourceFile;
14
+ private readRootSourceFile;
15
+ private copyRootSourceFile;
16
+ private readOptionalRootSourceFile;
17
+ readConfigFile(): Promise<string | null>;
18
+ preflightSourceFiles(): Promise<void>;
19
+ sourceSnapshotStates(): Record<string, string>;
20
+ clearSourceSnapshot(): void;
21
+ copyConfigFile(configFile: string): Promise<void>;
22
+ resetConfigFile(configFile: string): Promise<void>;
23
+ copyCustomConfigFiles(): Promise<void>;
24
+ copyFontConfigFile(): Promise<void>;
25
+ copyFontConfig(): Promise<void>;
26
+ removeFontConfig(): Promise<boolean>;
27
+ loadFontConfig(): Promise<FontConfig | null>;
28
+ loadAnalyticsConfig(): Promise<AnalyticsConfig | null>;
29
+ writeAnalyticsConfig(config: AnalyticsConfig | null): Promise<void>;
30
+ copyAnalyticsConfig(loadConfig: () => Promise<AnalyticsConfig | null>): Promise<void>;
31
+ resetAnalyticsConfig(): Promise<void>;
32
+ loadSectionsConfig(): Promise<SectionConfig[] | null>;
33
+ }
@@ -0,0 +1,191 @@
1
+ import chalk from "chalk";
2
+ import fs from "fs-extra";
3
+ import { createHash } from "node:crypto";
4
+ import path from "node:path";
5
+ import { resolveOutputPath } from "../lib/output-safety.js";
6
+ import { validateAnalyticsConfig, validateFontConfig, } from "../lib/project-config.js";
7
+ import { writeFileAtomic } from "../lib/utils.js";
8
+ import { validateSectionsConfig } from "./section-resolver.js";
9
+ const ARRAY_CONFIG_DEFAULTS = new Set([
10
+ "links.json",
11
+ "navigation.json",
12
+ "sections.json",
13
+ ]);
14
+ export class ProjectConfigRepository {
15
+ rootDir;
16
+ outputDir;
17
+ sourceFs;
18
+ configFiles;
19
+ fontConfigFile;
20
+ analyticsConfigFile;
21
+ sourceSnapshot = null;
22
+ constructor(rootDir, outputDir, sourceFs, configFiles, fontConfigFile, analyticsConfigFile) {
23
+ this.rootDir = rootDir;
24
+ this.outputDir = outputDir;
25
+ this.sourceFs = sourceFs;
26
+ this.configFiles = configFiles;
27
+ this.fontConfigFile = fontConfigFile;
28
+ this.analyticsConfigFile = analyticsConfigFile;
29
+ }
30
+ outputPath(...segments) {
31
+ return resolveOutputPath(this.outputDir, ...segments);
32
+ }
33
+ async hasRootSourceFile(fileName) {
34
+ if (this.sourceSnapshot?.has(fileName)) {
35
+ return this.sourceSnapshot.get(fileName)?.data !== null;
36
+ }
37
+ return fs.pathExists(path.join(this.rootDir, fileName));
38
+ }
39
+ async readRootSourceFile(sourcePath, label) {
40
+ const fileName = path.basename(sourcePath);
41
+ if (this.sourceSnapshot?.has(fileName)) {
42
+ const data = this.sourceSnapshot.get(fileName)?.data;
43
+ if (data === null || data === undefined) {
44
+ throw new Error(`Source file ${sourcePath} is not in the snapshot`);
45
+ }
46
+ return data;
47
+ }
48
+ return (await this.sourceFs.readProjectSourceFile(sourcePath, label)).data;
49
+ }
50
+ async copyRootSourceFile(sourcePath, destPath, label) {
51
+ const data = await this.readRootSourceFile(sourcePath, label);
52
+ await writeFileAtomic(destPath, data);
53
+ }
54
+ async readOptionalRootSourceFile(fileName, label) {
55
+ const sourcePath = path.join(this.rootDir, fileName);
56
+ if (!(await this.hasRootSourceFile(fileName)))
57
+ return null;
58
+ const data = await this.readRootSourceFile(sourcePath, label);
59
+ return data.toString("utf8");
60
+ }
61
+ async readConfigFile() {
62
+ return this.readOptionalRootSourceFile("config.json", "config source");
63
+ }
64
+ async preflightSourceFiles() {
65
+ const sources = [
66
+ ...this.configFiles.map((fileName) => [fileName, "config source"]),
67
+ [this.fontConfigFile, "font source"],
68
+ [this.analyticsConfigFile, "analytics source"],
69
+ ];
70
+ const snapshot = new Map();
71
+ for (const [fileName, label] of sources) {
72
+ const sourcePath = path.join(this.rootDir, fileName);
73
+ if (await fs.pathExists(sourcePath)) {
74
+ const { data, stat } = await this.sourceFs.readProjectSourceFile(sourcePath, label);
75
+ const hash = createHash("sha256").update(data).digest("hex");
76
+ snapshot.set(fileName, {
77
+ data,
78
+ state: `file:${stat.size}:${stat.mtimeMs}:${stat.dev}:${stat.ino}:${hash}`,
79
+ });
80
+ }
81
+ else {
82
+ snapshot.set(fileName, { data: null, state: "missing" });
83
+ }
84
+ }
85
+ this.sourceSnapshot = snapshot;
86
+ }
87
+ sourceSnapshotStates() {
88
+ return Object.fromEntries([...(this.sourceSnapshot ?? [])].map(([fileName, entry]) => [
89
+ fileName,
90
+ entry.state,
91
+ ]));
92
+ }
93
+ clearSourceSnapshot() {
94
+ this.sourceSnapshot = null;
95
+ }
96
+ async copyConfigFile(configFile) {
97
+ await this.copyRootSourceFile(path.join(this.rootDir, configFile), this.outputPath(configFile), "config source");
98
+ }
99
+ async resetConfigFile(configFile) {
100
+ await writeFileAtomic(this.outputPath(configFile), ARRAY_CONFIG_DEFAULTS.has(configFile) ? `[]\n` : `{}\n`);
101
+ }
102
+ async copyCustomConfigFiles() {
103
+ console.log(chalk.blue(`🔍 Checking for config files in: ${this.rootDir}`));
104
+ for (const configFile of this.configFiles) {
105
+ const sourcePath = path.join(this.rootDir, configFile);
106
+ console.log(chalk.gray(` Checking ${configFile}...`));
107
+ if (await this.hasRootSourceFile(configFile)) {
108
+ await this.copyConfigFile(configFile);
109
+ console.log(chalk.green(` ✓ Copied ${configFile} to Next.js app`));
110
+ }
111
+ else {
112
+ console.log(chalk.gray(` ✗ ${configFile} not found, skipping`));
113
+ }
114
+ }
115
+ }
116
+ async copyFontConfigFile() {
117
+ await this.copyRootSourceFile(path.join(this.rootDir, this.fontConfigFile), this.outputPath(this.fontConfigFile), "font source");
118
+ }
119
+ async copyFontConfig() {
120
+ console.log(chalk.blue(`🔍 Checking for font configuration...`));
121
+ const sourcePath = path.join(this.rootDir, this.fontConfigFile);
122
+ if (await this.hasRootSourceFile(this.fontConfigFile)) {
123
+ await this.copyFontConfigFile();
124
+ console.log(chalk.green(` ✓ Copied ${this.fontConfigFile} to Next.js app`));
125
+ }
126
+ else {
127
+ console.log(chalk.gray(` ✗ ${this.fontConfigFile} not found, skipping`));
128
+ }
129
+ }
130
+ async removeFontConfig() {
131
+ const destPath = this.outputPath(this.fontConfigFile);
132
+ if (!(await fs.pathExists(destPath)))
133
+ return false;
134
+ await fs.remove(destPath);
135
+ return true;
136
+ }
137
+ async loadFontConfig() {
138
+ try {
139
+ const content = await this.readOptionalRootSourceFile(this.fontConfigFile, "font source");
140
+ if (content !== null) {
141
+ return validateFontConfig(JSON.parse(content));
142
+ }
143
+ }
144
+ catch (error) {
145
+ console.warn(chalk.yellow(`⚠️ Error reading ${this.fontConfigFile}`), error);
146
+ }
147
+ return null;
148
+ }
149
+ async loadAnalyticsConfig() {
150
+ try {
151
+ const content = await this.readOptionalRootSourceFile(this.analyticsConfigFile, "analytics source");
152
+ if (content !== null) {
153
+ return validateAnalyticsConfig(JSON.parse(content));
154
+ }
155
+ }
156
+ catch (error) {
157
+ console.warn(chalk.yellow(`⚠️ Error reading ${this.analyticsConfigFile}`), error);
158
+ }
159
+ return null;
160
+ }
161
+ async writeAnalyticsConfig(config) {
162
+ await writeFileAtomic(this.outputPath(this.analyticsConfigFile), config ? `${JSON.stringify(config, null, 2)}\n` : `{}\n`);
163
+ }
164
+ async copyAnalyticsConfig(loadConfig) {
165
+ console.log(chalk.blue(`🔍 Checking for analytics configuration...`));
166
+ const sourcePath = path.join(this.rootDir, this.analyticsConfigFile);
167
+ if (await this.hasRootSourceFile(this.analyticsConfigFile)) {
168
+ await this.writeAnalyticsConfig(await loadConfig());
169
+ console.log(chalk.green(` ✓ Copied ${this.analyticsConfigFile} to Next.js app`));
170
+ }
171
+ else {
172
+ console.log(chalk.gray(` ✗ ${this.analyticsConfigFile} not found, skipping`));
173
+ }
174
+ }
175
+ async resetAnalyticsConfig() {
176
+ await this.writeAnalyticsConfig(null);
177
+ }
178
+ async loadSectionsConfig() {
179
+ try {
180
+ const content = await this.readOptionalRootSourceFile("sections.json", "sections source");
181
+ if (content !== null) {
182
+ const parsed = JSON.parse(content);
183
+ return validateSectionsConfig(parsed);
184
+ }
185
+ }
186
+ catch (error) {
187
+ console.warn(chalk.yellow("⚠️ Error reading sections.json"), error);
188
+ }
189
+ return null;
190
+ }
191
+ }
@@ -0,0 +1,20 @@
1
+ import { GeneratedArtifacts } from "../lib/generated-artifacts.js";
2
+ import type { PageWithBody } from "../templates/llms/llmsFull.js";
3
+ import { SecureSourceFs } from "./secure-source-fs.js";
4
+ export declare class PublicAssetManager {
5
+ private readonly rootDir;
6
+ private readonly outputDir;
7
+ private readonly artifacts;
8
+ private readonly sourceFs;
9
+ constructor(rootDir: string, outputDir: string, artifacts: GeneratedArtifacts, sourceFs: SecureSourceFs);
10
+ private outputPath;
11
+ publicOutputFilePath(relativePath: string): string;
12
+ copyRegularPublicFile(sourcePath: string, destPath: string): Promise<void>;
13
+ copyPublicFiles(): Promise<void>;
14
+ handlePublicFileChange(filePath: string, restoreGeneratedArtifacts: () => Promise<void>): Promise<void>;
15
+ handlePublicFileDelete(filePath: string, copyCurrentSource: () => Promise<void>, restoreGeneratedArtifacts: () => Promise<void>): Promise<void>;
16
+ findSourcePublicAsset(relativePath: string): Promise<string | null>;
17
+ writePublicAggregate(relativePath: string, content: string): Promise<void>;
18
+ syncMcpManifest(baseUrl: string | null, siteName: string): Promise<void>;
19
+ syncLlmsPageFiles(pages: PageWithBody[], baseUrl: string | null): Promise<void>;
20
+ }