ResponsePacket¶
Overview¶
The ResponsePacket collects the categories of a single "response" into the following sections: "Name Response" - A response that labels (names) some element to describe. "Object Response" - A response directly describing the state of the named element. "Context Response" - A response that describes surrounding context related to the named element or changes to it. "Hint Response" - A response that gives a hint about what en element is for or how to interact with it.
A response is most often tied to an element, or an object that is being described/voiced.
Individual categories of responses can be enabled or disabled. The ResponsePacket keeps track of all these responses. When it is time to alert the responses of this ResponsePacket, the ResponseCollector will assemble a final string depending on which categories of responses are enabled.
@author Jesse Greenberg @author Michael Kauzmann (PhET Interactive Simulations)
Class ResponsePacket¶
Constructor¶
new ResponsePacket( providedOptions? : ResponsePacketOptions )¶
Instance Methods¶
getNameResponse() : ResolvedResponse¶
setNameResponse( nameResponse : VoicingResponse )¶
getObjectResponse() : ResolvedResponse¶
setObjectResponse( objectResponse : VoicingResponse )¶
getContextResponse() : ResolvedResponse¶
setContextResponse( contextResponse : VoicingResponse )¶
getHintResponse() : ResolvedResponse¶
setHintResponse( hintResponse : VoicingResponse )¶
copy() : ResponsePacket¶
serialize() : Required<SpeakableNullableResolvedOptions>¶
Instance Properties¶
ignoreProperties : boolean¶
responsePatternCollection : ResponsePatternCollection¶
Static Methods¶
getResponseText( response : VoicingResponse ) : ResolvedResponse¶
Map VoicingResponse -> ResolvedResponse (resolve functions and Properties to their values)
Static Properties¶
DEFAULT_OPTIONS¶
(readonly)
Type ResolvedResponse¶
The text sent to an Announcer technology, after resolving it from potentially more complicated structures holding a response
string | number | null | TReadOnlyProperty<string>
Type ResponsePacketOptions¶
- nameResponse?: VoicingResponse
spoken when name responses are enabled - objectResponse?: VoicingResponse
spoken when object responses are enabled - contextResponse?: VoicingResponse
spoken when context responses are enabled - hintResponse?: VoicingResponse
spoken when interaction hints are enabled - ignoreProperties?: boolean
Whether this response should ignore the Properties of responseCollector. If true, the nameResponse, objectResponse, contextResponse, and interactionHint will all be spoken regardless of the values of the Properties of responseCollector - responsePatternCollection?: ResponsePatternCollection
Collection of string patterns to use with responseCollector.collectResponses, see ResponsePatternCollection for more information.
Type SpeakableNullableResolvedOptions¶
Add null support for certain cases
{ [PropertyName in keyof SpeakableResolvedOptions]: SpeakableResolvedOptions[PropertyName] extends SpeakableResolvedResponse ? SpeakableResolvedResponse | null : SpeakableResolvedOptions[PropertyName]; }
Type SpeakableResolvedOptions¶
{
// In speaking options, we don't allow a ResponseCreator function, but just a string|null. The <span style="color: hsla(calc(var(--md-hue) + 180deg),80%,40%,1);">undefined</span>
is to // match on the properties because they are optional (marked with ?
) [PropertyName in keyof ResponsePacketOptions]: ResponsePacketOptions[PropertyName] extends ( VoicingResponse | undefined ) ? SpeakableResolvedResponse : ResponsePacketOptions[PropertyName]; }
Type SpeakableResolvedResponse¶
No function creator because we don't want to support the execution of that function.
ResolvedResponse | TReadOnlyProperty<string>
Type VoicingResponse¶
ResponseCreator | ResolvedResponse
Source Code¶
See the source for ResponsePacket.ts in the utterance-queue repository.