Exporting Dart APIs to JavaScript, without a Dart VM -


i'd export dart api javascript on browsers without dart vm. example, given class a:

class {   string name;    a();    a.withname(this.name); } 

i'd create javascript object using exported api with:

var = new a(); 

an answer previous question pointed me js-interop.

however, i'm not able expected result when working through readme example. appears dart library isn't being exported javascript.

pubspec.yaml:

name: interop description: >   library useful applications or sharing on pub.dartlang.org. version: 0.0.1 dev_dependencies:   unittest: dependencies:   js:     git:       url: git://github.com/dart-lang/js-interop.git transformers:   - js   - js/initializer 

example/main.dart

library main:

import 'package:js/js.dart';  main() {   initializejavascript(); } 

lib/a.dart

library a;  import 'package:js/js.dart';  @export() class {   string name;    a();    a.withname(this.name); } 

index.html

<html>   <head>     <script src="packages/js/interop.js"></script>   </head>   <body>     <script type="application/dart" src="build/example/main.dart"></script>   </body> </html> 

(it's not clear src attribute of last script tag should point. i've tried using /example/main.dart well, doesn't change result.)

i expected able open console after compiling (tool -> pub build) , loading index.html, , this:

var = new dart.a.a(); 

however, instead: "cannot read property 'a' of undefined". in other words, dart.a undefined.

the inclusion of raw dart script in index.html suggests js-interop intended browser dart vm. tried running index.html on dartium same result.

what missing?

the src attribute of script tag still has point file dart script contains main() method. when application built javascript using pub build dart compiled javascript , can run in browsers without dart vm.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -