Why we made vorlon.js and how to use it to debug your JavaScript remotely

Vorlon.js is powered by node.JS, socket.io, and late-night coffee. I would like to share with you why we made it, how to incorporate it into your own testing workflow, and also share some more details into the art of building a JS library like it.

Recently at //BUILD/ 2015 we announced vorlon.js – an open source, extensible, platform-agnostic tool for remotely debugging and testing your JavaScript. I had the opportunity to create vorlon.JS with the help of some talented engineers and tech evangelists at Microsoft (the same guys that brought youhttp://www.babylonjs.com/).

Vorlon.js is powered by node.JS, socket.io, and late-night coffee. I would like to share with you why we made it, how to incorporate it into your own testing workflow, and also share some more details into the art of building a JS library like it.

Why Vorlon.js?

Vorlon.js helps you remotely load, inspect, test and debug JavaScript code running on any device with a web browser. Whether it is a game console, mobile device, or even an IoT- connected refrigerator, you can remotely connect up to 50 devices and execute JavaScript in each or all of them. The idea here is that dev teams can also debug together – each person can write code and the results are visible to all. We had a simple motto in this project: No native codeno dependency to a specific browser, only JavaScript, HTML and CSS running on the devices of your choice.

Vorlon.js itself is a small web server you can run from your local machine, or install on a server for your team to access, that serves the Vorlon.js dashboard (your command center) and communicates with the remote devices. Installing the Vorlon.js client in your web site or app is as easy as adding a single script tag. It‘s also extensible where devs can write plug-ins that add features to both the client and the dashboard, for example: feature detection, logging, and exception tracking.

So why the name? There are actually two reasons. The first one is because I am just crazy about Babylon 5 (The TV show). Based on this, the second reason is because the Vorlons are one of the wisest and most ancient races in the universe and thus, they are helpful as diplomats between younger races. Their helpfulness is what inspired us: for web devs, it‘s still just too hard to write JavaScript that works reliably in the various devices and browsers. Vorlon.js seeks to make it just a little easier.

You mentioned Vorlon.js has plug-ins?

Vorlon.js has been designed so that you can extend the dashboard and client application easily by writing or installing additional plugins. You can resize or add extra panes to the dashboard which can communicate bidirectionally with the client application. There are three plug-ins to begin with:

Console

Logging: The console tab will stream console messages from the client to the dashboard that you can use for debugging. Anything logged with console.log()console.warn() or console.error() will appear in the dashboard. Like the F12 Dev Tool DOM explorer, you can see the DOM tree, select a node (which will be highlighted on the device, and update or add new CSS properties).

Interactivity: You can also interact with the remote webpage by typing code into the input. Code entered will be evaluated in the context of the page.

DOM Explorer

The DOM inspector shows you the DOM of the remote webpage. You can inspect the DOM, clicking on nodes will highlight them in the host webpage, and if you select one you can also view and modify its css properties.

Modernizr

The Modernizr tab will show you the supported browser features as reported by Modernizr. You can use this to determine what features are actually available. This might be particularly useful on unusual mobile devices, or things like games consoles.

How do I use it?

From you node command line, just execute this:

$ npm i -g vorlon

$ vorlon

Now you have a server running on your localhost on port 1337.
To get access to the dashboard, just navigate to http://localhost:1337/dashboard/SESSIONID, where SESSIONID is the id for the current dashboard session. This can be any string you want.

You have then to add a single reference in your client project:

<script src="http://localhost:1337/vorlon.js/SESSIONID"></script>

Please note that SESSIONID can be omitted and in this case, it will be automatically replaced by "default".
And that‘s it! Now your client will send debug information to your dashboard seamlessly. Let‘s now have a look at an example using a real site.

Debugging babylonjs.com using vorlon.js

Let‘s use http://www.babylonjs.com/ for our example. First, I have to launch my server (using node start.js inside the /server folder). Then, I have just have to add this line to my client site:

<script src="http://localhost:1337/vorlon.js"></script>

Because I am not defining a SESSIONID, I can just go to http://localhost:1337/dashboard
The dashboard looks like this:

Sidenote: The browser shown above is Microsoft Edge (formerly known as Project Spartan), Microsoft‘s new browser for Windows 10. You can also test your web apps for it remotely on your Mac, iOS, Android, or Windows device @ http://dev.modern.ie/. Or try vorlon.js too.

Back to it: I can see console messages for instance, which is useful when I debug babylon.js on mobile devices (like iOS, Android or Windows Phone). I can click on any node on the DOM Explorer to get info about CSS properties:

On the client side, the selected node is highlighted with a red border:

Moreover, I can switch to Modernizr tab to see capabilities of my specific device:

On the left side, you can see the list of currently connected clients and you can use the [Identify a client] button to display a number on every connected devices.

A little more on how we built vorlon.js

From the very beginning, we wanted to be sure that vorlon.js remains as mobile-first and platform-agnostic as possible. So we decided to use open source tech that worked across the broader number of environments.

Our dev environment was Visual Studio Community which you can get for free now. We used the Node.JS tools for Visual Studio and Azure for the back-end. Our front-end was JavaScript and TypeScript. If you‘re not familiar with TypeScript, you can learn why we‘ve built babylon.js with it here. Recently Angular 2 has been built with TypeScript. But you don‘t have to know it to use vorlon.js.

Here‘s a global schema of how it works:

Here‘s are the parts with built with:

  • A node.js server is hosting a dashboard page (served using express) and a service
  • The service is using socket.io to establish a direct connection with both the dashboard and the various devices
  • Devices have to reference a simple vorlon.js page served by the server. It contains all the plugins client code which interact with the client device and communicate with the dashboard through the server.
  • Every plug-in is split in two parts:
    • The client side, used to capture information and to interact with the device
    • The dashboard side, used to generate a command panel for the plugin inside the dashboard

For instance, the console plugin works this way:

  • The client side generates a hook on top of console.log(), console.warn() or console.error(). This hook is used to send the parameters of these functions to the dashboard. It can also receive orders from the dashboard side that it will evaluate
  • The dashboard side gathers these parameters and display them on the dashboard

The result is simply a remote console:

You can get an even better understanding of vorlon.js extensibility including how to build your own plug-ins here.

What‘s next?

Vorlon.js is built on the idea of extensibility. We encourage you to contribute! And we‘re already about how we might integrate vorlonJS into browser dev tools as well as Web Audio debugging.

If you want to try it, you are just one click away: vorlonjs.com. And the more technical docs are here on our GitHub.

More hands-on with JavaScript

It might surprise you a bit, but Microsoft has a bunch of free learning on many open source JavaScript topics and we’re on a mission to create a lot more with Microsoft Edge. Check out my own:

Or our team’s learning series:

And some free tools: Visual Studio CommunityAzure Trial, and cross-browser testing tools for Mac, Linux, or Windows.

This article is part of the web dev tech series from Microsoft. We’re excited to share Microsoft Edge and the newEdgeHTML rendering engine with you. Get free virtual machines or test remotely on your Mac, iOS, Android, or Windows device @ http://dev.modern.ie/

时间: 2024-10-15 00:39:27

Why we made vorlon.js and how to use it to debug your JavaScript remotely的相关文章

Ext JS学习第三天 我们所熟悉的javascript(二)

•javascript之函数 •对于Ext开发者,我还是希望你能对javascript原生的东西非常了解.甚至熟练掌握运用.那么函数,无疑是非常重要的概念.首先在前面一讲,我们知道了函数也是一种数据类型,创建函数一共有三种方式.每种方式他们都会有区别,分别为: –function语句形式 –函数直接量形式 –构造函数形式 •函数中的arguments对象 –argument的作用一:接受函数的实际参数 –argument的作用二:用于做递归操作 栗子代码 1 //Function 函数 2 //

js/ajax跨越访问-jsonp的原理和实例(javascript和jquery实现代码)

最近做了一个项目,需要用子域名调用主域名下的一个现有的功能,于是想到了用jsonp来解决,在我们平常的项目中不乏有这种需求的朋友,于是记录下来以便以后查阅同时也希望能帮到大家,需要了解的朋友可以参考下 很庆幸,我又见到了末日后新升的太阳,所以我还能在这里写文章,言归正传哈,最近做了一个项目,需要用子域名调用主域名下的一个现有的功能,于是想到了用jsonp来解决,在我们平常的项目中不乏有这种需求的朋友,于是记录下来以便以后查阅同时也希望能帮到大家. 什么是JSONP协议? JSONP即JSON w

安卓webview和js+html交互利用的addJavascriptInterface和webview.loadUrl(&quot;javascript:**&quot;);

近期做一个项目需要把一个 服务支持的界面用webview来显示..呀 html白雪了js更是一样啥也不会,相信很多初学屌丝员跟我一样,, html开发工具都不知道怎么写..哈哈哈.....现在把做完的结果分享一下先上图了 ,, 这是从项目中特意分离出来的demo这里之上一些关键代码 源码下载地址  http://download.csdn.net/download/yung7086/7554309 步骤 首先在assets目录下建一个html文件 <!DOCTYPE html PUBLIC &quo

JS基础知识回顾:在HTML中使用JavaScript

想HTML页面中插入JavaScript的主要方法就是使用<script>元素. HTML4.01当中为<script>元素定义了下列6个属性: language(已废弃):原来用于表示编写代码使用的脚本语言,如JavaScript.JavaScript1.2.VBScript等,由于大多数浏览器会忽略此属性,因此就没有必要再用了: type(可选):可以看成是language的替代属性,表示编写代码使用的脚本语言的内容类型,也被称作MIME类型,在未指定此属性的情况下会被默认为t

Ext JS学习第五天 我们所熟悉的javascript(四)

此文用来记录学习笔记: •javascript之对象.面向对象 •可能对于高级语言你可能了解甚至精通OOP面向对象,那么对于javascript你又熟悉多少呢?我们一起来学习javascript面向对象,这样非常有帮助我们理解Ext的基础架构,Ext本身就是一个JS面向对象的框架. •使用json对象(JavaScript Object Notation) –JS对象的特性 –对于js来说json对象非常的重要,我们要学会如何操作json对象 •面向对象的概念 –如何定义一个类.如何实例化对象.

Ext JS学习第四天 我们所熟悉的javascript(三)

此文用来记录学习笔记: •javascript之函数 •this关键字的使用 –this关键字总是指向调用者,谁调用函数,this就指向谁 •call.apply的使用 –call和apply主要应用与框架底层,用于绑定函数的执行环境/作用域 •块的概念 –和高级程序语言不同,js里没有块的概念,我们一般用小括号包裹块级作用域 •闭包:掌握闭包必须要深入清楚的概念 –执行环境 –作用域链 –垃圾回收机制 附上栗子 代码 1 // This 关键字 在javascript里的使用 2 //this

平稳退化,JS和HTML标记分离,极致性能的JavaScript图片库

1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>JavaScript图片库</title> 6 <script type="text/javascript"> 7 <!--平稳退化,JS和HTML标记分离,极致性能的JS图片库--> 8 fu

js面向对象学习笔记之二(debug调试方法)

1. js的调试 很明显,js 调试只能够通过 alert 进行打印 alert(id); 对于复杂的数据类型,我们可以通过将其转换成json格式 再进行弹出 alert(JSON.stringify(data)); 2. DOM 信息调试 对于我们需要获取到的信息 可以根据要求打印到dom元素里 document.write(data); //会覆盖整个文档 3. 在程序端调试 直接在程序端打印所需信息后退出 var_dump() print_r() 4. js 其他错误信息处理 /*====

Clipboard.js:不用Flash实现剪贴板功能的轻量级JavaScript库

Zeno Rocha发布了一个专门用于从web页面向本地计算机的剪贴板复制文本的JavaScript库:Clipboard.js. 在每一个Github仓库页面的侧边栏上都有一个小部件,用来显示repo的HTTPS克隆地址,当你点击紧挨着这个部件的按钮时,就会复制当前repo的URL到用户的剪贴板中.Github用JavaScript库ZeroClipboard来实现这一功能,问题是这个库是用一个不可见的Flash来完成剪贴操作,而Flash技术正被各大浏览器厂商冷落,所以势必要有一个新的方案.