Skip to content

Commit afcb2c1

Browse files
More junk to make typescript docs generation backwards compat (#3160)
1 parent b52c9d0 commit afcb2c1

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

script/postprocess-docs.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,32 @@ function updateAssetFile(filePath, renameMap) {
7878

7979
let content = fs.readFileSync(filePath, 'utf8');
8080

81+
// Handle compressed navigation.js (base64 + pako)
82+
if (filePath.endsWith('navigation.js')) {
83+
const match = content.match(/window\.navigationData = "([^"]+)"/);
84+
if (match) {
85+
try {
86+
const pako = require('pako');
87+
const decoded = Buffer.from(match[1], 'base64');
88+
let jsonStr = pako.inflate(decoded, { to: 'string' });
89+
90+
// Update references to lowercase in the JSON
91+
for (const [original, lowercase] of renameMap) {
92+
jsonStr = jsonStr.replace(new RegExp(original.replace('.', '\\.'), 'g'), lowercase);
93+
}
94+
95+
// Re-compress and encode
96+
const compressed = pako.deflate(jsonStr);
97+
const encoded = Buffer.from(compressed).toString('base64');
98+
content = `window.navigationData = "${encoded}"`;
99+
fs.writeFileSync(filePath, content, 'utf8');
100+
return;
101+
} catch (e) {
102+
console.warn('Failed to process navigation.js:', e.message);
103+
}
104+
}
105+
}
106+
81107
// Format for readability (search.js specific)
82108
if (filePath.endsWith('search.js')) {
83109
content = content.replace(/","/g, '",\n"');

0 commit comments

Comments
 (0)