Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions inputfiles/removals/Authenticator.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enum AuthenticatorTransport {
smart-card // WebKit only as of 2023-05
}
3 changes: 0 additions & 3 deletions inputfiles/removedTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
},
"enums": {
"enum": {
"AuthenticatorTransport": {
"value": ["smart-card"] // WebKit only as of 2023-05
},
"ConnectionType": {
"value": ["wimax"]
},
Expand Down
4 changes: 3 additions & 1 deletion src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ async function emitDom() {

const overriddenItems = await readInputJSON("overridingTypes.jsonc");
const addedItems = await readInputJSON("addedTypes.jsonc");
const patches = await readPatches();
const patches = await readPatches("patches");
const removals = await readPatches("removals");
const comments = await readInputJSON("comments.json");
const documentationFromMDN = await generateDescriptions();
const removedItems = await readInputJSON("removedTypes.jsonc");
Expand Down Expand Up @@ -204,6 +205,7 @@ async function emitDom() {
webidl = merge(webidl, getRemovalData(webidl));
webidl = merge(webidl, getDocsData(webidl));
webidl = prune(webidl, removedItems);
webidl = prune(webidl, removals);
webidl = merge(webidl, addedItems);
webidl = merge(webidl, overriddenItems);
webidl = merge(webidl, patches);
Expand Down
31 changes: 27 additions & 4 deletions src/build/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,37 @@ export async function readPatch(fileUrl: URL): Promise<any> {
return parseKDL(text);
}

function removeNamesDeep(obj: unknown): unknown {
if (Array.isArray(obj)) {
return obj.map(removeNamesDeep);
} else if (obj && typeof obj === "object") {
const newObj: { [key: string]: unknown } = {};
for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {
if (key !== "name") {
newObj[key] = removeNamesDeep(value);
}
}
return newObj;
}
return obj;
}

/**
* Read, parse, and merge all KDL files under the input folder.
*/
export default async function readPatches(): Promise<any> {
const patchDirectory = new URL("../../inputfiles/patches/", import.meta.url);
export default async function readPatches(
folder: "patches" | "removals",
): Promise<any> {
const patchDirectory = new URL(
`../../inputfiles/${folder}/`,
import.meta.url,
);
const fileUrls = await getAllFileURLs(patchDirectory);

const parsedContents = await Promise.all(fileUrls.map(readPatch));

return parsedContents.reduce((acc, current) => merge(acc, current), {});
const res = parsedContents.reduce((acc, current) => merge(acc, current), {});
if (folder == "removals") {
return removeNamesDeep(res);
}
return res;
}