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
9 changes: 0 additions & 9 deletions inputfiles/addedTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,6 @@
"additionalTypes": ["Headers"],
"name": "HeadersInit"
},
{
"overrideType": "number | string | Date | BufferSource | IDBValidKey[]",
"name": "IDBValidKey"
},
{
"type": {
"0": {
Expand Down Expand Up @@ -489,11 +485,6 @@
}
]
},
{
"name": "ImportValue",
"legacyNamespace": "WebAssembly",
"overrideType": "ExportValue | number"
},
{
"name": "ModuleImports",
"legacyNamespace": "WebAssembly",
Expand Down
10 changes: 10 additions & 0 deletions inputfiles/patches/indexeddb.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ interface IDBRequest {
}

interface IDBOpenDBRequest extends=IDBRequest<IDBDatabase>

typedef IDBValidKey {
type long
type DOMString
type Date
type BufferSource
type sequence {
type IDBValidKey
}
}
5 changes: 5 additions & 0 deletions inputfiles/patches/webassembly.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ dictionary MemoryDescriptor {
member shared type=boolean
}

typedef ImportValue legacyNamespace=WebAssembly {
type ExportValue
type long
}

removals {
// Overridden with `keyof ValueTypeMap`
enum ValueType
Expand Down
23 changes: 23 additions & 0 deletions src/build/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
Dictionary,
Member,
Signature,
TypeDef,
} from "./types.js";
import { readdir, readFile } from "fs/promises";
import { merge } from "./helpers.js";
Expand Down Expand Up @@ -120,6 +121,7 @@ function convertKDLNodes(nodes: Node[]): DeepPartial<WebIdl> {
const mixin: Record<string, DeepPartial<Interface>> = {};
const interfaces: Record<string, DeepPartial<Interface>> = {};
const dictionary: Record<string, DeepPartial<Dictionary>> = {};
const typedefs: DeepPartial<TypeDef>[] = [];

for (const node of nodes) {
// Note: no "removals" handling here; caller is responsible for splitting
Expand All @@ -143,6 +145,9 @@ function convertKDLNodes(nodes: Node[]): DeepPartial<WebIdl> {
case "dictionary":
dictionary[name] = merge(dictionary[name], handleDictionary(node));
break;
case "typedef":
typedefs.push(handleTypeDef(node));
break;
default:
throw new Error(`Unknown node name: ${node.name}`);
}
Expand All @@ -155,6 +160,7 @@ function convertKDLNodes(nodes: Node[]): DeepPartial<WebIdl> {
interface: interfaces,
}),
...optionalNestedMember("dictionaries", dictionary, { dictionary }),
...optionalNestedMember("typedefs", typedefs, { typedef: typedefs }),
};
}

Expand Down Expand Up @@ -432,6 +438,23 @@ function handleMember(c: Node): DeepPartial<Member> {
};
}

/**
* Handles type definition nodes
* @param node The type definition node to handle.
*/
function handleTypeDef(node: Node): DeepPartial<TypeDef> {
const typeNodes = node.children.filter((c) => c.name === "type");
return {
name: string(node.values[0]),
...handleTyped(typeNodes),
...optionalMember(
"legacyNamespace",
"string",
node.properties?.legacyNamespace,
),
};
}

/**
* Collect all file URLs in a directory.
*/
Expand Down