Dart VM - 外部浏览器(非Google) [英] Dart VM - foreign browsers (non Google)

查看:158
本文介绍了Dart VM - 外部浏览器(非Google)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和Dart玩了一点,我觉得很棒。我知道它可以输出本机JS,并且VM可能会在他们的浏览器中由Google支持。由于其他浏览器供应商可能不支持Dart VM,是否可以在客户端计算机上安装Dart VM以便在外国浏览器中使用?

I have played a little with Dart and I think it's great. I understand that it can output native JS and that the VM will likely be supported by Google in their browser. As it is possible that other browser suppliers won't support the Dart VM, is it at all possible to install the Dart VM on client machines for use in foreign browsers?

推荐答案


是否可以在客户端计算机上安装Dart VM以便在外国浏览器中使用?

is it at all possible to install the Dart VM on client machines for use in foreign browsers?

这是,但是更容易自己提供Dart VM。

It is, however it is easier to supply the Dart VM yourself.

Javascript完全能够:

Javascript is perfectly able to:


  • 查找脚本 c> type

  • 将脚本转换为Javascript

  • 执行编译脚本

  • Find a script of a specific type
  • Convert the script into Javascript
  • Execute the compiled script

虽然这在技术上不是一个Dart虚拟机,它会得到你的Dart代码全速执行。但是,您必须等待编译完成。通常的方式是在服务器上进行编译(一次),并且只将编译的JavaScript发送给客户端。

While this is technically not a Dart Virtual Machine, it will get your Dart code executed at full speed. However, you do have to wait for the compilation to complete. The usual way is to do the compilation on the server (once), and only send the compiled javascript to clients.

另一个选项是解释代码。而不是编译为javascript,Dart指令是一个一个执行。 Dart不是机器级语言,所以它需要解析,但下面是解释。缺点是性能降低。这将让你尽可能接近有一个完整的虚拟机(与Javascript一个独立)。

Another option is interpreted code. Instead of compiling to javascript, the Dart instructions are executed one-by-one. Dart is not a machine-level language, so it needs parsing, but what follows is interpretation. The downside is reduced performance. This will get you as close to having a full-blown virtual machine (separate from the Javascript one) as possible.

通常,你不关心你是谁(也许你甚至会得到一个即时编译器),但它确实在Dart 虚拟机方面有所不同(而不是让你的代码执行)。

Normally, you don't care which one you get (maybe you'll even get a just-in-time compiler), but it does make a difference in terms of a Dart virtual machine being present (rather than just getting your code executed).

Dart编译器需要显示在页面上(除非您预编译)。

The Dart compiler needs to be present on the page somehow (unless you precompile).

最简单的方法是写< script src =path / to / your / dart-compiler.js>< / script> 进头。

The easiest way is to just write <script src="path/to/your/dart-compiler.js"></script> into the head.

Dartium浏览器本身支持Dart,但它不是为常用而设计的。 维基百科说:

The Dartium browser does support Dart natively, but it is not designed for common use. Wikipedia says:


在Dartium浏览器中:Dart SDK附带的Chromium网络浏览器版本已修改为包含Dart虚拟机。这个浏览器可以直接运行Dart代码而不需要编译Javascript。它目前不是用于通用目的,而是作为Dart应用程序的开发工具。[7] 将Dart代码嵌入到网络应用中时,当前推荐的步骤是加载引导JavaScript文件dart.js,它将检测Dart VM的存在或不存在,并加载相应的Dart或编译的Javascript代码,[8]因此保证浏览器与自定义Dart VM的兼容性。

In the Dartium Browser: The Dart SDK ships with a version of the Chromium web browser modified to include a Dart virtual machine. This browser can run Dart code directly without compilation to Javascript. It is currently not intended for general-purpose use, but rather as a development tool for Dart applications.[7] When embedding Dart code into web apps, the current recommended procedure is to load a bootstrap JavaScript file, "dart.js", which will detect the presence or absence of the Dart VM and load the corresponding Dart or compiled Javascript code, respectively,[8] therefore guaranteeing browser compatibility with or without the custom Dart VM.

运行Dart依赖于客户端机器而不是页面,还有几种方法。

If you want the ability to run Dart be dependent on the client machine rather than on the page, there are a few ways too.

一种方法是将编译器包括为用户脚本。这将工作在所有两个现代桌面浏览器。但是,我不确定是否有一种现有的方式来向Internet Explorer添加用户脚本支持。

One way is to include the compiler as a user-script. This will work in all both modern desktop browsers. However, I'm not sure if there's an existing way to add user-script support to Internet Explorer.

一种方法是添加浏览器扩展。所有现代桌面浏览器都支持扩展程序,而且 Internet Explorer具有浏览器帮助对象

One way is to add a browser extension. All modern desktop browsers support extensions, and Internet Explorer has Browser Helper Objects.

所有这些都需要额外的Javascript步骤。如果你想要本地解释绕过Javascript,你需要一个插件。插件需要运行特定的mime类型(不确定脚本类型是否计数),但是您可以安装将触发插件使用的扩展。但是,DOM操作仍然需要额外的Javascript步骤。没有办法。

All of these will require the extra Javascript step. If you want native interpretation that bypasses Javascript, you need a plugin. Plugins require a specific mime-type to run (not sure if the script type counts), but you can install an extension that will trigger the use of the plugin. However, DOM manipulation still needs the extra Javascript step. There is no way around it.

桌面安装程序可以在浏览器中安装插件。事实上,这是插件通常安装的方式。从桌面安装程序安装扩展程序也是可能的,但我现在无法确认或拒绝此最后的声明。

A desktop installer can definitely install a plugin into a browser. Indeed, this is the way plugins normally get installed. Installing extensions from a desktop installer might be possible as well, but I can't confirm or deny this last claim for now.

这篇关于Dart VM - 外部浏览器(非Google)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆