@freenetorg/freenet-stdlib

中文文档
0.4.0发布于 2026/09/01MIT+APACHE-2.0TypeScriptCommonJS近 30 天下载 2930

Freenet standard library and utils

原始使用文档

Locutus Javascript/Typescript Std Lib

Locutus Javascript/Typescript Standard Library contains utilities for developing web apps which interact with Locutus node.

The stdlib offers a series of facilities in which you will be able to communicate with the network ergonomically.

Here is a minimal example of how you could write your application to interact with the node:

import {
  GetResponse,
  HostError,
  Key,
  FreenetWsApi,
  PutResponse,
  UpdateNotification,
  UpdateResponse,
} from "@freenetorg/freenet-stdlib/websocket-interface";

const handler = {
  onPut: (_response: PutResponse) => {},
  onGet: (_response: GetResponse) => {},
  onUpdate: (_up: UpdateResponse) => {},
  onUpdateNotification: (_notif: UpdateNotification) => {},
  onErr: (err: HostError) => {},
  onOpen: () => {},
};

const API_URL = new URL(`ws://${location.host}/contract/command/`);
const locutusApi = new FreenetWsApi(API_URL, handler);

const CONTRACT = "DCBi7HNZC3QUZRiZLFZDiEduv5KHgZfgBk8WwTiheGq1";

async function loadState() {
  let getRequest = {
    key: Key.fromSpec(CONTRACT),
    fetch_contract: false,
  };
  await locutusApi.get(getRequest);
}

版本与发布记录

@freenetorg/freenet-stdlib 共发布 8 个版本,首次发布于 2023/09/19;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.4.0latest2026/09/012 个月前
0.3.02026/06/274 个月前
0.2.02026/04/236 个月前
0.0.82023/09/273 年前
0.0.72023/09/273 年前
0.0.62023/09/263 年前

关于 @freenetorg/freenet-stdlib 的常见问题

@freenetorg/freenet-stdlib 是什么?

Freenet standard library and utils

如何安装 @freenetorg/freenet-stdlib?

在项目目录运行 npm install @freenetorg/freenet-stdlib,或使用 pnpm add / yarn add / bun add。

@freenetorg/freenet-stdlib 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@freenetorg/freenet-stdlib 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@freenetorg/freenet-stdlib 可以商用吗?

@freenetorg/freenet-stdlib 使用 MIT+APACHE-2.0 许可。声明的许可为 MIT+APACHE-2.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@freenetorg/freenet-stdlib 的下载量有多少?

根据 npm 官方下载统计,@freenetorg/freenet-stdlib 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,930 次,日均约 98 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@freenetorg/freenet-stdlib 还在维护吗?

最新版本 0.4.0 发布于 2026/09/01(2 个月前);至今共发布 8 个版本,其中过去 12 个月发布了 3 个;首次发布于 2023/09/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。