| OLD | NEW |
| 1 Contributing | 1 Contributing |
| 2 ============ | 2 ============ |
| 3 | 3 |
| 4 [sky_sdk](https://github.com/domokit/sky_sdk) is generated from the | 4 [sky_sdk](https://github.com/domokit/sky_sdk) is generated from the |
| 5 [mojo repository](https://github.com/domokit/mojo) using | 5 [mojo repository](https://github.com/domokit/mojo) using |
| 6 [deploy_sdk.py](https://github.com/domokit/mojo/blob/master/sky/tools/deploy_sdk
.py) | 6 [deploy_sdk.py](https://github.com/domokit/mojo/blob/master/sky/tools/deploy_sdk
.py) |
| 7 Static files (including this README.md) are located under | 7 Static files (including this README.md) are located under |
| 8 [sky/sdk](https://github.com/domokit/mojo/tree/master/sky/sdk). Pull | 8 [sky/sdk](https://github.com/domokit/mojo/tree/master/sky/sdk). Pull |
| 9 requests and issue reports are glady accepted at the | 9 requests and issue reports are glady accepted at the |
| 10 [mojo repository](https://github.com/domokit/mojo)! | 10 [mojo repository](https://github.com/domokit/mojo)! |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 Sky uses Dart and Sky applications are | 40 Sky uses Dart and Sky applications are |
| 41 [Dart Packages](https://www.dartlang.org/docs/tutorials/shared-pkgs/). | 41 [Dart Packages](https://www.dartlang.org/docs/tutorials/shared-pkgs/). |
| 42 Application creation starts by creating a new directory and | 42 Application creation starts by creating a new directory and |
| 43 adding a [pubspec.yaml](https://www.dartlang.org/tools/pub/pubspec.html): | 43 adding a [pubspec.yaml](https://www.dartlang.org/tools/pub/pubspec.html): |
| 44 | 44 |
| 45 pubspec.yaml for your app: | 45 pubspec.yaml for your app: |
| 46 ```yaml | 46 ```yaml |
| 47 name: your_app_name | 47 name: your_app_name |
| 48 dependencies: | 48 dependencies: |
| 49 sky: any | 49 sky: any |
| 50 ``` | 50 ``` |
| 51 | 51 |
| 52 Once the pubspec is in place, create a `lib` directory (where your dart code | 52 Once the pubspec is in place, create a `lib` directory (where your dart code |
| 53 will go), ensure that the 'dart' and 'pub' executables are on your $PATH and | 53 will go), ensure that the 'dart' and 'pub' executables are on your $PATH and |
| 54 run the following: | 54 run the following: |
| 55 | 55 |
| 56 `pub get && pub run sky:init`. | 56 `pub get && pub run sky:init`. |
| 57 | 57 |
| 58 Currently the Sky Engine assumes the entry point for your application is a | 58 Currently the Sky Engine assumes the entry point for your application is a |
| 59 `main` function located inside a `main.sky` file at the root of the package. | 59 `main` function in a Dart file inside your package: |
| 60 `.sky` is an html-like format: | |
| 61 ``` | |
| 62 <sky> | |
| 63 <script> | |
| 64 import 'package:your_app_name/main.dart'; | |
| 65 | |
| 66 void main() { | |
| 67 new HelloWorldApp(); | |
| 68 } | |
| 69 </script> | |
| 70 </sky> | |
| 71 ``` | |
| 72 | |
| 73 The rest of the application then goes inside the `lib` directory of the package | |
| 74 thus `lib/main.dart` would be: | |
| 75 | 60 |
| 76 ```dart | 61 ```dart |
| 77 import 'package:sky/framework/fn.dart'; | 62 import 'package:sky/widgets/basic.dart'; |
| 78 | 63 |
| 79 class HelloWorldApp extends App { | 64 class HelloWorldApp extends App { |
| 80 UINode build() { | 65 Widget build() { |
| 81 return new Text('Hello, world!'); | 66 return new Text('Hello, world!'); |
| 82 } | 67 } |
| 83 } | 68 } |
| 69 |
| 70 void main() { |
| 71 runApp(new HelloWorldApp()); |
| 72 } |
| 84 ``` | 73 ``` |
| 85 | 74 |
| 86 Execution starts in `main`, which creates the `HelloWorldApp`. The framework | 75 Execution starts in `main`, which instructs the framework to run a new |
| 87 then marks `HelloWorldApp` as dirty, which schedules it to build during the next | 76 instance of the `HelloWorldApp`. The framework then calls the `build()` |
| 88 animation frame. Each animation frame, the framework calls `build` on all the | 77 function on `HelloWorldApp` to create a tree of widgets, some of which might |
| 89 dirty components and diffs the virtual `UINode` hierarchy returned this frame | 78 be other `Components`, which in turn have `build()` functions that generate |
| 90 with the hierarchy returned last frame. Any differences are then applied as | 79 more widgets iteratively to create the widget hierarchy. |
| 91 mutations to the physical hierarchy retained by the engine. | |
| 92 | 80 |
| 93 Skip down to "Running a Sky application" to learn how to load and run this | 81 Later, if a `Component` changes state, the framework calls that component's |
| 94 example on your device. | 82 `build()` function again to create a new widget tree. The framework diffs the |
| 83 new widget tree against the old widget tree and any differences are applyed |
| 84 to the underlying render tree. |
| 95 | 85 |
| 96 For examples, please see the [examples directory](examples/). | 86 * To learn more about the widget system, please see the |
| 87 [widgets tutorial](lib/widgets/README.md). |
| 88 * To learn how to run Sky on your device, please see the |
| 89 [Running a Sky application](#running-a-sky-application) section in this |
| 90 document. |
| 91 * To dive into examples, please see the [examples directory](examples/). |
| 97 | 92 |
| 98 Services | 93 Services |
| 99 -------- | 94 -------- |
| 100 | 95 |
| 101 Sky apps can access services from the host operating system using Mojo IPC. For | 96 Sky apps can access services from the host operating system using Mojo IPC. For |
| 102 example, you can access the network using the `network_service.mojom` interface. | 97 example, you can access the network using the `network_service.mojom` interface. |
| 103 Although you can use these low-level interfaces directly, you might prefer to | 98 Although you can use these low-level interfaces directly, you might prefer to |
| 104 access these services via libraries in the framework. For example, the | 99 access these services via libraries in the framework. For example, the |
| 105 `fetch.dart` library wraps the underlying `network_service.mojom` in an | 100 `fetch.dart` library wraps the underlying `network_service.mojom` in an |
| 106 ergonomic interface: | 101 ergonomic interface: |
| 107 | 102 |
| 108 ```dart | 103 ```dart |
| 109 import 'package:sky/framework/net/fetch.dart'; | 104 import 'package:sky/mojo/net/fetch.dart'; |
| 110 | 105 |
| 111 main() async { | 106 main() async { |
| 112 Response response = await fetchBody('example.txt'); | 107 Response response = await fetchBody('example.txt'); |
| 113 print(response.bodyAsString()); | 108 print(response.bodyAsString()); |
| 114 } | 109 } |
| 115 ``` | 110 ``` |
| 116 | 111 |
| 117 Set up your computer | 112 Set up your computer |
| 118 -------------------- | 113 -------------------- |
| 119 | 114 |
| 120 1. Install the Dart SDK: | 115 1. Install the Dart SDK: |
| 121 - https://www.dartlang.org/tools/download.html | 116 - https://www.dartlang.org/tools/download.html |
| 122 | 117 |
| 123 2. Install the ``adb`` tool from the Android SDK: | 118 2. Install the `adb` tool from the Android SDK: |
| 124 - https://developer.android.com/sdk/installing/index.html | 119 - https://developer.android.com/sdk/installing/index.html |
| 125 | 120 |
| 126 3. Install the Sky SDK: | 121 3. Install the Sky SDK: |
| 127 - ``git clone https://github.com/domokit/sky_sdk.git`` | 122 - `git clone https://github.com/domokit/sky_sdk.git` |
| 128 | 123 |
| 129 4. Ensure that $DART_SDK is set to the path of your Dart SDK and 'adb' | 124 4. Ensure that `$DART_SDK` is set to the path of your Dart SDK and `adb` |
| 130 (inside 'platform-tools' in the android sdk) is in your $PATH. | 125 (inside `platform-tools` in the android sdk) is in your `$PATH`. |
| 131 | 126 |
| 132 Set up your device | 127 Set up your device |
| 133 ------------------ | 128 ------------------ |
| 134 | 129 |
| 135 Currently Sky requires an Android device running the Lollipop (or newer) version | 130 Currently Sky requires an Android device running the Lollipop (or newer) version |
| 136 of the Android operating system. | 131 of the Android operating system. |
| 137 | 132 |
| 138 1. Enable developer mode on your device by visiting ``Settings > About phone`` | 133 1. Enable developer mode on your device by visiting `Settings > About phone` |
| 139 and tapping the ``Build number`` field five times. | 134 and tapping the `Build number` field five times. |
| 140 | 135 |
| 141 2. Enable ``USB debugging`` in ``Settings > Developer options``. | 136 2. Enable `USB debugging` in `Settings > Developer options`. |
| 142 | 137 |
| 143 3. Using a USB cable, plug your phone into your computer. If prompted on your | 138 3. Using a USB cable, plug your phone into your computer. If prompted on your |
| 144 device, authorize your computer to access your device. | 139 device, authorize your computer to access your device. |
| 145 | 140 |
| 146 Running a Sky application | 141 Running a Sky application |
| 147 ------------------------- | 142 ------------------------- |
| 148 | 143 |
| 149 The `sky` pub package includes a `sky_tool` script to assist in running | 144 The `sky` pub package includes a `sky_tool` script to assist in running |
| 150 Sky applications inside the `SkyDemo.apk` harness. The sky_tool script expects | 145 Sky applications inside the `SkyDemo.apk` harness. The `sky_tool` script |
| 151 to be run from the root directory of your application pub package. To run | 146 expects to be run from the root directory of your application pub package. To |
| 152 one of the examples in this SDK, try: | 147 run one of the examples in this SDK, try: |
| 153 | 148 |
| 154 1. ``cd examples/stocks`` | 149 1. `cd examples/stocks` |
| 155 | 150 |
| 156 2. ``pub get`` to set up a copy of the sky package in the app directory. | 151 2. `pub get` to set up a copy of the sky package in the app directory. |
| 157 | 152 |
| 158 3. ``./packages/sky/sky_tool start`` to start the dev server and upload your | 153 3. `./packages/sky/sky_tool start` to start the dev server and upload your |
| 159 app to the device. | 154 app to the device. |
| 160 (NOTE: add a ``--install`` flag to install SkyDemo.apk if not already | 155 (NOTE: add a `--install` flag to install `SkyDemo.apk` if it is not already |
| 161 installed on the device.) | 156 installed on the device.) |
| 162 | 157 |
| 163 4. Use ``adb logcat`` to view any errors or Dart print() output from the app. | 158 4. Use `adb logcat` to view any errors or Dart `print()` output from the app. |
| 164 ``adb logcat -s chromium`` can be used to filter only adb messages from | 159 `adb logcat -s chromium` can be used to filter only adb messages from |
| 165 `SkyDemo.apk` (which for | 160 `SkyDemo.apk` (which for |
| 166 [legacy reasons](https://github.com/domokit/mojo/issues/129) still uses the | 161 [legacy reasons](https://github.com/domokit/mojo/issues/129) still uses the |
| 167 android log tag 'chromium'). | 162 android log tag `chromium`). |
| 168 | 163 |
| 169 Measuring Performance | 164 Measuring Performance |
| 170 --------------------- | 165 --------------------- |
| 171 | 166 |
| 172 Sky has support for generating trace files compatible with | 167 Sky has support for generating trace files compatible with |
| 173 [Chrome's about:tracing](https://www.chromium.org/developers/how-tos/trace-event
-profiling-tool). | 168 [Chrome's about:tracing](https://www.chromium.org/developers/how-tos/trace-event
-profiling-tool). |
| 174 | 169 |
| 175 `packages/sky/sky_tool start_tracing` and `packages/sky/sky_tool stop_tracing` | 170 `packages/sky/sky_tool start_tracing` and `packages/sky/sky_tool stop_tracing` |
| 176 are the commands to use. | 171 are the commands to use. |
| 177 | 172 |
| 178 Due to https://github.com/domokit/mojo/issues/127 tracing currently | 173 Due to https://github.com/domokit/mojo/issues/127 tracing currently |
| 179 requires root access on the device. | 174 requires root access on the device. |
| 180 | 175 |
| 181 Debugging | 176 Debugging |
| 182 --------- | 177 --------- |
| 183 | 178 |
| 184 Dart's [Observatory](https://www.dartlang.org/tools/observatory/) | 179 Sky uses [Observatory](https://www.dartlang.org/tools/observatory/) for |
| 185 (VM Debugger & Profiler) support in Sky is | 180 debugging and profiling. While running your Sky app using `sky_tool`, you can |
| 186 [in progress](https://codereview.chromium.org/1107803002) and should | 181 access Observatory by navigating your web browser to http://localhost:8181/. |
| 187 be released shortly after Dart Summit 2015. | |
| 188 | 182 |
| 189 Building a standalone MyApp | 183 Building a standalone MyApp |
| 190 --------------------------- | 184 --------------------------- |
| 191 | 185 |
| 192 Although it is possible to bundle the Sky Engine in your own app (instead of | 186 Although it is possible to bundle the Sky Engine in your own app (instead of |
| 193 running your code inside SkyDemo.apk), right now doing so is difficult. | 187 running your code inside SkyDemo.apk), right now doing so is difficult. |
| 194 | 188 |
| 195 There is one example of doing so if you're feeling brave: | 189 There is one example of doing so if you're feeling brave: |
| 196 https://github.com/domokit/mojo/tree/master/sky/apk/stocks | 190 https://github.com/domokit/mojo/tree/master/sky/apk/stocks |
| 197 | 191 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 214 [Keyboard](https://github.com/domokit/mojo/blob/master/mojo/services/keyboard/pu
blic/interfaces/keyboard.mojom) | 208 [Keyboard](https://github.com/domokit/mojo/blob/master/mojo/services/keyboard/pu
blic/interfaces/keyboard.mojom) |
| 215 service to allow Sky Framework Dart code to interface with the underlying | 209 service to allow Sky Framework Dart code to interface with the underlying |
| 216 platform's Keyboard, but also to expose any additional non-Dart business logic | 210 platform's Keyboard, but also to expose any additional non-Dart business logic |
| 217 to Sky/Dart UI code. | 211 to Sky/Dart UI code. |
| 218 | 212 |
| 219 As an example, [SkyApplication](https://github.com/domokit/mojo/blob/master/sky/
shell/org/domokit/sky/shell/SkyApplication.java) | 213 As an example, [SkyApplication](https://github.com/domokit/mojo/blob/master/sky/
shell/org/domokit/sky/shell/SkyApplication.java) |
| 220 exposes a mojo `network_service` (required by Sky Engine C++ code) | 214 exposes a mojo `network_service` (required by Sky Engine C++ code) |
| 221 [SkyDemoApplication](https://github.com/domokit/mojo/blob/master/sky/apk/demo/or
g/domokit/sky/demo/SkyDemoApplication.java) | 215 [SkyDemoApplication](https://github.com/domokit/mojo/blob/master/sky/apk/demo/or
g/domokit/sky/demo/SkyDemoApplication.java) |
| 222 additionally exposes `keyboard_service` and `sensor_service` for use by the Sky | 216 additionally exposes `keyboard_service` and `sensor_service` for use by the Sky |
| 223 Framework from Dart. | 217 Framework from Dart. |
| OLD | NEW |