To make it easier to develop web applications in Dart, we propose adding a new mime type (application/dart) for HTML documents that allows embedding dart scripts. We wrote a script (htmlconverter.py) that will translate an HTML page with these new mime types into an HTML page with JavaScript code.
Then you can invoke the script as follows:
Using htmlconverter.py
To invoke this script, ensure that you have a checkout of the project, and that you have built the dartc compiler (see instructions in Building).Then you can invoke the script as follows:
$ python dart/client/tools/htmlconverter.py input.html -o out/The script will do the following:
- Invoke the dartc compiler on any code in the page, embedding the result on a script tag.
- Inline any css code
- Within css, embed images as a data-url using a base64 encoding.
Work in progress
The following is still pending to be implemented in htmlconverter.py:- Support heavy isolates: currently the tool inlines all script tags in the html page. Heavy isolates can only be spawned from scripts that are loaded via a URL (a restriction derived from web workers).
- Implement support for multiple isolates in the HTML page. This includes:
- Allow multiple script tags in a page, mapping each script to an isolate.
- Introduce an isolate discovery mechanism (e.g. a registry), so that top-level isolates don’t have to use window.postMessage to communicate.
No comments:
Post a Comment