encodeSemanticAction function
Uint8List
encodeSemanticAction(
- SemanticNodeId id,
- SemanticAction action, {
- Object? value,
- String? targetToken,
Encodes a peer's semantic-action request — the browser or an agent
activating a node in its accessible DOM — as the node id, the action name,
and an optional JSON-encoded payload (carried only by setValue).
Implementation
Uint8List encodeSemanticAction(
SemanticNodeId id,
SemanticAction action, {
Object? value,
String? targetToken,
}) {
final w = _Writer();
w.vstr(
id.value,
maxBytes: maxRemoteSemanticNodeIdBytes,
field: 'semantic node id',
);
w.vstr(action.name);
w.boolean(value != null);
if (value != null) w.vstr(jsonEncode(value));
// The token is present only for a positional id.
w.boolean(targetToken != null);
if (targetToken != null) {
w.vstr(targetToken, maxBytes: 64, field: 'semantic action target token');
}
return w.take();
}