Skip to content

Commit 84d21aa

Browse files
committed
Continued development
1. Code reorganization. All Node libraries are in the ./node directory 2. Added Node "os" module 3. Added Node "https" module 4. Added Node StringDecoder class 5. Improved compatibility for the fs module and others
1 parent 48191fb commit 84d21aa

File tree

153 files changed

+817
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+817
-97
lines changed

README.md

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
MEANS.js
22
=============
3-
Type-safe Scala.js Bindings for the MEAN Stack (MongoDB ExpressJS AngularJS NodeJS).
3+
MEANS.js is a Scala.js Facade for the MEAN Stack (MongoDB ExpressJS AngularJS NodeJS).
44

5-
Table of Contents
5+
## Table of Contents
66

77
* <a href="#Introduction">Introduction</a>
88
* <a href="#Development">Development</a>
@@ -21,16 +21,18 @@ Table of Contents
2121
<a name="Introduction"></a>
2222
## Introduction
2323

24-
The goal of MEANS.js is to be complete set of type-safe Scala.js bindings for the entire MEAN Stack + Scala.js.
25-
MEANS.js goes to great lengths to make all the things you love about writing Scala on the MEAN Stack.
24+
The goal of MEANS.js is to be a complete Scala.js facade for the entire MEAN Stack. Why? Because I love NodeJS,
25+
but I have a love/hate relationship with JavaScript. And many others feel the same way about JavaScript, which is why
26+
there are so many languages that are designed to improve the experience (CoffeeScript, TypeScript, Scala.js and others).
27+
Simply put, MEANS.js let's me have my cake and eat it too! And as such, I've gone to great lengths to bring all the
28+
things you love about developing applications on the MEAN Stack to Scala.
2629

2730
<a name="Development"></a>
2831
## Development
2932

3033
<a name="Requirements"></a>
3134
#### Build Requirements
3235

33-
* [Java SDK 1.8] (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
3436
* [Scala 2.11.8+] (http://scala-lang.org/download/)
3537
* [SBT 0.13.11+] (http://www.scala-sbt.org/download.html)
3638

@@ -457,8 +459,8 @@ Consider the following example:
457459

458460
```scala
459461
$http.get[js.Dynamic]("/api/tradingClock/status") onComplete {
460-
case Success(obj) => console.log(angular.toJson(obj))
461-
case Failure(e) => ...
462+
case Success(status) => console.log(angular.toJson(status))
463+
case Failure(e) => console.error(e.getMessage)
462464
}
463465
```
464466

@@ -473,10 +475,11 @@ However, sometimes we instead want to retrieve the data as a type-safe Scala obj
473475

474476
```scala
475477
$http.get[MarketStatus]("/api/tradingClock/status") onComplete {
476-
case Success(status) => ...
477-
case Failure(e) => ...
478+
case Success(status) => console.log(angular.toJson(status))
479+
case Failure(e) => console.error(e.getMessage)
478480
}
479481

482+
@js.native
480483
trait MarketStatus extends js.Object {
481484
var stateChanged: Boolean = js.native
482485
var active: Boolean = js.native

build.sbt

+44-35
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import sbt.Keys._
44
import sbt.Project.projectToRef
55
import sbt._
66

7-
val apiVersion = "0.0.8"
7+
val apiVersion = "0.0.9"
88
val paradisePluginVersion = "2.1.0"
99
val _scalaVersion = "2.11.8"
1010
val scalaJsDomVersion = "0.9.0"
@@ -25,14 +25,14 @@ val commonSettings = Seq(
2525
)
2626

2727
lazy val root = (project in file(".")).
28-
aggregate(core, angularjs, express, facebook, kafka_node, linkedin, mongodb, node_zookeeper, nodejs, repl)
28+
aggregate(core, angularjs, express, facebook, kafka_node, linkedin, mongodb, node, node_os, node_zookeeper, repl)
2929

3030
lazy val core = (project in file("core")).
3131
enablePlugins(ScalaJSPlugin).
3232
settings(commonSettings: _*).
3333
settings(
34-
name := "means",
35-
description := "Core bindings for MEANS.js"
34+
name := "means-core",
35+
description := "MEANS.js core utilities"
3636
)
3737

3838
lazy val angularjs = (project in file("angularjs")).
@@ -41,92 +41,101 @@ lazy val angularjs = (project in file("angularjs")).
4141
settings(commonSettings: _*).
4242
settings(
4343
name := "means-angularjs",
44-
description := "AngularJS bindings for Scala.js"
44+
description := "AngularJS facade for Scala.js"
4545
)
4646

47-
lazy val facebook = (project in file("facebook")).
47+
lazy val facebook = (project in file("social/facebook")).
4848
dependsOn(core, angularjs).
4949
enablePlugins(ScalaJSPlugin).
5050
settings(commonSettings: _*).
5151
settings(
52-
name := "means-facebook",
53-
description := "Facebook buildings for Scala.js"
52+
name := "means-social-facebook",
53+
description := "Social/Facebook facade for Scala.js"
5454
)
5555

56-
lazy val express = (project in file("express")).
57-
dependsOn(core, nodejs).
56+
lazy val express = (project in file("node/express")).
57+
dependsOn(core, node).
5858
enablePlugins(ScalaJSPlugin).
5959
settings(commonSettings: _*).
6060
settings(
61-
name := "means-express",
62-
description := "Express.js bindings for Scala.js"
61+
name := "means-node-express",
62+
description := "NodeJS/Express facade for Scala.js"
6363
)
6464

65-
lazy val linkedin = (project in file("linkedin")).
65+
lazy val linkedin = (project in file("social/linkedin")).
6666
dependsOn(core, angularjs).
6767
enablePlugins(ScalaJSPlugin).
6868
settings(commonSettings: _*).
6969
settings(
70-
name := "means-linkedin",
71-
description := "LinkedIn buildings for Scala.js"
70+
name := "means-social-linkedin",
71+
description := "Social/LinkedIn facade for Scala.js"
7272
)
7373

74-
lazy val kafka_node = (project in file("kafka_node")).
75-
dependsOn(core, nodejs, node_zookeeper).
74+
lazy val kafka_node = (project in file("node/kafka_node")).
75+
dependsOn(core, node, node_zookeeper).
7676
enablePlugins(ScalaJSPlugin).
7777
settings(commonSettings: _*).
7878
settings(
79-
name := "means-kafka-node",
80-
description := "Kafka bindings for Scala.js"
79+
name := "means-node-kafkanode",
80+
description := "NodeJS/Kafka facade for Scala.js"
8181
)
8282

83-
lazy val mongodb = (project in file("mongodb")).
84-
dependsOn(core, nodejs).
83+
lazy val mongodb = (project in file("node/mongodb")).
84+
dependsOn(core, node).
8585
enablePlugins(ScalaJSPlugin).
8686
settings(commonSettings: _*).
8787
settings(
88-
name := "means-mongodb",
89-
description := "MongoDB bindings for Scala.js"
88+
name := "means-node-mongodb",
89+
description := "NodeJS/MongoDB facade for Scala.js"
9090
)
9191

92-
lazy val nodejs = (project in file("nodejs")).
92+
lazy val node = (project in file("node/core")).
9393
dependsOn(core).
9494
enablePlugins(ScalaJSPlugin).
9595
settings(commonSettings: _*).
9696
settings(
97-
name := "means-nodejs",
98-
description := "Node.js bindings for Scala.js"
97+
name := "means-node-core",
98+
description := "NodeJS/Core facade for Scala.js"
9999
)
100100

101-
lazy val node_zookeeper = (project in file("node_zookeeper")).
102-
dependsOn(core, nodejs).
101+
lazy val node_os = (project in file("node/os")).
102+
dependsOn(core, node).
103+
enablePlugins(ScalaJSPlugin).
104+
settings(commonSettings: _*).
105+
settings(
106+
name := "means-node-os",
107+
description := "NodeJS/OS facade for Scala.js"
108+
)
109+
110+
lazy val node_zookeeper = (project in file("node/node_zookeeper")).
111+
dependsOn(core, node).
103112
enablePlugins(ScalaJSPlugin).
104113
settings(commonSettings: _*).
105114
settings(
106115
name := "means-node-zookeeper-client",
107-
description := "Zookeeper client bindings for Scala.js"
116+
description := "NodeJS/Zookeeper-client facade for Scala.js"
108117
)
109118

110-
lazy val repl = (project in file("repl")).
111-
dependsOn(core, nodejs).
119+
lazy val repl = (project in file("node/repl")).
120+
dependsOn(core, node).
112121
enablePlugins(ScalaJSPlugin).
113122
settings(commonSettings: _*).
114123
settings(
115124
name := "means-node-repl",
116-
description := "REPL bindings for Scala.js"
125+
description := "NodeJS/REPL facade for Scala.js"
117126
)
118127

119128
lazy val examples = (project in file("examples")).
120-
aggregate(core, express, kafka_node, mongodb, nodejs, node_zookeeper, repl).
121-
dependsOn(core, express, kafka_node, mongodb, nodejs, node_zookeeper, repl).
129+
aggregate(core, express, kafka_node, mongodb, node, node_os, node_zookeeper, repl).
130+
dependsOn(core, express, kafka_node, mongodb, node, node_os, node_zookeeper, repl).
122131
enablePlugins(ScalaJSPlugin).
123132
settings(commonSettings: _*).
124133
settings(
125134
name := "means-examples",
126135
description := "MEANS.js examples",
127136
pipelineStages := Seq(gzip),
128137
compile in Compile <<=
129-
(compile in Compile) dependsOn (fastOptJS in(nodejs, Compile)),
138+
(compile in Compile) dependsOn (fastOptJS in(node, Compile)),
130139
ivyScala := ivyScala.value map (_.copy(overrideScalaVersion = true))
131140
)
132141

examples/examples.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
(function () {
66
require("./target/scala-2.11/means-examples-fastopt.js");
77
const facade = examples.Examples();
8-
facade.start(require);
8+
facade.start(require, this);
99
})();
1010

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* String Decoder Example
3+
4+
*/
5+
(function () {
6+
7+
const StringDecoder = require('string_decoder').StringDecoder;
8+
const decoder = new StringDecoder('utf8');
9+
10+
const cent = new Buffer([0xC2, 0xA2]);
11+
console.log(decoder.write(cent));
12+
13+
const euro = new Buffer([0xE2, 0x82, 0xAC]);
14+
console.log(decoder.write(euro));
15+
16+
})();

0 commit comments

Comments
 (0)