This repository was archived by the owner on Nov 12, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed
Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ export interface InteractiveCanvas {
3232 * Types for Interactive Canvas callbacks.
3333 * @see https://developers.google.com/assistant/interactivecanvas/reference#interactivecanvascallbacks
3434 */
35- interface InteractiveCanvasCallbacks {
35+ export interface InteractiveCanvasCallbacks {
3636 onUpdate : ( data : Object [ ] ) => Promise < void > | undefined ;
3737 onTtsMark : ( markName : string ) => void ;
3838}
Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17- import { InteractiveCanvas } from './interactive-canvas' ;
17+ import {
18+ InteractiveCanvas ,
19+ InteractiveCanvasCallbacks ,
20+ } from './interactive-canvas' ;
1821
1922/**
2023 * A representation of Interactive Canvas events that appear in the History tab
@@ -85,6 +88,7 @@ export interface InteractiveCanvasWindow extends Window {
8588 */
8689 logoSrcData : string ;
8790 } ;
91+ interactiveCanvasDebug : InteractiveCanvasCallbacks ;
8892 /**
8993 * JSYaml is a 3P library that converts YAML to JSON.
9094 * @see https://www.npmjs.com/package/js-yaml
Original file line number Diff line number Diff line change @@ -490,6 +490,36 @@ function addUnsupportedApiWarnings() {
490490 addPropertyWarning ( 'webkitSpeechRecognition' , window ) ;
491491}
492492
493+ /**
494+ * Add methods as `window.interactiveCanvasDebug` to trigger callbacks
495+ * programmatically from the DevTools console.
496+ */
497+ function addDebuggingMethodsInJsConsole ( ) {
498+ window . interactiveCanvasDebug = {
499+ onUpdate : ( data : Object [ ] ) => {
500+ const msgData = {
501+ data : {
502+ type : 'payload' ,
503+ requestId : 'requestId' ,
504+ data,
505+ } ,
506+ } ;
507+ document . dispatchEvent ( new MessageEvent ( 'message' , msgData ) ) ;
508+ return undefined ;
509+ } ,
510+ onTtsMark : ( markName : string ) => {
511+ const msgData = {
512+ data : {
513+ type : 'payload' ,
514+ requestId : 'requestId' ,
515+ data : markName ,
516+ } ,
517+ } ;
518+ document . dispatchEvent ( new MessageEvent ( 'message' , msgData ) ) ;
519+ } ,
520+ } ;
521+ }
522+
493523window . requestAnimationFrame ( ( ) => {
494524 const hasInteractiveCanvas = window . interactiveCanvas !== undefined ;
495525
@@ -528,6 +558,7 @@ window.requestAnimationFrame(() => {
528558
529559 window . interactiveCanvasProcessSdk = processSdk ;
530560 addUnsupportedApiWarnings ( ) ;
561+ addDebuggingMethodsInJsConsole ( ) ;
531562} ) ;
532563
533564document . addEventListener ( 'message' , ( e : Event ) => {
You can’t perform that action at this time.
0 commit comments