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

推荐订阅源

Know Your Adversary
Know Your Adversary
C
CERT Recently Published Vulnerability Notes
V
Vulnerabilities – Threatpost
N
News | PayPal Newsroom
O
OpenAI News
A
About on SuperTechFans
月光博客
月光博客
Martin Fowler
Martin Fowler
L
LangChain Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V2EX - 技术
V2EX - 技术
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
人人都是产品经理
人人都是产品经理
T
Tor Project blog
D
DataBreaches.Net
Cloudbric
Cloudbric
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
云风的 BLOG
云风的 BLOG
F
Full Disclosure
S
SegmentFault 最新的问题
Vercel News
Vercel News
T
Tailwind CSS Blog
Schneier on Security
Schneier on Security
宝玉的分享
宝玉的分享
M
MIT News - Artificial intelligence
博客园 - 【当耐特】
P
Privacy International News Feed
美团技术团队
S
Secure Thoughts
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
Scott Helme
Scott Helme
Forbes - Security
Forbes - Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recent Announcements
Recent Announcements
AWS News Blog
AWS News Blog
Stack Overflow Blog
Stack Overflow Blog
S
Security Affairs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
T
Tenable Blog
Cyberwarzone
Cyberwarzone
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
J
Java Code Geeks
T
Threatpost

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
Fresh 1.2 – welcoming a full-time maintainer, sharing state between islands, limited npm support, and more | Deno
Luca Casonat · 2023-06-15 · via Deno

It’s been almost a year since we introduced Fresh 1.0, a modern, Deno-first, edge-native full stack web framework. It embraces modern developments in tooling and progressive enhancement, using server-side just-in-time rendering and client hydration using islands. Fresh sends 0KB of JavaScript to the client by default. Since last year, Fresh has seen tremendous growth, becoming one of the top starred frontend projects in GitHub.

However, there’s been one elephant in the room - is Fresh something that the Deno team is actually committed to maintaining? When you’ve asked, we’ve always said “Yes!”, but reality was more complicated. We started April with over 60 open (and unreviewed) pull requests on the Fresh repo - we were not keeping up with maintenance to the level you’re used to from the Deno runtime project. A lot of this boiled down to me not having enough time to focus on Fresh.

We saw the first signs of this around the end of last year - so we started looking for someone to replace me as the primary maintainer of Fresh. Long story short, find we did. I’m ecstatic to announce that Marvin Hagemeister has joined the Deno company and will lead the Fresh project full-time moving forward. In case you don’t already know who Marvin is: he is a maintainer of Preact, builder of Preact DevTools, and speeder upper of the JavaScript ecosystem (just this year he sped up npm scripts from 400ms overhead to 22ms!). Give him a follow if you haven’t already.

The future of Fresh looks brighter than ever. In the coming months, you can expect significant improvements to usability, features, performance, and project maintenance. We’re still working out the exact roadmap for our plans going forward, which we’ll share once it’s ready.

For now, let’s dive into the highlight features of Fresh 1.2:

  • Passing signals, Uint8Arrays, and circular data in island props
  • Passing JSX to islands and nesting islands within each other
  • Limited support for npm: specifiers
  • Support for custom HEAD handlers
  • Status and header override for HandlerContext.render
  • Subdirectories in the ./islands folder
  • Async plugin rendering
  • Simplified testing of Fresh projects

To create a new Fresh project, run:

$ deno run -A -r https://fresh.deno.dev my-app

To update your project to the latest version of Fresh, run the update script from the root of your project:

$ deno run -A -r https://fresh.deno.dev/update .

Don’t have Deno installed yet? Install it now.

Passing signals, Uint8Arrays, and circular data in island props

At the core of Fresh’s design are islands: individual components rendered on both server and client. (All other JSX in Fresh is just rendered on the server.) To make it easy to “resume” with the client render after performing the initial server render, users can pass props to islands, just like they can with all other components.

Starting today, users can pass circular objects, Uint8Array, or Preact Signals to islands in addition to all existing JSON serializable values. This unlocks a bunch of new use cases, such as passing the same signal to multiple islands and using that signal to share state between these islands:


import { useSignal } from "@preact/signals";
import Header from "../islands/Header.tsx";
import AddToCart from "../islands/AddToCart.tsx";

export default function Page() {
  const cart = useSignal<string[]>([]);
  return (
    <div>
      <Header cart={cart} />
      <div>
        <h1>Lemon</h1>
        <p>A very fresh fruit.</p>
        <AddToCart cart={cart} id="lemon" />
      </div>
    </div>
  );
}


import { Signal } from "@preact/signals";

export default function Header(props: { cart: Signal<string[]> }) {
  return (
    <header>
      <span>Fruit Store</span>
      <button>Open cart ({props.cart.value.length})</button>
    </header>
  );
}


import { Signal } from "@preact/signals";

export default function AddToCart(props: {
  cart: Signal<string[]>;
  id: string;
}) {
  function add() {
    props.cart.value = [...props.cart.value, id];
  }
  return <button onClick={add}>Add to cart</button>;
}

Up to now, the props passed to islands had to be JSON serializable so they could be serialized on the server, sent to the client over HTTP, and deserialized in the browser. This JSON serialization meant that many kinds of objects could not be serialized: for example circular structures, Uint8Array, or Preact Signals.

Passing JSX to islands and nesting islands within each other

To do one better, we added support for passing JSX children to islands. They can even be nested within each other, if you desire. This allows you to mix dynamic and static parts in a way that’s best for your app.


import MyIsland from "../islands/my-island.tsx";

export default function Home() {
  return (
    <MyIsland>
      <p>This text is rendered on the server</p>
    </MyIsland>
  );
}

In the browser, we can deduce that the <p>-element was passed as children to the MyIsland from the HTML alone. This keeps your site lean and lightweight, because we don’t need any additional information other than the HTML that we need to render anyway.

Similarily, we now detect when you nest an island within another one. Whenever that occurs, we’ll treat the inner island like a standard Preact component.


import MyIsland from "../islands/my-island.tsx";
import OtherIsland from "../islands/other-island.tsx";

export default function Home() {
  return (
    <MyIsland>
      <OtherIsland>
        <p>This text is rendered on the server</p>
      </OtherIsland>
    </MyIsland>
  );
}

In the future, we’re hoping to experiment more with allowing nested islands to be lazily initialized instead. So stay tuned!

If you’re interested in the internal implementation details we recommend you to check out the pull request that made it possible: https://github.com/denoland/fresh/pull/1285 .

Limited support for npm: specifiers

Importing npm: packages is now supported in Fresh, both during server rendering and for islands. No local node_modules/ folder is required to use npm: specifiers — just like you are used to from Deno.


import isNumber from "npm:is-number";

export const handler = {
  async GET(req) {
    const input = await req.json();
    return Response.json(isNumber(input));
  },
};

Note that Deno Deploy does not currently support npm: specifiers, so they can not be used when deploying Fresh applications to Deno Deploy. You can expect support for npm: specifiers in Deno Deploy soon. For now, you can use npm: specifiers when deploying Fresh to a VPS or via Docker to a service like Fly.io.

Support for custom HEAD handlers

It’s now possible to declare a handler for HEAD requests in routes. Previously, routes used a default implementation with a GET handler for HEAD requests, omitting the body. This behaviour still works, but can be overridden by passing a custom function for HEAD requests.


export const handler = {
  async HEAD(_req, ctx) {
    const headers = await fileHeaders(ctx.params.id);
    return new Response(null, { headers });
  },
  async GET(_req, ctx) {
    const headers = await fileHeaders(ctx.params.id);
    const body = await fileBody(ctx.params.id);
    return new Response(body, { headers });
  },
};

Thank you to Kamil Ogórek for the contribution.

Status and header override for HandlerContext.render

It’s now possible to set the status and headers of a Response created via ctx.render — for example, if you’d like to respond with an HTML page that has status code 400, you can now do:


export const handler = {
  async GET(req, ctx) {
    const url = new URL(req.url);
    const user = url.searchParams.get("user");
    if (!user) {
      return ctx.render(null, {
        status: 400,
        headers: { "x-error": "missing user" },
      });
    }
    return ctx.render(user);
  },
};

Subdirectories in the ./islands folder

Previously, all islands had to declared in files directly inside of the ./islands directory. Now, they can be contained in folders inside of the ./islands directory.

Thank you Asher Gomez for adding this feature.

Async plugin rendering

Fresh supports plugins, which can customize how a page is rendered. For example, the Twind plugin extracts Tailwind CSS classes out of the rendered page and generates a CSS style sheet for these classes.

So far these “render hooks” had to be synchronous. However, some use cases (like using UnoCSS) require async “render hooks”. Now, Fresh supports an renderAsync hook.

See the documentation for information on using the renderAsync hook: https://fresh.deno.dev/docs/concepts/plugins#hook-renderasync.

Thank you Tom for adding this to fresh.

Simplified testing of Fresh projects

$fresh/server.ts now exports a new createHandler function that can be used to create a handler function from your Fresh manifest that can be used for testing.

import { createHandler } from "$fresh/server.ts";
import manifest from "../fresh.gen.ts";
import { assert, assertEquals } from "$std/testing/asserts.ts";

Deno.test("/ serves HTML", async () => {
  const handler = await createHandler(manifest);

  const resp = await handler(new Request("http://127.0.0.1/"));
  assertEquals(resp.status, 200);
  assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
});

Read more on writing tests for Fresh projects in the docs: https://fresh.deno.dev/docs/examples/writing-tests

Thank you to Octo8080X for making testing easier.

What’s next

We’re thrilled to have a full-time maintainer to improve and grow Fresh. As always, if you have any questions, please let us know in Discord.

Don’t miss any updates — follow us on Twitter!