@commercetools/nimbus-docs-build 0.0.0-canary-20251107124701
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 +129 -0
- package/dist/assets/index.d.ts +5 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/assets/index.js +5 -0
- package/dist/assets/index.js.map +1 -0
- package/dist/assets/optimize-assets.d.ts +5 -0
- package/dist/assets/optimize-assets.d.ts.map +1 -0
- package/dist/assets/optimize-assets.js +36 -0
- package/dist/assets/optimize-assets.js.map +1 -0
- package/dist/builders/build.d.ts +6 -0
- package/dist/builders/build.d.ts.map +1 -0
- package/dist/builders/build.js +65 -0
- package/dist/builders/build.js.map +1 -0
- package/dist/builders/index.d.ts +8 -0
- package/dist/builders/index.d.ts.map +1 -0
- package/dist/builders/index.js +8 -0
- package/dist/builders/index.js.map +1 -0
- package/dist/builders/manifest-builder.d.ts +6 -0
- package/dist/builders/manifest-builder.d.ts.map +1 -0
- package/dist/builders/manifest-builder.js +19 -0
- package/dist/builders/manifest-builder.js.map +1 -0
- package/dist/builders/mdx-builder.d.ts +6 -0
- package/dist/builders/mdx-builder.d.ts.map +1 -0
- package/dist/builders/mdx-builder.js +40 -0
- package/dist/builders/mdx-builder.js.map +1 -0
- package/dist/builders/seo-builder.d.ts +6 -0
- package/dist/builders/seo-builder.d.ts.map +1 -0
- package/dist/builders/seo-builder.js +19 -0
- package/dist/builders/seo-builder.js.map +1 -0
- package/dist/builders/types-builder.d.ts +6 -0
- package/dist/builders/types-builder.d.ts.map +1 -0
- package/dist/builders/types-builder.js +18 -0
- package/dist/builders/types-builder.js.map +1 -0
- package/dist/cache/build-cache.d.ts +41 -0
- package/dist/cache/build-cache.d.ts.map +1 -0
- package/dist/cache/build-cache.js +147 -0
- package/dist/cache/build-cache.js.map +1 -0
- package/dist/cache/index.d.ts +5 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +5 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/generators/index.d.ts +8 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +8 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/robots.d.ts +5 -0
- package/dist/generators/robots.d.ts.map +1 -0
- package/dist/generators/robots.js +34 -0
- package/dist/generators/robots.js.map +1 -0
- package/dist/generators/routes.d.ts +6 -0
- package/dist/generators/routes.d.ts.map +1 -0
- package/dist/generators/routes.js +77 -0
- package/dist/generators/routes.js.map +1 -0
- package/dist/generators/search.d.ts +6 -0
- package/dist/generators/search.d.ts.map +1 -0
- package/dist/generators/search.js +44 -0
- package/dist/generators/search.js.map +1 -0
- package/dist/generators/sitemap.d.ts +6 -0
- package/dist/generators/sitemap.d.ts.map +1 -0
- package/dist/generators/sitemap.js +33 -0
- package/dist/generators/sitemap.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/filter-props.d.ts +15 -0
- package/dist/parsers/filter-props.d.ts.map +1 -0
- package/dist/parsers/filter-props.js +50 -0
- package/dist/parsers/filter-props.js.map +1 -0
- package/dist/parsers/index.d.ts +8 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +8 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/parse-mdx.d.ts +20 -0
- package/dist/parsers/parse-mdx.d.ts.map +1 -0
- package/dist/parsers/parse-mdx.js +172 -0
- package/dist/parsers/parse-mdx.js.map +1 -0
- package/dist/parsers/parse-types.d.ts +24 -0
- package/dist/parsers/parse-types.d.ts.map +1 -0
- package/dist/parsers/parse-types.js +83 -0
- package/dist/parsers/parse-types.js.map +1 -0
- package/dist/parsers/process-types.d.ts +19 -0
- package/dist/parsers/process-types.d.ts.map +1 -0
- package/dist/parsers/process-types.js +44 -0
- package/dist/parsers/process-types.js.map +1 -0
- package/dist/schemas/index.d.ts +6 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +6 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/lifecycle-states.d.ts +16 -0
- package/dist/schemas/lifecycle-states.d.ts.map +1 -0
- package/dist/schemas/lifecycle-states.js +50 -0
- package/dist/schemas/lifecycle-states.js.map +1 -0
- package/dist/schemas/mdx-document.d.ts +233 -0
- package/dist/schemas/mdx-document.d.ts.map +1 -0
- package/dist/schemas/mdx-document.js +118 -0
- package/dist/schemas/mdx-document.js.map +1 -0
- package/dist/types/config.d.ts +106 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mdx.d.ts +16 -0
- package/dist/types/mdx.d.ts.map +1 -0
- package/dist/types/mdx.js +2 -0
- package/dist/types/mdx.js.map +1 -0
- package/dist/utils/file-utils.d.ts +28 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +111 -0
- package/dist/utils/file-utils.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +16 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/sluggify.d.ts +17 -0
- package/dist/utils/sluggify.d.ts.map +1 -0
- package/dist/utils/sluggify.js +26 -0
- package/dist/utils/sluggify.js.map +1 -0
- package/dist/utils/validate-file-path.d.ts +23 -0
- package/dist/utils/validate-file-path.d.ts.map +1 -0
- package/dist/utils/validate-file-path.js +39 -0
- package/dist/utils/validate-file-path.js.map +1 -0
- package/dist/validation/index.d.ts +5 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +5 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/validate-content.d.ts +12 -0
- package/dist/validation/validate-content.d.ts.map +1 -0
- package/dist/validation/validate-content.js +95 -0
- package/dist/validation/validate-content.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build Cache System
|
|
3
|
+
*
|
|
4
|
+
* Implements incremental builds by tracking file hashes and
|
|
5
|
+
* only rebuilding changed content.
|
|
6
|
+
*/
|
|
7
|
+
import fs from "fs/promises";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import crypto from "crypto";
|
|
10
|
+
import { validateFilePath } from "../utils/validate-file-path.js";
|
|
11
|
+
const DEFAULT_CACHE_DIR = ".cache";
|
|
12
|
+
const CACHE_FILENAME = "build-cache.json";
|
|
13
|
+
/**
|
|
14
|
+
* Get cache file path
|
|
15
|
+
*/
|
|
16
|
+
function getCachePath(cacheDir) {
|
|
17
|
+
const dir = cacheDir || DEFAULT_CACHE_DIR;
|
|
18
|
+
// Validate cache directory path to prevent traversal
|
|
19
|
+
const baseDir = process.cwd();
|
|
20
|
+
return validateFilePath(baseDir, dir, CACHE_FILENAME);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Calculate file hash for cache validation
|
|
24
|
+
*
|
|
25
|
+
* @param filePath - Absolute path to file (should be pre-validated by caller)
|
|
26
|
+
* @note Callers must ensure filePath is validated to prevent path traversal
|
|
27
|
+
*/
|
|
28
|
+
export async function calculateFileHash(filePath) {
|
|
29
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
30
|
+
return crypto.createHash("sha256").update(content).digest("hex");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Load build cache from disk
|
|
34
|
+
*/
|
|
35
|
+
export async function loadCache(cacheDir) {
|
|
36
|
+
try {
|
|
37
|
+
const cachePath = getCachePath(cacheDir);
|
|
38
|
+
const cacheFileDir = path.dirname(cachePath);
|
|
39
|
+
await fs.mkdir(cacheFileDir, { recursive: true });
|
|
40
|
+
const content = await fs.readFile(cachePath, "utf-8");
|
|
41
|
+
const data = JSON.parse(content);
|
|
42
|
+
return {
|
|
43
|
+
version: data.version || "1.0.0",
|
|
44
|
+
files: new Map(Object.entries(data.files || {})),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Cache doesn't exist or is invalid, return empty cache
|
|
49
|
+
return {
|
|
50
|
+
version: "1.0.0",
|
|
51
|
+
files: new Map(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Save build cache to disk
|
|
57
|
+
*/
|
|
58
|
+
export async function saveCache(cache, cacheDir) {
|
|
59
|
+
const cachePath = getCachePath(cacheDir);
|
|
60
|
+
const cacheFileDir = path.dirname(cachePath);
|
|
61
|
+
await fs.mkdir(cacheFileDir, { recursive: true });
|
|
62
|
+
const data = {
|
|
63
|
+
version: cache.version,
|
|
64
|
+
files: Object.fromEntries(cache.files),
|
|
65
|
+
};
|
|
66
|
+
await fs.writeFile(cachePath, JSON.stringify(data, null, 2), "utf-8");
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Check if a file needs rebuilding
|
|
70
|
+
*/
|
|
71
|
+
export async function needsRebuild(filePath, cache) {
|
|
72
|
+
try {
|
|
73
|
+
const currentHash = await calculateFileHash(filePath);
|
|
74
|
+
const cacheEntry = cache.files.get(filePath);
|
|
75
|
+
// No cache entry = needs build
|
|
76
|
+
if (!cacheEntry)
|
|
77
|
+
return true;
|
|
78
|
+
// Hash changed = needs rebuild
|
|
79
|
+
if (cacheEntry.hash !== currentHash)
|
|
80
|
+
return true;
|
|
81
|
+
// Check if output still exists
|
|
82
|
+
try {
|
|
83
|
+
await fs.access(cacheEntry.outputPath);
|
|
84
|
+
return false; // Output exists and hash matches
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return true; // Output missing, needs rebuild
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Error reading file, assume needs rebuild
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Update cache entry for a file
|
|
97
|
+
*/
|
|
98
|
+
export function updateCacheEntry(cache, filePath, hash, outputPath) {
|
|
99
|
+
cache.files.set(filePath, {
|
|
100
|
+
hash,
|
|
101
|
+
timestamp: Date.now(),
|
|
102
|
+
outputPath,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Clear stale cache entries (files that no longer exist)
|
|
107
|
+
*/
|
|
108
|
+
export async function cleanCache(cache, validFiles) {
|
|
109
|
+
const validSet = new Set(validFiles);
|
|
110
|
+
for (const [filePath] of cache.files) {
|
|
111
|
+
if (!validSet.has(filePath)) {
|
|
112
|
+
cache.files.delete(filePath);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get cache statistics
|
|
118
|
+
*/
|
|
119
|
+
export function getCacheStats(cache) {
|
|
120
|
+
let oldestEntry = Date.now();
|
|
121
|
+
let newestEntry = 0;
|
|
122
|
+
for (const [, entry] of cache.files) {
|
|
123
|
+
if (entry.timestamp < oldestEntry)
|
|
124
|
+
oldestEntry = entry.timestamp;
|
|
125
|
+
if (entry.timestamp > newestEntry)
|
|
126
|
+
newestEntry = entry.timestamp;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
totalFiles: cache.files.size,
|
|
130
|
+
oldestEntry,
|
|
131
|
+
newestEntry,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Clear entire cache
|
|
136
|
+
*/
|
|
137
|
+
export async function clearCache(cacheDir) {
|
|
138
|
+
try {
|
|
139
|
+
const dir = cacheDir || DEFAULT_CACHE_DIR;
|
|
140
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
141
|
+
console.log("✓ Build cache cleared");
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
console.warn("Warning: Could not clear cache:", error);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=build-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-cache.js","sourceRoot":"","sources":["../../src/cache/build-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AACnC,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAE1C;;GAEG;AACH,SAAS,YAAY,CAAC,QAAiB;IACrC,MAAM,GAAG,GAAG,QAAQ,IAAI,iBAAiB,CAAC;IAC1C,qDAAqD;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9B,OAAO,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAgB;IACtD,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAiB;IAC/C,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7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AU,aAAa,CAAC,KAAiB;IAK7C,IAAI,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QACpC,IAAI,KAAK,CAAC,SAAS,GAAG,WAAW;YAAE,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC;QACjE,IAAI,KAAK,CAAC,SAAS,GAAG,WAAW;YAAE,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC;IACnE,CAAC;IAED,OAAO;QACL,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI;QAC5B,WAAW;QACX,WAAW;KACZ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAiB;IAChD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,QAAQ,IAAI,iBAAiB,CAAC;QAC1C,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"robots.d.ts","sourceRoot":"","sources":["../../src/generators/robots.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAsBf"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Robots.txt Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates robots.txt for SEO and crawler control
|
|
5
|
+
*/
|
|
6
|
+
import fs from "fs/promises";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { validateFilePath } from "../utils/validate-file-path.js";
|
|
9
|
+
/**
|
|
10
|
+
* Generate robots.txt
|
|
11
|
+
*/
|
|
12
|
+
export async function generateRobots(baseUrl, outputPath) {
|
|
13
|
+
const robots = `# Nimbus Documentation Robots.txt
|
|
14
|
+
# Allow all crawlers
|
|
15
|
+
User-agent: *
|
|
16
|
+
Allow: /
|
|
17
|
+
|
|
18
|
+
# Sitemap location
|
|
19
|
+
Sitemap: ${baseUrl}/sitemap.xml
|
|
20
|
+
|
|
21
|
+
# Crawl rate (optional)
|
|
22
|
+
Crawl-delay: 1
|
|
23
|
+
|
|
24
|
+
# Disallow private/internal routes if any
|
|
25
|
+
# Disallow: /api/
|
|
26
|
+
# Disallow: /internal/
|
|
27
|
+
`;
|
|
28
|
+
// Validate output path to prevent traversal
|
|
29
|
+
const outputDir = path.dirname(outputPath);
|
|
30
|
+
const validatedPath = validateFilePath(outputDir, path.basename(outputPath));
|
|
31
|
+
await fs.writeFile(validatedPath, robots, "utf-8");
|
|
32
|
+
console.log(`✓ Generated robots.txt`);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=robots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"robots.js","sourceRoot":"","sources":["../../src/generators/robots.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAe,EACf,UAAkB;IAElB,MAAM,MAAM,GAAG;;;;;;WAMN,OAAO;;;;;;;;CAQjB,CAAC;IAEA,4CAA4C;IAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7E,MAAM,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MdxDocument, RouteManifest } from "../types/mdx.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generate route manifest from parsed documents
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateRouteManifest(docs: Map<string, MdxDocument>, outputPath: string): Promise<RouteManifest>;
|
|
6
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/generators/routes.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EAGd,MAAM,iBAAiB,CAAC;AAKzB;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAC9B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,CAAC,CA+ExB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route Manifest Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates route configuration from parsed MDX documents
|
|
5
|
+
*/
|
|
6
|
+
import fs from "fs/promises";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { routeManifestSchema } from "../schemas/mdx-document.js";
|
|
9
|
+
import { flog } from "../utils/logger.js";
|
|
10
|
+
import { validateFilePath } from "../utils/validate-file-path.js";
|
|
11
|
+
/**
|
|
12
|
+
* Generate route manifest from parsed documents
|
|
13
|
+
*/
|
|
14
|
+
export async function generateRouteManifest(docs, outputPath) {
|
|
15
|
+
const routes = [];
|
|
16
|
+
const categoriesMap = new Map();
|
|
17
|
+
// Process each document
|
|
18
|
+
for (const [, doc] of docs) {
|
|
19
|
+
const { meta } = doc;
|
|
20
|
+
const category = meta.menu[0] || "Uncategorized";
|
|
21
|
+
const routePath = `/${meta.route}`;
|
|
22
|
+
// Create route info
|
|
23
|
+
const route = {
|
|
24
|
+
path: routePath,
|
|
25
|
+
id: meta.id,
|
|
26
|
+
title: meta.title,
|
|
27
|
+
description: meta.description || "",
|
|
28
|
+
lifecycleState: meta.lifecycleState,
|
|
29
|
+
category,
|
|
30
|
+
tags: meta.tags || [],
|
|
31
|
+
menu: meta.menu,
|
|
32
|
+
order: meta.order || 999,
|
|
33
|
+
chunkName: `route-${meta.route.replace(/\//g, "-")}`,
|
|
34
|
+
icon: meta.icon,
|
|
35
|
+
tabs: meta.tabs || [],
|
|
36
|
+
};
|
|
37
|
+
routes.push(route);
|
|
38
|
+
// Build categories
|
|
39
|
+
if (!categoriesMap.has(category)) {
|
|
40
|
+
categoriesMap.set(category, {
|
|
41
|
+
id: category.toLowerCase().replace(/\s+/g, "-"),
|
|
42
|
+
label: category,
|
|
43
|
+
order: 999,
|
|
44
|
+
items: [],
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
categoriesMap.get(category).items.push(route);
|
|
48
|
+
}
|
|
49
|
+
// Convert categories map to array and sort
|
|
50
|
+
const categories = Array.from(categoriesMap.values()).sort((a, b) => a.order - b.order);
|
|
51
|
+
// Build navigation structure
|
|
52
|
+
const navigation = categories.reduce((acc, category) => {
|
|
53
|
+
acc[category.id] = {
|
|
54
|
+
label: category.label,
|
|
55
|
+
items: category.items.map((item) => ({
|
|
56
|
+
id: item.id,
|
|
57
|
+
title: item.title,
|
|
58
|
+
path: item.path,
|
|
59
|
+
})),
|
|
60
|
+
};
|
|
61
|
+
return acc;
|
|
62
|
+
}, {});
|
|
63
|
+
const manifest = {
|
|
64
|
+
routes,
|
|
65
|
+
categories,
|
|
66
|
+
navigation,
|
|
67
|
+
};
|
|
68
|
+
// Validate
|
|
69
|
+
const validatedManifest = routeManifestSchema.parse(manifest);
|
|
70
|
+
// Write to disk
|
|
71
|
+
const outputDir = path.dirname(outputPath);
|
|
72
|
+
const validatedPath = validateFilePath(outputDir, path.basename(outputPath));
|
|
73
|
+
await fs.writeFile(validatedPath, JSON.stringify(validatedManifest, null, 2));
|
|
74
|
+
flog(`[Routes] Generated manifest with ${routes.length} routes`);
|
|
75
|
+
return validatedManifest;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/generators/routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IA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C,CAAC;IAE9D,gBAAgB;IAChB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7E,MAAM,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAE9E,IAAI,CAAC,oCAAoC,MAAM,CAAC,MAAM,SAAS,CAAC,CAAC;IAEjE,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/generators/search.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAkBnD;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAC9B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Index Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates a searchable index from documentation
|
|
5
|
+
*/
|
|
6
|
+
import fs from "fs/promises";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { flog } from "../utils/logger.js";
|
|
9
|
+
import { validateFilePath } from "../utils/validate-file-path.js";
|
|
10
|
+
/**
|
|
11
|
+
* Strip markdown formatting from text
|
|
12
|
+
*/
|
|
13
|
+
function stripMarkdown(text) {
|
|
14
|
+
return text
|
|
15
|
+
.replace(/#{1,6}\s/g, "") // Remove headers
|
|
16
|
+
.replace(/\*\*([^*]+)\*\*/g, "$1") // Remove bold
|
|
17
|
+
.replace(/\*([^*]+)\*/g, "$1") // Remove italic
|
|
18
|
+
.replace(/`([^`]+)`/g, "$1") // Remove code
|
|
19
|
+
.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1") // Remove links
|
|
20
|
+
.replace(/!\[([^\]]*)\]\([^)]+\)/g, "") // Remove images
|
|
21
|
+
.trim();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Generate search index from parsed documents
|
|
25
|
+
*/
|
|
26
|
+
export async function generateSearchIndex(docs, outputPath) {
|
|
27
|
+
const searchItems = Array.from(docs.values())
|
|
28
|
+
.map((doc) => ({
|
|
29
|
+
id: doc.meta.id,
|
|
30
|
+
title: doc.meta.title,
|
|
31
|
+
description: doc.meta.description || "",
|
|
32
|
+
tags: doc.meta.tags || [],
|
|
33
|
+
route: doc.meta.route,
|
|
34
|
+
menu: doc.meta.menu,
|
|
35
|
+
// Strip markdown and truncate content for search (first 500 chars)
|
|
36
|
+
content: stripMarkdown(doc.mdx).slice(0, 500),
|
|
37
|
+
}))
|
|
38
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
39
|
+
const outputDir = path.dirname(outputPath);
|
|
40
|
+
const validatedPath = validateFilePath(outputDir, path.basename(outputPath));
|
|
41
|
+
await fs.writeFile(validatedPath, JSON.stringify(searchItems, null, 2));
|
|
42
|
+
flog(`[Search] Generated index with ${searchItems.length} items`);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/generators/search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE;;GAEG;AACH,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI;SACR,OAAO,CAAC,WAAW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BAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7E,MAAM,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAExE,IAAI,CAAC,iCAAiC,WAAW,CAAC,MAAM,QAAQ,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sitemap.d.ts","sourceRoot":"","sources":["../../src/generators/sitemap.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;GAEG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAuBf"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sitemap Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates sitemap.xml for SEO
|
|
5
|
+
*/
|
|
6
|
+
import fs from "fs/promises";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { validateFilePath } from "../utils/validate-file-path.js";
|
|
9
|
+
/**
|
|
10
|
+
* Generate sitemap.xml from route manifest
|
|
11
|
+
*/
|
|
12
|
+
export async function generateSitemap(manifest, baseUrl, outputPath) {
|
|
13
|
+
const urls = manifest.routes.map((route) => {
|
|
14
|
+
const lastmod = new Date().toISOString().split("T")[0];
|
|
15
|
+
const priority = route.path === "/" ? "1.0" : "0.8";
|
|
16
|
+
const changefreq = "weekly";
|
|
17
|
+
return ` <url>
|
|
18
|
+
<loc>${baseUrl}${route.path}</loc>
|
|
19
|
+
<lastmod>${lastmod}</lastmod>
|
|
20
|
+
<changefreq>${changefreq}</changefreq>
|
|
21
|
+
<priority>${priority}</priority>
|
|
22
|
+
</url>`;
|
|
23
|
+
});
|
|
24
|
+
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
|
|
25
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
26
|
+
${urls.join("\n")}
|
|
27
|
+
</urlset>`;
|
|
28
|
+
const outputDir = path.dirname(outputPath);
|
|
29
|
+
const validatedPath = validateFilePath(outputDir, path.basename(outputPath));
|
|
30
|
+
await fs.writeFile(validatedPath, sitemap, "utf-8");
|
|
31
|
+
console.log(`✓ Generated sitemap with ${urls.length} URLs`);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=sitemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sitemap.js","sourceRoot":"","sources":["../../src/generators/sitemap.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAuB,EACvB,OAAe,EACf,UAAkB;IAElB,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACzC,MAAM,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QACpD,MAAM,UAAU,GAAG,QAAQ,CAAC;QAE5B,OAAO;WACA,OAAO,GAAG,KAAK,CAAC,IAAI;eAChB,OAAO;kBACJ,UAAU;gBACZ,QAAQ;SACf,CAAC;IACR,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG;;EAEhB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;UACP,CAAC;IAET,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7E,MAAM,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,CAAC,MAAM,OAAO,CAAC,CAAC;AAC9D,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @commercetools/nimbus-docs-build
|
|
3
|
+
*
|
|
4
|
+
* Documentation build system for Nimbus design system
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { build } from "./builders/build.js";
|
|
9
|
+
export { buildMdx, buildTypes, buildManifest, buildSeo, } from "./builders/index.js";
|
|
10
|
+
export { parseMdxFile, parseAllMdx, parseTypes, parseTypesToFile, parseTypesToFiles, } from "./parsers/index.js";
|
|
11
|
+
export { generateRouteManifest, generateSearchIndex, generateRobots, generateSitemap, } from "./generators/index.js";
|
|
12
|
+
export { validateContent } from "./validation/index.js";
|
|
13
|
+
export { loadCache, saveCache, needsRebuild, updateCacheEntry, cleanCache, getCacheStats, clearCache, calculateFileHash, } from "./cache/index.js";
|
|
14
|
+
export { optimizeAssets } from "./assets/index.js";
|
|
15
|
+
export { flog, errorLog, warnLog, successLog, sluggify, menuToPath, findMonorepoRoot, getPathFromMonorepoRoot, findFiles, findFilesByExtensions, validateFilePath, } from "./utils/index.js";
|
|
16
|
+
export * from "./schemas/index.js";
|
|
17
|
+
export * from "./types/index.js";
|
|
18
|
+
export type { ComponentDoc, PropItem } from "react-docgen-typescript";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C,OAAO,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,YAAY,EACZ,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EACL,SAAS,EACT,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,UAAU,EACV,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,UAAU,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,SAAS,EACT,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAG1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AAGjC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @commercetools/nimbus-docs-build
|
|
3
|
+
*
|
|
4
|
+
* Documentation build system for Nimbus design system
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
// Main build function
|
|
9
|
+
export { build } from "./builders/build.js";
|
|
10
|
+
// Individual builders (for advanced usage)
|
|
11
|
+
export { buildMdx, buildTypes, buildManifest, buildSeo, } from "./builders/index.js";
|
|
12
|
+
// Parsers
|
|
13
|
+
export { parseMdxFile, parseAllMdx, parseTypes, parseTypesToFile, parseTypesToFiles, } from "./parsers/index.js";
|
|
14
|
+
// Generators
|
|
15
|
+
export { generateRouteManifest, generateSearchIndex, generateRobots, generateSitemap, } from "./generators/index.js";
|
|
16
|
+
// Validation
|
|
17
|
+
export { validateContent } from "./validation/index.js";
|
|
18
|
+
// Cache utilities
|
|
19
|
+
export { loadCache, saveCache, needsRebuild, updateCacheEntry, cleanCache, getCacheStats, clearCache, calculateFileHash, } from "./cache/index.js";
|
|
20
|
+
// Asset optimization
|
|
21
|
+
export { optimizeAssets } from "./assets/index.js";
|
|
22
|
+
// Utilities
|
|
23
|
+
export { flog, errorLog, warnLog, successLog, sluggify, menuToPath, findMonorepoRoot, getPathFromMonorepoRoot, findFiles, findFilesByExtensions, validateFilePath, } from "./utils/index.js";
|
|
24
|
+
// Schemas and types
|
|
25
|
+
export * from "./schemas/index.js";
|
|
26
|
+
export * from "./types/index.js";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,sBAAsB;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,2CAA2C;AAC3C,OAAO,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAE7B,UAAU;AACV,OAAO,EACL,YAAY,EACZ,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,aAAa;AACb,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B,aAAa;AACb,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,kBAAkB;AAClB,OAAO,EACL,SAAS,EACT,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,UAAU,EACV,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,qBAAqB;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,YAAY;AACZ,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,UAAU,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,SAAS,EACT,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,oBAAoB;AACpB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop filtering logic extracted from react-docgen-typescript parsing.
|
|
3
|
+
* Filters out inherited HTML, React, Chakra, and ARIA props to show only
|
|
4
|
+
* component-specific props in documentation.
|
|
5
|
+
*/
|
|
6
|
+
import type { PropItem } from "react-docgen-typescript";
|
|
7
|
+
/**
|
|
8
|
+
* Determines whether a prop should be filtered out of documentation.
|
|
9
|
+
* Returns true if the prop should be KEPT, false if it should be FILTERED.
|
|
10
|
+
*
|
|
11
|
+
* @param prop - The prop item from react-docgen-typescript
|
|
12
|
+
* @returns true if prop should be kept, false if it should be filtered
|
|
13
|
+
*/
|
|
14
|
+
export declare const shouldFilterProp: (prop: PropItem) => boolean;
|
|
15
|
+
//# sourceMappingURL=filter-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-props.d.ts","sourceRoot":"","sources":["../../src/parsers/filter-props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,QAAQ,KAAG,OAqDjD,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether a prop should be filtered out of documentation.
|
|
3
|
+
* Returns true if the prop should be KEPT, false if it should be FILTERED.
|
|
4
|
+
*
|
|
5
|
+
* @param prop - The prop item from react-docgen-typescript
|
|
6
|
+
* @returns true if prop should be kept, false if it should be filtered
|
|
7
|
+
*/
|
|
8
|
+
export const shouldFilterProp = (prop) => {
|
|
9
|
+
// React Key attribute
|
|
10
|
+
const isReactKeyAttribute = prop.name === "key";
|
|
11
|
+
// All HTML attributes
|
|
12
|
+
const isHTMLAttribute = prop.parent?.name === "HTMLAttributes";
|
|
13
|
+
// HTML-Event listener
|
|
14
|
+
const isDOMAttribute = prop.parent?.name === "DOMAttributes";
|
|
15
|
+
// ButtonHTMLAttributes
|
|
16
|
+
const isButtonAttribute = prop.parent?.name === "ButtonHTMLAttributes";
|
|
17
|
+
// GlobalDOMEvents
|
|
18
|
+
const isGlobalDOMEvent = prop.parent?.name === "GlobalDOMEvents";
|
|
19
|
+
// GlobalDOMAttribute
|
|
20
|
+
const isGlobalDOMAttribute = prop.parent?.name === "GlobalDOMAttributes";
|
|
21
|
+
// Chakra related props
|
|
22
|
+
const isChakraSystemProperty = prop.parent?.name === "SystemProperties";
|
|
23
|
+
const isChakraCondition = prop.parent?.name === "Conditions";
|
|
24
|
+
const isSlotRecipeDefinition = prop.name === "recipe";
|
|
25
|
+
// Default accessibility props
|
|
26
|
+
const isAriaAttribute = prop.parent?.name === "AriaAttributes";
|
|
27
|
+
/**
|
|
28
|
+
* Fallback props: When standard HTML attribute names (e.g., "height") are
|
|
29
|
+
* repurposed for style APIs, their actual DOM equivalents are generated
|
|
30
|
+
* as "HtmlProps" (e.g., "htmlHeight") to avoid conflicts.
|
|
31
|
+
*/
|
|
32
|
+
const isHtmlFallbackProp = prop.parent?.name === "HtmlProps";
|
|
33
|
+
// Exclude redundant props
|
|
34
|
+
if (isReactKeyAttribute ||
|
|
35
|
+
isHTMLAttribute ||
|
|
36
|
+
isDOMAttribute ||
|
|
37
|
+
isButtonAttribute ||
|
|
38
|
+
isGlobalDOMEvent ||
|
|
39
|
+
isGlobalDOMAttribute ||
|
|
40
|
+
isAriaAttribute ||
|
|
41
|
+
isChakraSystemProperty ||
|
|
42
|
+
isChakraCondition ||
|
|
43
|
+
isSlotRecipeDefinition ||
|
|
44
|
+
isHtmlFallbackProp) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
// Keep all other props
|
|
48
|
+
return true;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=filter-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-props.js","sourceRoot":"","sources":["../../src/parsers/filter-props.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAc,EAAW,EAAE;IAC1D,sBAAsB;IACtB,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC;IAEhD,sBAAsB;IACtB,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,gBAAgB,CAAC;IAE/D,sBAAsB;IACtB,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,eAAe,CAAC;IAE7D,uBAAuB;IACvB,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,sBAAsB,CAAC;IAEvE,kBAAkB;IAClB,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,iBAAiB,CAAC;IAEjE,qBAAqB;IACrB,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,qBAAqB,CAAC;IAEzE,uBAAuB;IACvB,MAAM,sBAAsB,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,kBAAkB,CAAC;IACxE,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,YAAY,CAAC;IAC7D,MAAM,sBAAsB,GAAG,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;IAEtD,8BAA8B;IAC9B,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,gBAAgB,CAAC;IAE/D;;;;OAIG;IACH,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,WAAW,CAAC;IAE7D,0BAA0B;IAC1B,IACE,mBAAmB;QACnB,eAAe;QACf,cAAc;QACd,iBAAiB;QACjB,gBAAgB;QAChB,oBAAoB;QACpB,eAAe;QACf,sBAAsB;QACtB,iBAAiB;QACjB,sBAAsB;QACtB,kBAAkB,EAClB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,uBAAuB;IACvB,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parsers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parsers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|