Deno 1.8 发布:实验性支持 WebGPU API、导入映射已稳定

栏目: 软件资讯 · 发布时间: 4年前

内容简介:Deno 1.8 已正式发布,此版本包含许多新功能以及稳定化的改进。 实验性支持 WebGPU API:主要是为在 Deno 中支持开箱即用的 CPU 加速机器学习做准备 启用内置的国际化 API:所有 JS Intl API 支持开箱即用 改进测...

Deno 1.8 已正式发布,此版本包含许多新功能以及稳定化的改进。

如果已经安装了 Deno,运行deno upgrade命令即可升级到 1.8 版本。如果是首次安装,可以参考下面的方法:

# Using Shell (macOS and Linux):
curl -fsSL https://deno.land/x/install/install.sh | sh

# Using PowerShell (Windows):
iwr https://deno.land/x/install/install.ps1 -useb | iex

# Using Homebrew (macOS):
brew install deno

# Using Scoop (Windows):
scoop install deno

# Using Chocolatey (Windows):
choco install deno

实验性支持 WebGPU API

WebGPU API 为开发者提供了一种底层、高性能、跨架构的方式来通过 JavaScript 对 GPU 硬件进行编程。它被认为是 WebGL 在 Web 上的实际继任者。WebGPU 规范尚未最终确定,不过 Firefox、Chromium 和 Safari 已添加对它的支持,现在 Deno 也已添加了实验性支持。

开发者可以通过此 API 直接从 Deno 内部访问 GPU 渲染和通用 GPU 计算。下面是一个基础示例,演示了如何访问连接的 GPU 设备以及读取名称和支持的功能:

// Run with `deno run --unstable https://deno.land/posts/v1.8/webgpu_discover.ts`

// Try to get an adapter from the user agent.
const adapter = await navigator.gpu.requestAdapter();
if (adapter) {
  // Print out some basic details about the adapter.
  console.log(`Found adapter: ${adapter.name}`);
  const features = [...adapter.features.values()];
  console.log(`Supported features: ${features.join(", ")}`);
} else {
  console.error("No adapter found");
}

下面的例子演示了 GPU 使用渲染着色器在绿色背景上渲染出一个简单的红色三角形:

$ deno run --unstable --allow-write=output.png https://raw.githubusercontent.com/crowlKats/webgpu-examples/f3b979f57fd471b11a28c5b0c91d0447221ba77b/hello-triangle/mod.ts

Deno 1.8 发布:实验性支持 WebGPU API、导入映射已稳定

Deno 开发团队提到,此功能最终合并的 PR 包含多达 15.5 万行代码,并且花费了整整 5 个月的时间进行合并。

改进测试覆盖工具:deno coverage

此版本扩大了覆盖范围基础架构,以添加一些强大的新功能,其中主要变化是,覆盖率处理现在分为覆盖率集合和覆盖率报告。

导入映射已稳定

导入映射在 Chrome 89 已处于稳定状态,Deno 开发团队也紧跟着进行了更新以匹配该规范的最新版本,并且现在也被认为已处于稳定状态。这就意味着使用--import-map时不再需要--unstableflag。

$ deno run --import-map=./import_map.json ./mod.ts

此外,--import-mapflag 现在不仅接受本地路径,而且接受 URL,从而可以从远程服务器加载导入映射。

$ deno run --import-map=https://example.com/import_map.json ./mod.ts

导入映射允许用户使用所谓的“裸”说明符来表示依赖关系,而不是相对或绝对文件地址/http URL:

// Deno does not support such specifiers by default,
// but by providing an import map, users can remap bare specifiers
// to some other URLs.
import * as http from "std/http";
{
  "imports": {
    "std/http": "https://deno.land/std@0.85.0/http/mod.ts"
  }
}

除了这些更新亮点,发布公告还介绍了许多其他新特性和改进,详情点此查看


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Introduction to Graph Theory

Introduction to Graph Theory

Douglas B. West / Prentice Hall / 2000-9-1 / USD 140.00

For undergraduate or graduate courses in Graph Theory in departments of mathematics or computer science. This text offers a comprehensive and coherent introduction to the fundamental topics of graph ......一起来看看 《Introduction to Graph Theory》 这本书的介绍吧!

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具