Interactive Canvas DevTools is a Chrome DevTools extension for debugging an Interactive Canvas web app by allowing for events and commands to be routed through a DevTools tab. This allows development to occur unbundled from a webhook and conversational model and testing everything together.
You can install the extension from the Chrome Web Store.
Once installed, you can open your Interactive Canvas project in your web browser, either from a hosted URL or localhost. In Chrome DevTools, find the Interactive Canvas tab and select it.
In the Send Data tab, you can type in JSON data to manually call the onUpdate
callback.
In the TTS Mark tab, you can type in SSML marks to manually call the onTtsMark
callback.
After sending data from the Chrome extension to the web app, a suggestion chip will appear underneath the textbox to allow you to quickly reenter the same data.
Web app calls to sendTextQuery
and setCanvasState
are routed to the Chrome extension instead of the Google Assistant or your webhook. They are viewable in the History tab in reverse-chronological order.
Multiple changes to the canvas state will result in a JSON diff.
There are other preferences that you can enable in the extension to better target their development environment.
- The Show Header button will add a header to the webpage that resembles what the header will look like on a smart display. This can let you optimize your layout for that screen size.
- The Import /SDK button will let you navigate to and select the project's
sdk
folder if you're using Actions SDK. The extension will then find JSON payloads and TTS marks from your project and make them available as suggestion chips. - Enabling Client-side logging will show messages in your DevTools console.
- Enabling Extension debug logging will show messages for development of this tool.
- Methods that are not supported in Interactive Canvas can be presented as a console warning or throw an error so your local development environment can better resemble a physical device.
If you would like to compile and test this extension with a local build, follow these instructions:
This project is built using Node.js >=10.18.0 and Angular >=12.
- Run
npm i
to install dependencies - Run
npm run build
to build the extension. It will build the entire project. Alternatively, you can build each part separately.- Run
npm run build:client
to build the code which will be run in the context of the webpage. The Node module artifacts are stored in thedist/client
directory. - This command also uses Parcel to transpile these artifacts to run in a browser environment. These transpiled artifacts are stored in the
dist/client-bundle
directory. - Run
npm run build:extension
to build the project components that make up the DevTools page. It also will package the artifacts indist/client-bundle
and outputs the bundle in thedist/interactive-canvas-extension
directory.
- Run
- Open Chrome extensions menu:
chrome://extensions/
- Enable Developer Mode.
- Select Load Unpacked.
- Select project directory
/path-to-project.../dist/interactive-canvas-extension
. - The extension will now be loaded.
Style is enforced using ESLint. There are also several unit tests on specific logical functions in this repo. There are not higher-order integration tests between the various components of the overall architecture.
The /example
directory contains an SDK project based on the
public Snowpal sample.
This example project is used in several unit tests. It is only used for
development purposes and is not included in the packaged extension.
- Run
npm run test
to run both ESLint and unit tests. Alternatively, you can run each test separately.- Run
npm run lint
to run ESLint. - Run
npm run fix
to run ESLint and automatically fix style errors. - Run
npm run test:unit
to run unit tests with Ava.
- Run
- Questions? Go to StackOverflow or Assistant Developer Community on Reddit.
- For bugs, please report an issue on Github.
- Actions on Google Documentation
- Actions on Google Codelabs.
Please read and follow the steps in the CONTRIBUTING.md.
See LICENSE.