During a brief exchange with Seth Ladd, he suggested that the ICE Code Editor might be able to perform Dart coding similar to try.dartlang.org. I am not quite convinced that the additional compile time would make for a satisfactory experience (there is already a 2 second delay between the end of typing and an auto-update). But, it an intriguing enough idea that I am going to explore it.
First up, can I edit and run Dart code in ICE with the Dartium browser? Yes I can:

As an aside I would really like to suppress those Application Cache messages. They are really, really annoying. Anyhow…
I am going to get those editor warnings since the JavaScript syntax highlighter is in action. I will have to live with them for a bit. Next I add another warning by importing the
dart:html library and doing something simple with it:<body></body>
<script src="/ice/packages/browser/dart.js"></script>
<script type="application/dart">
import 'dart:html';
main() {
print("Yay Dart!!!");
document.body
..append(new Element.html('<h1>Howdy Space Cowboy!</h1>'))
..style.margin = '250px';
}
</script>That works as well. The <h1> element is successfully appended to the preview frame behind the code:
I have no reason to think that Three.dart would not work in there as well.
At this point, I am sufficiently satisfied that I am ready to dive into a try.dartlang.org-like implementation for non-Dart browsers (i.e. all of them). This is likely a multi-night exploration, but I need to start somewhere. That somewhere is to pull in the compiled JavaScript that try.dartlang.org currently uses:
<!-- ... --> <script src="http://try.dartlang.org/leap.dart.js"></script>Unsurprisingly, that does not work, failing while trying to call
appendChild() on null. In other words, that leap.dart.js expects the page in which it is embedded to contain a DOM structure nearly identical to that of try.dartlang.org.So I spend some time digging through the
leap.dart code used on try.dartlang.org. Happily, it looks like I will not need large sections of it (parsing syntax highlighting and communicating with iframes) as ICE already does that. I will need to be able to extract the Dart code between <script> tags, so I will pick up there tomorrow and see if I can pull enough of leap.dart into my own library to get it working on a local copy of ICE.This should be fun, mostly because I have a built-in excuse to dig through someone else's code for a few days. I love reading other people's code!
Day #825
No comments:
Post a Comment