Skip to content

Commit 54b5eb9

Browse files
authored
Update Web Speech API to match idl (#924)
* Updated Web Speech API Types * Fixed Speech API error event type * Update removedTypes.json Added initStorageEvent back to removedTypes.json (mistakenly removed last commit) * updated baseline to match generated
1 parent 0d6f5b1 commit 54b5eb9

File tree

5 files changed

+37
-18
lines changed

5 files changed

+37
-18
lines changed

baselines/dom.generated.d.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,16 @@ interface ShareData {
17001700
url?: string;
17011701
}
17021702

1703+
interface SpeechRecognitionErrorEventInit extends EventInit {
1704+
error: SpeechRecognitionErrorCode;
1705+
message?: string;
1706+
}
1707+
1708+
interface SpeechRecognitionEventInit extends EventInit {
1709+
resultIndex?: number;
1710+
results: SpeechRecognitionResultList;
1711+
}
1712+
17031713
interface SpeechSynthesisErrorEventInit extends SpeechSynthesisEventInit {
17041714
error: SpeechSynthesisErrorCode;
17051715
}
@@ -4680,6 +4690,7 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad
46804690
createEvent(eventInterface: "SVGZoomEvents"): SVGZoomEvent;
46814691
createEvent(eventInterface: "SecurityPolicyViolationEvent"): SecurityPolicyViolationEvent;
46824692
createEvent(eventInterface: "ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent;
4693+
createEvent(eventInterface: "SpeechRecognitionErrorEvent"): SpeechRecognitionErrorEvent;
46834694
createEvent(eventInterface: "SpeechRecognitionEvent"): SpeechRecognitionEvent;
46844695
createEvent(eventInterface: "SpeechSynthesisErrorEvent"): SpeechSynthesisErrorEvent;
46854696
createEvent(eventInterface: "SpeechSynthesisEvent"): SpeechSynthesisEvent;
@@ -4929,6 +4940,7 @@ interface DocumentEvent {
49294940
createEvent(eventInterface: "SVGZoomEvents"): SVGZoomEvent;
49304941
createEvent(eventInterface: "SecurityPolicyViolationEvent"): SecurityPolicyViolationEvent;
49314942
createEvent(eventInterface: "ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent;
4943+
createEvent(eventInterface: "SpeechRecognitionErrorEvent"): SpeechRecognitionErrorEvent;
49324944
createEvent(eventInterface: "SpeechRecognitionEvent"): SpeechRecognitionEvent;
49334945
createEvent(eventInterface: "SpeechSynthesisErrorEvent"): SpeechSynthesisErrorEvent;
49344946
createEvent(eventInterface: "SpeechSynthesisEvent"): SpeechSynthesisEvent;
@@ -15093,7 +15105,7 @@ interface SpeechRecognitionEventMap {
1509315105
"audioend": Event;
1509415106
"audiostart": Event;
1509515107
"end": Event;
15096-
"error": ErrorEvent;
15108+
"error": SpeechRecognitionErrorEvent;
1509715109
"nomatch": SpeechRecognitionEvent;
1509815110
"result": SpeechRecognitionEvent;
1509915111
"soundend": Event;
@@ -15112,7 +15124,7 @@ interface SpeechRecognition extends EventTarget {
1511215124
onaudioend: ((this: SpeechRecognition, ev: Event) => any) | null;
1511315125
onaudiostart: ((this: SpeechRecognition, ev: Event) => any) | null;
1511415126
onend: ((this: SpeechRecognition, ev: Event) => any) | null;
15115-
onerror: ((this: SpeechRecognition, ev: ErrorEvent) => any) | null;
15127+
onerror: ((this: SpeechRecognition, ev: SpeechRecognitionErrorEvent) => any) | null;
1511615128
onnomatch: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null;
1511715129
onresult: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null;
1511815130
onsoundend: ((this: SpeechRecognition, ev: Event) => any) | null;
@@ -15144,14 +15156,24 @@ declare var SpeechRecognitionAlternative: {
1514415156
new(): SpeechRecognitionAlternative;
1514515157
};
1514615158

15159+
interface SpeechRecognitionErrorEvent extends Event {
15160+
readonly error: SpeechRecognitionErrorCode;
15161+
readonly message: string;
15162+
}
15163+
15164+
declare var SpeechRecognitionErrorEvent: {
15165+
prototype: SpeechRecognitionErrorEvent;
15166+
new(type: string, eventInitDict: SpeechRecognitionErrorEventInit): SpeechRecognitionErrorEvent;
15167+
};
15168+
1514715169
interface SpeechRecognitionEvent extends Event {
1514815170
readonly resultIndex: number;
1514915171
readonly results: SpeechRecognitionResultList;
1515015172
}
1515115173

1515215174
declare var SpeechRecognitionEvent: {
1515315175
prototype: SpeechRecognitionEvent;
15154-
new(): SpeechRecognitionEvent;
15176+
new(type: string, eventInitDict: SpeechRecognitionEventInit): SpeechRecognitionEvent;
1515515177
};
1515615178

1515715179
interface SpeechRecognitionResult {
@@ -20102,6 +20124,7 @@ type SelectionMode = "end" | "preserve" | "select" | "start";
2010220124
type ServiceWorkerState = "activated" | "activating" | "installed" | "installing" | "parsed" | "redundant";
2010320125
type ServiceWorkerUpdateViaCache = "all" | "imports" | "none";
2010420126
type ShadowRootMode = "closed" | "open";
20127+
type SpeechRecognitionErrorCode = "aborted" | "audio-capture" | "bad-grammar" | "language-not-supported" | "network" | "no-speech" | "not-allowed" | "service-not-allowed";
2010520128
type SpeechSynthesisErrorCode = "audio-busy" | "audio-hardware" | "canceled" | "interrupted" | "invalid-argument" | "language-unavailable" | "network" | "not-allowed" | "synthesis-failed" | "synthesis-unavailable" | "text-too-long" | "voice-unavailable";
2010620129
type TextTrackKind = "captions" | "chapters" | "descriptions" | "metadata" | "subtitles";
2010720130
type TextTrackMode = "disabled" | "hidden" | "showing";

inputfiles/addedTypes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@
986986
},
987987
{
988988
"name": "error",
989-
"type": "ErrorEvent"
989+
"type": "SpeechRecognitionErrorEvent"
990990
},
991991
{
992992
"name": "end",

inputfiles/idl/Web Speech API.widl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ interface SpeechRecognition : EventTarget {
1010
attribute unsigned long maxAlternatives;
1111

1212
// methods to drive the speech interaction
13-
void start();
14-
void stop();
15-
void abort();
13+
undefined start();
14+
undefined stop();
15+
undefined abort();
1616

1717
// event methods
1818
attribute EventHandler onaudiostart;
@@ -99,9 +99,9 @@ interface SpeechGrammarList {
9999
constructor();
100100
readonly attribute unsigned long length;
101101
getter SpeechGrammar item(unsigned long index);
102-
void addFromURI(DOMString src,
102+
undefined addFromURI(DOMString src,
103103
optional float weight = 1.0);
104-
void addFromString(DOMString string,
104+
undefined addFromString(DOMString string,
105105
optional float weight = 1.0);
106106
};
107107

@@ -113,10 +113,10 @@ interface SpeechSynthesis : EventTarget {
113113

114114
attribute EventHandler onvoiceschanged;
115115

116-
void speak(SpeechSynthesisUtterance utterance);
117-
void cancel();
118-
void pause();
119-
void resume();
116+
undefined speak(SpeechSynthesisUtterance utterance);
117+
undefined cancel();
118+
undefined pause();
119+
undefined resume();
120120
sequence<SpeechSynthesisVoice> getVoices();
121121
};
122122

inputfiles/removedTypes.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,6 @@
283283
}
284284
}
285285
},
286-
"SpeechRecognitionEvent": {
287-
"constructor": null
288-
},
289-
"SpeechRecognitionErrorEvent": null,
290286
"StorageEvent": {
291287
"methods": {
292288
"method": {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function emitDom() {
7676
const idl: string = fs.readFileSync(path.join(inputFolder, "idl", filename), { encoding: "utf-8" });
7777
const commentsMapFilePath = path.join(inputFolder, "idl", title + ".commentmap.json");
7878
const commentsMap: Record<string, string> = fs.existsSync(commentsMapFilePath) ? require(commentsMapFilePath) : {};
79-
commentCleanup(commentsMap)
79+
commentCleanup(commentsMap);
8080
const result = convert(idl, commentsMap);
8181
if (deprecated) {
8282
mapToArray(result.browser.interfaces!.interface).forEach(markAsDeprecated);

0 commit comments

Comments
 (0)