noraneko · drops

dl.f3liz.casa/drop を読んでいます

undo-closed-tab

閉じたタブを戻すボタンを、ツールバーに一つ

uuid 812dbda7-0729-469e-8a9b-901a5047ccaa

install

Press inside noraneko. It catches the link, opens its settings with this uuid, downloads the xpi, checks the sha256 and the registry's signature, and shows you everything below again before anything runs.

install in noraneko In another browser this is a plain link to the xpi. Stock Firefox will refuse it as unverified; paste the uuid into about:nora:settings in noraneko instead.

who

gh/nyanrus

what is served

undo-closed-tab · undo-closed-tab@noraneko.app · version 1.2.0 · 24149 bytes sha256 e5876c841d6ac9bf7dd46133cf2919192ee06f1f3e50c9f62cc3726099c097d3 built from drops/undo-closed-tab/src @ 59b96c854c (2026-09-14T07:24:00Z) served at https://dl.f3liz.casa/drop/812dbda7-0729-469e-8a9b-901a5047ccaa/

in the registry

drops/undo-closed-tab/ @ 59b96c854c — この版が出てきた木 actors: undo-closed-tab

the source, as it is

These come from source.json next to the manifest — the same text the xpi carries under source/, and dl checks its sha256 against the signed manifest before handing it over. Not a copy of the repository: what you read and what runs came out of the same build. 5 files; press one to open it.

_shared/defineActor.ts · 118 lines
// SPDX-License-Identifier: MPL-2.0

// Authoring surface for an "actor": a small xpi whose page side is a
// JSWindowActor (the same shape as Firefox's own about:newtab add-on). Each
// actor lives in one file that exports three things by name:
//
//   export const meta    = { id, namespace, matches, ... };
//   export const parent  = defineParent({ method(...) { ... } });  // main process (JSWindowActorParent)
//   export const content = defineContent((parent, ctx) => { ... }); // page side (run by JSWindowActorChild)
//
// The page side is NOT a WebExtension content script: content scripts are not
// injected into about:* / chrome:* documents in stock Firefox (see README,
// "addon 式が駄目だった理由"). The child actor loads content.js into the page's
// process with `window` / `document` on the scope chain, so the hook is written
// the same way, but it runs with the child actor's privileges.
//
// Named exports (rather than one nested object) are deliberate: the build
// bundles `parent` and `content` into separate outputs, and named exports let
// the bundler tree-shake each side so the content bundle never drags in the
// parent's privileged code and vice versa.
//
// IMPORTANT: the module top level must be pure. Reference Firefox globals
// (Services, ChromeUtils, window, exportFunction, browser) only *inside* method
// or hook bodies — the build imports this file under Deno to read `meta`, and
// top-level use of those globals would throw there.

export interface ActorMeta {
  /** Extension id, e.g. "settings-bridge@noraneko.app". */
  id: string;
  /** Extension version. */
  version: string;
  /** Experiment-API namespace, e.g. "noraSettings". Also the message channel. */
  namespace: string;
  /** Match patterns for the pages the content hook runs in (JSWindowActor `matches`). */
  matches: string[];
  /**
   * When the content hook runs. Maps to a child actor event:
   * document_start → DOMDocElementInserted, document_end → DOMContentLoaded,
   * document_idle → load. Defaults to "document_end".
   */
  runAt?: "document_start" | "document_end" | "document_idle";
  /**
   * JSWindowActor name. Defaults to "Nora" + PascalCase(<dir>), e.g. NoraNewtab.
   * A drop with the same actor name replaces the built-in one (unregister → register).
   */
  actor?: string;
  /** Legacy JSActor (BrowserGlue) this one replaces; it is unregistered when this actor is registered. */
  replaces?: string;
}

import type { Io } from "./io.ts";

type ParentMethods = Record<string, (...args: any[]) => unknown>;

export interface ContentCtx {
  /** True in dev builds (import.meta.env.MODE === "dev"). */
  dev: boolean;
  /** Expose functions on the page window (via exportFunction). */
  expose(funcs: Record<string, (...args: any[]) => unknown>): void;
  /**
   * Run when this actor goes away in this window (the drop is removed or
   * replaced). Put back what the hook changed: DOM, observers, listeners.
   */
  onDestroy(fn: () => void): void;
  /**
   * Place things through these (DOM, styles, listeners, pref observers) and
   * they are taken out again by themselves: each verb puts its way back on
   * the same ledger as onDestroy.
   */
  io: Io;
  /** This actor's own files: `${ctx.base}ops/x.tsubaki` and the like. */
  base: string;
  /**
   * The actor's logic in Tsubaki (when it ships wasm/): run a .tsubaki file of
   * its own with load("ops/x.tsubaki"), then call(name, ...args). Values cross
   * as ordinary JS values; a Tsubaki error is a JS Error. undefined without wasm/.
   *
   * Every verb answers with a Promise, because for an actor of the browser
   * WINDOW the logic lives a process away (wasm can't compile in the parent
   * process, so it runs in a hidden page of this window instead). A drop never
   * has to know which side it got.
   */
  ops: Ops | undefined;
}

export interface Ops {
  ready: Promise<void>;
  call(name: string, ...args: unknown[]): Promise<unknown>;
}

/** Proxy to the parent methods; each call is forwarded to the main process. */
type ParentProxy<T extends ParentMethods> = {
  [K in keyof T]: (...args: Parameters<T[K]>) => Promise<Awaited<ReturnType<T[K]>>>;
};

export type ContentHook<T extends ParentMethods = ParentMethods> = (
  parent: ParentProxy<T>,
  ctx: ContentCtx,
) => void;

// Identity helpers that pin types for authoring:
//
//   export const parent  = defineParent({ method(...) { ... } });
//   export const content = defineContent<typeof parent>((parent, ctx) => { ... });
//
// They are listed in the build's treeshake.manualPureFunctions, so an unused
// call (e.g. defineContent in the parent bundle) is dropped along with anything
// it references (birpc). Without that, the bundler would keep the call for its
// possible side effects and the unused side would not tree-shake.

/** Pins the parent-method types so the content hook's proxy is typed. */
export const defineParent = <T extends ParentMethods>(methods: T): T => methods;

/** Pins the content hook against the parent's method types. */
export const defineContent = <T extends ParentMethods>(
  hook: ContentHook<T>,
): ContentHook<T> => hook;
undo-closed-tab/actor.ts · 29 lines
// SPDX-License-Identifier: MPL-2.0
// GENERATED by build.ts. この drop の actor は Tsubaki で書かれている:
// 直すのは ops/Style.tsubaki / ops/undo-closed-tab.tsubaki と drop.toml の [actor]。
//
// 殻は lib の std-actor。logic が答える三つの door(setup / start / dispatch)
// を呼んで、返ってきた view を描き、effects を carry out する。殻の bytes は
// その lib に一枚だけあって、ここには入らない(この drop に残るのは、下の宣言だけ)。

import { defineContent, defineParent, type ActorMeta } from "../_shared/defineActor.ts";
import { runTsubakiActor } from "std-actor";

export const meta: ActorMeta = {
  "id": "undo-closed-tab@noraneko.app",
  "version": "1.2.0",
  "namespace": "noraUndoClosedTab",
  "matches": [
    "chrome://browser/content/browser.xhtml"
  ],
  "runAt": "document_end"
};

export const parent = defineParent({});

export const content = defineContent<typeof parent>((_parent, ctx) => {
  runTsubakiActor(ctx, {"prefs":[],"keys":[],"commands":["restore-last-tab"],"browserPages":[],"menus":[],"tabs":"","tabMarks":false,"tabValues":false,"windowValues":false,"prompt":false,"currentUrl":false,"openUrl":false,"webFrame":false,"chromeStyle":false,"ownPrefix":"noraneko.undo-closed-tab.","name":"undo-closed-tab","uuid":"812dbda7-0729-469e-8a9b-901a5047ccaa","strings":{"en":{"label":"Reopen closed tab","tooltip":"Reopen the tab you closed last"},"ja":{"label":"閉じたタブを戻す","tooltip":"さっき閉じたタブを、もう一度開く"}}}).catch((e) =>
    console.error("[undo-closed-tab] failed:", e)
  );
});
undo-closed-tab/ops/Style.tsubaki · 16 lines
# SPDX-License-Identifier: MPL-2.0
#
# ボタン一つぶん。字ではなくデータで、CSS にするのは殻(_shared/style.ts)。
# 生の CSS は出していないので、chrome_style の宣言も要らない。
#
# 色は決めない。`-moz-context-properties: fill` と `fill: currentColor` を
# 置いておけば、絵はツールバーの字の色で塗られる -- 明るい / 暗いの切り替えも、
# ブラウザのほうでしてくれる。

module Style
    button() = Dict(
        :_moz_context_properties => :fill,
        :fill => :currentColor,
    )
end
undo-closed-tab/ops/undo-closed-tab.tsubaki · 45 lines
# SPDX-License-Identifier: MPL-2.0
#
# undo-closed-tab: 閉じたタブを戻すボタン。
#
# この drop の全部が、ここに書いてある。押されたら命令を一つ出す -- state も、
# pref も、style の一枚も無い。
#
# **置き場所を、この drop は知らない。** `at: "toolbar"` と言うと殻が
# CustomizableUI の widget を一つ作って、入れた人が customize mode で動かした
# 場所をブラウザが覚える。drop が言えるのは「最初は nav-bar に」だけで、その後
# どこに居るのかは訊けない。減らした機能ではなく、そういう約束 -- 位置は
# 入れた人のもの。
#
# Floorp のほうは 95 行あって、その差はだいたい三つ: widget の作りかた(殻に
# 上がった)、i18n の observer(殻に上がった)、tooltip の要素を手で作って
# #mainPopupSet に足すところ(ここでは tooltiptext 一つ)。

import Style

setup() = Setup(
    anchors = [Anchor(at = "toolbar", area = "nav-bar", id = "nora-undo-closed-tab")]
)

# 押されたこと。それだけ
struct Undo end

view() = el("toolbarbutton", Dict(
    "id" => "nora-undo-closed-tab-button",
    "class" => "toolbarbutton-1 chromeclass-toolbar-additional",
    "label" => t(:label),
    "tooltiptext" => t(:tooltip),
    "image" => "chrome://global/skin/icons/undo.svg",
    "style" => Style.button(),
    "on:command" => Undo()
))

start(facts) = frame(view())

function dispatch(a)
    if get(a, :__type, "") != "Undo"
        error("undo-closed-tab: no action named " * get(a, :__type, ""))
    end
    return frame(view(), [DoCommand("restore-last-tab")])
end
undo-closed-tab/strings.toml · 8 lines
[en]
label = "Reopen closed tab"
tooltip = "Reopen the tab you closed last"

[ja]
label = "閉じたタブを戻す"
tooltip = "さっき閉じたタブを、もう一度開く"

What a drop is, how it reaches you, and what it is not: f3liz.casa/noraneko/drops/. Served by https://dl.f3liz.casa/drop, signed by https://github.com/f3liz-casa/noraneko-registry/.github/workflows/verify-and-sign.yml@refs/heads/main.

This page is built when you ask for it, out of what https://dl.f3liz.casa/drop is serving right now (2026-09-23T08:38:28.032Z). Drafted by Shiro, an AI assistant, sitting next to nyanrus.