diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 6096c0d..0000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules/ -dist/ -docs/ \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 747eca5..0000000 --- a/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 webduino.io. All rights reserved. -Copyright (c) 2011-2014 Breakout Authors. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 49e52ce..0000000 --- a/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# webduino-js -The Webduino Javascript Core, for Browser and Node.js - -## Installation -#### Browser -Using [bower](http://bower.io): -```sh -$ bower install webduino-js -``` - -Build dist files and docs: -```sh -$ cd bower_components/webduino-js -$ npm install && npm run build -``` - -Insert scripts: -```html - - -... (modules used) -``` - -Or all-in-one: -```html - -``` - -#### Node.js -```sh -$ npm install webduino-js -``` - -## Usage -**webduino-js** provides isomorphic APIs: - -```javascript -// need to acquire 'webduino' in Node.js: -// var webduino = require('webduino-js'); - -var board, led; - -board = new webduino.WebArduino('device_id'); - -board.on('ready', function() { - led = new webduino.module.Led(board, board.getDigitalPin(10)); - led.on(); -}); -``` - -## Transports -**webduino-js** talks to Webduino Dev Board via MQTT by default. However, since **webduino-js** speaks [Firmata](https://www.arduino.cc/en/Reference/Firmata), we can also _directly_ talk to standard Arduino or any dev board that understands firmata. - -Currently we have transports supporting USB serial port and Bluetooth (HC-06 tested) communications: _(Note: you have to install Firmata library first)_ - -* [webduino-serial-transport](https://github.com/webduinoio/webduino-serial-transport) -* [webduino-bluetooth-transport](https://github.com/webduinoio/webduino-bluetooth-transport) - -## See Also -* [Webduino Dev Board and Webduino Dev Kit](https://webduino.io) -* [The Firmata Protocol](https://github.com/firmata/protocol) -* [Arduino Firmata Installation](http://www.instructables.com/id/Arduino-Installing-Standard-Firmata) - -## License -[MIT](LICENSE) \ No newline at end of file diff --git a/bower.json b/bower.json deleted file mode 100644 index 4dd6158..0000000 --- a/bower.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "webduino-js", - "description": "The Webduino Javascript Core, for Browser and Node.js", - "repository": "https://github.com/webduinoio/webduino-js.git", - "homepage": "https://webduino.io", - "keywords": [ - "arduino", - "webduino" - ], - "license": "MIT", - "dependencies": { - "paho": "webduinoio/org.eclipse.paho.mqtt.javascript#develop", - "setimmediate": "YuzuJS/setImmediate#1.x", - "chrome-api-proxy": "chrome-api-proxy#0.x", - "webduino-serial-transport": "webduino-serial-transport#0.x", - "webduino-bluetooth-transport": "webduino-bluetooth-transport#0.x" - } -} diff --git a/dist/webduino-all.js b/dist/webduino-all.js new file mode 100644 index 0000000..99a0398 --- /dev/null +++ b/dist/webduino-all.js @@ -0,0 +1,9465 @@ +(function (global, undefined) { + "use strict"; + + if (global.setImmediate) { + return; + } + + var nextHandle = 1; // Spec says greater than zero + var tasksByHandle = {}; + var currentlyRunningATask = false; + var doc = global.document; + var registerImmediate; + + function setImmediate(callback) { + // Callback can either be a function or a string + if (typeof callback !== "function") { + callback = new Function("" + callback); + } + // Copy function arguments + var args = new Array(arguments.length - 1); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i + 1]; + } + // Store and register the task + var task = { callback: callback, args: args }; + tasksByHandle[nextHandle] = task; + registerImmediate(nextHandle); + return nextHandle++; + } + + function clearImmediate(handle) { + delete tasksByHandle[handle]; + } + + function run(task) { + var callback = task.callback; + var args = task.args; + switch (args.length) { + case 0: + callback(); + break; + case 1: + callback(args[0]); + break; + case 2: + callback(args[0], args[1]); + break; + case 3: + callback(args[0], args[1], args[2]); + break; + default: + callback.apply(undefined, args); + break; + } + } + + function runIfPresent(handle) { + // From the spec: "Wait until any invocations of this algorithm started before this one have completed." + // So if we're currently running a task, we'll need to delay this invocation. + if (currentlyRunningATask) { + // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a + // "too much recursion" error. + setTimeout(runIfPresent, 0, handle); + } else { + var task = tasksByHandle[handle]; + if (task) { + currentlyRunningATask = true; + try { + run(task); + } finally { + clearImmediate(handle); + currentlyRunningATask = false; + } + } + } + } + + function installNextTickImplementation() { + registerImmediate = function(handle) { + process.nextTick(function () { runIfPresent(handle); }); + }; + } + + function canUsePostMessage() { + // The test against `importScripts` prevents this implementation from being installed inside a web worker, + // where `global.postMessage` means something completely different and can't be used for this purpose. + if (global.postMessage && !global.importScripts) { + var postMessageIsAsynchronous = true; + var oldOnMessage = global.onmessage; + global.onmessage = function() { + postMessageIsAsynchronous = false; + }; + global.postMessage("", "*"); + global.onmessage = oldOnMessage; + return postMessageIsAsynchronous; + } + } + + function installPostMessageImplementation() { + // Installs an event handler on `global` for the `message` event: see + // * https://developer.mozilla.org/en/DOM/window.postMessage + // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages + + var messagePrefix = "setImmediate$" + Math.random() + "$"; + var onGlobalMessage = function(event) { + if (event.source === global && + typeof event.data === "string" && + event.data.indexOf(messagePrefix) === 0) { + runIfPresent(+event.data.slice(messagePrefix.length)); + } + }; + + if (global.addEventListener) { + global.addEventListener("message", onGlobalMessage, false); + } else { + global.attachEvent("onmessage", onGlobalMessage); + } + + registerImmediate = function(handle) { + global.postMessage(messagePrefix + handle, "*"); + }; + } + + function installMessageChannelImplementation() { + var channel = new MessageChannel(); + channel.port1.onmessage = function(event) { + var handle = event.data; + runIfPresent(handle); + }; + + registerImmediate = function(handle) { + channel.port2.postMessage(handle); + }; + } + + function installReadyStateChangeImplementation() { + var html = doc.documentElement; + registerImmediate = function(handle) { + // Create a + + + + +
+ Languages : CH ++<link href="prettify.css" type="text/css" rel="stylesheet" /> +<script type="text/javascript" src="prettify.js"></script>+
onload="prettyPrint()" to your
+ document's body tag.
+ Put code snippets in + <pre class="prettyprint">...</pre> + or <code class="prettyprint">...</code> + and it will automatically be pretty printed. + +
| The original + | Prettier + |
|---|---|
class Voila { +public: + // Voila + static const string VOILA = "Voila"; + + // will not interfere with embedded tags. +}+ + | class Voila { +public: + // Voila + static const string VOILA = "Voila"; + + // will not interfere with embedded tags. +}+ |
The comments in prettify.js are authoritative but the lexer + should work on a number of languages including C and friends, + Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles. + It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl + and Ruby, but, because of commenting conventions, doesn't work on + Smalltalk, or CAML-like languages.
+ +LISPy languages are supported via an extension:
+ lang-lisp.js.
And similarly for
+ CSS,
+ Haskell,
+ Lua,
+ OCAML, SML, F#,
+ Visual Basic,
+ SQL,
+ Protocol Buffers, and
+ WikiText..
+
+
If you'd like to add an extension for your favorite language, please + look at src/lang-lisp.js and file an + issue including your language extension, and a testcase.
+ +You don't need to specify the language since prettyprint()
+ will guess. You can specify a language by specifying the language extension
+ along with the prettyprint class like so:
<pre class="prettyprint lang-html"> + The lang-* class specifies the language file extensions. + File extensions supported by default include + "bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html", + "java", "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh", + "xhtml", "xml", "xsl". +</pre>+ +
Yes. Prettifying obfuscated code is like putting lipstick on a pig + — i.e. outside the scope of this tool.
+ +It's been tested with IE 6, Firefox 1.5 & 2, and Safari 2.0.4. + Look at the test page to see if it + works in your browser.
+ +See the change log
+ +Apparently wordpress does "smart quoting" which changes close quotes. + This causes end quotes to not match up with open quotes. +
This breaks prettifying as well as copying and pasting of code samples. + See + WordPress's help center for info on how to stop smart quoting of code + snippets.
+ +You can use the linenums class to turn on line
+ numbering. If your code doesn't start at line number 1, you can
+ add a colon and a line number to the end of that class as in
+ linenums:52.
+
+
For example +
<pre class="prettyprint linenums:4" +>// This is line 4. +foo(); +bar(); +baz(); +boo(); +far(); +faz(); +<pre>+ produces +
// This is line 4. +foo(); +bar(); +baz(); +boo(); +far(); +faz(); ++ +
You can use the nocode class to identify a span of markup
+ that is not code.
+
<pre class=prettyprint> +int x = foo(); /* This is a comment <span class="nocode">This is not code</span> + Continuation of comment */ +int y = bar(); +</pre>+produces +
+int x = foo(); /* This is a comment This is not code
+ Continuation of comment */
+int y = bar();
+
+
+ For a more complete example see the issue22 + testcase.
+ +If you are calling prettyPrint via an event handler, wrap it in a function.
+ Instead of doing
+
+ addEventListener('load', prettyPrint, false);
+
+ wrap it in a closure like
+
+ addEventListener('load', function (event) { prettyPrint() }, false);
+
+ so that the browser does not pass an event object to prettyPrint which
+ will confuse it.
+
+