Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
73855ea
chore: install deps
Bashamega Jul 6, 2025
82c47f9
Parser
Bashamega Jul 6, 2025
ac0e253
patch: types
Bashamega Jul 6, 2025
99e1b99
-
Bashamega Jul 8, 2025
28cdf7d
chore: ignore mdn and idl folders
Bashamega Jul 8, 2025
ae4e21b
Merge branch 'microsoft:main' into kdl/parser
Bashamega Jul 8, 2025
b68c508
Update src/build/utils/kdl.ts
Bashamega Jul 9, 2025
761bc35
Update src/build/utils/kdl.ts
Bashamega Jul 9, 2025
1aaee0d
Update src/build/utils/kdl.ts
Bashamega Jul 9, 2025
fc238c7
Update src/build/utils/kdl.ts
Bashamega Jul 9, 2025
56f7ebf
Update src/build/utils/kdl.ts
Bashamega Jul 9, 2025
4f15c5d
-
Bashamega Jul 9, 2025
4625aa4
chore: rename
Bashamega Jul 9, 2025
3f1bd04
chore: create patches folder
Bashamega Jul 9, 2025
97e5390
patch: rename url
Bashamega Jul 9, 2025
4c85911
-
Bashamega Jul 9, 2025
16c4f14
KDL parser
Bashamega Jul 9, 2025
2d3d3e4
-
Bashamega Jul 9, 2025
da909af
feat: rename
Bashamega Jul 10, 2025
3e236c4
chore: remove EnumDescriptor
Bashamega Jul 10, 2025
1f4e523
chore: remove an extra variable
Bashamega Jul 10, 2025
c9c4eee
rename
Bashamega Jul 10, 2025
f69385e
rename
Bashamega Jul 10, 2025
7213180
lint
Bashamega Jul 10, 2025
a5176a7
rename
Bashamega Jul 10, 2025
b056cf1
split into smaller functions
Bashamega Jul 10, 2025
609c174
Update src/build/patches.ts
Bashamega Jul 10, 2025
72303fd
Update src/build/patches.ts
Bashamega Jul 10, 2025
2552032
Integrate more enums
Bashamega Jul 10, 2025
4d1ab0f
Revert "Integrate more enums" (#3)
Bashamega Jul 11, 2025
811a217
Update patches.ts
saschanaz Jul 12, 2025
e7e2597
Update and rename autoFills.kdl to autocomplete.kdl
saschanaz Jul 12, 2025
7ff687c
Update build.ts
saschanaz Jul 12, 2025
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
92 changes: 0 additions & 92 deletions inputfiles/addedTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -373,98 +373,6 @@
// Full support: https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API#browser_compatibility
"storage-access"
]
},
"AutoFillBase": {
"name": "AutoFillBase",
"value": [
// Off
"off",
// Automatic
"on",
""
]
},
"AutoFillAddressKind": {
"name": "AutoFillAddressKind",
"value": [
"shipping",
"billing"
]
},
"AutoFillNormalField": {
"name": "AutoFillNormalField",
"value": [
"name",
"honorific-prefix",
"given-name",
"additional-name",
"family-name",
"honorific-suffix",

"username",
"new-password",
"current-password",
// Supported in iOS Safari too even though WPT tests
// for Safari currently fail as of 2023-06.
"one-time-code",

"organization",
"street-address",
"address-line1",
"address-line2",
"address-line3",
"address-level4",
"address-level3",
"address-level2",
"address-level1",
"country",
"country-name",
"postal-code",

"cc-name",
"cc-given-name",
"cc-family-name",
"cc-number",
"cc-exp",
"cc-exp-month",
"cc-exp-year",
"cc-csc",
"cc-type",
"transaction-currency",
"transaction-amount",

"bday-day",
"bday-month",
"bday-year"
]
},
"AutoFillContactKind": {
"name": "AutoFillContactKind",
"value": [
"home",
"work",
"mobile"
]
},
"AutoFillContactField": {
"name": "AutoFillContactField",
"value": [
"tel",
"tel-country-code",
"tel-national",
"tel-area-code",
"tel-local",
"tel-local-prefix",
"tel-local-suffix",
"tel-extension",
"email"
]
},
"AutoFillCredentialField": {
"name": "AutoFillCredentialField",
"value": [
"webauthn"
]
}
}
},
Expand Down
70 changes: 70 additions & 0 deletions inputfiles/patches/autoFills.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
enum AutoFillBase {
// Off
value "off"
// Automatic
value "on"
value ""
}
enum AutoFillAddressKind {
value "shipping"
value "billing"
}
enum AutoFillNormalField {
value "name"
value "honorific-prefix"
value "given-name"
value "additional-name"
value "family-name"
value "honorific-suffix"
value "username"
value "new-password"
value "current-password"
// Supported in iOS Safari too even though WPT tests
// for Safari currently fail as of 2023-06.
value "one-time-code"
value "organization"
value "street-address"
value "address-line1"
value "address-line2"
value "address-line3"
value "address-level4"
value "address-level3"
value "address-level2"
value "address-level1"
value "country"
value "country-name"
value "postal-code"
value "cc-name"
value "cc-given-name"
value "cc-family-name"
value "cc-number"
value "cc-exp"
value "cc-exp-month"
value "cc-exp-year"
value "cc-csc"
value "cc-type"
value "transaction-currency"
value "transaction-amount"
value "bday-day"
value "bday-month"
value "bday-year"
}
enum AutoFillContactKind {
value "home"
value "work"
value "mobile"
}
enum AutoFillContactField {
value "tel"
value "tel-country-code"
value "tel-national"
value "tel-area-code"
value "tel-local"
value "tel-local-prefix"
value "tel-local-suffix"
value "tel-extension"
value "email"
}
enum AutoFillCredentialField {
value "webauthn"
}
77 changes: 77 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"eslint-plugin-prettier": "^5.1.3",
"globals": "^16.0.0",
"jsonc-parser": "^3.2.1",
"kdljs": "^0.3.0",
"node-fetch": "^3.3.2",
"prettier": "^3.2.5",
"print-diff": "^2.0.0",
Expand Down
3 changes: 3 additions & 0 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { getInterfaceToEventMap } from "./build/webref/events.js";
import { getWebidls } from "./build/webref/idl.js";
import jsonc from "jsonc-parser";
import { generateDescriptions } from "./build/mdn-comments.js";
import readPatches from "./build/patches.js";

function mergeNamesakes(filtered: Browser.WebIdl) {
const targets = [
Expand Down Expand Up @@ -97,6 +98,7 @@ async function emitDom() {
const deprecatedInfo = await readInputJSON("deprecatedMessage.json");
const documentationFromMDN = await generateDescriptions();
const removedItems = await readInputJSON("removedTypes.jsonc");
const addedItemsKDL = await readPatches();

async function readInputJSON(filename: string) {
const content = await fs.readFile(new URL(filename, inputFolder), "utf8");
Expand Down Expand Up @@ -229,6 +231,7 @@ async function emitDom() {
webidl = prune(webidl, removedItems);
webidl = mergeApiDescriptions(webidl, documentationFromMDN);
webidl = merge(webidl, addedItems);
webidl = merge(webidl, addedItemsKDL);
webidl = merge(webidl, overriddenItems);
webidl = merge(webidl, comments);
webidl = mergeDeprecatedMessage(webidl, deprecatedInfo);
Expand Down
70 changes: 70 additions & 0 deletions src/build/patches.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { parse } from "kdljs";
import { Enum } from "./types";
import { readdir, readFile } from "fs/promises";
import { merge } from "./helpers.js";

/**
* Converts patch files in KDL to match the [types](types.d.ts).
*/
export function parseKDL(kdlText: string) {
const { output, errors } = parse(kdlText);

if (errors.length) {
throw new Error("KDL parse errors", { cause: errors });
}

const nodes = output!;
const enums: Record<string, Enum> = {};

for (const node of nodes) {
if (node.name === "enum") {
// Handle enum
const name = node.values[0];
if (typeof name !== "string") {
throw new Error("Missing enum name");
}
const values: string[] = [];

for (const child of node.children ?? []) {
if (child.name !== "value" || typeof child.values[0] !== "string") {
throw new Error(
"enum values should be in the form of `value {name}`",
);
}
values.push(child.values[0]);
}

enums[name] = { name, value: values };
}
}

return { enums: { enum: enums } };
}

/**
* Collect all file URLs in a directory.
*/
async function getAllKDLFileURLs(folder: URL): Promise<URL[]> {
const entries = await readdir(folder, { withFileTypes: true });
return entries.map((entry) => new URL(entry.name, folder));
}

/**
* Read and parse a single KDL file.
*/
export async function readPatch(fileUrl: URL): Promise<any> {
const text = await readFile(fileUrl, "utf8");
return parseKDL(text);
}

/**
* 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);
const fileUrls = await getAllKDLFileURLs(patchDirectory);

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

return parsedContents.reduce((acc, current) => merge(acc, current), {});
}