@fedify/botkit 0.3.0-dev.111 → 0.3.0-dev.113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bot.d.ts CHANGED
@@ -3,7 +3,7 @@ Date.prototype.toTemporalInstant = toTemporalInstant;
3
3
  import { Text } from "./text.js";
4
4
  import { Session } from "./session.js";
5
5
  import { CustomEmoji, DeferredCustomEmoji } from "./emoji.js";
6
- import { AcceptEventHandler, FollowEventHandler, LikeEventHandler, MentionEventHandler, MessageEventHandler, QuoteEventHandler, ReactionEventHandler, RejectEventHandler, ReplyEventHandler, SharedMessageEventHandler, UndoneReactionEventHandler, UnfollowEventHandler, UnlikeEventHandler } from "./events.js";
6
+ import { AcceptEventHandler, FollowEventHandler, LikeEventHandler, MentionEventHandler, MessageEventHandler, QuoteEventHandler, ReactionEventHandler, RejectEventHandler, ReplyEventHandler, SharedMessageEventHandler, UndoneReactionEventHandler, UnfollowEventHandler, UnlikeEventHandler, VoteEventHandler } from "./events.js";
7
7
  import { Repository } from "./repository.js";
8
8
  import { Context, Federation, KvStore, MessageQueue } from "@fedify/fedify/federation";
9
9
  import { Application, Application as Application$1, Image, Image as Image$1, Service, Service as Service$1 } from "@fedify/fedify/vocab";
@@ -116,6 +116,20 @@ interface Bot<TContextData> {
116
116
  * @since 0.2.0
117
117
  */
118
118
  onUnreact?: UndoneReactionEventHandler<TContextData>;
119
+ /**
120
+ * An event handler for a vote in a poll. This event is only triggered when
121
+ * the bot is the author of the poll, and the vote is made by another actor.
122
+ * If the poll allows multiple selections, this event is triggered multiple
123
+ * times, once for each option selected by the actor.
124
+ *
125
+ * Note that this event can be triggered even if the voter vote an option
126
+ * multiple times or multiple options for a poll that disallows multiple
127
+ * selections. You should validate the vote in the event handler by storing
128
+ * the votes in a persistent store, and checking if the vote is valid.
129
+ * (This behavior can subject to change in the future.)
130
+ * @since 0.3.0
131
+ */
132
+ onVote?: VoteEventHandler<TContextData>;
119
133
  }
120
134
  /**
121
135
  * A specialized {@link Bot} tpe that doesn't require context data.
package/dist/bot.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bot.d.ts","names":[],"sources":["../src/bot.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;UAqDiB;EAAA;;;;EAKgB,SAgBZ,UAAA,EAhBE,UAgBF,CAhBa,YAgBb,CAAA;EAAG;;;EAEZ,SAOkB,UAAA,EAAA,MAAA;EAAY;;;;;;;;EAwBJ,UAAE,CAAA,MAAA,EAAA,MAAA,GAjCnB,GAiCmB,EAAA,WAAA,EAhCvB,YAgCuB,CAAA,EA/BnC,OA+BmC,CA/B3B,YA+B2B,CAAA;EAAW;;;;;EACC,UAAtC,CAAA,OAAA,EAzBQ,OAyBR,CAzBgB,YAyBhB,CAAA,CAAA,EAzBgC,OAyBhC,CAzBwC,YAyBxC,CAAA;EAAM;;;;;;;EAeiB,KAKC,CAAA,OAAA,EApCrB,OAoCqB,EAAA,WAAA,EApCC,YAoCD,CAAA,EApCgB,OAoChB,CApCwB,QAoCxB,CAAA;EAAY;;;;;;;;;;;;EAiCV,eAA7B,CAAA,mBAAA,MAAA,CAAA,CAAA,MAAA,EAtDC,QAsDD,CAtDU,MAsDV,CAtDiB,UAsDjB,EAtD6B,WAsD7B,CAAA,CAAA,CAAA,EArDN,QAqDM,CArDG,MAqDH,CArDU,UAqDV,EArDsB,mBAqDtB,CArD0C,YAqD1C,CAAA,CAAA,CAAA;EAAgB;;;EAWkB,QAAjC,CAAA,EA3DC,kBA2DD,CA3DoB,YA2DpB,CAAA;EAAoB;;AAMQ;EAMvB,UAAA,CAAA,EAlEF,oBAkEyB,CAlEJ,YAkEI,CAAA;EAAA;;;EAY5B,cAOU,CAAA,EAhFH,kBAgFG,CAhFgB,YAgFhB,CAAA;EAAO;;;EAQc,cAQ1B,CAAA,EA3FE,kBA2FF,CA3FqB,YA2FrB,CAAA;EAAO;;;EAnC2B,SAAA,CAAA,EAnDrC,mBAmDq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,CAAA,EA9NU,kBA8NV,CA9N6B,YA8N7B,CAAA;EAAY;;;AAA4C;YAxN/C,qBAAqB;;;;;cAMnB,2BAA2B;;;;;;;;;;;;;;WAe9B,iBAAiB;;;;;UAMX,sBAAA,SAA+B;;;;;;;;;8BAU3B,yBAEhB;;;;;;sBAOiB,gBAAgB;;;;;;;8BAQR,MAAM;;;;;;;iBAQnB,UAAU,QAAQ;;;;;UAMlB;;;;;;;;;;;;;;;0BAgBS,mBAAiB;;;;;;;;;;;;;qBAgBtB,cAAc;;;;kBAKjB,MAAM;;;;;mBAML,MAAM;;;;;wBAMD,eAAe,yBAAyB;;;;;;;;;;;;;;;eAiBjD;;;;;wBAMS;;;;;;mBAOL;;;;;sBAMG;;;;;;;;;;;;;mBAeH;;;;;UAMF,YAAA;;;;;;;;;;;;;;;;;;iBAwCD,wCACL,iBAAiB,gBACzB,4BAA4B,yBAAyB,IAAI"}
package/dist/bot.js CHANGED
@@ -108,6 +108,12 @@ function createBot(options) {
108
108
  },
109
109
  set onUnreact(value) {
110
110
  bot.onUnreact = value;
111
+ },
112
+ get onVote() {
113
+ return bot.onVote;
114
+ },
115
+ set onVote(value) {
116
+ bot.onVote = value;
111
117
  }
112
118
  };
113
119
  return wrapper;
package/dist/bot.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bot.js","names":["options: CreateBotOptions<TContextData>","b?","emojis: Readonly<Record<TEmojiName, CustomEmoji>>"],"sources":["../src/bot.ts"],"sourcesContent":["// BotKit by Fedify: A framework for creating ActivityPub bots\n// Copyright (C) 2025 Hong Minhee <https://hongminhee.org/>\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as\n// published by the Free Software Foundation, either version 3 of the\n// License, or (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport type {\n Context,\n Federation,\n KvStore,\n MessageQueue,\n} from \"@fedify/fedify/federation\";\nimport type { Software } from \"@fedify/fedify/nodeinfo\";\nimport type { Application, Image, Service } from \"@fedify/fedify/vocab\";\nimport { BotImpl } from \"./bot-impl.ts\";\nimport type { CustomEmoji, DeferredCustomEmoji } from \"./emoji.ts\";\nimport type {\n AcceptEventHandler,\n FollowEventHandler,\n LikeEventHandler,\n MentionEventHandler,\n MessageEventHandler,\n QuoteEventHandler,\n ReactionEventHandler,\n RejectEventHandler,\n ReplyEventHandler,\n SharedMessageEventHandler,\n UndoneReactionEventHandler,\n UnfollowEventHandler,\n UnlikeEventHandler,\n} from \"./events.ts\";\nimport type { Repository } from \"./repository.ts\";\nimport type { Session } from \"./session.ts\";\nimport type { Text } from \"./text.ts\";\nexport {\n parseSemVer,\n type SemVer,\n type Software,\n} from \"@fedify/fedify/nodeinfo\";\nexport { Application, Image, Service } from \"@fedify/fedify/vocab\";\n\n/**\n * A bot that can interact with the ActivityPub network.\n */\nexport interface Bot<TContextData> {\n /**\n * An internal Fedify federation instance. Normally you don't need to access\n * this directly.\n */\n readonly federation: Federation<TContextData>;\n\n /**\n * The internal identifier for the bot actor. It is used for the actor URI.\n */\n readonly identifier: string;\n\n /**\n * Gets a new session to control the bot for a specific origin and context\n * data.\n * @param origin The origin of the session. Even if a URL with some path or\n * query is passed, only the origin part will be used.\n * @param contextData The context data to pass to the federation.\n * @returns The session for the origin and context data.\n */\n getSession(\n origin: string | URL,\n contextData: TContextData,\n ): Session<TContextData>;\n\n /**\n * Gets a new session to control bot for a specific Fedify context.\n * @param context The Fedify context of the session.\n * @returns The session for the Fedify context.\n */\n getSession(context: Context<TContextData>): Session<TContextData>;\n\n /**\n * The fetch API for handling HTTP requests. You can pass this to an HTTP\n * server (e.g., `Deno.serve()`, `Bun.serve()`) to handle incoming requests.\n * @param request The request to handle.\n * @param contextData The context data to pass to the federation.\n * @returns The response to the request.\n */\n fetch(request: Request, contextData: TContextData): Promise<Response>;\n\n /**\n * Defines custom emojis for the bot. The custom emojis are used for\n * rendering the bot's profile and posts. The custom emojis are defined\n * by their names, and the names are used as the keys of the emojis.\n * @param emojis The custom emojis to define. The keys are the names of\n * the emojis, and the values are the custom emoji definitions.\n * @returns The defined emojis. The keys are the names of the emojis, and\n * the values are the emoji objects, which are used for passing\n * to the {@link customEmoji} function.\n * @throws {TypeError} If any emoji name is invalid or duplicate.\n * @since 0.2.0\n */\n addCustomEmojis<TEmojiName extends string>(\n emojis: Readonly<Record<TEmojiName, CustomEmoji>>,\n ): Readonly<Record<TEmojiName, DeferredCustomEmoji<TContextData>>>;\n\n /**\n * An event handler for a follow request to the bot.\n */\n onFollow?: FollowEventHandler<TContextData>;\n\n /**\n * An event handler for an unfollow event from the bot.\n */\n onUnfollow?: UnfollowEventHandler<TContextData>;\n\n /**\n * An event handler invoked when a follow request the bot sent is accepted.\n */\n onAcceptFollow?: AcceptEventHandler<TContextData>;\n\n /**\n * An event handler invoked when a follow request the bot sent is rejected.\n */\n onRejectFollow?: RejectEventHandler<TContextData>;\n\n /**\n * An event handler for a message mentioned to the bot.\n */\n onMention?: MentionEventHandler<TContextData>;\n\n /**\n * An event handler for a reply to the bot.\n */\n onReply?: ReplyEventHandler<TContextData>;\n\n /**\n * An event handler for a quote of the bot's message.\n * @since 0.2.0\n */\n onQuote?: QuoteEventHandler<TContextData>;\n\n /**\n * An event handler for a message shown to the bot's timeline. To listen\n * to this event, your bot needs to follow others first.\n */\n onMessage?: MessageEventHandler<TContextData>;\n\n /**\n * An event handler for a message shared to the bot. To listen to this event,\n * your bot needs to follow others first.\n */\n onSharedMessage?: SharedMessageEventHandler<TContextData>;\n\n /**\n * An event handler for a like of a message.\n */\n onLike?: LikeEventHandler<TContextData>;\n\n /**\n * An event handler for an undoing of a like of a message.\n */\n onUnlike?: UnlikeEventHandler<TContextData>;\n\n /**\n * An event handler for an emoji reaction to a message.\n * @since 0.2.0\n */\n onReact?: ReactionEventHandler<TContextData>;\n\n /**\n * An event handler for an undoing of an emoji reaction to a message.\n * @since 0.2.0\n */\n onUnreact?: UndoneReactionEventHandler<TContextData>;\n}\n\n/**\n * A specialized {@link Bot} tpe that doesn't require context data.\n */\nexport interface BotWithVoidContextData extends Bot<void> {\n /**\n * Gets a new session to control the bot for a specific origin and context\n * data.\n * @param origin The origin of the session. Even if a URL with some path or\n * query is passed, only the origin part will be used.\n * @param contextData The context data to pass to the federation.\n * @returns The session for the origin and context data.\n */\n getSession(\n origin: string | URL,\n contextData: void,\n ): Session<void>;\n\n /**\n * Gets a new session to control bot for a specific Fedify context.\n * @param context The Fedify context of the session.\n * @returns The session for the Fedify context.\n */\n getSession(context: Context<void>): Session<void>;\n\n /**\n * Gets a new session to control the bot for a specific origin and context\n * data.\n * @param origin The origin of the session. Even if a URL with some path or\n * query is passed, only the origin part will be used.\n */\n getSession(origin: string | URL): Session<void>;\n\n /**\n * The fetch API for handling HTTP requests. You can pass this to an HTTP\n * server (e.g., `Deno.serve()`, `Bun.serve()`) to handle incoming requests.\n * @param request The request to handle.\n * @returns The response to the request.\n */\n fetch(request: Request): Promise<Response>;\n}\n\n/**\n * Options for creating a bot.\n */\nexport interface CreateBotOptions<TContextData> {\n /**\n * The internal identifier of the bot. Since it is used for the actor URI,\n * it *should not* be changed after the bot is federated.\n *\n * If omitted, `\"bot\"` will be used.\n * @default `\"bot\"`\n */\n readonly identifier?: string;\n\n /**\n * The type of the bot actor. It should be either `Service` or `Application`.\n *\n * If omitted, `Service` will be used.\n * @default `Service`\n */\n readonly class?: typeof Service | typeof Application;\n\n /**\n * The username of the bot. It will be a part of the fediverse handle.\n * It can be changed after the bot is federated.\n */\n readonly username: string;\n\n /**\n * The display name of the bot. It can be changed after the bot is federated.\n */\n readonly name?: string;\n\n /**\n * The description of the bot. It can be changed after the bot is federated.\n */\n readonly summary?: Text<\"block\", TContextData>;\n\n /**\n * The avatar URL of the bot. It can be changed after the bot is federated.\n */\n readonly icon?: URL | Image;\n\n /**\n * The header image URL of the bot. It can be changed after the bot is\n * federated.\n */\n readonly image?: URL | Image;\n\n /**\n * The custom properties of the bot. It can be changed after the bot is\n * federated.\n */\n readonly properties?: Record<string, Text<\"block\" | \"inline\", TContextData>>;\n\n /**\n * How to handle incoming follow requests. Note that this behavior can be\n * overridden by manually invoking {@link FollowRequest.accept} or\n * {@link FollowRequest.reject} in the {@link Bot.onFollow} event handler.\n *\n * - `\"accept\"` (default): Automatically accept all incoming follow requests.\n * - `\"reject\"`: Automatically reject all incoming follow requests.\n * - `\"manual\"`: Require manual handling of incoming follow requests.\n * @default `\"accept\"`\n */\n readonly followerPolicy?: \"accept\" | \"reject\" | \"manual\";\n\n /**\n * The underlying key-value store to use for storing data.\n */\n readonly kv: KvStore;\n\n /**\n * The underlying repository to use for storing data. If omitted,\n * {@link KvRepository} will be used.\n */\n readonly repository?: Repository;\n\n /**\n * The underlying message queue to use for handling incoming and outgoing\n * activities. If omitted, incoming activities are processed immediately,\n * and outgoing activities are sent immediately.\n */\n readonly queue?: MessageQueue;\n\n /**\n * The software information of the bot. If omitted, the NodeInfo protocol\n * will be unimplemented.\n */\n readonly software?: Software;\n\n /**\n * Whether to trust `X-Forwarded-*` headers. If your bot application is\n * behind an L7 reverse proxy, turn it on.\n *\n * Turned off by default.\n * @default `false`\n */\n readonly behindProxy?: boolean;\n\n /**\n * The options for the web pages of the bot. If omitted, the default options\n * will be used.\n */\n readonly pages?: PagesOptions;\n}\n\n/**\n * Options for the web pages of the bot.\n */\nexport interface PagesOptions {\n /**\n * The color of the theme. It will be used for the theme color of the web\n * pages. The default color is `\"green\"`.\n * @default `\"green\"`\n */\n readonly color?:\n | \"amber\"\n | \"azure\"\n | \"blue\"\n | \"cyan\"\n | \"fuchsia\"\n | \"green\"\n | \"grey\"\n | \"indigo\"\n | \"jade\"\n | \"lime\"\n | \"orange\"\n | \"pink\"\n | \"pumpkin\"\n | \"purple\"\n | \"red\"\n | \"sand\"\n | \"slate\"\n | \"violet\"\n | \"yellow\"\n | \"zinc\";\n\n /**\n * The CSS code for the bot. It will be used for the custom CSS of the web\n * pages.\n */\n readonly css?: string;\n}\n\n/**\n * Creates a {@link Bot} instance.\n * @param options The options for creating the bot.\n * @returns The created bot instance.\n */\nexport function createBot<TContextData = void>(\n options: CreateBotOptions<TContextData>,\n): TContextData extends void ? BotWithVoidContextData : Bot<TContextData> {\n const bot = new BotImpl<TContextData>(options);\n // Since `deno serve` does not recognize a class instance having fetch(),\n // we wrap a BotImpl instance with a plain object.\n // See also https://github.com/denoland/deno/issues/24062\n const wrapper = {\n impl: bot,\n get federation() {\n return bot.federation;\n },\n get identifier() {\n return bot.identifier;\n },\n getSession(a, b?) {\n // @ts-ignore: BotImpl.getSession() implements Bot.getSession()\n return bot.getSession(a, b);\n },\n fetch(request, contextData) {\n return bot.fetch(request, contextData);\n },\n addCustomEmojis<TEmojiName extends string>(\n emojis: Readonly<Record<TEmojiName, CustomEmoji>>,\n ): Readonly<Record<TEmojiName, DeferredCustomEmoji<TContextData>>> {\n return bot.addCustomEmojis(emojis);\n },\n get onFollow() {\n return bot.onFollow;\n },\n set onFollow(value) {\n bot.onFollow = value;\n },\n get onUnfollow() {\n return bot.onUnfollow;\n },\n set onUnfollow(value) {\n bot.onUnfollow = value;\n },\n get onAcceptFollow() {\n return bot.onAcceptFollow;\n },\n set onAcceptFollow(value) {\n bot.onAcceptFollow = value;\n },\n get onRejectFollow() {\n return bot.onRejectFollow;\n },\n set onRejectFollow(value) {\n bot.onRejectFollow = value;\n },\n get onMention() {\n return bot.onMention;\n },\n set onMention(value) {\n bot.onMention = value;\n },\n get onReply() {\n return bot.onReply;\n },\n set onReply(value) {\n bot.onReply = value;\n },\n get onQuote() {\n return bot.onQuote;\n },\n set onQuote(value) {\n bot.onQuote = value;\n },\n get onMessage() {\n return bot.onMessage;\n },\n set onMessage(value) {\n bot.onMessage = value;\n },\n get onSharedMessage() {\n return bot.onSharedMessage;\n },\n set onSharedMessage(value) {\n bot.onSharedMessage = value;\n },\n get onLike() {\n return bot.onLike;\n },\n set onLike(value) {\n bot.onLike = value;\n },\n get onUnlike() {\n return bot.onUnlike;\n },\n set onUnlike(value) {\n bot.onUnlike = value;\n },\n get onReact() {\n return bot.onReact;\n },\n set onReact(value) {\n bot.onReact = value;\n },\n get onUnreact() {\n return bot.onUnreact;\n },\n set onUnreact(value) {\n bot.onUnreact = value;\n },\n } satisfies Bot<TContextData> & { impl: BotImpl<TContextData> };\n // @ts-ignore: the wrapper implements BotWithVoidContextData\n return wrapper;\n}\n"],"mappings":";;;;;;;;;;;;;;AAmXA,SAAgB,UACdA,SACwE;CACxE,MAAM,MAAM,IAAI,QAAsB;CAItC,MAAM,UAAU;EACd,MAAM;EACN,IAAI,aAAa;AACf,UAAO,IAAI;EACZ;EACD,IAAI,aAAa;AACf,UAAO,IAAI;EACZ;EACD,WAAW,GAAGC,GAAI;AAEhB,UAAO,IAAI,WAAW,GAAG,EAAE;EAC5B;EACD,MAAM,SAAS,aAAa;AAC1B,UAAO,IAAI,MAAM,SAAS,YAAY;EACvC;EACD,gBACEC,QACiE;AACjE,UAAO,IAAI,gBAAgB,OAAO;EACnC;EACD,IAAI,WAAW;AACb,UAAO,IAAI;EACZ;EACD,IAAI,SAAS,OAAO;AAClB,OAAI,WAAW;EAChB;EACD,IAAI,aAAa;AACf,UAAO,IAAI;EACZ;EACD,IAAI,WAAW,OAAO;AACpB,OAAI,aAAa;EAClB;EACD,IAAI,iBAAiB;AACnB,UAAO,IAAI;EACZ;EACD,IAAI,eAAe,OAAO;AACxB,OAAI,iBAAiB;EACtB;EACD,IAAI,iBAAiB;AACnB,UAAO,IAAI;EACZ;EACD,IAAI,eAAe,OAAO;AACxB,OAAI,iBAAiB;EACtB;EACD,IAAI,YAAY;AACd,UAAO,IAAI;EACZ;EACD,IAAI,UAAU,OAAO;AACnB,OAAI,YAAY;EACjB;EACD,IAAI,UAAU;AACZ,UAAO,IAAI;EACZ;EACD,IAAI,QAAQ,OAAO;AACjB,OAAI,UAAU;EACf;EACD,IAAI,UAAU;AACZ,UAAO,IAAI;EACZ;EACD,IAAI,QAAQ,OAAO;AACjB,OAAI,UAAU;EACf;EACD,IAAI,YAAY;AACd,UAAO,IAAI;EACZ;EACD,IAAI,UAAU,OAAO;AACnB,OAAI,YAAY;EACjB;EACD,IAAI,kBAAkB;AACpB,UAAO,IAAI;EACZ;EACD,IAAI,gBAAgB,OAAO;AACzB,OAAI,kBAAkB;EACvB;EACD,IAAI,SAAS;AACX,UAAO,IAAI;EACZ;EACD,IAAI,OAAO,OAAO;AAChB,OAAI,SAAS;EACd;EACD,IAAI,WAAW;AACb,UAAO,IAAI;EACZ;EACD,IAAI,SAAS,OAAO;AAClB,OAAI,WAAW;EAChB;EACD,IAAI,UAAU;AACZ,UAAO,IAAI;EACZ;EACD,IAAI,QAAQ,OAAO;AACjB,OAAI,UAAU;EACf;EACD,IAAI,YAAY;AACd,UAAO,IAAI;EACZ;EACD,IAAI,UAAU,OAAO;AACnB,OAAI,YAAY;EACjB;CACF;AAED,QAAO;AACR"}
1
+ {"version":3,"file":"bot.js","names":["options: CreateBotOptions<TContextData>","b?","emojis: Readonly<Record<TEmojiName, CustomEmoji>>"],"sources":["../src/bot.ts"],"sourcesContent":["// BotKit by Fedify: A framework for creating ActivityPub bots\n// Copyright (C) 2025 Hong Minhee <https://hongminhee.org/>\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as\n// published by the Free Software Foundation, either version 3 of the\n// License, or (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport type {\n Context,\n Federation,\n KvStore,\n MessageQueue,\n} from \"@fedify/fedify/federation\";\nimport type { Software } from \"@fedify/fedify/nodeinfo\";\nimport type { Application, Image, Service } from \"@fedify/fedify/vocab\";\nimport { BotImpl } from \"./bot-impl.ts\";\nimport type { CustomEmoji, DeferredCustomEmoji } from \"./emoji.ts\";\nimport type {\n AcceptEventHandler,\n FollowEventHandler,\n LikeEventHandler,\n MentionEventHandler,\n MessageEventHandler,\n QuoteEventHandler,\n ReactionEventHandler,\n RejectEventHandler,\n ReplyEventHandler,\n SharedMessageEventHandler,\n UndoneReactionEventHandler,\n UnfollowEventHandler,\n UnlikeEventHandler,\n VoteEventHandler,\n} from \"./events.ts\";\nimport type { Repository } from \"./repository.ts\";\nimport type { Session } from \"./session.ts\";\nimport type { Text } from \"./text.ts\";\nexport {\n parseSemVer,\n type SemVer,\n type Software,\n} from \"@fedify/fedify/nodeinfo\";\nexport { Application, Image, Service } from \"@fedify/fedify/vocab\";\n\n/**\n * A bot that can interact with the ActivityPub network.\n */\nexport interface Bot<TContextData> {\n /**\n * An internal Fedify federation instance. Normally you don't need to access\n * this directly.\n */\n readonly federation: Federation<TContextData>;\n\n /**\n * The internal identifier for the bot actor. It is used for the actor URI.\n */\n readonly identifier: string;\n\n /**\n * Gets a new session to control the bot for a specific origin and context\n * data.\n * @param origin The origin of the session. Even if a URL with some path or\n * query is passed, only the origin part will be used.\n * @param contextData The context data to pass to the federation.\n * @returns The session for the origin and context data.\n */\n getSession(\n origin: string | URL,\n contextData: TContextData,\n ): Session<TContextData>;\n\n /**\n * Gets a new session to control bot for a specific Fedify context.\n * @param context The Fedify context of the session.\n * @returns The session for the Fedify context.\n */\n getSession(context: Context<TContextData>): Session<TContextData>;\n\n /**\n * The fetch API for handling HTTP requests. You can pass this to an HTTP\n * server (e.g., `Deno.serve()`, `Bun.serve()`) to handle incoming requests.\n * @param request The request to handle.\n * @param contextData The context data to pass to the federation.\n * @returns The response to the request.\n */\n fetch(request: Request, contextData: TContextData): Promise<Response>;\n\n /**\n * Defines custom emojis for the bot. The custom emojis are used for\n * rendering the bot's profile and posts. The custom emojis are defined\n * by their names, and the names are used as the keys of the emojis.\n * @param emojis The custom emojis to define. The keys are the names of\n * the emojis, and the values are the custom emoji definitions.\n * @returns The defined emojis. The keys are the names of the emojis, and\n * the values are the emoji objects, which are used for passing\n * to the {@link customEmoji} function.\n * @throws {TypeError} If any emoji name is invalid or duplicate.\n * @since 0.2.0\n */\n addCustomEmojis<TEmojiName extends string>(\n emojis: Readonly<Record<TEmojiName, CustomEmoji>>,\n ): Readonly<Record<TEmojiName, DeferredCustomEmoji<TContextData>>>;\n\n /**\n * An event handler for a follow request to the bot.\n */\n onFollow?: FollowEventHandler<TContextData>;\n\n /**\n * An event handler for an unfollow event from the bot.\n */\n onUnfollow?: UnfollowEventHandler<TContextData>;\n\n /**\n * An event handler invoked when a follow request the bot sent is accepted.\n */\n onAcceptFollow?: AcceptEventHandler<TContextData>;\n\n /**\n * An event handler invoked when a follow request the bot sent is rejected.\n */\n onRejectFollow?: RejectEventHandler<TContextData>;\n\n /**\n * An event handler for a message mentioned to the bot.\n */\n onMention?: MentionEventHandler<TContextData>;\n\n /**\n * An event handler for a reply to the bot.\n */\n onReply?: ReplyEventHandler<TContextData>;\n\n /**\n * An event handler for a quote of the bot's message.\n * @since 0.2.0\n */\n onQuote?: QuoteEventHandler<TContextData>;\n\n /**\n * An event handler for a message shown to the bot's timeline. To listen\n * to this event, your bot needs to follow others first.\n */\n onMessage?: MessageEventHandler<TContextData>;\n\n /**\n * An event handler for a message shared to the bot. To listen to this event,\n * your bot needs to follow others first.\n */\n onSharedMessage?: SharedMessageEventHandler<TContextData>;\n\n /**\n * An event handler for a like of a message.\n */\n onLike?: LikeEventHandler<TContextData>;\n\n /**\n * An event handler for an undoing of a like of a message.\n */\n onUnlike?: UnlikeEventHandler<TContextData>;\n\n /**\n * An event handler for an emoji reaction to a message.\n * @since 0.2.0\n */\n onReact?: ReactionEventHandler<TContextData>;\n\n /**\n * An event handler for an undoing of an emoji reaction to a message.\n * @since 0.2.0\n */\n onUnreact?: UndoneReactionEventHandler<TContextData>;\n\n /**\n * An event handler for a vote in a poll. This event is only triggered when\n * the bot is the author of the poll, and the vote is made by another actor.\n * If the poll allows multiple selections, this event is triggered multiple\n * times, once for each option selected by the actor.\n *\n * Note that this event can be triggered even if the voter vote an option\n * multiple times or multiple options for a poll that disallows multiple\n * selections. You should validate the vote in the event handler by storing\n * the votes in a persistent store, and checking if the vote is valid.\n * (This behavior can subject to change in the future.)\n * @since 0.3.0\n */\n onVote?: VoteEventHandler<TContextData>;\n}\n\n/**\n * A specialized {@link Bot} tpe that doesn't require context data.\n */\nexport interface BotWithVoidContextData extends Bot<void> {\n /**\n * Gets a new session to control the bot for a specific origin and context\n * data.\n * @param origin The origin of the session. Even if a URL with some path or\n * query is passed, only the origin part will be used.\n * @param contextData The context data to pass to the federation.\n * @returns The session for the origin and context data.\n */\n getSession(\n origin: string | URL,\n contextData: void,\n ): Session<void>;\n\n /**\n * Gets a new session to control bot for a specific Fedify context.\n * @param context The Fedify context of the session.\n * @returns The session for the Fedify context.\n */\n getSession(context: Context<void>): Session<void>;\n\n /**\n * Gets a new session to control the bot for a specific origin and context\n * data.\n * @param origin The origin of the session. Even if a URL with some path or\n * query is passed, only the origin part will be used.\n */\n getSession(origin: string | URL): Session<void>;\n\n /**\n * The fetch API for handling HTTP requests. You can pass this to an HTTP\n * server (e.g., `Deno.serve()`, `Bun.serve()`) to handle incoming requests.\n * @param request The request to handle.\n * @returns The response to the request.\n */\n fetch(request: Request): Promise<Response>;\n}\n\n/**\n * Options for creating a bot.\n */\nexport interface CreateBotOptions<TContextData> {\n /**\n * The internal identifier of the bot. Since it is used for the actor URI,\n * it *should not* be changed after the bot is federated.\n *\n * If omitted, `\"bot\"` will be used.\n * @default `\"bot\"`\n */\n readonly identifier?: string;\n\n /**\n * The type of the bot actor. It should be either `Service` or `Application`.\n *\n * If omitted, `Service` will be used.\n * @default `Service`\n */\n readonly class?: typeof Service | typeof Application;\n\n /**\n * The username of the bot. It will be a part of the fediverse handle.\n * It can be changed after the bot is federated.\n */\n readonly username: string;\n\n /**\n * The display name of the bot. It can be changed after the bot is federated.\n */\n readonly name?: string;\n\n /**\n * The description of the bot. It can be changed after the bot is federated.\n */\n readonly summary?: Text<\"block\", TContextData>;\n\n /**\n * The avatar URL of the bot. It can be changed after the bot is federated.\n */\n readonly icon?: URL | Image;\n\n /**\n * The header image URL of the bot. It can be changed after the bot is\n * federated.\n */\n readonly image?: URL | Image;\n\n /**\n * The custom properties of the bot. It can be changed after the bot is\n * federated.\n */\n readonly properties?: Record<string, Text<\"block\" | \"inline\", TContextData>>;\n\n /**\n * How to handle incoming follow requests. Note that this behavior can be\n * overridden by manually invoking {@link FollowRequest.accept} or\n * {@link FollowRequest.reject} in the {@link Bot.onFollow} event handler.\n *\n * - `\"accept\"` (default): Automatically accept all incoming follow requests.\n * - `\"reject\"`: Automatically reject all incoming follow requests.\n * - `\"manual\"`: Require manual handling of incoming follow requests.\n * @default `\"accept\"`\n */\n readonly followerPolicy?: \"accept\" | \"reject\" | \"manual\";\n\n /**\n * The underlying key-value store to use for storing data.\n */\n readonly kv: KvStore;\n\n /**\n * The underlying repository to use for storing data. If omitted,\n * {@link KvRepository} will be used.\n */\n readonly repository?: Repository;\n\n /**\n * The underlying message queue to use for handling incoming and outgoing\n * activities. If omitted, incoming activities are processed immediately,\n * and outgoing activities are sent immediately.\n */\n readonly queue?: MessageQueue;\n\n /**\n * The software information of the bot. If omitted, the NodeInfo protocol\n * will be unimplemented.\n */\n readonly software?: Software;\n\n /**\n * Whether to trust `X-Forwarded-*` headers. If your bot application is\n * behind an L7 reverse proxy, turn it on.\n *\n * Turned off by default.\n * @default `false`\n */\n readonly behindProxy?: boolean;\n\n /**\n * The options for the web pages of the bot. If omitted, the default options\n * will be used.\n */\n readonly pages?: PagesOptions;\n}\n\n/**\n * Options for the web pages of the bot.\n */\nexport interface PagesOptions {\n /**\n * The color of the theme. It will be used for the theme color of the web\n * pages. The default color is `\"green\"`.\n * @default `\"green\"`\n */\n readonly color?:\n | \"amber\"\n | \"azure\"\n | \"blue\"\n | \"cyan\"\n | \"fuchsia\"\n | \"green\"\n | \"grey\"\n | \"indigo\"\n | \"jade\"\n | \"lime\"\n | \"orange\"\n | \"pink\"\n | \"pumpkin\"\n | \"purple\"\n | \"red\"\n | \"sand\"\n | \"slate\"\n | \"violet\"\n | \"yellow\"\n | \"zinc\";\n\n /**\n * The CSS code for the bot. It will be used for the custom CSS of the web\n * pages.\n */\n readonly css?: string;\n}\n\n/**\n * Creates a {@link Bot} instance.\n * @param options The options for creating the bot.\n * @returns The created bot instance.\n */\nexport function createBot<TContextData = void>(\n options: CreateBotOptions<TContextData>,\n): TContextData extends void ? BotWithVoidContextData : Bot<TContextData> {\n const bot = new BotImpl<TContextData>(options);\n // Since `deno serve` does not recognize a class instance having fetch(),\n // we wrap a BotImpl instance with a plain object.\n // See also https://github.com/denoland/deno/issues/24062\n const wrapper = {\n impl: bot,\n get federation() {\n return bot.federation;\n },\n get identifier() {\n return bot.identifier;\n },\n getSession(a, b?) {\n // @ts-ignore: BotImpl.getSession() implements Bot.getSession()\n return bot.getSession(a, b);\n },\n fetch(request, contextData) {\n return bot.fetch(request, contextData);\n },\n addCustomEmojis<TEmojiName extends string>(\n emojis: Readonly<Record<TEmojiName, CustomEmoji>>,\n ): Readonly<Record<TEmojiName, DeferredCustomEmoji<TContextData>>> {\n return bot.addCustomEmojis(emojis);\n },\n get onFollow() {\n return bot.onFollow;\n },\n set onFollow(value) {\n bot.onFollow = value;\n },\n get onUnfollow() {\n return bot.onUnfollow;\n },\n set onUnfollow(value) {\n bot.onUnfollow = value;\n },\n get onAcceptFollow() {\n return bot.onAcceptFollow;\n },\n set onAcceptFollow(value) {\n bot.onAcceptFollow = value;\n },\n get onRejectFollow() {\n return bot.onRejectFollow;\n },\n set onRejectFollow(value) {\n bot.onRejectFollow = value;\n },\n get onMention() {\n return bot.onMention;\n },\n set onMention(value) {\n bot.onMention = value;\n },\n get onReply() {\n return bot.onReply;\n },\n set onReply(value) {\n bot.onReply = value;\n },\n get onQuote() {\n return bot.onQuote;\n },\n set onQuote(value) {\n bot.onQuote = value;\n },\n get onMessage() {\n return bot.onMessage;\n },\n set onMessage(value) {\n bot.onMessage = value;\n },\n get onSharedMessage() {\n return bot.onSharedMessage;\n },\n set onSharedMessage(value) {\n bot.onSharedMessage = value;\n },\n get onLike() {\n return bot.onLike;\n },\n set onLike(value) {\n bot.onLike = value;\n },\n get onUnlike() {\n return bot.onUnlike;\n },\n set onUnlike(value) {\n bot.onUnlike = value;\n },\n get onReact() {\n return bot.onReact;\n },\n set onReact(value) {\n bot.onReact = value;\n },\n get onUnreact() {\n return bot.onUnreact;\n },\n set onUnreact(value) {\n bot.onUnreact = value;\n },\n get onVote() {\n return bot.onVote;\n },\n set onVote(value) {\n bot.onVote = value;\n },\n } satisfies Bot<TContextData> & { impl: BotImpl<TContextData> };\n // @ts-ignore: the wrapper implements BotWithVoidContextData\n return wrapper;\n}\n"],"mappings":";;;;;;;;;;;;;;AAmYA,SAAgB,UACdA,SACwE;CACxE,MAAM,MAAM,IAAI,QAAsB;CAItC,MAAM,UAAU;EACd,MAAM;EACN,IAAI,aAAa;AACf,UAAO,IAAI;EACZ;EACD,IAAI,aAAa;AACf,UAAO,IAAI;EACZ;EACD,WAAW,GAAGC,GAAI;AAEhB,UAAO,IAAI,WAAW,GAAG,EAAE;EAC5B;EACD,MAAM,SAAS,aAAa;AAC1B,UAAO,IAAI,MAAM,SAAS,YAAY;EACvC;EACD,gBACEC,QACiE;AACjE,UAAO,IAAI,gBAAgB,OAAO;EACnC;EACD,IAAI,WAAW;AACb,UAAO,IAAI;EACZ;EACD,IAAI,SAAS,OAAO;AAClB,OAAI,WAAW;EAChB;EACD,IAAI,aAAa;AACf,UAAO,IAAI;EACZ;EACD,IAAI,WAAW,OAAO;AACpB,OAAI,aAAa;EAClB;EACD,IAAI,iBAAiB;AACnB,UAAO,IAAI;EACZ;EACD,IAAI,eAAe,OAAO;AACxB,OAAI,iBAAiB;EACtB;EACD,IAAI,iBAAiB;AACnB,UAAO,IAAI;EACZ;EACD,IAAI,eAAe,OAAO;AACxB,OAAI,iBAAiB;EACtB;EACD,IAAI,YAAY;AACd,UAAO,IAAI;EACZ;EACD,IAAI,UAAU,OAAO;AACnB,OAAI,YAAY;EACjB;EACD,IAAI,UAAU;AACZ,UAAO,IAAI;EACZ;EACD,IAAI,QAAQ,OAAO;AACjB,OAAI,UAAU;EACf;EACD,IAAI,UAAU;AACZ,UAAO,IAAI;EACZ;EACD,IAAI,QAAQ,OAAO;AACjB,OAAI,UAAU;EACf;EACD,IAAI,YAAY;AACd,UAAO,IAAI;EACZ;EACD,IAAI,UAAU,OAAO;AACnB,OAAI,YAAY;EACjB;EACD,IAAI,kBAAkB;AACpB,UAAO,IAAI;EACZ;EACD,IAAI,gBAAgB,OAAO;AACzB,OAAI,kBAAkB;EACvB;EACD,IAAI,SAAS;AACX,UAAO,IAAI;EACZ;EACD,IAAI,OAAO,OAAO;AAChB,OAAI,SAAS;EACd;EACD,IAAI,WAAW;AACb,UAAO,IAAI;EACZ;EACD,IAAI,SAAS,OAAO;AAClB,OAAI,WAAW;EAChB;EACD,IAAI,UAAU;AACZ,UAAO,IAAI;EACZ;EACD,IAAI,QAAQ,OAAO;AACjB,OAAI,UAAU;EACf;EACD,IAAI,YAAY;AACd,UAAO,IAAI;EACZ;EACD,IAAI,UAAU,OAAO;AACnB,OAAI,YAAY;EACjB;EACD,IAAI,SAAS;AACX,UAAO,IAAI;EACZ;EACD,IAAI,OAAO,OAAO;AAChB,OAAI,SAAS;EACd;CACF;AAED,QAAO;AACR"}
@@ -2,7 +2,7 @@ import { Temporal, toTemporalInstant } from "@js-temporal/polyfill";
2
2
  Date.prototype.toTemporalInstant = toTemporalInstant;
3
3
  import { MessageClass } from "../message.js";
4
4
  import { Session } from "../session.js";
5
- import * as hono_utils_html1 from "hono/utils/html";
5
+ import * as hono_utils_html0 from "hono/utils/html";
6
6
 
7
7
  //#region src/components/Message.d.ts
8
8
  interface MessageProps {
@@ -12,7 +12,7 @@ interface MessageProps {
12
12
  declare function Message({
13
13
  session,
14
14
  message
15
- }: MessageProps): Promise<hono_utils_html1.HtmlEscapedString>;
15
+ }: MessageProps): Promise<hono_utils_html0.HtmlEscapedString>;
16
16
  declare function renderCustomEmojis(html: string, emojis: Record<string, string>): string;
17
17
  //# sourceMappingURL=Message.d.ts.map
18
18
 
package/dist/deno.js CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  //#region deno.json
6
6
  var name = "@fedify/botkit";
7
- var version = "0.3.0-dev.111+1b9cba8a";
7
+ var version = "0.3.0-dev.113+70a401fa";
8
8
  var license = "AGPL-3.0-only";
9
9
  var unstable = ["kv", "temporal"];
10
10
  var exports = {
@@ -14,13 +14,14 @@ var exports = {
14
14
  "./events": "./src/events.ts",
15
15
  "./follow": "./src/follow.ts",
16
16
  "./message": "./src/message.ts",
17
+ "./poll": "./src/poll.ts",
17
18
  "./reaction": "./src/reaction.ts",
18
19
  "./repository": "./src/repository.ts",
19
20
  "./session": "./src/session.ts",
20
21
  "./text": "./src/text.ts"
21
22
  };
22
23
  var imports = {
23
- "@fedify/fedify": "jsr:@fedify/fedify@^1.6.1",
24
+ "@fedify/fedify": "jsr:@fedify/fedify@^1.7.1",
24
25
  "@fedify/markdown-it-hashtag": "jsr:@fedify/markdown-it-hashtag@^0.3.0",
25
26
  "@fedify/markdown-it-mention": "jsr:@fedify/markdown-it-mention@^0.3.0",
26
27
  "@logtape/logtape": "jsr:@logtape/logtape@^1.0.0",
@@ -51,7 +52,12 @@ var fmt = { "exclude": [
51
52
  var tasks = {
52
53
  "check": "deno check src/ && deno lint && deno fmt --check && deno publish --dry-run --allow-dirty && deno run scripts/check_versions.ts",
53
54
  "test": "deno test --allow-env=NODE_V8_COVERAGE,JEST_WORKER_ID --allow-net=hollo.social --parallel",
54
- "test-all": "deno task check && deno task test",
55
+ "test:node": "pnpm install && pnpm test",
56
+ "test-all": { "dependencies": [
57
+ "check",
58
+ "test",
59
+ "test:node"
60
+ ] },
55
61
  "coverage": "deno task test --coverage --clean && deno coverage --html",
56
62
  "hooks:install": "deno run --allow-read=deno.json,.git/hooks/ --allow-write=.git/hooks/ jsr:@hongminhee/deno-task-hooks",
57
63
  "hooks:pre-commit": "deno task check"
package/dist/deno.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"deno.js","names":[],"sources":["../deno.json"],"sourcesContent":["{\n \"name\": \"@fedify/botkit\",\n \"version\": \"0.3.0-dev.111+1b9cba8a\",\n \"license\": \"AGPL-3.0-only\",\n \"unstable\": [\n \"kv\",\n \"temporal\"\n ],\n \"exports\": {\n \".\": \"./src/mod.ts\",\n \"./bot\": \"./src/bot.ts\",\n \"./emoji\": \"./src/emoji.ts\",\n \"./events\": \"./src/events.ts\",\n \"./follow\": \"./src/follow.ts\",\n \"./message\": \"./src/message.ts\",\n \"./reaction\": \"./src/reaction.ts\",\n \"./repository\": \"./src/repository.ts\",\n \"./session\": \"./src/session.ts\",\n \"./text\": \"./src/text.ts\"\n },\n \"imports\": {\n \"@fedify/fedify\": \"jsr:@fedify/fedify@^1.6.1\",\n \"@fedify/markdown-it-hashtag\": \"jsr:@fedify/markdown-it-hashtag@^0.3.0\",\n \"@fedify/markdown-it-mention\": \"jsr:@fedify/markdown-it-mention@^0.3.0\",\n \"@logtape/logtape\": \"jsr:@logtape/logtape@^1.0.0\",\n \"@phensley/language-tag\": \"npm:@phensley/language-tag@^1.12.2\",\n \"hono\": \"jsr:@hono/hono@^4.8.2\",\n \"html-entities\": \"npm:html-entities@^2.6.0\",\n \"markdown-it\": \"npm:markdown-it@^14.1.0\",\n \"mime-db\": \"npm:mime-db@^1.54.0\",\n \"tsdown\": \"npm:tsdown@^0.12.8\",\n \"uuid\": \"npm:uuid@^11.1.0\",\n \"x-forwarded-fetch\": \"jsr:@hongminhee/x-forwarded-fetch@^0.2.0\",\n \"xss\": \"npm:xss@^1.0.15\"\n },\n \"nodeModulesDir\": \"none\",\n \"exclude\": [\n \".github\",\n \".vscode\",\n \"dist\",\n \"docs\",\n \"src/css\"\n ],\n \"fmt\": {\n \"exclude\": [\n \"*.md\",\n \"*.yaml\",\n \"*.yml\",\n \"src/static/*.ts\"\n ]\n },\n \"tasks\": {\n \"check\": \"deno check src/ && deno lint && deno fmt --check && deno publish --dry-run --allow-dirty && deno run scripts/check_versions.ts\",\n \"test\": \"deno test --allow-env=NODE_V8_COVERAGE,JEST_WORKER_ID --allow-net=hollo.social --parallel\",\n \"test-all\": \"deno task check && deno task test\",\n \"coverage\": \"deno task test --coverage --clean && deno coverage --html\",\n \"hooks:install\": \"deno run --allow-read=deno.json,.git/hooks/ --allow-write=.git/hooks/ jsr:@hongminhee/deno-task-hooks\",\n \"hooks:pre-commit\": \"deno task check\"\n }\n}\n"],"mappings":";;;;;WACU;cACG;cACA;eACC,CACV,MACA,UACD;cACU;CACT,KAAK;CACL,SAAS;CACT,WAAW;CACX,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,cAAc;CACd,gBAAgB;CAChB,aAAa;CACb,UAAU;AACX;cACU;CACT,kBAAkB;CAClB,+BAA+B;CAC/B,+BAA+B;CAC/B,oBAAoB;CACpB,0BAA0B;CAC1B,QAAQ;CACR,iBAAiB;CACjB,eAAe;CACf,WAAW;CACX,UAAU;CACV,QAAQ;CACR,qBAAqB;CACrB,OAAO;AACR;qBACiB;cACP;CACT;CACA;CACA;CACA;CACA;AACD;UACM,EACL,WAAW;CACT;CACA;CACA;CACA;AACD,EACF;YACQ;CACP,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,YAAY;CACZ,iBAAiB;CACjB,oBAAoB;AACrB;mBA1DH;;;;;;;;;;;AA2DC"}
1
+ {"version":3,"file":"deno.js","names":[],"sources":["../deno.json"],"sourcesContent":["{\n \"name\": \"@fedify/botkit\",\n \"version\": \"0.3.0-dev.113+70a401fa\",\n \"license\": \"AGPL-3.0-only\",\n \"unstable\": [\n \"kv\",\n \"temporal\"\n ],\n \"exports\": {\n \".\": \"./src/mod.ts\",\n \"./bot\": \"./src/bot.ts\",\n \"./emoji\": \"./src/emoji.ts\",\n \"./events\": \"./src/events.ts\",\n \"./follow\": \"./src/follow.ts\",\n \"./message\": \"./src/message.ts\",\n \"./poll\": \"./src/poll.ts\",\n \"./reaction\": \"./src/reaction.ts\",\n \"./repository\": \"./src/repository.ts\",\n \"./session\": \"./src/session.ts\",\n \"./text\": \"./src/text.ts\"\n },\n \"imports\": {\n \"@fedify/fedify\": \"jsr:@fedify/fedify@^1.7.1\",\n \"@fedify/markdown-it-hashtag\": \"jsr:@fedify/markdown-it-hashtag@^0.3.0\",\n \"@fedify/markdown-it-mention\": \"jsr:@fedify/markdown-it-mention@^0.3.0\",\n \"@logtape/logtape\": \"jsr:@logtape/logtape@^1.0.0\",\n \"@phensley/language-tag\": \"npm:@phensley/language-tag@^1.12.2\",\n \"hono\": \"jsr:@hono/hono@^4.8.2\",\n \"html-entities\": \"npm:html-entities@^2.6.0\",\n \"markdown-it\": \"npm:markdown-it@^14.1.0\",\n \"mime-db\": \"npm:mime-db@^1.54.0\",\n \"tsdown\": \"npm:tsdown@^0.12.8\",\n \"uuid\": \"npm:uuid@^11.1.0\",\n \"x-forwarded-fetch\": \"jsr:@hongminhee/x-forwarded-fetch@^0.2.0\",\n \"xss\": \"npm:xss@^1.0.15\"\n },\n \"nodeModulesDir\": \"none\",\n \"exclude\": [\n \".github\",\n \".vscode\",\n \"dist\",\n \"docs\",\n \"src/css\"\n ],\n \"fmt\": {\n \"exclude\": [\n \"*.md\",\n \"*.yaml\",\n \"*.yml\",\n \"src/static/*.ts\"\n ]\n },\n \"tasks\": {\n \"check\": \"deno check src/ && deno lint && deno fmt --check && deno publish --dry-run --allow-dirty && deno run scripts/check_versions.ts\",\n \"test\": \"deno test --allow-env=NODE_V8_COVERAGE,JEST_WORKER_ID --allow-net=hollo.social --parallel\",\n \"test:node\": \"pnpm install && pnpm test\",\n \"test-all\": {\n \"dependencies\": [\n \"check\",\n \"test\",\n \"test:node\"\n ]\n },\n \"coverage\": \"deno task test --coverage --clean && deno coverage --html\",\n \"hooks:install\": \"deno run --allow-read=deno.json,.git/hooks/ --allow-write=.git/hooks/ jsr:@hongminhee/deno-task-hooks\",\n \"hooks:pre-commit\": \"deno task check\"\n }\n}\n"],"mappings":";;;;;WACU;cACG;cACA;eACC,CACV,MACA,UACD;cACU;CACT,KAAK;CACL,SAAS;CACT,WAAW;CACX,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,UAAU;CACV,cAAc;CACd,gBAAgB;CAChB,aAAa;CACb,UAAU;AACX;cACU;CACT,kBAAkB;CAClB,+BAA+B;CAC/B,+BAA+B;CAC/B,oBAAoB;CACpB,0BAA0B;CAC1B,QAAQ;CACR,iBAAiB;CACjB,eAAe;CACf,WAAW;CACX,UAAU;CACV,QAAQ;CACR,qBAAqB;CACrB,OAAO;AACR;qBACiB;cACP;CACT;CACA;CACA;CACA;CACA;AACD;UACM,EACL,WAAW;CACT;CACA;CACA;CACA;AACD,EACF;YACQ;CACP,SAAS;CACT,QAAQ;CACR,aAAa;CACb,YAAY,EACV,gBAAgB;EACd;EACA;EACA;CACD,EACF;CACD,YAAY;CACZ,iBAAiB;CACjB,oBAAoB;AACrB;mBAlEH;;;;;;;;;;;AAmEC"}
package/dist/events.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Temporal, toTemporalInstant } from "@js-temporal/polyfill";
2
2
  Date.prototype.toTemporalInstant = toTemporalInstant;
3
3
  import { Like, Reaction } from "./reaction.js";
4
4
  import { Message, MessageClass, SharedMessage } from "./message.js";
5
+ import { Vote } from "./poll.js";
5
6
  import { Session } from "./session.js";
6
7
  import { FollowRequest } from "./follow.js";
7
8
  import { Actor } from "@fedify/fedify/vocab";
@@ -103,8 +104,19 @@ type ReactionEventHandler<TContextData> = (session: Session<TContextData>, react
103
104
  * @since 0.2.0
104
105
  */
105
106
  type UndoneReactionEventHandler<TContextData> = (session: Session<TContextData>, reaction: Reaction<TContextData>) => void | Promise<void>;
107
+ /**
108
+ * An event handler for a vote in a poll. This event is only triggered when
109
+ * the bot is the author of the poll, and the vote is made by another actor.
110
+ * Note that if the poll allows multiple selections, this event is triggered
111
+ * multiple times, once for each option selected by the actor.
112
+ * @typeParam TContextData The type of the context data.
113
+ * @param session The session of the bot.
114
+ * @param vote The vote made by another actor in the poll.
115
+ * @since 0.3.0
116
+ */
117
+ type VoteEventHandler<TContextData> = (session: Session<TContextData>, vote: Vote<TContextData>) => void | Promise<void>;
106
118
  //# sourceMappingURL=events.d.ts.map
107
119
 
108
120
  //#endregion
109
- export { AcceptEventHandler, FollowEventHandler, LikeEventHandler, MentionEventHandler, MessageEventHandler, QuoteEventHandler, ReactionEventHandler, RejectEventHandler, ReplyEventHandler, SharedMessageEventHandler, UndoneReactionEventHandler, UnfollowEventHandler, UnlikeEventHandler };
121
+ export { AcceptEventHandler, FollowEventHandler, LikeEventHandler, MentionEventHandler, MessageEventHandler, QuoteEventHandler, ReactionEventHandler, RejectEventHandler, ReplyEventHandler, SharedMessageEventHandler, UndoneReactionEventHandler, UnfollowEventHandler, UnlikeEventHandler, VoteEventHandler };
110
122
  //# sourceMappingURL=events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","names":[],"sources":["../src/events.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;AA2BY,KAAA,kBAAkB,CAAA,YAAA,CAAA,GAAA,CAAA,OAAA,EACnB,OADmB,CACX,YADW,CAAA,EAAA,aAAA,EAEb,aAFa,EAAA,GAAA,IAAA,GAGlB,OAHkB,CAAA,IAAA,CAAA;;;;;;AAGX;AAQP,KAAA,oBAAoB,CAAA,YAAA,CAAA,GAAA,CAAA,OAAA,EACrB,OADqB,CACb,YADa,CAAA,EAAA,QAAA,EAEpB,KAFoB,EAAA,GAAA,IAAA,GAGpB,OAHoB,CAAA,IAAA,CAAA;;;;;;AAGb;AAQP,KAAA,kBAAkB,CAAA,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 Date.prototype.toTemporalInstant = toTemporalInstant;
3
3
  import { AuthorizedLike, AuthorizedReaction, EmojiReact, Like, RawLike, Reaction } from "./reaction.js";
4
4
  import { Text, customEmoji, em, hashtag, link, mention, plainText, strong, text } from "./text.js";
5
5
  import { Actor, Article, Audio, AuthorizedMessage, AuthorizedSharedMessage, ChatMessage, Document, Hashtag, LanguageTag, Message, MessageClass, MessageShareOptions, MessageVisibility, Note, Question, SharedMessage, Video, isActor, parseLanguageTag } from "./message.js";
6
+ import { Poll, Vote } from "./poll.js";
6
7
  import { Session, SessionGetOutboxOptions, SessionPublishOptions, SessionPublishOptionsWithClass } from "./session.js";
7
8
  import { CustomEmoji, DeferredCustomEmoji, Emoji, emoji, isEmoji } from "./emoji.js";
8
9
  import { FollowRequest } from "./follow.js";
9
- import { AcceptEventHandler, FollowEventHandler, LikeEventHandler, MentionEventHandler, MessageEventHandler, QuoteEventHandler, ReactionEventHandler, RejectEventHandler, ReplyEventHandler, SharedMessageEventHandler, UndoneReactionEventHandler, UnfollowEventHandler, UnlikeEventHandler } from "./events.js";
10
+ import { AcceptEventHandler, FollowEventHandler, LikeEventHandler, MentionEventHandler, MessageEventHandler, QuoteEventHandler, ReactionEventHandler, RejectEventHandler, ReplyEventHandler, SharedMessageEventHandler, UndoneReactionEventHandler, UnfollowEventHandler, UnlikeEventHandler, VoteEventHandler } from "./events.js";
10
11
  import { Announce, Create, KvRepository, MemoryCachedRepository, MemoryRepository, Repository } from "./repository.js";
11
12
  import { Application, Bot, BotWithVoidContextData, CreateBotOptions, Image, PagesOptions, SemVer, Service, Software, createBot, parseSemVer } from "./bot.js";
12
13
  import { InProcessMessageQueue, InProcessMessageQueueOptions, MemoryKvStore, ParallelMessageQueue } from "@fedify/fedify/federation";
13
- export { AcceptEventHandler, Actor, Announce, Application, Article, Audio, AuthorizedLike, AuthorizedMessage, AuthorizedReaction, AuthorizedSharedMessage, Bot, BotWithVoidContextData, ChatMessage, Create, CreateBotOptions, CustomEmoji, DeferredCustomEmoji, Document, Emoji, EmojiReact, FollowEventHandler, FollowRequest, Hashtag, Image, InProcessMessageQueue, InProcessMessageQueueOptions, KvRepository, LanguageTag, Like, LikeEventHandler, MemoryCachedRepository, MemoryKvStore, MemoryRepository, MentionEventHandler, Message, MessageClass, MessageEventHandler, MessageShareOptions, MessageVisibility, Note, PagesOptions, ParallelMessageQueue, Question, QuoteEventHandler, RawLike, Reaction, ReactionEventHandler, RejectEventHandler, ReplyEventHandler, Repository, SemVer, Service, Session, SessionGetOutboxOptions, SessionPublishOptions, SessionPublishOptionsWithClass, SharedMessage, SharedMessageEventHandler, Software, Text, UndoneReactionEventHandler, UnfollowEventHandler, UnlikeEventHandler, Video, createBot, customEmoji, em, emoji, hashtag, isActor, isEmoji, link, mention, parseLanguageTag, parseSemVer, plainText, strong, text };
14
+ export { AcceptEventHandler, Actor, Announce, Application, Article, Audio, AuthorizedLike, AuthorizedMessage, AuthorizedReaction, AuthorizedSharedMessage, Bot, BotWithVoidContextData, ChatMessage, Create, CreateBotOptions, CustomEmoji, DeferredCustomEmoji, Document, Emoji, EmojiReact, FollowEventHandler, FollowRequest, Hashtag, Image, InProcessMessageQueue, InProcessMessageQueueOptions, KvRepository, LanguageTag, Like, LikeEventHandler, MemoryCachedRepository, MemoryKvStore, MemoryRepository, MentionEventHandler, Message, MessageClass, MessageEventHandler, MessageShareOptions, MessageVisibility, Note, PagesOptions, ParallelMessageQueue, Poll, Question, QuoteEventHandler, RawLike, Reaction, ReactionEventHandler, RejectEventHandler, ReplyEventHandler, Repository, SemVer, Service, Session, SessionGetOutboxOptions, SessionPublishOptions, SessionPublishOptionsWithClass, SharedMessage, SharedMessageEventHandler, Software, Text, UndoneReactionEventHandler, UnfollowEventHandler, UnlikeEventHandler, Video, Vote, VoteEventHandler, createBot, customEmoji, em, emoji, hashtag, isActor, isEmoji, link, mention, parseLanguageTag, parseSemVer, plainText, strong, text };
package/dist/mod.js CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  import { emoji, isEmoji } from "./emoji.js";
6
6
  import { Announce, Create, KvRepository, MemoryCachedRepository, MemoryRepository } from "./repository.js";
7
+ import { Article, Audio, ChatMessage, Document, Hashtag, LanguageTag, Note, Question, Video, isActor, parseLanguageTag } from "./message.js";
7
8
  import { Application, Image, Service, createBot, parseSemVer } from "./bot.js";
8
9
  import { customEmoji, em, hashtag, link, mention, plainText, strong, text } from "./text.js";
9
- import { Article, Audio, ChatMessage, Document, Hashtag, LanguageTag, Note, Question, Video, isActor, parseLanguageTag } from "./message.js";
10
10
  import { EmojiReact, RawLike } from "./reaction.js";
11
11
  import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "@fedify/fedify/federation";
12
12
 
package/dist/pages.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Temporal, toTemporalInstant } from "@js-temporal/polyfill";
2
2
  Date.prototype.toTemporalInstant = toTemporalInstant;
3
3
  import { BotImpl } from "./bot-impl.js";
4
4
  import { Hono } from "hono";
5
- import * as hono_types0 from "hono/types";
5
+ import * as hono_types1 from "hono/types";
6
6
 
7
7
  //#region src/pages.d.ts
8
8
  interface Bindings {
@@ -12,7 +12,7 @@ interface Bindings {
12
12
  interface Env {
13
13
  readonly Bindings: Bindings;
14
14
  }
15
- declare const app: Hono<Env, hono_types0.BlankSchema, "/">;
15
+ declare const app: Hono<Env, hono_types1.BlankSchema, "/">;
16
16
  //# sourceMappingURL=pages.d.ts.map
17
17
 
18
18
  //#endregion
package/dist/poll.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ import { Temporal, toTemporalInstant } from "@js-temporal/polyfill";
2
+ Date.prototype.toTemporalInstant = toTemporalInstant;
3
+ import { Message } from "./message.js";
4
+ import { Actor, Note, Question } from "@fedify/fedify/vocab";
5
+
6
+ //#region src/poll.d.ts
7
+ /**
8
+ * An interface representing a poll.
9
+ * @since 0.3.0
10
+ */
11
+ interface Poll {
12
+ /**
13
+ * Whether the poll allows multiple selections.
14
+ */
15
+ readonly multiple: boolean;
16
+ /**
17
+ * The options of the poll. Each option is a string. **Every option must be
18
+ * unique, and must not be empty.**
19
+ */
20
+ readonly options: readonly string[];
21
+ /**
22
+ * The time when the poll ends.
23
+ */
24
+ readonly endTime: Temporal.Instant;
25
+ }
26
+ /**
27
+ * An interface representing a vote in a poll. Note that if the poll allows
28
+ * multiple selections, the options are represented as multiple {@link Vote}
29
+ * objects, each with a single option.
30
+ * @typeParam TContextData The type of the context data.
31
+ * @since 0.3.0
32
+ */
33
+ interface Vote<TContextData> {
34
+ /**
35
+ * The underlying raw note object.
36
+ */
37
+ readonly raw: Note;
38
+ /**
39
+ * The actor who voted.
40
+ */
41
+ readonly actor: Actor;
42
+ /**
43
+ * The question to which the poll belongs.
44
+ */
45
+ readonly message: Message<Question, TContextData>;
46
+ /**
47
+ * The poll to which the vote belongs.
48
+ */
49
+ readonly poll: Poll;
50
+ /**
51
+ * The options selected by the actor. Note that this is a string even
52
+ * if the poll allows multiple selections. If the poll allows multiple
53
+ * selections, the options are represented as multiple {@link Vote} objects.
54
+ */
55
+ readonly option: string;
56
+ }
57
+ //# sourceMappingURL=poll.d.ts.map
58
+ //#endregion
59
+ export { Poll, Vote };
60
+ //# sourceMappingURL=poll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poll.d.ts","names":[],"sources":["../src/poll.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UAsBiB,IAAA;;AAAjB;AAyBA;EAAqB,SAAA,QAAA,EAAA,OAAA;EAAA;;;;EAc6B,SAA9B,OAAA,EAAA,SAAA,MAAA,EAAA;EAAO;AAKN;;oBA7BD,QAAA,CAAS;;;;;;;;;UAUZ;;;;gBAID;;;;kBAKE;;;;oBAKE,QAAQ,UAAU;;;;iBAKrB"}
package/dist/poll.js ADDED
@@ -0,0 +1,4 @@
1
+
2
+ import { Temporal, toTemporalInstant } from "@js-temporal/polyfill";
3
+ Date.prototype.toTemporalInstant = toTemporalInstant;
4
+