Skip to content

Commit b612542

Browse files
chore(deps-dev): bump typedoc from 0.27.2 to 0.27.6 (#5322)
* chore(deps-dev): bump typedoc from 0.27.2 to 0.27.6 Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.27.2 to 0.27.6. - [Release notes](https://github.com/TypeStrong/TypeDoc/releases) - [Changelog](https://github.com/TypeStrong/typedoc/blob/master/CHANGELOG.md) - [Commits](TypeStrong/typedoc@v0.27.2...v0.27.6) --- updated-dependencies: - dependency-name: typedoc dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * fix: typedoc --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Zhongpin Wang <[email protected]>
1 parent 12298ee commit b612542

File tree

3 files changed

+45
-36
lines changed

3 files changed

+45
-36
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"ts-jest": "^29.2.5",
115115
"ts-node": "^10.9.2",
116116
"turbo": "^2.3.3",
117-
"typedoc": "^0.27.2",
117+
"typedoc": "^0.27.6",
118118
"typescript": "~5.7.2"
119119
},
120120
"resolutions": {

scripts/generate-docs.ts

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import { resolve, basename, extname } from 'path';
44
import execa from 'execa';
55
import { unixEOL } from '@sap-cloud-sdk/util';
66
import { transformFile } from './util';
7-
import { gunzip, gzip } from 'zlib';
7+
import { deflate } from 'zlib';
88
import { promisify } from 'util';
99

10-
const gunzipP = promisify(gunzip);
11-
const gzipP = promisify(gzip);
10+
const deflateP = promisify(deflate);
1211

1312
const docPath = resolve(
1413
JSON.parse(readFileSync('tsconfig.typedoc.json', 'utf8')).typedocOptions.out
@@ -36,8 +35,8 @@ const isNavigationJs = fileName => basename(fileName) === 'navigation.js';
3635

3736
const pipe =
3837
(...fns) =>
39-
start =>
40-
fns.reduce((state, fn) => fn(state), start);
38+
start =>
39+
fns.reduce((state, fn) => fn(state), start);
4140

4241
async function adjustForGitHubPages() {
4342
const documentationFilePaths = flatten(readDir(resolve(docPath)));
@@ -57,6 +56,34 @@ async function adjustForGitHubPages() {
5756
htmlPaths.forEach(filePath => removeUnderlinePrefixFromFileName(filePath));
5857
}
5958

59+
/**
60+
* Decompresses Base64-encoded deflate compressed data and parses it into a JSON object.
61+
* @link https://github.com/TypeStrong/typedoc/blob/82449253188582f6b63695fecf608d9887ba1761/src/lib/output/themes/default/assets/typedoc/utils/decompress.ts
62+
*
63+
* @param base64 - The Base64-encoded string representing the deflate-compressed JSON string.
64+
* @returns A promise that resolves to the parsed JSON object.
65+
*/
66+
export async function decompressJson(base64: string) {
67+
const binaryData = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
68+
const blob = new Blob([binaryData]);
69+
const decompressedStream = blob
70+
.stream()
71+
.pipeThrough(new DecompressionStream("deflate"));
72+
const decompressedText = await new Response(decompressedStream).text();
73+
return JSON.parse(decompressedText);
74+
}
75+
76+
/**
77+
* Compresses a JSON-serializable object into a Base64-encoded deflate string.
78+
* @link https://github.com/TypeStrong/typedoc/blob/82449253188582f6b63695fecf608d9887ba1761/src/lib/utils/compress.ts
79+
* @param data - The JSON-serializable object to compress.
80+
* @returns A promise that resolves to a Base64-encoded string of the deflate-compressed data.
81+
*/
82+
export async function compressJson(data: any) {
83+
const gz = await deflateP(Buffer.from(JSON.stringify(data)));
84+
return gz.toString("base64");
85+
}
86+
6087
async function adjustSearchJs(paths) {
6188
const filtered = paths.filter(isSearchJs);
6289
if (filtered.length !== 1) {
@@ -65,31 +92,22 @@ async function adjustSearchJs(paths) {
6592

6693
await transformFile(filtered[0], async file => {
6794
const dataRegexResult =
68-
/window.searchData = "data:application\/octet-stream;base64,(.*)"/.exec(
95+
/window.searchData = "(.*)";/.exec(
6996
file
7097
);
71-
7298
if (!dataRegexResult) {
7399
throw Error(
74100
`Cannot adjust links in 'search.js'. File content did not match expected pattern.`
75101
);
76102
}
77103

78-
const encodedData = dataRegexResult[1];
79-
80-
const ungzipped = (
81-
await gunzipP(Buffer.from(encodedData, 'base64'))
82-
).toString('utf8');
83-
const searchItems = JSON.parse(ungzipped);
84-
104+
const searchItems = await decompressJson(dataRegexResult[1]);
85105
searchItems.rows.forEach(s => {
86106
s.url = removeUnderlinePrefix(s.url);
87107
});
88108

89-
const encodedAdjustedData = (
90-
await gzipP(JSON.stringify(searchItems))
91-
).toString('base64');
92-
return `window.searchData = "data:application/octet-stream;base64,${encodedAdjustedData}"`;
109+
const encodedAdjustedData = await compressJson(searchItems);
110+
return `window.searchData = "${encodedAdjustedData}"`;
93111
});
94112
}
95113

@@ -101,23 +119,16 @@ async function adjustNavigationJs(paths) {
101119

102120
await transformFile(filtered[0], async file => {
103121
const dataRegexResult =
104-
/window.navigationData = "data:application\/octet-stream;base64,(.*)"/.exec(
122+
/window.navigationData = "(.*)"/.exec(
105123
file
106124
);
107-
108125
if (!dataRegexResult) {
109126
throw Error(
110127
`Cannot adjust links in 'navigation.js'. File content did not match expected pattern.`
111128
);
112129
}
113130

114-
const encodedData = dataRegexResult[1];
115-
116-
const ungzipped = (
117-
await gunzipP(Buffer.from(encodedData, 'base64'))
118-
).toString('utf8');
119-
const navigationItems = JSON.parse(ungzipped);
120-
131+
const navigationItems = await decompressJson(dataRegexResult[1]);
121132
navigationItems
122133
.filter(n => n.path)
123134
.forEach(n => {
@@ -127,10 +138,8 @@ async function adjustNavigationJs(paths) {
127138
});
128139
});
129140

130-
const encodedAdjustedData = (
131-
await gzipP(JSON.stringify(navigationItems))
132-
).toString('base64');
133-
return `window.navigationData = "data:application/octet-stream;base64,${encodedAdjustedData}"`;
141+
const encodedAdjustedData = await compressJson(navigationItems);
142+
return `window.navigationData = "${encodedAdjustedData}"`;
134143
});
135144
}
136145

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9603,10 +9603,10 @@ typedarray@^0.0.6:
96039603
resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
96049604
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==
96059605

9606-
typedoc@^0.27.2:
9607-
version "0.27.2"
9608-
resolved "https://registry.npmjs.org/typedoc/-/typedoc-0.27.2.tgz#8a4e0303f4c49174af21e981e0b60e8a637d8167"
9609-
integrity sha512-C2ima5TZJHU3ecnRIz50lKd1BsYck5LhYQIy7MRPmjuSEJreUEAt+uAVcZgY7wZsSORzEI7xW8miZIdxv/cbmw==
9606+
typedoc@^0.27.6:
9607+
version "0.27.6"
9608+
resolved "https://registry.npmjs.org/typedoc/-/typedoc-0.27.6.tgz#7e8d067bd5386b7908afcb12c9054a83e8bb326b"
9609+
integrity sha512-oBFRoh2Px6jFx366db0lLlihcalq/JzyCVp7Vaq1yphL/tbgx2e+bkpkCgJPunaPvPwoTOXSwasfklWHm7GfAw==
96109610
dependencies:
96119611
"@gerrit0/mini-shiki" "^1.24.0"
96129612
lunr "^2.3.9"

0 commit comments

Comments
 (0)