惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
The Cloudflare Blog
大猫的无限游戏
大猫的无限游戏
MyScale Blog
MyScale Blog
B
Blog
爱范儿
爱范儿
博客园 - 【当耐特】
P
Proofpoint News Feed
Y
Y Combinator Blog
博客园 - 司徒正美
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
Jina AI
Jina AI
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
G
Google Developers Blog
Apple Machine Learning Research
Apple Machine Learning Research
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
D
DataBreaches.Net
F
Full Disclosure
WordPress大学
WordPress大学
月光博客
月光博客
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
I
InfoQ
酷 壳 – CoolShell
酷 壳 – CoolShell
S
SegmentFault 最新的问题
Microsoft Security Blog
Microsoft Security Blog
雷峰网
雷峰网
C
Check Point Blog
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
N
Netflix TechBlog - Medium
D
Docker
L
LangChain Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recorded Future
Recorded Future

Deno

Deno 2.8 | Deno Claw Patrol: an open-source security firewall for agents | Deno Fresh 2.3: Zero JS by default, View Transitions, and Temporal support | Deno Deno 2.7: Temporal API, Windows ARM, and npm overrides | Deno Build a dinosaur runner game with Deno, pt. 6 | Deno Build a dinosaur runner game with Deno, pt. 5 | Deno Deno Deploy is Generally Available | Deno Introducing Deno Sandbox | Deno Build a dinosaur runner game with Deno, pt. 4 | Deno Build a dinosaur runner game with Deno, pt. 3 | Deno Build a dinosaur runner game with Deno, pt. 2 | Deno React / Next.js Denial-of-Service Vulnerability: Deno Deploy users protected | Deno Deno 2.6: dx is the new npx | Deno Build a dinosaur runner game with Deno, pt. 1 | Deno React Server Functions / Next.js Vulnerability: Deno Deploy users protected | Deno My highlights from the new Deno Deploy | Deno Deno's Other Open Source Projects | Deno How Deno protects against npm exploits | Deno Help Us Raise $200k to Free JavaScript from Oracle | Deno Deno 2.5: Permissions in the config file | Deno Fresh 2.0 Graduates to Beta, Adds Vite Support | Deno Deno 2.4: deno bundle is back | Deno JavaScript™ Trademark Update | Deno What's coming to JavaScript | Deno A brief history of JavaScript | Deno Reports of Deno's Demise Have Been Greatly Exaggerated | Deno An Update on Fresh | Deno How Plaid migrated 100 services to a new database platform 5x faster with Deno | Deno Deno 2.3: Improved deno compile, local npm packages, and more | Deno Add JSR packages with pnpm and Yarn | Deno Zero-config Debugging with Deno and OpenTelemetry | Deno Exploring Art with TypeScript, Jupyter, Polars, and Observable Plot | Deno Deno v Oracle Update 3: Fighting the JavaScript Trademark | Deno Build a custom RAG AI agent in TypeScript and Jupyter | Deno How to get deep traces in your Node.js backend with OTel and Deno | Deno toranoana.deno #20 登録受付中(2025年3月14日) | Deno Node just added TypeScript support. What does that mean for Deno? | Deno The Dino 🦕, the Llama 🦙, and the Whale 🐋 | Deno Publish a lint rule, get a prize | Deno Deno 2.2: OpenTelemetry, Lint Plugins, node:sqlite | Deno If you're not using npm specifiers, you're doing it wrong | Deno How Deno's documentation is evolving | Deno Oracle justified its JavaScript trademark with Node.js—now it wants that ignored | Deno Introducing the JSR open governance board | Deno Intro to Wasm in Deno | Deno Announcing OpenAI on JSR | Deno Deno in 2024 | Deno Goodbye WinterCG, welcome WinterTC | Deno Build a SolidJS app with Deno | Deno Run your Next.js SSR app on Deno Deploy | Deno Solve Advent of Code 2024 with Deno and Win Prizes! | Deno Deno v. Oracle: Canceling the JavaScript Trademark | Deno Deno 2.1: Wasm Imports and other enhancements | Deno Build a Typesafe API with tRPC and Deno | Deno Self-contained Executable Programs with Deno Compile | Deno Build a Database App with Drizzle ORM and Deno | Deno Introducing your new JavaScript package manager: Deno | Deno Announcing Growthbook on JSR | Deno Build an Astro site with Deno | Deno How to convert CommonJS to ESM | Deno Announcing Deno 2 | Deno The Final Touches: What’s New In v2.0.0-rc.10 | Deno Announcing Stable V8 Bindings for Rust | Deno Deno 2.0 Release Candidate | Deno Secure, efficient private npm registries with Cloudsmith and Deno | Deno Painting the Plane as We Fly It: Designing JSR | Deno Introducing Web Cache API support on Deno Deploy | Deno Deno 1.46: The Last 1.x Release | Deno Protect your cloud spend with new Deno Deploy spend limits | Deno What we got wrong about HTTP imports | Deno Benchmarking AWS Lambda Cold Starts Across JavaScript Runtimes | Deno Announcing Supabase on JSR | Deno Deno 1.45: Workspace and Monorepo Support | Deno Introducing KV Backup for Deno Subhosting | Deno A Gentle Intro to TypeScript | Deno Announcing Hono on JSR | Deno How We Made the Deno Language Server Ten Times Faster | Deno How the Guardian uses Deno to audit accessibility and performance across their 2.7 million articles | Deno Introducing More Flexible Domain Association for Deno Subhosting | Deno The stabilization process of the Standard Library has begun | Deno Deno 1.44: Private npm registries, improved Node.js compat, and performance boosts | Deno How we built a secure, performant, multi-tenant cloud platform to run untrusted code | Deno The Deno Standard Library is now available on JSR | Deno How to document your JavaScript package | Deno Your Low Code Solution Needs an Escape Hatch | Deno Deno 1.43: Improved Language Server performance | Deno How Slack used Deno to save months of engineering effort in launching their new platform | Deno JSR Is Not Another Package Manager | Deno Announcing the Hookdeck SDK on JSR | Deno Announcing the Neon Serverless Driver on JSR | Deno An intro to TSConfig for JavaScript Developers | Deno How we built JSR | Deno How Netlify used Deno Subhosting to build a successful edge functions product | Deno Introducing Simpler Project Creation in Deno Deploy | Deno Deno 1.42: Better dependency management with JSR | Deno Introducing deployctl, the command line interface for Deno Deploy | Deno Introducing JSR - the JavaScript Registry | Deno How to add Monaco to a Next.js app and securely run untrusted user code | Deno Survey Results and Roadmap | Deno Deno 1.41: smaller deno compile binaries | Deno
Deno 1.40: Temporal API | Deno
2024-01-26 · via Deno

We are excited to announce the release of Deno 1.40, a significant step forward in the evolution of Deno. This new version is packed with features that enhance the Deno experience, introducing the powerful Temporal API for advanced date and time operations, and embracing the latest decorator syntax for more expressive code. Alongside these advancements, we’ve implemented a series of deprecations, stabilizations, and removals aimed at streamlining Deno’s capabilities and preparing for Deno 2.

If you already have Deno installed, upgrade to version 1.40 in your terminal with:

If you don’t yet have Deno installed, you can install it with one of the following commands, or many other ways.

MacOS / Linux Install

curl -fsSL https://deno.land/install.sh | sh

Windows Install

irm https://deno.land/install.ps1 | iex

Here’s an overview of what’s new in Deno 1.40:

  • Temporal API
  • import.meta.filename and import.meta.dirname
  • Decorators
  • Simpler imports in deno.json
  • Deprecations, stabilizations, and removals
  • Web API: rejectionhandled event
  • WebGPU windowing / “Bring your own Window”
  • Node.js API updates
  • LSP improvements
  • Better looking diagnostics
  • deno lint updates
  • Changes to how we handle unstable features

Temporal API

The Temporal API is designed to address some of the shortcomings and complexities associated with the existing Date object in JavaScript.

Temporal proposal is actively implemented by all major JavaScript engines and we’re happy to announce it’s now available in Deno with the --unstable-temporal flag.

const birthday = Temporal.PlainMonthDay.from("12-15");
const birthdayIn2030 = birthday.toPlainDate({ year: 2030 });
console.log(birthdayIn2030.toString());


console.log("day of week", birthdayIn2030.dayOfWeek);
Temporal’s user friendly API makes it easy to parse and manipulate date and time.

It’s unlikely that Temporal API will be changed and we aim to stabilize it in Deno 2. We encourage you to explore the Temporal API docs.

Deno now supports import.meta.filename and import.meta.dirname properties.

These properties mirror __filename and __dirname properties from the CommonJS module system:

  • import.meta.filename provides the absolute path to the current module file
  • import.meta.dirname provides the absolute path to the directory containing the current module file

Both of these properties are aware of the OS specific path separator and provide proper separators for the current platform:

console.log(import.meta.filename);
console.log(import.meta.dirname);

In Unix:

$ deno run /dev/my_module.ts
/dev/my_module.ts
/dev/

And in Windows:

$ deno run C:\dev\my_module.ts
C:\dev\my_module.ts
C:\dev\

These properties are available only for local modules (ie. modules loaded from the file system) and are undefined for remote modules (modules imported from http:// or https://).

Decorators

Deno now supports the TC39 stage 3 Decorators proposal, which will soon be implemented in all browsers.

Decorators are a proposal for extending JavaScript classes which is widely adopted among developers in transpiler environments, with broad interest in standardization. TC39 has been iterating on decorators proposals for over five years. This document describes a new proposal for decorators based on elements from all past proposals.

This feature is available in .ts, .jsx and .tsx files. Support in pure JavaScript is waiting on implementation in V8.

Here is an example of an @trace decorator that logs out whenever a function is called, and when it returns:

function trace(fn: any, ctx: ClassMethodDecoratorContext) {
  return function (...args: unknown[]) {
    console.log("ENTERED", ctx.name);
    const v = fn(...args);
    console.log("EXITED", ctx.name);
    return v;
  };
}

class App {
  @trace
  static start() {
    console.log("Hello World!");
  }
}

App.start();

If you rely on the legacy “experimental TypeScript decorators”, you can still use them with the following configuration:

{
  "compilerOptions": {
    "experimentalDecorators": true
  }
}

Note: There was a bug discovered after v1.40.0 was cut that TypeScript’s experimentalDecorators was still turned on in the LSP. Please upgrade to v1.40.1.

Simpler imports in deno.json

The imports field in deno.json now supports a simpler syntax for specifying dependencies that have subpath exports. Previously, when wanting to use preact from npm, you had to add this to your imports object in your deno.json:

{
  "imports": {
    "preact": "npm:preact@10.5.13",
    "preact/": "npm:/preact@10.5.13/"
  }
}

This allowed you to import both preact, and subpath exports, like preact/hooks.

In this release we have simplified this, so that you can now just do:

{
  "imports": {
    "preact": "npm:preact@10.5.13"
  }
}

In Deno 1.40.0, this will allow you to import both preact and preact/hooks from npm.

Previously Deno considered the imports field in deno.json to just be a regular import map. Now, we pre-process the imports field in deno.json and expand any entries with a npm: prefix on the right hand side into two entries in an internal import map that we use for resolution.

Deprecations, stabilizations, and removals

As we gear up for Deno 2, we’re committed to refining the runtime while ensuring a smooth transition from Deno 1. While most Deno 1 code will remain compatible, we’re streamlining certain APIs for the platform’s long-term health.

Deprecations

We’re introducing deprecations to phase out older APIs, alongside warnings to assist your migration:

  • window – The global variable window is used often across the JavaScript ecosystem to test if code is running in a browser. It is an easy fix to use globalThis or self instead. There is no runtime warning for this deprecation yet, but it will show up in deno lint in starting this release.

  • Deno.run() – This is the old and error-prone subprocess API. We have since introduced the much more versatile Deno.Command API which was stabilized a year ago.

  • Deno.serveHttp() – Replaced by the faster and simpler Deno.serve(). Documentation here.

  • Deno.metrics() – To focus on performance, we’re shifting towards more targeted command-line flags and APIs. Custom metrics implementations are available via op_metrics_factory_fn and a new --strace-ops flag for runtime ops tracing.

  • Stream-related Functions: Transitioning to Web Streams, we’re deprecating several Deno.Reader/ Deno.Writer stream functions. The deprecated functions are still accessible via the Deno standard library:

  • Deno.FsWatcher.return() – To align with other async iterators, we’re deprecating this in favor of explicit close methods.

  • Deno.customInspect – To encourage browser-compatible code, we’ve switched to Symbol.for("Deno.customInspect").

In Deno 2, we are removing the concept of “resource ids”. Resource ids are integer references to sockets, files, or other resources managed outside of JavaScript. They’re analogous to file descriptors. However most users do not touch these directly, and we’d like to start introducing resources reference by native JavaScript objects. For this reason we’re deprecating these APIs:

  • Deno.isatty() – instead use the isTerminal() method, for example Deno.stdout.isTerminal().

  • Deno.close() – this API also operates on rid. Users are encouraged to use .close() method on relevant objects instead. For example, file.close() rather than Deno.close(file.rid).

  • Deno.resources() – This API also exposes resource ids and has little utility.

  • Deno.ftruncate() and Deno.ftruncateSync() – These function are now avaiable on Deno.FsFile as truncate() and truncateSync().

All rid properties are now deprecated and will be removed in Deno 2.0:

  • Deno.Conn.rid
  • Deno.FsWatcher.rid
  • Deno.TcpConn.rid
  • Deno.TlsConn.rid
  • Deno.UnixConn.rid
  • Deno.Listener.rid

Loading certificates from files is now deprecated, read them yourself instead:

  • Deno.ListenTlsOptions.certFile - Use Deno.ListenTlsOptions.cert and Deno.readTextFile instead.
  • Deno.ListenTlsOptions.keyFile - Use Deno.ListenTlsOptions.key and Deno.readTextFile instead.
  • Deno.ConnectTlsOptions.certFile -Use Deno.ConnectTlsOptions.cert and Deno.readTextFile instead.

Stabilizations

Following Deno APIs have been stabilized and un-flagged:

  • Deno.Conn.ref()
  • Deno.Conn.unref()
  • Deno.connect() for unix transport
  • Deno.connectTls
  • Deno.stderr.isTerminal()
  • Deno.stdin.isTerminal()
  • Deno.stdout.isTerminal()
  • Deno.TlsConn.handshake()

Removals

Finally, the unstable API Deno.upgradeHttp has been removed. This API was error prone and easy to misuse. We encourage everyone to use Deno.serve() and Deno.upgradeWebsocket().

Web API: rejectionhandled event

We’ve added support for the rejectionhandled event, which is emitted anytime a .catch() handler is attached to a promise that has already been rejected. Also, this event will only emitted if you have a unhandledrejection event listener that calls event.preventDefault() (otherwise the promise will be rejected and the process will exit with an error).

globalThis.addEventListener("unhandledrejection", (event) => {
  
  event.preventDefault();
  console.log("unhandledrejection", event.reason);
});

globalThis.addEventListener("rejectionhandled", (event) => {
  console.log(
    "A .catch() handler was added to the promise after it has already rejected.",
    event.reason,
  );
});


const a = Promise.reject(new Error("boom!"));


setTimeout(async () => {
  a.catch(() => console.log("Added catch handler to the promise"));
}, 10);
$ deno run main.js
unhandledrejection Error: boom!
    at file:///dev/main.js:12:26
Added catch handler to the promise
A .catch() handler was added to the promise after it has already rejected. Error: boom!
    at file:///dev/main.js:12:26

WebGPU windowing / “Bring your own Window”

We’re introducing a new unstable Deno.UnsafeWindowSurface API to address windowing in Deno. Our goal is to provide a windowing solution for WebGPU without linking to native windowing systems like X11.

This is a low level API that can be used by FFI windowing libraries like sdl2, glfw, raylib, winit and more to create a WebGPU surface using native window and display handles.

Here’s an example using deno.land/x/sdl2:

import {
  EventType,
  WindowBuilder,
} from "https://deno.land/x/sdl2@0.8.0/mod.ts";

const win = new WindowBuilder("Hello, World!", 800, 600).build();

const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();


const surface = win.windowSurface();

const context = surface.getContext("webgpu");

context.configure({});

for (const event of win.events()) {
  if (event.type == EventType.Quit) break;

  
  const r = Math.sin(Date.now() / 1000) / 2 + 0.5;
  const g = Math.sin(Date.now() / 1000 + 2) / 2 + 0.5;
  const b = Math.sin(Date.now() / 1000 + 4) / 2 + 0.5;

  const textureView = context.getCurrentTexture().createView();
  const renderPassDescriptor = {
    colorAttachments: [
      {
        view: textureView,
        clearValue: { r, g, b, a: 1.0 },
        loadOp: "clear",
        storeOp: "store",
      },
    ],
  };

  const commandEncoder = device.createCommandEncoder();
  const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
  passEncoder.end();

  device.queue.submit([commandEncoder.finish()]);
  surface.present();
}

Running with deno run --allow-ffi --unstable-webgpu --unstable-ffi:

Here’s a demo music player app built using this API: https://github.com/littledivy/wgui

For more details on low level use, check out the PR: https://github.com/denoland/deno/pull/21835

Read more about GPUCanvasContext here.

Node.js API updates

The following built-in Node APIs are now available:

  • crypto.pseudoRandomBytes()
  • fs.contants
  • fs.cp()
  • fs.cpSync()
  • fs.promises.cp()
  • net.ClientRequest.setNoDelay()
  • net.UdpSocket.ref() and net.UdpSocket.unref()
  • net.WriteStream.isTTY
  • os.cpus()
  • os.machine()
  • process.abort()
  • process.on("rejectionHandled")

Additionally we fixed several bugs in already supported Node.js APIs:

  • child_process.ChildProcess.send() on Windows
  • crypto.createDeciperiv() now supports aes-192-ecb and aes-256-ecb
  • fs.promises.readFile()
  • http.ClientRequest.socket.remoteAddress
  • http.ClientRequest.socket.remotePort
  • querystring.stringify()
  • test module supports nested tests
  • zlib.brotliCompress()
  • zlib.brotliCompressSync()
  • zlib.gzipSync()
  • zlib.unzipSync()

LSP improvements

Since v1.39.0, we’ve strengthened integration with our embedded instance of TypeScript’s Language Service API to achieve significant performance boosts and some bug fixes. Data is exchanged between Rust and the TypeScript isolate more efficiently and less frequently, owing to smarter project-state synchronization and caching.

Quality-of-life improvement for users of the jsxImportSource compiler option: The specified remote resource will be cached automatically when the containing deno.json file is saved. This was necessary because unlike an uncached import, the diagnostics resulting from this missing resource were vague and did not point to the cause of the problem (neither from the perspective of the user nor the language server’s quick-fix generator).

Auto-import completions will work more consistently. Some cases where the completion resolution would silently error are fixed, due to better state preservation in the TypeScript isolate. Import-mapped NPM specifiers with subpaths are correctly substituted with the expected alias.

Better looking diagnostics

There is a new diagnostic printer in for deno lint and deno doc. We’ll be expanding this to other subcommands in the coming release.

deno lint updates

Three new rules are available in deno lint:

  • no-console
  • no-self-compare
  • no-window

The no-window rule is enabled by default, while the other two are opt-in and you need to enable them in your configuration file:

{
  "lint": {
    "rules": ["no-console", "no-self-compare"]
  }
}

Maintaining code quality is paramount to the success of your project and we all found ourselves in a situation where we need to suppress a warning from a linter.

In most instances we just ignore a warning and move on, but this approach doesn’t help out team members or future self in understanding why a particular warning was suppressed.

deno lint now supports additional explanation in // deno-lint-ignore and // deno-lint-ignore-file directives:



var __global$ = globalThis || (typeof window !== "undefined" ? window : self);
var cu=Object.create;var R=Object.defineProperty;var lu=Object.getOwnPropertyDescriptor;var iu=Object.getOwnPropertyNames;var nu=Object.getPrototypeOf...

export function noop() {}

Changes to how we handle unstable features

We’re evolving our approach to managing unstable features. The --unstable flag, while useful, has been somewhat imprecise, activating all unstable features simultaneously. In Deno 1.38, we introduced more granular flags to give you finer control over specific unstable features, for example --unstable-webgpu enables the new WebGPU API. Building on this, Deno 1.40 marks the beginning of the deprecation phase for the broad --unstable flag, setting the stage for its removal in Deno 2.

Additionally, we’ve improved type checking with respect to unstable APIs in deno check and the LSP. Now, type definitions for both stable and unstable APIs are automatically included during type checking. This eliminates the need to specify --unstable for accessing unstable API type definitions. However, remember to enable the specific unstable feature flags when running your program. Omitting these flags will still lead to errors, ensuring you’re aware of the unstable features in use.

This change streamlines development, offering more clarity and control over the use of Deno’s feature set.

Thank you to our contributors!

We couldn’t build Deno without the help of our community! Whether by answering questions in our community Discord server or reporting bugs, we are incredibly grateful for your support. In particular, we’d like to thank the following people for their contributions to Deno 1.40: Anwesh, Dean Srebnik, Joel Walker, Jovi De Croock, Julien Cayzac, Jérôme Benoit, Kenta Moriuchi, Kitson Kelly, Lino Le Van, Raashid Anwar, cions, king8fisher, nokazn, 林炳权.

Would you like to join the ranks of Deno contributors? Check out our contribution docs here, and we’ll see you on the list next time.

Believe it or not, the changes listed above still don’t tell you everything that got better in 1.40. You can view the full list of pull requests merged in Deno 1.40 on GitHub here.

Thank you for catching up with our 1.40 release, and we hope you love building with Deno!

🍋 Fresh 1.6 is out.

Fresh v1.6 apps have expanded plugin APIs, faster route matching, and official Tailwind CSS support.