@seedcord/core 0.11.0 → 0.12.0-next.0
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/Bus-W1K-uMeO.mjs +930 -0
- package/dist/Bus-W1K-uMeO.mjs.map +1 -0
- package/dist/{CoordinatedShutdown-H5YjZn8A.d.mts → CoordinatedShutdown-BVtNNSsF.d.mts} +13 -4
- package/dist/{CoordinatedStartup-CGnJrqcl.mjs → CoordinatedStartup-DA3gW8op.mjs} +22 -20
- package/dist/CoordinatedStartup-DA3gW8op.mjs.map +1 -0
- package/dist/Generated-ByC53_A2.d.mts +26 -0
- package/dist/{HmrModuleHandler-8ZC-UuZh.mjs → HmrModuleHandler-BMD7dg8N.mjs} +2 -2
- package/dist/HmrModuleHandler-BMD7dg8N.mjs.map +1 -0
- package/dist/PluginHost-CYe-UVpp.mjs +552 -0
- package/dist/PluginHost-CYe-UVpp.mjs.map +1 -0
- package/dist/{PluginHost-DB4j8unu.d.mts → PluginHost-DWBgBS6Q.d.mts} +35 -8
- package/dist/{PluginLifecycle-AhQ46NIr.mjs → PluginLifecycle-DdwRzcDj.mjs} +3 -3
- package/dist/PluginLifecycle-DdwRzcDj.mjs.map +1 -0
- package/dist/{ServerHost-CtmAhEXn.mjs → ServerHost-DHg-Y2_q.mjs} +17 -6
- package/dist/{ServerHost-CtmAhEXn.mjs.map → ServerHost-DHg-Y2_q.mjs.map} +1 -1
- package/dist/{ServerHost-DYeh0KTk.d.mts → ServerHost-whpI0h4d.d.mts} +7 -6
- package/dist/bindViteEnv-NFzvdqlT.mjs +32 -0
- package/dist/{bindViteEnv-DWq5rftJ.mjs.map → bindViteEnv-NFzvdqlT.mjs.map} +1 -1
- package/dist/env-internal.index.mjs +1 -1
- package/dist/hmr.index.mjs +1 -1
- package/dist/{index-Du71Xx69.d.mts → index-Boo33hh3.d.mts} +10 -11
- package/dist/index.d.mts +108 -6
- package/dist/index.mjs +118 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal.index.d.mts +25 -7
- package/dist/internal.index.mjs +8 -8
- package/dist/node-internal.index.d.mts +7 -4
- package/dist/node-internal.index.mjs +19 -6
- package/dist/node-internal.index.mjs.map +1 -1
- package/dist/node.index.d.mts +3 -3
- package/dist/node.index.mjs +22 -28
- package/dist/node.index.mjs.map +1 -1
- package/dist/{phases-FTM69J3a.d.mts → phases-Dojnr-ng.d.mts} +111 -12
- package/dist/plugin.index.d.mts +3 -2
- package/dist/plugin.index.mjs +1 -1
- package/dist/{subscribers-Ce3SWy23.mjs → subscribers-D4_HZcgw.mjs} +12 -829
- package/dist/subscribers-D4_HZcgw.mjs.map +1 -0
- package/dist/{bindViteEnv-DWq5rftJ.mjs → usingCtx-Cf2cZi96.mjs} +1 -31
- package/package.json +11 -9
- package/dist/CoordinatedStartup-CGnJrqcl.mjs.map +0 -1
- package/dist/HmrModuleHandler-8ZC-UuZh.mjs.map +0 -1
- package/dist/PluginHost-B8kxLOeb.mjs +0 -245
- package/dist/PluginHost-B8kxLOeb.mjs.map +0 -1
- package/dist/PluginLifecycle-AhQ46NIr.mjs.map +0 -1
- package/dist/phases-BauKJOTT.mjs +0 -31
- package/dist/phases-BauKJOTT.mjs.map +0 -1
- package/dist/publishDefault-D3dAyzZ9.mjs +0 -7
- package/dist/publishDefault-D3dAyzZ9.mjs.map +0 -1
- package/dist/subscribers-Ce3SWy23.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { A as serializeReply, B as contextMenuRouteOf, C as NotAllowed, D as OnCooldown, E as NotOwner, F as AckTrace, H as storeComponentRoute, I as checkAckLegality, L as sendTarget, M as attemptWrite, N as publishResponse, O as defineEffectGate, R as RegisterInteractionMiddleware, S as NeedsAny, T as NotInGuild, U as storeInteractionRoute, X as ContextMenus, Y as Commands, a as RequireBotPermissions, b as MissingPermissions, d as presentNames, f as pickNotice, ft as NoticeCard, g as runCheck, h as rollbackCommits, i as Silence, j as translateSerializationError, k as defineGate, l as hasAll, m as markCommits, n as pageCursor, o as RequirePermissions, pt as Notice, q as RegisterCommand, r as ResolvedEmoji, s as RequireRole, t as PAGE_MAX, u as missingNames, w as NotInDm, y as HasDangerousPermissions } from "./subscribers-D4_HZcgw.mjs";
|
|
2
|
+
import { M as RowComponent, T as InteractionKind, _ as MemoryDriver, d as WebhookLog, f as Subscriber, j as BuilderComponent, l as WebhookUrl, t as Bus, u as Subscribe, v as ShutdownPhase, y as StartupPhase } from "./Bus-W1K-uMeO.mjs";
|
|
3
3
|
import "reflect-metadata";
|
|
4
4
|
import { CustomId, decodeFor, prefixOf, setCustomIdErrors, setCustomIdErrors as setCustomIdErrors$1 } from "@seedcord/custom-id";
|
|
5
5
|
import { ActionRowBuilder, ButtonBuilder, TextDisplayBuilder } from "@discordjs/builders";
|
|
@@ -291,15 +291,15 @@ function MentionableMenuRoute(...defs) {
|
|
|
291
291
|
|
|
292
292
|
//#endregion
|
|
293
293
|
//#region src/dispatch/DispatchContext.ts
|
|
294
|
-
/**
|
|
295
|
-
* A typed bag allocated once per interaction dispatch and handed to the handler. The middleware and i18n
|
|
296
|
-
* work reads and writes it through {@link DispatchState}. Today the bag is empty, so it only carries the
|
|
297
|
-
* dispatched `routeId`.
|
|
298
|
-
*/
|
|
294
|
+
/** State shared by middleware and handlers during one dispatch. */
|
|
299
295
|
var DispatchContext = class {
|
|
300
|
-
routeId;
|
|
301
296
|
state = Object.create(null);
|
|
302
297
|
id = crypto.randomUUID();
|
|
298
|
+
/**
|
|
299
|
+
* The dispatch identifier, such as `slash:search/docs`, `button:approve`, or `event:messageCreate`.
|
|
300
|
+
* Component identifiers contain the custom-ID prefix without encoded params.
|
|
301
|
+
*/
|
|
302
|
+
routeId;
|
|
303
303
|
constructor(routeId) {
|
|
304
304
|
this.routeId = routeId;
|
|
305
305
|
}
|
|
@@ -359,10 +359,8 @@ var BaseHandler = class {
|
|
|
359
359
|
var RepliableHandler = class extends BaseHandler {
|
|
360
360
|
/** The reply surface for this interaction. Pass the handler to reply from outside its class. */
|
|
361
361
|
sender;
|
|
362
|
-
routeId;
|
|
363
362
|
constructor(event, core, dispatch, sender) {
|
|
364
363
|
super(event, core, dispatch, "interactions");
|
|
365
|
-
this.routeId = dispatch.routeId;
|
|
366
364
|
this.sender = sender ?? this.buildSender(event, core, dispatch);
|
|
367
365
|
}
|
|
368
366
|
/** Send the initial response, exactly once. */
|
|
@@ -1146,11 +1144,119 @@ var CursorSourceBase = class {
|
|
|
1146
1144
|
}
|
|
1147
1145
|
};
|
|
1148
1146
|
|
|
1147
|
+
//#endregion
|
|
1148
|
+
//#region src/kv/KeyvDriver.ts
|
|
1149
|
+
/**
|
|
1150
|
+
* Wraps a Keyv instance for `config.kv`.
|
|
1151
|
+
*
|
|
1152
|
+
* @example
|
|
1153
|
+
* ```ts
|
|
1154
|
+
* new Seedcord({ ...config, kv: new KeyvDriver(new Keyv(new KeyvSqlite('sqlite://./kv.sqlite'))) });
|
|
1155
|
+
* ```
|
|
1156
|
+
*/
|
|
1157
|
+
var KeyvDriver = class {
|
|
1158
|
+
keyv;
|
|
1159
|
+
constructor(keyv) {
|
|
1160
|
+
this.keyv = keyv;
|
|
1161
|
+
}
|
|
1162
|
+
async get(key) {
|
|
1163
|
+
const value = await this.keyv.get(key);
|
|
1164
|
+
return typeof value === "string" ? value : void 0;
|
|
1165
|
+
}
|
|
1166
|
+
async set(key, value, ttlMs) {
|
|
1167
|
+
if (!await this.keyv.set(key, value, ttlMs)) throw new SeedcordError(SeedcordErrorCode.CoreKvDriverFailed, ["write", key]);
|
|
1168
|
+
}
|
|
1169
|
+
async delete(key) {
|
|
1170
|
+
await this.keyv.delete(key);
|
|
1171
|
+
}
|
|
1172
|
+
/** @throws A **SeedcordError** when the Keyv store can't list its keys, like `@keyv/memcache`. */
|
|
1173
|
+
async *entries(prefix) {
|
|
1174
|
+
if (!this.#canListKeys()) throw new SeedcordError(SeedcordErrorCode.CoreKvKeysUnsupported);
|
|
1175
|
+
for await (const [key, value] of this.keyv.iterator()) if (key.startsWith(prefix) && typeof value === "string") yield [key, value];
|
|
1176
|
+
}
|
|
1177
|
+
async [Symbol.asyncDispose]() {
|
|
1178
|
+
await this.keyv.disconnect();
|
|
1179
|
+
}
|
|
1180
|
+
#canListKeys() {
|
|
1181
|
+
const capabilities = this.keyv.store.capabilities;
|
|
1182
|
+
return capabilities?.store === "mapLike" || capabilities?.methods.iterator.exists === true;
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
|
|
1186
|
+
//#endregion
|
|
1187
|
+
//#region src/kv/UnstorageDriver.ts
|
|
1188
|
+
const MIN_TTL_SECONDS = 60;
|
|
1189
|
+
const MS_PER_SECOND = 1e3;
|
|
1190
|
+
function storageKey(key) {
|
|
1191
|
+
return `_${encodeURIComponent(key).replaceAll(".", "%2E")}`;
|
|
1192
|
+
}
|
|
1193
|
+
function originalKey(stored) {
|
|
1194
|
+
return decodeURIComponent(stored.slice(1));
|
|
1195
|
+
}
|
|
1196
|
+
function text(raw) {
|
|
1197
|
+
if (raw === null) return void 0;
|
|
1198
|
+
return typeof raw === "string" ? raw : new TextDecoder().decode(raw);
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Wraps an unstorage `Storage` for `config.kv`.
|
|
1202
|
+
*
|
|
1203
|
+
* @example
|
|
1204
|
+
* ```ts
|
|
1205
|
+
* new Seedcord({ ...config, kv: new UnstorageDriver(createStorage({ driver: fsDriver({ base: './.kv' }) })) });
|
|
1206
|
+
* ```
|
|
1207
|
+
*/
|
|
1208
|
+
var UnstorageDriver = class {
|
|
1209
|
+
storage;
|
|
1210
|
+
constructor(storage) {
|
|
1211
|
+
this.storage = storage;
|
|
1212
|
+
}
|
|
1213
|
+
async get(key) {
|
|
1214
|
+
return text(await this.storage.getItemRaw(storageKey(key)));
|
|
1215
|
+
}
|
|
1216
|
+
async set(key, value, ttlMs) {
|
|
1217
|
+
const ttl = ttlMs === void 0 ? {} : { ttl: Math.max(MIN_TTL_SECONDS, Math.ceil(ttlMs / MS_PER_SECOND)) };
|
|
1218
|
+
await this.storage.setItemRaw(storageKey(key), value, ttl);
|
|
1219
|
+
}
|
|
1220
|
+
async delete(key) {
|
|
1221
|
+
await this.storage.removeItem(storageKey(key));
|
|
1222
|
+
}
|
|
1223
|
+
async *entries(prefix) {
|
|
1224
|
+
const storedPrefix = storageKey(prefix);
|
|
1225
|
+
for (const key of await this.storage.getKeys()) {
|
|
1226
|
+
if (!key.startsWith(storedPrefix)) continue;
|
|
1227
|
+
const value = text(await this.storage.getItemRaw(key));
|
|
1228
|
+
if (value !== void 0) yield [originalKey(key), value];
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
async [Symbol.asyncDispose]() {
|
|
1232
|
+
await this.storage.dispose();
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
|
|
1236
|
+
//#endregion
|
|
1237
|
+
//#region src/rateLimiter/buildKey.ts
|
|
1238
|
+
/**
|
|
1239
|
+
* Builds a rate-limit key from a prefix and scope parts, joined with `:`. A null or undefined part
|
|
1240
|
+
* becomes `'global'`. A key built from a DM's guild id reads `<prefix>:global` for every DM caller.
|
|
1241
|
+
*
|
|
1242
|
+
* @param prefix - The bucket family, e.g. `'cooldown'`.
|
|
1243
|
+
* @param parts - Scope values, e.g. a user or guild id.
|
|
1244
|
+
*
|
|
1245
|
+
* @example
|
|
1246
|
+
* ```ts
|
|
1247
|
+
* buildKey('report', interaction.guildId); // 'report:1234...' or 'report:global' in a DM
|
|
1248
|
+
* ```
|
|
1249
|
+
*/
|
|
1250
|
+
function buildKey(prefix, ...parts) {
|
|
1251
|
+
if (parts.length === 0) return prefix;
|
|
1252
|
+
return [prefix, ...parts.map((part) => part ?? "global")].join(":");
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1149
1255
|
//#endregion
|
|
1150
1256
|
//#region src/index.ts
|
|
1151
1257
|
/** Package version */
|
|
1152
|
-
const version = "0.
|
|
1258
|
+
const version = "0.12.0-next.0";
|
|
1153
1259
|
|
|
1154
1260
|
//#endregion
|
|
1155
|
-
export { ArraySourceBase, AutocompleteRoute, BaseHandler, BaseReplySender, BuilderComponent, Bus, ButtonRoute, ChannelMenuRoute, Commands, ContextMenus, Cooldown, CursorSourceBase, CustomId, DispatchContext, DmOnly, Fault, GuildOnly, InteractionKind, MentionableMenuRoute, MessageContextMenuRoute, ModalRoute, Notice, OwnerOnly, PaginatorBase, RegisterCommand, RegisterInteractionMiddleware, RepliableHandler, RequireBotPermissions, RequirePermissions, RequireRole, ResolvedEmoji, RoleMenuRoute, RowComponent, ShutdownPhase, Silence, SlashRoute, StartupPhase, StringMenuRoute, Subscribe, Subscriber, UserContextMenuRoute, UserMenuRoute, WebhookLog, WebhookUrl, and, assertPermissions, decodeFor, defineEffectGate, defineGate, mergeRoles, or, paginate, prefixOf, setCustomIdErrors, version };
|
|
1261
|
+
export { ArraySourceBase, AutocompleteRoute, BaseHandler, BaseReplySender, BuilderComponent, Bus, ButtonRoute, ChannelMenuRoute, Commands, ContextMenus, Cooldown, CursorSourceBase, CustomId, DispatchContext, DmOnly, Fault, GuildOnly, InteractionKind, KeyvDriver, MemoryDriver, MentionableMenuRoute, MessageContextMenuRoute, ModalRoute, Notice, OwnerOnly, PaginatorBase, RegisterCommand, RegisterInteractionMiddleware, RepliableHandler, RequireBotPermissions, RequirePermissions, RequireRole, ResolvedEmoji, RoleMenuRoute, RowComponent, ShutdownPhase, Silence, SlashRoute, StartupPhase, StringMenuRoute, Subscribe, Subscriber, UnstorageDriver, UserContextMenuRoute, UserMenuRoute, WebhookLog, WebhookUrl, and, assertPermissions, buildKey, decodeFor, defineEffectGate, defineGate, mergeRoles, or, paginate, prefixOf, setCustomIdErrors, version };
|
|
1156
1262
|
//# sourceMappingURL=index.mjs.map
|