| OLD | NEW |
| 1 Sky Module System | 1 Sky Module System |
| 2 ================= | 2 ================= |
| 3 | 3 |
| 4 This document describes the Sky module system. | 4 This document describes the Sky module system. |
| 5 | 5 |
| 6 Overview | 6 Overview |
| 7 -------- | 7 -------- |
| 8 | 8 |
| 9 The Sky module system is based on the ``import`` element. In its | 9 The Sky module system is based on the ``import`` element. In its |
| 10 most basic form, you import a module as follows: | 10 most basic form, you import a module as follows: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 ```html | 30 ```html |
| 31 <import src="path/to/chocolate.sky" as="chocolate" /> | 31 <import src="path/to/chocolate.sky" as="chocolate" /> |
| 32 ``` | 32 ``` |
| 33 | 33 |
| 34 | 34 |
| 35 Module API | 35 Module API |
| 36 ---------- | 36 ---------- |
| 37 | 37 |
| 38 Each module consists of one or more libraries. The first library in a | 38 Each module consists of one or more libraries. The first library in a |
| 39 module is the *element tree library*, which imports the sky:core | 39 module is the *element tree library*, which imports the dart:sky |
| 40 module and then consists of the following code for a Sky module: | 40 module and then consists of the following code for a Sky module: |
| 41 | 41 |
| 42 ```dart | 42 ```dart |
| 43 final Module module = new Module(); | 43 final Module module = new Module(); |
| 44 ``` | 44 ``` |
| 45 | 45 |
| 46 ...and the following code for a Sky application: | 46 ...and the following code for a Sky application: |
| 47 | 47 |
| 48 ```dart | 48 ```dart |
| 49 final Module module = new Application(); | 49 final Module module = new Application(); |
| 50 ``` | 50 ``` |
| 51 | 51 |
| 52 The ``<script>`` elements found in the document create the subsequent | 52 The ``<script>`` elements found in the document create the subsequent |
| 53 libraries. Each one first imports the ``dart:mirror`` library, then | 53 libraries. Each one first imports the ``dart:mirror`` library, then |
| 54 the ``sky:core`` module, then the first library described above, then | 54 the ``dart:sky`` module, then the first library described above, then |
| 55 all the modules referenced by ``<import>`` element up to that | 55 all the modules referenced by ``<import>`` element up to that |
| 56 ``<script>`` element and all the libraries defined by ``<script>`` | 56 ``<script>`` element and all the libraries defined by ``<script>`` |
| 57 elements up to that point, interleaved so as to maintain the same | 57 elements up to that point, interleaved so as to maintain the same |
| 58 relative order as those elements were first seen by the parser. | 58 relative order as those elements were first seen by the parser. |
| 59 | 59 |
| 60 When a library imports a module, it actually imports all the libraries | 60 When a library imports a module, it actually imports all the libraries |
| 61 that were declared by that module except the aforementioned element | 61 that were declared by that module except the aforementioned element |
| 62 tree library. If the ``as`` attribute is present on the ``import`` | 62 tree library. If the ``as`` attribute is present on the ``import`` |
| 63 element, all the libraries are bound to the same name. | 63 element, all the libraries are bound to the same name. |
| 64 | 64 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 76 init(); | 76 init(); |
| 77 AutomaticMetadata.runLibrary(library, module); | 77 AutomaticMetadata.runLibrary(library, module); |
| 78 } | 78 } |
| 79 ``` | 79 ``` |
| 80 | 80 |
| 81 Then, that ``main()`` function is called. | 81 Then, that ``main()`` function is called. |
| 82 | 82 |
| 83 TODO(ianh): decide what URL and name we should give the libraries, as | 83 TODO(ianh): decide what URL and name we should give the libraries, as |
| 84 exposed in MirrorSystem.getName(libraryMirror.qualifiedName) etc | 84 exposed in MirrorSystem.getName(libraryMirror.qualifiedName) etc |
| 85 | 85 |
| 86 The ``Module`` class is defined in ``sky:core`` as follows: | 86 The ``Module`` class is defined in ``dart:sky`` as follows: |
| 87 | 87 |
| 88 ```dart | 88 ```dart |
| 89 abstract class AbstractModule extends EventTarget { | 89 abstract class AbstractModule extends EventTarget { |
| 90 AbstractModule({this.url, this.elements}); | 90 AbstractModule({this.url, this.elements}); |
| 91 | 91 |
| 92 final String url; | 92 final String url; |
| 93 | 93 |
| 94 final Root elements; // O(1) | 94 final Root elements; // O(1) |
| 95 // the Root node of the module or application's element tree | 95 // the Root node of the module or application's element tree |
| 96 | 96 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 121 } | 121 } |
| 122 | 122 |
| 123 class Application extends AbstractModule { | 123 class Application extends AbstractModule { |
| 124 Application({String url, Root elements, this.gestureManager}) : | 124 Application({String url, Root elements, this.gestureManager}) : |
| 125 super(url: url, elements: elements); // O(1) | 125 super(url: url, elements: elements); // O(1) |
| 126 external String get title; // O(1) | 126 external String get title; // O(1) |
| 127 external void set title(String newValue); // O(1) | 127 external void set title(String newValue); // O(1) |
| 128 final GestureManager gestureManager; | 128 final GestureManager gestureManager; |
| 129 } | 129 } |
| 130 ``` | 130 ``` |
| OLD | NEW |