summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2016-11-08 00:08:58 -0800
committerJakob Odersky <jakob@odersky.com>2016-11-08 16:52:27 -0800
commit163eaefe508832a84d51db29f8c2b4356550b026 (patch)
tree688bbc6e6837e561a41460f8992ec9f1ee0645af
parent137aac4781e3da76c7f1631999e70309ed09ce2f (diff)
downloadworkbench-163eaefe508832a84d51db29f8c2b4356550b026.tar.gz
workbench-163eaefe508832a84d51db29f8c2b4356550b026.tar.bz2
workbench-163eaefe508832a84d51db29f8c2b4356550b026.zip
Update documentation
-rw-r--r--readme.md72
1 files changed, 17 insertions, 55 deletions
diff --git a/readme.md b/readme.md
index 9a0130c..913798b 100644
--- a/readme.md
+++ b/readme.md
@@ -1,4 +1,4 @@
-workbench 0.2.3
+workbench 0.3.0
---------------
![Example](https://github.com/lihaoyi/scala-js-workbench/blob/master/Example.png?raw=true)
@@ -7,32 +7,19 @@ A SBT plugin for [scala-js](https://github.com/lampepfl/scala-js) projects to ma
- Spins up a local web server on (by default) `localhost:12345`, whenever you're in the SBT console. Navigate to localhost:12345 in the browser and it'll show a simple page tell you it's alive. You can access any file within your project directory by going to `localhost:12345/path/to/file` in a browser.
- Forwards all SBT logging from your SBT console to the browser console, so you can see what's going on (e.g. when the project is recompiling) without having to flip back and forth between browser and terminal.
-- Sends commands to tell the connected browsers to refresh/update every time your Scala.Js project completes a `packageJS`.
+- Sends commands to tell the connected browsers to refresh/update every time your Scala.Js project completes a `fastOptJS`.
Check out the [example app](https://github.com/lihaoyi/workbench-example-app) for a plug-and-play example of workbench in action.
Installation
------------
-
- Add to your `project/plugins.sbt`
```scala
-resolvers += "spray repo" at "http://repo.spray.io"
-
-resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
-
-addSbtPlugin("com.lihaoyi" % "workbench" % "0.2.3")
+addSbtPlugin("com.lihaoyi" % "workbench" % "0.3.0")
```
- Add to your `build.sbt`
```scala
-workbenchSettings
-```
-If you're using `project/Build.scala` or similar, also add:
-```scala
-import com.lihaoyi.workbench.Plugin._
-```
-- So that workbench knows how to restart your application, specify a `bootSnippet` property in your SBT build, which is a javascript command to start your application, e.g.
-```scala
-bootSnippet := "ScalaJSExample().main();"
+enablePlugins(WorkbenchPlugin)
```
- For all web pages you would like to integrate with workbench, add
```html
@@ -41,50 +28,20 @@ bootSnippet := "ScalaJSExample().main();"
### Usage
-Once the above installation steps are completed, simply open your desired HTML file via `http://localhost:12345` with the URL path being any file part relative to your project root. e.g. `localhost:12345/target/scala-2.10/classes/index.html`. This should serve up the HTML file and connect it to workbench.
+Once the above installation steps are completed, simply open your desired HTML file via `http://localhost:12345` with the URL path being any file part relative to your project root. e.g. `localhost:12345/target/scala-2.12/classes/index.html`. This should serve up the HTML file and connect it to workbench.
# Live Reloading
You have a choice of what you want to do when the code compiles.
-#### refreshBrowsers
-
-```scala
-refreshBrowsers <<= refreshBrowsers.triggeredBy(packageJS in Compile)
-```
-
-This will to make any client browsers refresh every time `packageJS` completes, saving you flipping back and forth between SBT and the browser to refresh the page after compilation is finished.
-
-#### updateBrowsers
+#### Refresh page
+This will to make any client browsers refresh every time `fastOptJS` completes, saving you flipping back and forth between SBT and the browser to refresh the page after compilation is finished. This is the default behavior.
+#### Splice changes
```scala
-updateBrowsers <<= updateBrowsers.triggeredBy(packageJS in Compile)
-```
-
-This will attempt to perform an update without refreshing the page every time `fastOptJS` completes. This involves:
-
-- Returning the state of `document.body` to the initial state before any javascript was run
-- Stripping all event listeners from things within body
-- Clearing all repeated timeouts and intervals
-- Running the `bootSnippet` again
-
-`updateBrowsers` is a best-effort cleanup, and does not do things like:
-
-- clear up outstanding websocket/ajax connections
-- undo modifications done to `window` or `document`
-- mutations to global javascript objects
-
-Nonetheless, for the bulk of javascript libraries these limitations are acceptable. As long as you're not doing anything too crazy, `updateBrowsers` but should suffice for most applications.
-
-You can force the clean-up-and-reboot to happen from the browser via the shortcut Ctrl-Alt-Shift-Enter if you simply wish to reset the browser to a clean state.
-
-#### spliceBrowsers
-
-```scala
-ScalaJSKeys.inliningMode := scala.scalajs.sbtplugin.InliningMode.Off
-
-spliceBrowsers <<= spliceBrowsers.triggeredBy(ScalaJSKeys.fastOptJS in Compile)
+// WorkbenchPlugin must NOT be enabled at the same time
+enablePlugins(WorkbenchSplicePlugin)
```
This is an experimental feature that aims to perform an update to the code running in the browser *without losing the state of the running code*! Thus you can make changes to the code and have them immediately appear in the program, without having to restart and lose the current state of the application. See [this video](https://vimeo.com/105852957) for a demo of it in action.
@@ -124,18 +81,23 @@ With this done, you should be receiving the SBT logspam (compilation, warnings,
To develop, go into `example/` and run `sbt ~fastOptJS`. Then you can go to
```
-http://localhost:12345/target/scala-2.11/classes/index-dev.html
+http://localhost:12345/target/scala-2.12/classes/index-dev.html
```
and see a small sierpinski-triangle application. Editing the code within `example/` should cause the SBT log-spam to appear in the browser console, and changes (e.g. changing the color of the background fill) should cause a recompile and updating of the browser animation.
-To make changes to workbench, modify the workbench source code and stop/re-run `sbt ~fastOptJS`. When workbench finishes re-compiling, SBT re-starts and the page becomes accessible, your changes to workbench will take effect. You can replace `fullOptJs` in the `built.sbt` file with `fastOptJS`, and swapping the reference to `client-opt.js` to `client-fastopt.js`, if you want to speed up the development cycle.
+To make changes to workbench, modify the workbench source code and stop/re-run `sbt ~fastOptJS`. When workbench finishes re-compiling, SBT re-starts and the page becomes accessible, your changes to workbench will take effect.
Pull requests welcome!
Change Log
----------
+##0.3.0
+- Migration to AutoPlugins
+- Removal of `updateBrowsers` feature, made obsolete by increased speed of `fastOptJS`
+- General upgrade of dependencies
+
##0.2.3
- Upgraded uPickle, removed need for special resolver