noraneko · drops

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

hello-tsubaki

actor まで Tsubaki で書いた、いちばん小さい drop(ツールバーの数字。押すと増えて、pref に残る)

uuid 1da7ff69-3500-4bdc-b838-029dfce35a34

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

hello · hello-tsubaki@noraneko.app · version 1.2.0 · 33922 bytes sha256 15a6d4e563940cdb6e106feba116d4d9e7f9ff1aea78b66b65d1449b341c90aa built from drops/hello-tsubaki/src @ 59b96c854c (2026-09-14T07:24:00Z) served at https://dl.f3liz.casa/drop/1da7ff69-3500-4bdc-b838-029dfce35a34/

in the registry

drops/hello-tsubaki/ @ 59b96c854c — この版が出てきた木 actors: hello

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. 3 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;
hello/actor.ts · 29 lines
// SPDX-License-Identifier: MPL-2.0
// GENERATED by build.ts. この drop の actor は Tsubaki で書かれている:
// 直すのは ops/main.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": "hello-tsubaki@noraneko.app",
  "version": "1.2.0",
  "namespace": "noraHelloTsubaki",
  "matches": [
    "chrome://browser/content/browser.xhtml"
  ],
  "runAt": "document_end"
};

export const parent = defineParent({});

export const content = defineContent<typeof parent>((_parent, ctx) => {
  runTsubakiActor(ctx, {"prefs":["noraneko.hello.count"],"keys":[],"commands":[],"browserPages":[],"menus":[],"tabs":"","tabMarks":false,"tabValues":false,"windowValues":false,"prompt":false,"currentUrl":false,"openUrl":false,"webFrame":false,"chromeStyle":true,"ownPrefix":"noraneko.hello-tsubaki.","name":"hello-tsubaki","uuid":"1da7ff69-3500-4bdc-b838-029dfce35a34","strings":{}}).catch((e) =>
    console.error("[hello] failed:", e)
  );
});
hello/ops/main.tsubaki · 89 lines
# SPDX-License-Identifier: MPL-2.0
#
# actor まで Tsubaki で書いた drop。この file と drop.toml の [actor] のほかには、
# 何も無い(JS は一行も書いていない。build が、どの drop でも同じ殻を着せる)。
#
# 殻が訊いてくるのは三つ:
#
#   setup()           どこに置くか、style、見ていてほしい pref
#   start(facts)      最初の一枚(facts = もう本当だったこと。prefs と url)
#   dispatch(action)  次の一枚と、してほしいこと
#
# VNode / frame / SetPref は std のことば(std-tsubaki-runtime の ops/std.tsubaki)。

PREF = "noraneko.hello.count"

setup() = Dict(
    "anchor" => Dict("at" => "parent", "selector" => "#nav-bar", "tag" => "hbox", "id" => "nora-hello"),
    "style" => "#nora-hello { flex: 0 0 auto; align-items: center; margin-inline: 6px; } #nora-hello label { white-space: nowrap; padding: 2px 8px; border-radius: 6px; background: color-mix(in srgb, currentColor 12%, transparent); }",
    "prefs" => [PREF]
)

@kwdef struct AppState
    count = 0
end

STATE = AppState()

# --- view ---------------------------------------------------------------------

# ツールバーの toolbarbutton は label を隠すので、素の XUL の label に置いた
view(s) = el("label", Dict(
    "value" => "hello " * string(s.count),
    "tooltiptext" => PREF,
    "on:click" => Bump()
))

# --- actions ------------------------------------------------------------------

struct Bump end

"about:config で数を書き換えられたとき、殻が投げてくる"
struct PrefChanged
    name
    value
end

action_of(a) = begin
    kind = get(a, :__type, "")
    if kind == "Bump"
        Bump()
    elseif kind == "PrefChanged"
        PrefChanged(get(a, :name, ""), get(a, :value, 0))
    else
        error("hello: no action named " * kind)
    end
end

# --- update -------------------------------------------------------------------

update(s::AppState, a::Bump) = begin
    n = s.count + 1
    Step(AppState(count = n), [SetPref(PREF, n)])
end

update(s::AppState, a::PrefChanged) = begin
    n = a.value === nothing ? 0 : a.value
    Step(AppState(count = n), [])
end

struct Step
    state
    effects
end

# --- the doors ----------------------------------------------------------------

function start(facts)
    prefs = get(facts, :prefs, Dict())
    held = get(prefs, PREF, 0)
    STATE = AppState(count = held === nothing ? 0 : held)
    return frame(view(STATE))
end

function dispatch(a)
    st = update(STATE, action_of(a))
    STATE = st.state
    return frame(view(STATE), st.effects)
end

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.