@seedcord/core 0.1.0-next.7 → 0.1.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/{Plugin-3rlH0uxH.d.mts → Plugin-BZit5HUI.d.mts} +52 -117
- package/dist/{Plugin-Cgp1a0uQ.cjs → Plugin-BlkhHNRm.cjs} +6 -34
- package/dist/Plugin-BlkhHNRm.cjs.map +1 -0
- package/dist/{Plugin-j9GYdroS.mjs → Plugin-CDAV7P9l.mjs} +7 -29
- package/dist/Plugin-CDAV7P9l.mjs.map +1 -0
- package/dist/basic-1hebYVcN.d.mts +22 -0
- package/dist/contextMenuLeaves-f2rbyo83.d.mts +19 -0
- package/dist/{Silence-DiP95iwD.cjs → cursor-BMkFAwO2.cjs} +293 -16
- package/dist/cursor-BMkFAwO2.cjs.map +1 -0
- package/dist/{Silence-dbC2slOB.mjs → cursor-BvSH8tgw.mjs} +222 -17
- package/dist/cursor-BvSH8tgw.mjs.map +1 -0
- package/dist/{AutocompleteOptions-DLp_B8as.d.mts → cursor-j5bRcn2O.d.mts} +166 -24
- package/dist/{index-Dueqztyy.d.mts → index-DafutfX8.d.mts} +8 -15
- package/dist/index.cjs +362 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +244 -44
- package/dist/index.mjs +322 -7
- package/dist/index.mjs.map +1 -1
- package/dist/internal.index.cjs +50 -43
- package/dist/internal.index.cjs.map +1 -1
- package/dist/internal.index.d.mts +46 -41
- package/dist/internal.index.mjs +13 -14
- package/dist/internal.index.mjs.map +1 -1
- package/dist/node-internal.index.cjs +196 -29
- package/dist/node-internal.index.cjs.map +1 -1
- package/dist/node-internal.index.d.mts +59 -9
- package/dist/node-internal.index.mjs +196 -30
- package/dist/node-internal.index.mjs.map +1 -1
- package/dist/{phases-BfpAG6w3.mjs → phases-BauKJOTT.mjs} +2 -2
- package/dist/phases-BauKJOTT.mjs.map +1 -0
- package/dist/{phases-C_BGNyVo.cjs → phases-DcuDHoQl.cjs} +2 -2
- package/dist/phases-DcuDHoQl.cjs.map +1 -0
- package/dist/plugin.index.cjs +1 -1
- package/dist/plugin.index.d.mts +2 -2
- package/dist/plugin.index.mjs +1 -1
- package/dist/{publishDefault-l0NQ-SHo.cjs → publishDefault-CVlwYUS5.cjs} +32 -3
- package/dist/publishDefault-CVlwYUS5.cjs.map +1 -0
- package/dist/{publishDefault-CCf1azzW.mjs → publishDefault-CldnxcT2.mjs} +27 -4
- package/dist/publishDefault-CldnxcT2.mjs.map +1 -0
- package/dist/slashRouteLeaves-BANDtPFm.mjs +23 -0
- package/dist/slashRouteLeaves-BANDtPFm.mjs.map +1 -0
- package/dist/slashRouteLeaves-nfxOAM7Q.cjs +28 -0
- package/dist/slashRouteLeaves-nfxOAM7Q.cjs.map +1 -0
- package/dist/{subscribers-DYqFVP1X.mjs → subscribers-CmDKqC7y.mjs} +5 -5
- package/dist/subscribers-CmDKqC7y.mjs.map +1 -0
- package/dist/{subscribers-B1G6_LlK.cjs → subscribers-CojcCgj1.cjs} +5 -5
- package/dist/subscribers-CojcCgj1.cjs.map +1 -0
- package/package.json +8 -8
- package/dist/Plugin-Cgp1a0uQ.cjs.map +0 -1
- package/dist/Plugin-j9GYdroS.mjs.map +0 -1
- package/dist/Silence-DiP95iwD.cjs.map +0 -1
- package/dist/Silence-dbC2slOB.mjs.map +0 -1
- package/dist/basic-D7bDlgSP.d.mts +0 -10
- package/dist/phases-BfpAG6w3.mjs.map +0 -1
- package/dist/phases-C_BGNyVo.cjs.map +0 -1
- package/dist/publishDefault-CCf1azzW.mjs.map +0 -1
- package/dist/publishDefault-l0NQ-SHo.cjs.map +0 -1
- package/dist/subscribers-B1G6_LlK.cjs.map +0 -1
- package/dist/subscribers-DYqFVP1X.mjs.map +0 -1
package/dist/internal.index.cjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
|
|
3
|
-
const require_publishDefault = require('./publishDefault-
|
|
4
|
-
const
|
|
3
|
+
const require_publishDefault = require('./publishDefault-CVlwYUS5.cjs');
|
|
4
|
+
const require_cursor = require('./cursor-BMkFAwO2.cjs');
|
|
5
5
|
const require_devChannel = require('./devChannel-CoCmAVDx.cjs');
|
|
6
|
+
const require_slashRouteLeaves = require('./slashRouteLeaves-nfxOAM7Q.cjs');
|
|
6
7
|
require("reflect-metadata");
|
|
7
|
-
let _seedcord_errors = require("@seedcord/errors");
|
|
8
|
-
let _seedcord_errors_internal = require("@seedcord/errors/internal");
|
|
9
8
|
let _discordjs_builders = require("@discordjs/builders");
|
|
10
9
|
let _seedcord_logger = require("@seedcord/logger");
|
|
10
|
+
let _seedcord_errors = require("@seedcord/errors");
|
|
11
|
+
let _seedcord_errors_internal = require("@seedcord/errors/internal");
|
|
11
12
|
let _seedcord_utils = require("@seedcord/utils");
|
|
12
13
|
let chalk = require("chalk");
|
|
13
14
|
chalk = require_rolldown_runtime.__toESM(chalk, 1);
|
|
@@ -24,7 +25,7 @@ function routeIdOf(handlerCtor) {
|
|
|
24
25
|
async function timedCheck(gate, ctx, observe) {
|
|
25
26
|
const start = performance.now();
|
|
26
27
|
try {
|
|
27
|
-
await
|
|
28
|
+
await require_cursor.runCheck(gate, ctx);
|
|
28
29
|
} finally {
|
|
29
30
|
observe(gate.name, performance.now() - start);
|
|
30
31
|
}
|
|
@@ -36,10 +37,10 @@ async function timedCheck(gate, ctx, observe) {
|
|
|
36
37
|
*/
|
|
37
38
|
async function runGates(gates, ctx, observe) {
|
|
38
39
|
try {
|
|
39
|
-
for (const gate of gates) await (observe ? timedCheck(gate, ctx, observe) :
|
|
40
|
-
await
|
|
40
|
+
for (const gate of gates) await (observe ? timedCheck(gate, ctx, observe) : require_cursor.runCheck(gate, ctx));
|
|
41
|
+
await require_cursor.runCommits(ctx);
|
|
41
42
|
} finally {
|
|
42
|
-
|
|
43
|
+
require_cursor.discardCommits(ctx);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
async function runHandlerGates(handlerCtor, ctx, routeId, observe) {
|
|
@@ -77,6 +78,13 @@ function slowGateMonitor() {
|
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/miscellaneous/emojiConfig.ts
|
|
83
|
+
/** Narrows a configured emoji value to the `[name, guildId]` form. @internal */
|
|
84
|
+
function isEmojiTuple(value) {
|
|
85
|
+
return Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "string";
|
|
86
|
+
}
|
|
87
|
+
|
|
80
88
|
//#endregion
|
|
81
89
|
//#region src/hmr/wrapHot.ts
|
|
82
90
|
/**
|
|
@@ -138,15 +146,6 @@ function asError(caught) {
|
|
|
138
146
|
return Error.isError(caught) ? caught : new Error(String(caught), { cause: caught });
|
|
139
147
|
}
|
|
140
148
|
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/pagination/cursor.ts
|
|
143
|
-
const PAGE_MAX = 1e6;
|
|
144
|
-
const SLOT_MAX = 4;
|
|
145
|
-
/** Build the page cursor for a paginator. */
|
|
146
|
-
function pageCursor(prefix) {
|
|
147
|
-
return new require_Silence.CustomId(prefix).int("page", 0, PAGE_MAX).int("slot", 0, SLOT_MAX);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
149
|
//#endregion
|
|
151
150
|
//#region src/reply/ackLegality.ts
|
|
152
151
|
const showModalReason = {
|
|
@@ -653,8 +652,8 @@ var FaultThrottle = class FaultThrottle {
|
|
|
653
652
|
* @internal
|
|
654
653
|
*/
|
|
655
654
|
function outcomeFor(caught) {
|
|
656
|
-
if (caught instanceof
|
|
657
|
-
if (caught instanceof
|
|
655
|
+
if (caught instanceof require_cursor.Silence) return "refused";
|
|
656
|
+
if (caught instanceof require_cursor.Notice) return caught.report ? "failed" : "refused";
|
|
658
657
|
return "failed";
|
|
659
658
|
}
|
|
660
659
|
/**
|
|
@@ -691,59 +690,67 @@ function dispatchedPayload(report) {
|
|
|
691
690
|
//#endregion
|
|
692
691
|
exports.AckTrace = AckTrace;
|
|
693
692
|
exports.BaseReplySender = BaseReplySender;
|
|
693
|
+
exports.CommandInjector = require_cursor.CommandInjector;
|
|
694
694
|
exports.CommandMetadataKey = require_publishDefault.CommandMetadataKey;
|
|
695
|
-
exports.ComponentDefsKey =
|
|
695
|
+
exports.ComponentDefsKey = require_cursor.ComponentDefsKey;
|
|
696
696
|
exports.EventMetadataKey = require_publishDefault.EventMetadataKey;
|
|
697
697
|
exports.FaultThrottle = FaultThrottle;
|
|
698
|
-
exports.GateNotice =
|
|
698
|
+
exports.GateNotice = require_cursor.GateNotice;
|
|
699
699
|
exports.GatedMetadataKey = require_publishDefault.GatedMetadataKey;
|
|
700
|
+
exports.HasDangerousPermissions = require_cursor.HasDangerousPermissions;
|
|
700
701
|
exports.HmrManager = HmrManager;
|
|
701
702
|
exports.InteractionMetadataKey = require_publishDefault.InteractionMetadataKey;
|
|
702
703
|
exports.InteractionRouteKeys = require_publishDefault.InteractionRouteKeys;
|
|
703
704
|
exports.InteractionRoutes = require_publishDefault.InteractionRoutes;
|
|
704
705
|
exports.MiddlewareMetadataKey = require_publishDefault.MiddlewareMetadataKey;
|
|
705
|
-
exports.MissingPermissions =
|
|
706
|
-
exports.MissingRole =
|
|
707
|
-
exports.NeedsAny =
|
|
708
|
-
exports.NotAllowed =
|
|
709
|
-
exports.NotInDm =
|
|
710
|
-
exports.NotInGuild =
|
|
711
|
-
exports.NotOwner =
|
|
712
|
-
exports.NoticeCard =
|
|
713
|
-
exports.OnCooldown =
|
|
714
|
-
exports.PAGE_MAX = PAGE_MAX;
|
|
715
|
-
exports.PermissionNames =
|
|
706
|
+
exports.MissingPermissions = require_cursor.MissingPermissions;
|
|
707
|
+
exports.MissingRole = require_cursor.MissingRole;
|
|
708
|
+
exports.NeedsAny = require_cursor.NeedsAny;
|
|
709
|
+
exports.NotAllowed = require_cursor.NotAllowed;
|
|
710
|
+
exports.NotInDm = require_cursor.NotInDm;
|
|
711
|
+
exports.NotInGuild = require_cursor.NotInGuild;
|
|
712
|
+
exports.NotOwner = require_cursor.NotOwner;
|
|
713
|
+
exports.NoticeCard = require_cursor.NoticeCard;
|
|
714
|
+
exports.OnCooldown = require_cursor.OnCooldown;
|
|
715
|
+
exports.PAGE_MAX = require_cursor.PAGE_MAX;
|
|
716
|
+
exports.PermissionNames = require_cursor.PermissionNames;
|
|
716
717
|
exports.PublishDefault = require_publishDefault.PublishDefault;
|
|
717
718
|
exports.SubscribeMetadataKey = require_publishDefault.SubscribeMetadataKey;
|
|
718
719
|
exports.WebhookUrlMetadataKey = require_publishDefault.WebhookUrlMetadataKey;
|
|
719
|
-
exports.
|
|
720
|
+
exports.accessorStore = require_cursor.accessorStore;
|
|
721
|
+
exports.areRoutes = require_cursor.areRoutes;
|
|
720
722
|
exports.asError = asError;
|
|
721
723
|
exports.checkAckLegality = checkAckLegality;
|
|
722
|
-
exports.
|
|
723
|
-
exports.
|
|
724
|
-
exports.
|
|
724
|
+
exports.clearStore = require_cursor.clearStore;
|
|
725
|
+
exports.contextMenuLeaves = require_publishDefault.contextMenuLeaves;
|
|
726
|
+
exports.contextMenuRouteOf = require_cursor.contextMenuRouteOf;
|
|
727
|
+
exports.decodeComponentRoute = require_cursor.decodeComponentRoute;
|
|
728
|
+
exports.decodeFor = require_cursor.decodeFor;
|
|
725
729
|
exports.deferFlags = require_publishDefault.deferFlags;
|
|
726
730
|
exports.dispatchedPayload = dispatchedPayload;
|
|
727
731
|
exports.getDevChannel = require_devChannel.getDevChannel;
|
|
728
|
-
exports.
|
|
732
|
+
exports.guardedAccessor = require_cursor.guardedAccessor;
|
|
733
|
+
exports.interactionRoutesOf = require_cursor.interactionRoutesOf;
|
|
734
|
+
exports.isEmojiTuple = isEmojiTuple;
|
|
729
735
|
exports.outcomeFor = outcomeFor;
|
|
730
|
-
exports.pageCursor = pageCursor;
|
|
731
|
-
exports.pickNotice =
|
|
732
|
-
exports.prefixOf =
|
|
736
|
+
exports.pageCursor = require_cursor.pageCursor;
|
|
737
|
+
exports.pickNotice = require_cursor.pickNotice;
|
|
738
|
+
exports.prefixOf = require_cursor.prefixOf;
|
|
733
739
|
exports.queuedMsFor = queuedMsFor;
|
|
734
740
|
exports.reportedWrite = reportedWrite;
|
|
735
741
|
exports.routeIdOf = routeIdOf;
|
|
736
742
|
exports.runGates = runGates;
|
|
737
743
|
exports.runHandlerGates = runHandlerGates;
|
|
738
|
-
exports.selectMenuRouteOf =
|
|
744
|
+
exports.selectMenuRouteOf = require_cursor.selectMenuRouteOf;
|
|
739
745
|
exports.sendFlags = require_publishDefault.sendFlags;
|
|
740
746
|
exports.sendTarget = sendTarget;
|
|
741
747
|
exports.serializeReply = serializeReply;
|
|
742
748
|
exports.setBotColor = require_publishDefault.setBotColor;
|
|
743
749
|
exports.setDevChannel = require_devChannel.setDevChannel;
|
|
750
|
+
exports.slashRouteLeaves = require_slashRouteLeaves.slashRouteLeaves;
|
|
744
751
|
exports.slowGateMonitor = slowGateMonitor;
|
|
745
|
-
exports.storeComponentRoute =
|
|
746
|
-
exports.storeInteractionRoute =
|
|
752
|
+
exports.storeComponentRoute = require_cursor.storeComponentRoute;
|
|
753
|
+
exports.storeInteractionRoute = require_cursor.storeInteractionRoute;
|
|
747
754
|
exports.translateSerializationError = translateSerializationError;
|
|
748
755
|
exports.wrapHot = wrapHot;
|
|
749
756
|
//# sourceMappingURL=internal.index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.index.cjs","names":["InteractionRouteKeys","runCheck","runCommits","GatedMetadataKey","Logger","Envapter","paint","Logger","Envapter","CustomId","SeedcordError","SeedcordErrorCode","PublishDefault","SeedcordError","SeedcordErrorCode","TextDisplayBuilder","SeedcordError","SeedcordErrorCode","Silence","Notice"],"sources":["../src/gates/runGates.ts","../src/gates/slowGate.ts","../src/hmr/wrapHot.ts","../src/hmr/HmrManager.ts","../src/stops/asError.ts","../src/pagination/cursor.ts","../src/reply/ackLegality.ts","../src/reply/AckTrace.ts","../src/reply/responseReport.ts","../src/reply/translateSerialization.ts","../src/reply/serializeReply.ts","../src/reply/BaseReplySender.ts","../src/subscribers/FaultThrottle.ts","../src/dispatch/dispatchReport.ts"],"sourcesContent":["import 'reflect-metadata';\n\nimport { GatedMetadataKey, InteractionRouteKeys } from '@src/metadataKeys';\n\nimport { discardCommits, runCheck, runCommits } from './effects';\n\nimport type { Gate, GateContextBase } from './Gate';\n\n/**\n * Receives each gate's name and how long its check ran, in ms. A combinator (`and`/`or`) reports once\n * under its joined name.\n */\nexport type GateObserver = (gateName: string, elapsedMs: number) => void;\n\n// the stable id a route decorator stored, e.g. slash:daily or button:confirm. null for a plain event handler.\nexport function routeIdOf(handlerCtor: object): string | null {\n for (const [kind, key] of Object.entries(InteractionRouteKeys)) {\n // justified: getMetadata returns any, this key only ever stores the route/prefix string array\n const routes = Reflect.getMetadata(key, handlerCtor) as string[] | undefined;\n if (routes?.length) return `${kind}:${routes.join(',')}`;\n }\n return null;\n}\n\nasync function timedCheck(gate: Gate<GateContextBase>, ctx: GateContextBase, observe: GateObserver): Promise<void> {\n const start = performance.now();\n // finally so a refusing gate still reports\n try {\n await runCheck(gate, ctx);\n } finally {\n observe(gate.name, performance.now() - start);\n }\n}\n\n/**\n * Runs each gate's check in order, so the first refusal propagates to the dispatcher boundary. An effect\n * gate's commit runs once the whole set passes. When `observe` is given, each check is timed and reported,\n * commits excluded.\n */\nexport async function runGates(\n gates: readonly Gate<GateContextBase>[],\n ctx: GateContextBase,\n observe?: GateObserver\n): Promise<void> {\n try {\n for (const gate of gates) {\n await (observe ? timedCheck(gate, ctx, observe) : runCheck(gate, ctx));\n }\n await runCommits(ctx);\n } finally {\n discardCommits(ctx);\n }\n}\n\n// dispatchers call this before execute, inside the boundary, so a refusal renders or drops. the\n// explicit routeId overrides the ctor-derived id for manifest-driven handlers with no route metadata.\nexport async function runHandlerGates(\n handlerCtor: object,\n ctx: GateContextBase,\n routeId?: string,\n observe?: GateObserver\n): Promise<void> {\n // justified: getMetadata returns any, and this key only ever stores the @Gated gate array\n const gates = Reflect.getMetadata(GatedMetadataKey, handlerCtor) as readonly Gate<GateContextBase>[] | undefined;\n if (!gates) return;\n await runGates(gates, { ...ctx, routeId: routeId ?? routeIdOf(handlerCtor) }, observe);\n}\n","import { Logger, paint } from '@seedcord/logger';\nimport { Envapter } from 'envapt';\n\nimport type { GateObserver } from './runGates';\n\n// combined check time slower than this cuts into the 3s interaction-ack budget\nconst SLOW_GATE_MS = 750;\n\n// lazy because the logger reads the environment, which binds after this module loads\nlet gateLogger: Logger | undefined;\nfunction logger(): Logger {\n gateLogger ??= new Logger('Gates', { channel: 'gates' });\n return gateLogger;\n}\n\n/**\n * Collects each gate check's elapsed time for one dispatch. `report` warns once when the checks sum\n * past the threshold, naming the total, the route, and each gate's share.\n */\nexport interface SlowGateMonitor {\n readonly observe: GateObserver;\n report(routeId: string | null): void;\n}\n\n// undefined in production, so timedCheck skips the clock there. read per call, the environment binds late\nexport function slowGateMonitor(): SlowGateMonitor | undefined {\n if (Envapter.isProduction) return undefined;\n const readings: { name: string; ms: number }[] = [];\n return {\n observe: (name, ms) => readings.push({ name, ms }),\n report(routeId) {\n const total = readings.reduce((sum, reading) => sum + reading.ms, 0);\n if (total < SLOW_GATE_MS) return;\n const shares = readings\n .toSorted((a, b) => b.ms - a.ms)\n .map((reading) => `${paint.sky.bold(reading.name)} ${Math.round(reading.ms)}ms`);\n const route = routeId === null ? '' : ` for ${paint.sky.bold(routeId)}`;\n const headline = `gates${route} took ${paint.amber(`${Math.round(total)}ms`)} of the 3s ack budget`;\n logger().utils.block(headline, shares, 'warn', (text) => text);\n }\n };\n}\n","import type { DevChannel } from '@seedcord/types/internal';\n\n// the minimal raw-hot shape, satisfied by both vite's `import.meta.hot` and the CLI's `NormalizedHotChannel`.\ninterface RawHot {\n send(event: string, data?: unknown): void;\n on(event: string, cb: (data: unknown) => void): void;\n}\n\n/**\n * Wraps a raw vite hot object as a typed {@link DevChannel}.\n *\n * @internal\n */\nexport function wrapHot<TSend, TRecv>(hot: RawHot): DevChannel<TSend, TRecv> {\n return {\n send: (event, data) => hot.send(event, data),\n // justified: RawHot types every payload as unknown, the wire contract guarantees it matches TRecv[Key]\n on: (event, cb) => hot.on(event, cb as (data: unknown) => void)\n };\n}\n","// scoped here so import.meta.hot stays untyped in the rest of the package\n/// <reference types=\"vite/client\" />\nimport { Logger } from '@seedcord/logger';\nimport { formatFilePath } from '@seedcord/utils';\nimport chalk from 'chalk';\nimport { Envapter } from 'envapt';\n\nimport { setDevChannel } from './devChannel';\nimport { wrapHot } from './wrapHot';\n\nimport type { HmrAware, HmrUpdateEvent } from '@seedcord/types';\nimport type { SeedcordCliEvents, SeedcordFrameworkEvents } from '@seedcord/types/internal';\n\nexport class HmrManager {\n private readonly logger = new Logger('HMR', { channel: 'hmr' });\n private readonly listeners = new Set<HmrAware>();\n\n /** @internal */\n public init(): void {\n if (!import.meta.hot) return;\n // the only raw `import.meta.hot` read in the framework\n const channel = wrapHot<SeedcordFrameworkEvents, SeedcordCliEvents>(import.meta.hot);\n setDevChannel(channel);\n\n if (Envapter.isDevelopment || Envapter.isTest) {\n this.logger.info('Enabled');\n\n channel.on('seedcord:hmr', (payload) => {\n const affected = payload.affectedModules?.length ?? 0;\n this.logger.info(`${chalk.bold('1')} module changed, ${chalk.bold(affected)} affected modules`);\n\n if (payload.affectedModules) {\n this.logger.utils.list(\n payload.affectedModules.map((mod) => formatFilePath(mod)),\n 'Affected modules: '\n );\n }\n\n void this.handleUpdate(payload);\n });\n }\n }\n\n /** @internal */\n public register(listener: HmrAware): void {\n this.listeners.add(listener);\n }\n\n /** @internal */\n public unregister(listener: HmrAware): void {\n this.listeners.delete(listener);\n }\n\n private async handleUpdate(event: HmrUpdateEvent): Promise<void> {\n const promises = [...this.listeners].map(async (listener) => {\n try {\n await listener.onHmr(event);\n } catch (error) {\n this.logger.error(`Error handling HMR update in ${chalk.bold(listener.constructor.name)}: `, error);\n }\n });\n\n await Promise.all(promises);\n }\n}\n","// dropping a non-Error throw would leave the user with no fault card, and every report payload declares an Error\n/** @internal */\nexport function asError(caught: unknown): Error {\n return Error.isError(caught) ? caught : new Error(String(caught), { cause: caught });\n}\n","import { CustomId } from '@customId/CustomId';\n\nimport type { CustomIdField } from '@customId/Field';\n\n// Included in the layout hash so it is fixed per prefix. Reducing it marks every active button as StaleCustomId.\n// @internal\nexport const PAGE_MAX = 1_000_000;\n\n// Discord rejects a message with duplicate custom_ids, and two controls can target the same page (first and\n// prev both hit 0), so each control uses a distinct slot.\n// @internal\nconst SLOT_MAX = 4;\n\n/** Page cursor for a paginator. */\nexport type PageCursor<Prefix extends string> = CustomId<\n Prefix,\n { page: CustomIdField<number>; slot: CustomIdField<number> }\n>;\n\n/** Build the page cursor for a paginator. */\nexport function pageCursor<Prefix extends string>(prefix: Prefix): PageCursor<Prefix> {\n return new CustomId(prefix).int('page', 0, PAGE_MAX).int('slot', 0, SLOT_MAX);\n}\n","import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\nimport type { AckTrace } from './AckTrace';\n\nexport type AckState = 'unacked' | 'deferred-reply' | 'deferred-update' | 'replied';\n\nexport type ReplyMethod =\n | 'reply'\n | 'defer'\n | 'deferUpdate'\n | 'update'\n | 'followUp'\n | 'edit'\n | 'delete'\n | 'send'\n | 'showModal';\n\ninterface Illegal {\n // spliced into the message after \"was called when\"\n readonly reason: string;\n readonly alternative: string;\n}\n\nconst showModalReason: Illegal = {\n reason: 'this interaction was already acknowledged',\n alternative: 'showModal() must be the initial response.'\n};\n\nfunction deferReason(what: string): Illegal {\n return {\n reason: `this interaction was already acknowledged with ${what}`,\n alternative: 'A deferral can only be the initial response.'\n };\n}\n\n// a missing entry means legal in that state\nconst ILLEGAL: Record<Exclude<ReplyMethod, 'send'>, Partial<Record<AckState, Illegal>>> = {\n reply: {\n 'deferred-reply': {\n reason: 'this interaction was already deferred',\n alternative: 'Use edit() to fill the deferred reply or followUp() for a new message.'\n },\n 'deferred-update': {\n reason: 'this interaction was already acknowledged with a deferred update',\n alternative: 'Use followUp() for a new message.'\n },\n replied: {\n reason: 'this interaction was already replied to',\n alternative: 'Use followUp() for a new message or edit() to rewrite the reply.'\n }\n },\n defer: {\n 'deferred-reply': deferReason('a deferred reply'),\n 'deferred-update': deferReason('a deferred update'),\n replied: deferReason('a reply')\n },\n deferUpdate: {\n 'deferred-reply': deferReason('a deferred reply'),\n 'deferred-update': deferReason('a deferred update'),\n replied: deferReason('a reply')\n },\n update: {\n 'deferred-reply': {\n reason: 'this interaction was deferred as a reply',\n alternative: 'The placeholder is yours via edit(). update() rewrites a source message.'\n },\n replied: {\n reason: 'this interaction was already replied to',\n alternative: 'update() rewrites a source message. Use edit() or followUp() instead.'\n }\n },\n followUp: {\n unacked: {\n reason: 'this interaction has not been acknowledged yet',\n alternative: 'Ack first with reply() or defer().'\n }\n },\n edit: {\n unacked: {\n reason: 'nothing has been sent yet',\n alternative: 'Send with reply() or defer() first, then edit() rewrites it.'\n }\n },\n delete: {\n unacked: {\n reason: 'nothing has been sent yet',\n alternative: 'Acknowledge first with reply() or defer(), then delete() removes it.'\n }\n },\n showModal: {\n 'deferred-reply': showModalReason,\n 'deferred-update': showModalReason,\n replied: showModalReason\n }\n};\n\nconst SEND_TARGET: Record<AckState, 'reply' | 'edit' | 'followUp'> = {\n unacked: 'reply',\n 'deferred-reply': 'edit',\n 'deferred-update': 'followUp',\n replied: 'followUp'\n};\n\n/** Throws before any API call. `ackedBy` becomes the throw cause, its stack points at the first ack. */\nexport function checkAckLegality(method: ReplyMethod, state: AckState, routeId: string, ackedBy?: AckTrace): void {\n if (method === 'send') return;\n const illegal = ILLEGAL[method][state];\n if (!illegal) return;\n throw new SeedcordError(\n SeedcordErrorCode.ReplyIllegalAckState,\n [method, illegal.reason, illegal.alternative, routeId],\n { cause: ackedBy }\n );\n}\n\nexport function sendTarget(state: AckState): 'reply' | 'edit' | 'followUp' {\n return SEND_TARGET[state];\n}\n","import type { ReplyMethod } from './ackLegality';\n\n/** The first ack's stack, passed as the throw cause so a double-ack points to both lines. */\nexport class AckTrace extends Error {\n public constructor(method: ReplyMethod) {\n super(`${method}() acknowledged this interaction`);\n this.name = 'AckTrace';\n }\n}\n","import { asError } from '@stops/asError';\nimport { PublishDefault } from '@subscribers/publishDefault';\n\nimport type { ReplyMethod } from './ackLegality';\nimport type { Bus } from '@subscribers/Bus';\nimport type { ResponseOutcome } from '@subscribers/types/Subscriptions';\n\n/** What `publishResponse` requires. Without it the call returns without publishing. */\nexport interface ReplyTelemetry {\n readonly bus: Bus;\n readonly interactionId: string;\n}\n\n/** The reply verbs plus the autocomplete choices callback, which runs outside the ack state machine. */\nexport type WriteMethod = ReplyMethod | 'respond';\n\n/** What one write reports once it settles. */\nexport interface ResponseReport {\n readonly routeId: string;\n readonly method: WriteMethod;\n /** `performance.now()` captured before the write began. */\n readonly startedAt: number;\n readonly outcome: ResponseOutcome;\n readonly messageId: string | null;\n readonly error?: Error;\n}\n\n/** @internal */\nexport function publishResponse(telemetry: ReplyTelemetry | undefined, report: ResponseReport): void {\n if (!telemetry) return;\n telemetry.bus[PublishDefault]('responseAttempted', {\n routeId: report.routeId,\n interactionId: telemetry.interactionId,\n method: report.method,\n outcome: report.outcome,\n durationMs: performance.now() - report.startedAt,\n messageId: report.messageId,\n ...(report.error && { error: report.error })\n });\n}\n\n/**\n * Runs a write that returns no message and publishes whichever arm it takes.\n *\n * @internal\n */\nexport async function reportedWrite<Result>(\n telemetry: ReplyTelemetry | undefined,\n routeId: string,\n method: WriteMethod,\n write: () => Promise<Result>\n): Promise<Result> {\n const startedAt = performance.now();\n const result = await attemptWrite(telemetry, routeId, method, startedAt, write);\n publishResponse(telemetry, { routeId, method, startedAt, outcome: 'sent', messageId: null });\n return result;\n}\n\n/**\n * Runs a wire write and publishes the `failed` arm when it throws, since the caller's success report\n * sits after the write and a throw skips it.\n *\n * @internal\n */\nexport async function attemptWrite<Result>(\n telemetry: ReplyTelemetry | undefined,\n routeId: string,\n method: WriteMethod,\n startedAt: number,\n write: () => Promise<Result>\n): Promise<Result> {\n try {\n return await write();\n } catch (caught) {\n const error = asError(caught);\n publishResponse(telemetry, { routeId, method, startedAt, outcome: 'failed', messageId: null, error });\n // rethrown raw, so the caller catches the value the write threw\n throw caught;\n }\n}\n","import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\n// shapeshift aggregate errors nest, the cap bounds the recursion\nconst MAX_DEPTH = 8;\n\ninterface ShapeshiftLike {\n readonly message?: unknown;\n readonly errors?: unknown;\n readonly constraint?: unknown;\n readonly validator?: unknown;\n readonly expected?: unknown;\n readonly given?: unknown;\n}\n\nconst OPERATOR_WORD: Record<string, string> = {\n '<=': 'at most',\n '>=': 'at least',\n '<': 'fewer than',\n '>': 'more than'\n};\n\nconst KIND_WORD: Record<string, string> = {\n string: 'a string',\n number: 'a number',\n boolean: 'a boolean',\n bigint: 'a bigint',\n array: 'a list',\n tuple: 'a list',\n date: 'a date',\n object: 'an object'\n};\n\nfunction asRecord(value: unknown): ShapeshiftLike | null {\n return typeof value === 'object' && value !== null ? value : null;\n}\n\nfunction firstLine(message: unknown): string {\n if (typeof message !== 'string') return 'unknown validation failure';\n return message.split('\\n')[0] ?? message;\n}\n\n// strings over this limit render as a character count\nconst GIVEN_PREVIEW_LIMIT = 40;\n\nfunction gotPhrase(given: unknown): string {\n if (given === undefined) return 'nothing';\n if (given === null) return 'null';\n if (typeof given === 'string') {\n if (given.length === 0) return 'an empty string';\n if (given.length > GIVEN_PREVIEW_LIMIT) return `${given.length} characters`;\n return JSON.stringify(given);\n }\n if (Array.isArray(given)) return given.length === 0 ? 'an empty list' : `${given.length} items`;\n if (typeof given === 'number' || typeof given === 'bigint' || typeof given === 'boolean') return String(given);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- a null-prototype value has no constructor at runtime\n if (typeof given === 'object') return given.constructor?.name ?? 'an object';\n return typeof given;\n}\n\n// shapeshift constraint strings take the form 'expected.length >= 1' or 'expected <= 16777215'\nfunction needPhrase(expected: string, given: unknown): string | null {\n const bounds = [...expected.matchAll(/expected(\\.length)?\\s*(<=|>=|<|>)\\s*(\\d+)/g)];\n if (bounds.length === 0) return null;\n const phrases = bounds.map(([, lengthPart, operator, limit]) => {\n const word = OPERATOR_WORD[operator ?? ''] ?? operator ?? '';\n if (!lengthPart) return `${word} ${limit}`;\n const unit = typeof given === 'string' ? 'character' : 'item';\n return `${word} ${limit} ${Number(limit) === 1 ? unit : `${unit}s`}`;\n });\n return phrases.join(' and ');\n}\n\nfunction instanceName(expected: unknown): string {\n if (typeof expected === 'function' && expected.name) return expected.name;\n return 'specific class instance';\n}\n\nfunction describeLeaf(record: ShapeshiftLike): string {\n if (typeof record.constraint === 'string') {\n const need = typeof record.expected === 'string' ? needPhrase(record.expected, record.given) : null;\n if (need) return `need ${need}, got ${gotPhrase(record.given)}`;\n return `${firstLine(record.message)}${'given' in record ? ` (got ${gotPhrase(record.given)})` : ''}`;\n }\n if (typeof record.expected === 'function') {\n return `need a ${instanceName(record.expected)}, got ${gotPhrase(record.given)}`;\n }\n if (typeof record.validator === 'string') {\n const kind = KIND_WORD[record.validator.replace(/^s\\./, '').replace(/\\(.*$/, '')];\n if (kind) return `need ${kind}, got ${gotPhrase(record.given)}`;\n return `${firstLine(record.message)}, got ${gotPhrase(record.given)}`;\n }\n return firstLine(record.message);\n}\n\n// a concrete bound is picked first, then accepted instance classes, then the first branch\nfunction describeUnion(branches: unknown[], depth: number): string {\n const records: ShapeshiftLike[] = [];\n for (const branch of branches) {\n const record = asRecord(branch);\n if (record) records.push(record);\n }\n const bounded = records.find((record) => typeof record.constraint === 'string');\n if (bounded) return describeLeaf(bounded);\n\n const names: string[] = [];\n let allInstances = records.length > 0;\n for (const record of records) {\n if (typeof record.expected === 'function') names.push(instanceName(record.expected));\n else allInstances = false;\n }\n if (allInstances) {\n return `need a ${[...new Set(names)].join(' or ')}, got ${gotPhrase(records[0]?.given)}`;\n }\n return detailOf(branches[0], depth + 1);\n}\n\n// shapeshift nests errors as [key, inner] tuples\nfunction detailOf(value: unknown, depth: number): string {\n const record = asRecord(value);\n if (!record || depth >= MAX_DEPTH) return firstLine(record?.message);\n\n if (Array.isArray(record.errors) && record.errors.length > 0) {\n const errors = record.errors as unknown[];\n const [first] = errors;\n if (Array.isArray(first)) {\n const [key, inner] = first as [unknown, unknown];\n return `${String(key)}: ${detailOf(inner, depth + 1)}`;\n }\n return describeUnion(errors, depth);\n }\n\n return describeLeaf(record);\n}\n\n/**\n * Translates a shapeshift throw into an actionable message, keeping the original as `cause`. Any other\n * throw contributes its message as the detail.\n */\nexport function translateSerializationError(\n error: unknown,\n componentClass: string,\n index: number,\n routeId: string\n): SeedcordError<SeedcordErrorCode.ReplyComponentSerialization> {\n const detail = detailOf(error, 0);\n return new SeedcordError(SeedcordErrorCode.ReplyComponentSerialization, [componentClass, index, detail, routeId], {\n cause: error\n });\n}\n","import { TextDisplayBuilder } from '@discordjs/builders';\n\nimport { translateSerializationError } from './translateSerialization';\n\nimport type { ReplyResponse } from '@seedcord/types';\nimport type { APIMessageTopLevelComponent } from 'discord-api-types/v10';\n\n/** Serialized message data the transport wire writers consume. */\nexport interface SerializedReply {\n readonly components: APIMessageTopLevelComponent[];\n readonly allowedMentions?: ReplyResponse['allowedMentions'];\n readonly files?: ReplyResponse['files'];\n}\n\n/** Wraps a string in a TextDisplay component. */\nexport function serializeReply(response: ReplyResponse | string, routeId: string): SerializedReply {\n if (typeof response === 'string') {\n try {\n return { components: [new TextDisplayBuilder().setContent(response).toJSON()] };\n } catch (error) {\n throw translateSerializationError(error, 'TextDisplayBuilder', 0, routeId);\n }\n }\n\n const components = response.components.map((component, index) => {\n try {\n return component.toJSON();\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- a null-prototype value has no constructor at runtime\n const name = component.constructor?.name;\n throw translateSerializationError(error, !name || name === 'Object' ? 'component' : name, index, routeId);\n }\n });\n\n return {\n components,\n ...(response.allowedMentions && { allowedMentions: response.allowedMentions }),\n ...(response.files && { files: response.files })\n };\n}\n","import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\nimport { checkAckLegality, sendTarget } from './ackLegality';\nimport { AckTrace } from './AckTrace';\nimport { attemptWrite, publishResponse } from './responseReport';\nimport { serializeReply } from './serializeReply';\nimport { translateSerializationError } from './translateSerialization';\n\nimport type { AckState, ReplyMethod } from './ackLegality';\nimport type { ReplyTelemetry } from './responseReport';\nimport type { SerializedReply } from './serializeReply';\nimport type { DeferOpts, ReplyResponse, SendOpts } from '@seedcord/types';\nimport type { ResponseOutcome } from '@subscribers/types/Subscriptions';\nimport type { APIModalInteractionResponseCallbackData } from 'discord-api-types/v10';\n\n/** The shape djs modal builders emit from `toJSON()`. */\nexport interface ModalLike {\n toJSON(): APIModalInteractionResponseCallbackData;\n}\n\n/**\n * Tracks acknowledgement state and throws a translated `SeedcordError` on an illegal verb before any\n * transport call. Verbs execute the legality check, control the transport wire writer, then update the\n * state and ack trace. Each transport binds `TMessage` to its created-message lens and supplies the\n * writers.\n */\nexport abstract class BaseReplySender<TMessage extends { id: string }> {\n private state: AckState;\n // the only ids a targeted edit accepts\n private readonly sent = new Set<string>();\n // the cause carries the first ack's stack so a double-ack names both lines\n private ackedBy?: AckTrace;\n\n protected constructor(\n protected readonly routeId: string,\n initialState: AckState = 'unacked',\n // absent for getConfirmation, which builds a sender from an interaction alone and reaches no core\n private readonly telemetry?: ReplyTelemetry\n ) {\n this.state = initialState;\n }\n\n private report(method: ReplyMethod, startedAt: number, outcome: ResponseOutcome, messageId: string | null): void {\n publishResponse(this.telemetry, { routeId: this.routeId, method, startedAt, outcome, messageId });\n }\n\n private async attempt<Result>(\n method: ReplyMethod,\n startedAt: number,\n write: () => Promise<Result>\n ): Promise<Result> {\n return await attemptWrite(this.telemetry, this.routeId, method, startedAt, write);\n }\n\n public async reply(response: ReplyResponse | string, opts?: SendOpts): Promise<TMessage> {\n this.checkLegality('reply');\n const startedAt = performance.now();\n const created = await this.attempt('reply', startedAt, () => this.writeReply(response, opts));\n // the callback already acked discord, so record replied before the message guard can throw\n this.transition('reply', 'replied');\n const message = this.remember(this.requireMessage(created, 'reply'));\n this.report('reply', startedAt, 'sent', message.id);\n return message;\n }\n\n public async defer(opts?: DeferOpts): Promise<void> {\n this.checkLegality('defer');\n const startedAt = performance.now();\n await this.attempt('defer', startedAt, () => this.writeDefer(opts));\n this.transition('defer', 'deferred-reply');\n this.report('defer', startedAt, 'sent', null);\n }\n\n public async deferUpdate(): Promise<void> {\n this.checkLegality('deferUpdate');\n const startedAt = performance.now();\n await this.attempt('deferUpdate', startedAt, () => this.writeDeferUpdate());\n this.transition('deferUpdate', 'deferred-update');\n this.report('deferUpdate', startedAt, 'sent', null);\n }\n\n /**\n * After a deferUpdate the state stays deferred-update, so the rewrite repeats. The returned message\n * is the source message, editable only through a bare `update` or `edit`. A targeted `edit` or `delete`\n * of it throws the foreign-target error.\n */\n public async update(response: ReplyResponse | string): Promise<TMessage> {\n this.checkLegality('update');\n const startedAt = performance.now();\n // in deferred-update the source message is @original and the ack-legality check above already passed\n if (this.state === 'deferred-update') {\n const edited = await this.attempt('update', startedAt, () => this.editOriginal(response));\n this.report('update', startedAt, 'sent', edited.id);\n return edited;\n }\n const created = await this.attempt('update', startedAt, () => this.writeUpdate(response));\n this.transition('update', 'replied');\n const message = this.remember(this.requireMessage(created, 'update'));\n this.report('update', startedAt, 'sent', message.id);\n return message;\n }\n\n public async followUp(response: ReplyResponse | string, opts?: SendOpts): Promise<TMessage> {\n this.checkLegality('followUp');\n const startedAt = performance.now();\n const created = await this.attempt('followUp', startedAt, () => this.writeFollowUp(response, opts));\n const message = this.remember(created);\n this.report('followUp', startedAt, 'sent', message.id);\n return message;\n }\n\n public edit(response: ReplyResponse | string): Promise<TMessage>;\n public edit(target: TMessage, response: ReplyResponse | string): Promise<TMessage>;\n public async edit(\n targetOrResponse: TMessage | ReplyResponse | string,\n maybeResponse?: ReplyResponse | string\n ): Promise<TMessage> {\n this.checkLegality('edit');\n const startedAt = performance.now();\n if (maybeResponse === undefined) {\n // justified: the overloads narrow targetOrResponse to a response once maybeResponse is absent\n const edited = await this.attempt('edit', startedAt, () =>\n this.editOriginal(targetOrResponse as ReplyResponse | string)\n );\n this.report('edit', startedAt, 'sent', edited.id);\n return edited;\n }\n // justified: the overloads narrow targetOrResponse to a target message once maybeResponse is defined\n const target = targetOrResponse as TMessage;\n if (!this.sent.has(target.id)) {\n throw new SeedcordError(SeedcordErrorCode.ReplyForeignEditTarget, ['edit', target.id, this.routeId]);\n }\n const written = await this.attempt('edit', startedAt, () => this.writeEditTarget(target.id, maybeResponse));\n const message = this.remember(written);\n this.report('edit', startedAt, 'sent', message.id);\n return message;\n }\n\n public delete(): Promise<void>;\n public delete(target: TMessage): Promise<void>;\n public async delete(target?: TMessage): Promise<void> {\n this.checkLegality('delete');\n const startedAt = performance.now();\n if (target === undefined) {\n await this.attempt('delete', startedAt, () => this.writeDeleteOriginal());\n this.report('delete', startedAt, 'sent', null);\n return;\n }\n if (!this.sent.has(target.id)) {\n throw new SeedcordError(SeedcordErrorCode.ReplyForeignEditTarget, ['delete', target.id, this.routeId]);\n }\n await this.attempt('delete', startedAt, () => this.writeDeleteTarget(target.id));\n // evict so a later targeted edit of this id throws foreign\n this.sent.delete(target.id);\n this.report('delete', startedAt, 'sent', null);\n }\n\n /** Routes to the verb the current ack state permits. Every state has a route, so the illegal-ack throw is unreachable. */\n public async send(response: ReplyResponse | string, opts?: SendOpts): Promise<TMessage> {\n const target = sendTarget(this.state);\n if (target === 'reply') return await this.reply(response, opts);\n if (target === 'edit') return await this.edit(response);\n return await this.followUp(response, opts);\n }\n\n /** Must be the initial response. */\n public async showModal(modal: ModalLike): Promise<void> {\n this.checkLegality('showModal');\n this.guardModalSource();\n let data: APIModalInteractionResponseCallbackData;\n try {\n data = modal.toJSON();\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- a null-prototype modal has no constructor at runtime\n const name = modal.constructor?.name;\n throw translateSerializationError(error, !name || name === 'Object' ? 'modal' : name, 0, this.routeId);\n }\n const startedAt = performance.now();\n await this.attempt('showModal', startedAt, () => this.writeModal(data));\n this.transition('showModal', 'replied');\n this.report('showModal', startedAt, 'sent', null);\n }\n\n protected serialize(response: ReplyResponse | string): SerializedReply {\n return serializeReply(response, this.routeId);\n }\n\n protected remember(created: TMessage): TMessage {\n this.sent.add(created.id);\n return created;\n }\n\n // a with_response callback always returns the created message, this guards a wire-contract gap\n private requireMessage(created: TMessage | undefined, method: 'reply' | 'update'): TMessage {\n if (!created) throw new SeedcordError(SeedcordErrorCode.ReplyCallbackMissingMessage, [method, this.routeId]);\n return created;\n }\n\n private async editOriginal(response: ReplyResponse | string): Promise<TMessage> {\n const edited = await this.writeEditOriginal(response);\n // after a deferUpdate the source message is @original, which this interaction did not send\n if (this.state !== 'deferred-update') this.remember(edited);\n return edited;\n }\n\n private checkLegality(method: ReplyMethod): void {\n checkAckLegality(method, this.state, this.routeId, this.ackedBy);\n }\n\n private transition(method: ReplyMethod, state: AckState): void {\n this.state = state;\n this.ackedBy = new AckTrace(method);\n }\n\n // the modal-submit backstop, gateway overrides, the base call is a no-op elsewhere\n protected guardModalSource(): void {}\n\n protected abstract writeReply(response: ReplyResponse | string, opts?: SendOpts): Promise<TMessage | undefined>;\n protected abstract writeDefer(opts?: DeferOpts): Promise<void>;\n protected abstract writeDeferUpdate(): Promise<void>;\n protected abstract writeUpdate(response: ReplyResponse | string): Promise<TMessage | undefined>;\n protected abstract writeFollowUp(response: ReplyResponse | string, opts?: SendOpts): Promise<TMessage>;\n protected abstract writeEditOriginal(response: ReplyResponse | string): Promise<TMessage>;\n protected abstract writeEditTarget(targetId: string, response: ReplyResponse | string): Promise<TMessage>;\n protected abstract writeDeleteOriginal(): Promise<void>;\n protected abstract writeDeleteTarget(targetId: string): Promise<void>;\n protected abstract writeModal(data: APIModalInteractionResponseCallbackData): Promise<void>;\n}\n","/**\n * Drops duplicate fault reports inside a fixed window, so a recurring fault (a database outage on a\n * hot path) reports once per window and never floods the webhook.\n *\n * @internal\n */\nexport class FaultThrottle {\n // keyed by core so each bot gets its own window, and the entry is collected with the core\n private static readonly perCore = new WeakMap<object, FaultThrottle>();\n\n /**\n * The throttle for one bot instance.\n *\n * @internal\n */\n public static for(core: object): FaultThrottle {\n let throttle = FaultThrottle.perCore.get(core);\n if (!throttle) {\n throttle = new FaultThrottle();\n FaultThrottle.perCore.set(core, throttle);\n }\n return throttle;\n }\n\n private readonly lastReportedAt = new Map<string, number>();\n\n constructor(\n private readonly windowMs = 60_000,\n private readonly now: () => number = () => Date.now()\n ) {}\n\n /** Evicts the entry for this key if it has aged out. */\n public shouldReport(key: string): boolean {\n const last = this.lastReportedAt.get(key);\n if (last === undefined) return true;\n if (this.now() - last < this.windowMs) return false;\n\n this.lastReportedAt.delete(key);\n return true;\n }\n\n public markReported(key: string): void {\n this.lastReportedAt.set(key, this.now());\n }\n\n public clear(): void {\n this.lastReportedAt.clear();\n }\n}\n","import { timestampFromSnowflake } from '@seedcord/utils';\n\nimport { Notice } from '@stops/Notice';\nimport { Silence } from '@stops/Silence';\n\nimport type { InteractionRoutes } from '@src/metadataKeys';\nimport type { DispatchOutcome, SubscriptionData } from '@subscribers/types/Subscriptions';\n\n/**\n * Classifies a caught stop for `interactionDispatched` so a gate and a\n * handler label the same stop identically.\n *\n * @internal\n */\nexport function outcomeFor(caught: unknown): DispatchOutcome {\n if (caught instanceof Silence) return 'refused';\n if (caught instanceof Notice) return caught.report ? 'failed' : 'refused';\n return 'failed';\n}\n\n/** The values a dispatcher has once its handler chain settles. */\ninterface DispatchReport {\n readonly routeId: string;\n readonly interactionId: string;\n readonly kind: `${InteractionRoutes}`;\n readonly outcome: DispatchOutcome;\n /** True when no route matched and the unhandled default ran. */\n readonly fallback: boolean;\n /** `performance.now()` captured as the dispatch began. */\n readonly startedAt: number;\n /** {@link queuedMsFor} read at the same moment as `startedAt`. */\n readonly queuedMs: number;\n}\n\n/**\n * Discord's interaction creation to now, read from the snowflake. Called at dispatch entry, since\n * a later read would count the handler run into the queue time as well.\n *\n * @internal\n */\nexport function queuedMsFor(interactionId: string): number {\n // telemetry never breaks a dispatch, and BigInt() throws on a malformed id\n try {\n return Date.now() - timestampFromSnowflake(interactionId);\n } catch {\n return 0;\n }\n}\n\n/**\n * Builds the `interactionDispatched` payload both transports publish, so the two clocks are read the\n * same way on each.\n *\n * @internal\n */\nexport function dispatchedPayload(report: DispatchReport): SubscriptionData<'interactionDispatched'> {\n return {\n routeId: report.routeId,\n interactionId: report.interactionId,\n kind: report.kind,\n outcome: report.outcome,\n fallback: report.fallback,\n durationMs: performance.now() - report.startedAt,\n queuedMs: report.queuedMs\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAgB,UAAU,aAAoC;CAC1D,KAAK,MAAM,CAAC,MAAM,QAAQ,OAAO,QAAQA,2CAAoB,GAAG;EAE5D,MAAM,SAAS,QAAQ,YAAY,KAAK,WAAW;EACnD,IAAI,QAAQ,QAAQ,OAAO,GAAG,KAAK,GAAG,OAAO,KAAK,GAAG;CACzD;CACA,OAAO;AACX;AAEA,eAAe,WAAW,MAA6B,KAAsB,SAAsC;CAC/G,MAAM,QAAQ,YAAY,IAAI;CAE9B,IAAI;EACA,MAAMC,yBAAS,MAAM,GAAG;CAC5B,UAAU;EACN,QAAQ,KAAK,MAAM,YAAY,IAAI,IAAI,KAAK;CAChD;AACJ;;;;;;AAOA,eAAsB,SAClB,OACA,KACA,SACa;CACb,IAAI;EACA,KAAK,MAAM,QAAQ,OACf,OAAO,UAAU,WAAW,MAAM,KAAK,OAAO,IAAIA,yBAAS,MAAM,GAAG;EAExE,MAAMC,2BAAW,GAAG;CACxB,UAAU;EACN,+BAAe,GAA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,KAAsB;EACtC,MAAM,OAAO,KAAK,eAAe,IAAI,GAAG;EACxC,IAAI,SAAS,QAAW,OAAO;EAC/B,IAAI,KAAK,IAAI,IAAI,OAAO,KAAK,UAAU,OAAO;EAE9C,KAAK,eAAe,OAAO,GAAG;EAC9B,OAAO;CACX;CAEA,AAAO,aAAa,KAAmB;EACnC,KAAK,eAAe,IAAI,KAAK,KAAK,IAAI,CAAC;CAC3C;CAEA,AAAO,QAAc;EACjB,KAAK,eAAe,MAAM;CAC9B;AACJ;;;;;;;;;;AClCA,SAAgB,WAAW,QAAkC;CACzD,IAAI,kBAAkBC,yBAAS,OAAO;CACtC,IAAI,kBAAkBC,wBAAQ,OAAO,OAAO,SAAS,WAAW;CAChE,OAAO;AACX;;;;;;;AAsBA,SAAgB,YAAY,eAA+B;CAEvD,IAAI;EACA,OAAO,KAAK,IAAI,gDAA2B,aAAa;CAC5D,QAAQ;EACJ,OAAO;CACX;AACJ;;;;;;;AAQA,SAAgB,kBAAkB,QAAmE;CACjG,OAAO;EACH,SAAS,OAAO;EAChB,eAAe,OAAO;EACtB,MAAM,OAAO;EACb,SAAS,OAAO;EAChB,UAAU,OAAO;EACjB,YAAY,YAAY,IAAI,IAAI,OAAO;EACvC,UAAU,OAAO;CACrB;AACJ"}
|
|
1
|
+
{"version":3,"file":"internal.index.cjs","names":["InteractionRouteKeys","runCheck","runCommits","GatedMetadataKey","Logger","Envapter","paint","Logger","Envapter","SeedcordError","SeedcordErrorCode","PublishDefault","SeedcordError","SeedcordErrorCode","TextDisplayBuilder","SeedcordError","SeedcordErrorCode","Silence","Notice"],"sources":["../src/gates/runGates.ts","../src/gates/slowGate.ts","../src/miscellaneous/emojiConfig.ts","../src/hmr/wrapHot.ts","../src/hmr/HmrManager.ts","../src/stops/asError.ts","../src/reply/ackLegality.ts","../src/reply/AckTrace.ts","../src/reply/responseReport.ts","../src/reply/translateSerialization.ts","../src/reply/serializeReply.ts","../src/reply/BaseReplySender.ts","../src/subscribers/FaultThrottle.ts","../src/dispatch/dispatchReport.ts"],"sourcesContent":["import 'reflect-metadata';\n\nimport { GatedMetadataKey, InteractionRouteKeys } from '@src/metadataKeys';\n\nimport { discardCommits, runCheck, runCommits } from './effects';\n\nimport type { Gate, GateContextBase } from './Gate';\n\n/**\n * Receives each gate's name and how long its check ran, in ms. A combinator (`and`/`or`) reports once\n * under its joined name.\n */\nexport type GateObserver = (gateName: string, elapsedMs: number) => void;\n\n// the stable id a route decorator stored, e.g. slash:daily or button:confirm. null for a plain event handler.\nexport function routeIdOf(handlerCtor: object): string | null {\n for (const [kind, key] of Object.entries(InteractionRouteKeys)) {\n // justified: getMetadata returns any, this key only ever stores the route/prefix string array\n const routes = Reflect.getMetadata(key, handlerCtor) as string[] | undefined;\n if (routes?.length) return `${kind}:${routes.join(',')}`;\n }\n return null;\n}\n\nasync function timedCheck(gate: Gate<GateContextBase>, ctx: GateContextBase, observe: GateObserver): Promise<void> {\n const start = performance.now();\n // finally so a refusing gate still reports\n try {\n await runCheck(gate, ctx);\n } finally {\n observe(gate.name, performance.now() - start);\n }\n}\n\n/**\n * Runs each gate's check in order, so the first refusal propagates to the dispatcher boundary. An effect\n * gate's commit runs once the whole set passes. When `observe` is given, each check is timed and reported,\n * commits excluded.\n */\nexport async function runGates(\n gates: readonly Gate<GateContextBase>[],\n ctx: GateContextBase,\n observe?: GateObserver\n): Promise<void> {\n try {\n for (const gate of gates) {\n await (observe ? timedCheck(gate, ctx, observe) : runCheck(gate, ctx));\n }\n await runCommits(ctx);\n } finally {\n discardCommits(ctx);\n }\n}\n\n// dispatchers call this before execute, inside the boundary, so a refusal renders or drops. the\n// explicit routeId overrides the ctor-derived id for manifest-driven handlers with no route metadata.\nexport async function runHandlerGates(\n handlerCtor: object,\n ctx: GateContextBase,\n routeId?: string,\n observe?: GateObserver\n): Promise<void> {\n // justified: getMetadata returns any, and this key only ever stores the @Gated gate array\n const gates = Reflect.getMetadata(GatedMetadataKey, handlerCtor) as readonly Gate<GateContextBase>[] | undefined;\n if (!gates) return;\n await runGates(gates, { ...ctx, routeId: routeId ?? routeIdOf(handlerCtor) }, observe);\n}\n","import { Logger, paint } from '@seedcord/logger';\nimport { Envapter } from 'envapt';\n\nimport type { GateObserver } from './runGates';\n\n// combined check time slower than this cuts into the 3s interaction-ack budget\nconst SLOW_GATE_MS = 750;\n\n// lazy because the logger reads the environment, which binds after this module loads\nlet gateLogger: Logger | undefined;\nfunction logger(): Logger {\n gateLogger ??= new Logger('Gates', { channel: 'gates' });\n return gateLogger;\n}\n\n/**\n * Collects each gate check's elapsed time for one dispatch. `report` warns once when the checks sum\n * past the threshold, naming the total, the route, and each gate's share.\n */\nexport interface SlowGateMonitor {\n readonly observe: GateObserver;\n report(routeId: string | null): void;\n}\n\n// undefined in production, so timedCheck skips the clock there. read per call, the environment binds late\nexport function slowGateMonitor(): SlowGateMonitor | undefined {\n if (Envapter.isProduction) return undefined;\n const readings: { name: string; ms: number }[] = [];\n return {\n observe: (name, ms) => readings.push({ name, ms }),\n report(routeId) {\n const total = readings.reduce((sum, reading) => sum + reading.ms, 0);\n if (total < SLOW_GATE_MS) return;\n const shares = readings\n .toSorted((a, b) => b.ms - a.ms)\n .map((reading) => `${paint.sky.bold(reading.name)} ${Math.round(reading.ms)}ms`);\n const route = routeId === null ? '' : ` for ${paint.sky.bold(routeId)}`;\n const headline = `gates${route} took ${paint.amber(`${Math.round(total)}ms`)} of the 3s ack budget`;\n logger().utils.block(headline, shares, 'warn', (text) => text);\n }\n };\n}\n","/** Narrows a configured emoji value to the `[name, guildId]` form. @internal */\nexport function isEmojiTuple(value: unknown): value is readonly [string, string] {\n return Array.isArray(value) && value.length === 2 && typeof value[0] === 'string' && typeof value[1] === 'string';\n}\n","import type { DevChannel } from '@seedcord/types/internal';\n\n// the minimal raw-hot shape, satisfied by both vite's `import.meta.hot` and the CLI's `NormalizedHotChannel`.\ninterface RawHot {\n send(event: string, data?: unknown): void;\n on(event: string, cb: (data: unknown) => void): void;\n}\n\n/**\n * Wraps a raw vite hot object as a typed {@link DevChannel}.\n *\n * @internal\n */\nexport function wrapHot<TSend, TRecv>(hot: RawHot): DevChannel<TSend, TRecv> {\n return {\n send: (event, data) => hot.send(event, data),\n // justified: RawHot types every payload as unknown, the wire contract guarantees it matches TRecv[Key]\n on: (event, cb) => hot.on(event, cb as (data: unknown) => void)\n };\n}\n","// scoped here so import.meta.hot stays untyped in the rest of the package\n/// <reference types=\"vite/client\" />\nimport { Logger } from '@seedcord/logger';\nimport { formatFilePath } from '@seedcord/utils';\nimport chalk from 'chalk';\nimport { Envapter } from 'envapt';\n\nimport { setDevChannel } from './devChannel';\nimport { wrapHot } from './wrapHot';\n\nimport type { HmrAware, HmrUpdateEvent } from '@seedcord/types';\nimport type { SeedcordCliEvents, SeedcordFrameworkEvents } from '@seedcord/types/internal';\n\nexport class HmrManager {\n private readonly logger = new Logger('HMR', { channel: 'hmr' });\n private readonly listeners = new Set<HmrAware>();\n\n /** @internal */\n public init(): void {\n if (!import.meta.hot) return;\n // the only raw `import.meta.hot` read in the framework\n const channel = wrapHot<SeedcordFrameworkEvents, SeedcordCliEvents>(import.meta.hot);\n setDevChannel(channel);\n\n if (Envapter.isDevelopment || Envapter.isTest) {\n this.logger.info('Enabled');\n\n channel.on('seedcord:hmr', (payload) => {\n const affected = payload.affectedModules?.length ?? 0;\n this.logger.info(`${chalk.bold('1')} module changed, ${chalk.bold(affected)} affected modules`);\n\n if (payload.affectedModules) {\n this.logger.utils.list(\n payload.affectedModules.map((mod) => formatFilePath(mod)),\n 'Affected modules: '\n );\n }\n\n void this.handleUpdate(payload);\n });\n }\n }\n\n /** @internal */\n public register(listener: HmrAware): void {\n this.listeners.add(listener);\n }\n\n /** @internal */\n public unregister(listener: HmrAware): void {\n this.listeners.delete(listener);\n }\n\n private async handleUpdate(event: HmrUpdateEvent): Promise<void> {\n const promises = [...this.listeners].map(async (listener) => {\n try {\n await listener.onHmr(event);\n } catch (error) {\n this.logger.error(`Error handling HMR update in ${chalk.bold(listener.constructor.name)}: `, error);\n }\n });\n\n await Promise.all(promises);\n }\n}\n","// dropping a non-Error throw would leave the user with no fault card, and every report payload declares an Error\n/** @internal */\nexport function asError(caught: unknown): Error {\n return Error.isError(caught) ? caught : new Error(String(caught), { cause: caught });\n}\n","import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\nimport type { AckTrace } from './AckTrace';\n\nexport type AckState = 'unacked' | 'deferred-reply' | 'deferred-update' | 'replied';\n\nexport type ReplyMethod =\n | 'reply'\n | 'defer'\n | 'deferUpdate'\n | 'update'\n | 'followUp'\n | 'edit'\n | 'delete'\n | 'send'\n | 'showModal';\n\ninterface Illegal {\n // spliced into the message after \"was called when\"\n readonly reason: string;\n readonly alternative: string;\n}\n\nconst showModalReason: Illegal = {\n reason: 'this interaction was already acknowledged',\n alternative: 'showModal() must be the initial response.'\n};\n\nfunction deferReason(what: string): Illegal {\n return {\n reason: `this interaction was already acknowledged with ${what}`,\n alternative: 'A deferral can only be the initial response.'\n };\n}\n\n// a missing entry means legal in that state\nconst ILLEGAL: Record<Exclude<ReplyMethod, 'send'>, Partial<Record<AckState, Illegal>>> = {\n reply: {\n 'deferred-reply': {\n reason: 'this interaction was already deferred',\n alternative: 'Use edit() to fill the deferred reply or followUp() for a new message.'\n },\n 'deferred-update': {\n reason: 'this interaction was already acknowledged with a deferred update',\n alternative: 'Use followUp() for a new message.'\n },\n replied: {\n reason: 'this interaction was already replied to',\n alternative: 'Use followUp() for a new message or edit() to rewrite the reply.'\n }\n },\n defer: {\n 'deferred-reply': deferReason('a deferred reply'),\n 'deferred-update': deferReason('a deferred update'),\n replied: deferReason('a reply')\n },\n deferUpdate: {\n 'deferred-reply': deferReason('a deferred reply'),\n 'deferred-update': deferReason('a deferred update'),\n replied: deferReason('a reply')\n },\n update: {\n 'deferred-reply': {\n reason: 'this interaction was deferred as a reply',\n alternative: 'The placeholder is yours via edit(). update() rewrites a source message.'\n },\n replied: {\n reason: 'this interaction was already replied to',\n alternative: 'update() rewrites a source message. Use edit() or followUp() instead.'\n }\n },\n followUp: {\n unacked: {\n reason: 'this interaction has not been acknowledged yet',\n alternative: 'Ack first with reply() or defer().'\n }\n },\n edit: {\n unacked: {\n reason: 'nothing has been sent yet',\n alternative: 'Send with reply() or defer() first, then edit() rewrites it.'\n }\n },\n delete: {\n unacked: {\n reason: 'nothing has been sent yet',\n alternative: 'Acknowledge first with reply() or defer(), then delete() removes it.'\n }\n },\n showModal: {\n 'deferred-reply': showModalReason,\n 'deferred-update': showModalReason,\n replied: showModalReason\n }\n};\n\nconst SEND_TARGET: Record<AckState, 'reply' | 'edit' | 'followUp'> = {\n unacked: 'reply',\n 'deferred-reply': 'edit',\n 'deferred-update': 'followUp',\n replied: 'followUp'\n};\n\n/** Throws before any API call. `ackedBy` becomes the throw cause, its stack points at the first ack. */\nexport function checkAckLegality(method: ReplyMethod, state: AckState, routeId: string, ackedBy?: AckTrace): void {\n if (method === 'send') return;\n const illegal = ILLEGAL[method][state];\n if (!illegal) return;\n throw new SeedcordError(\n SeedcordErrorCode.ReplyIllegalAckState,\n [method, illegal.reason, illegal.alternative, routeId],\n { cause: ackedBy }\n );\n}\n\nexport function sendTarget(state: AckState): 'reply' | 'edit' | 'followUp' {\n return SEND_TARGET[state];\n}\n","import type { ReplyMethod } from './ackLegality';\n\n/** The first ack's stack, passed as the throw cause so a double-ack points to both lines. */\nexport class AckTrace extends Error {\n public constructor(method: ReplyMethod) {\n super(`${method}() acknowledged this interaction`);\n this.name = 'AckTrace';\n }\n}\n","import { asError } from '@stops/asError';\nimport { PublishDefault } from '@subscribers/publishDefault';\n\nimport type { ReplyMethod } from './ackLegality';\nimport type { Bus } from '@subscribers/Bus';\nimport type { ResponseOutcome } from '@subscribers/types/Subscriptions';\n\n/** What `publishResponse` requires. Without it the call returns without publishing. */\nexport interface ReplyTelemetry {\n readonly bus: Bus;\n readonly interactionId: string;\n}\n\n/** The reply verbs plus the autocomplete choices callback, which runs outside the ack state machine. */\nexport type WriteMethod = ReplyMethod | 'respond';\n\n/** What one write reports once it settles. */\nexport interface ResponseReport {\n readonly routeId: string;\n readonly method: WriteMethod;\n /** `performance.now()` captured before the write began. */\n readonly startedAt: number;\n readonly outcome: ResponseOutcome;\n readonly messageId: string | null;\n readonly error?: Error;\n}\n\n/** @internal */\nexport function publishResponse(telemetry: ReplyTelemetry | undefined, report: ResponseReport): void {\n if (!telemetry) return;\n telemetry.bus[PublishDefault]('responseAttempted', {\n routeId: report.routeId,\n interactionId: telemetry.interactionId,\n method: report.method,\n outcome: report.outcome,\n durationMs: performance.now() - report.startedAt,\n messageId: report.messageId,\n ...(report.error && { error: report.error })\n });\n}\n\n/**\n * Runs a write that returns no message and publishes whichever arm it takes.\n *\n * @internal\n */\nexport async function reportedWrite<Result>(\n telemetry: ReplyTelemetry | undefined,\n routeId: string,\n method: WriteMethod,\n write: () => Promise<Result>\n): Promise<Result> {\n const startedAt = performance.now();\n const result = await attemptWrite(telemetry, routeId, method, startedAt, write);\n publishResponse(telemetry, { routeId, method, startedAt, outcome: 'sent', messageId: null });\n return result;\n}\n\n/**\n * Runs a wire write and publishes the `failed` arm when it throws, since the caller's success report\n * sits after the write and a throw skips it.\n *\n * @internal\n */\nexport async function attemptWrite<Result>(\n telemetry: ReplyTelemetry | undefined,\n routeId: string,\n method: WriteMethod,\n startedAt: number,\n write: () => Promise<Result>\n): Promise<Result> {\n try {\n return await write();\n } catch (caught) {\n const error = asError(caught);\n publishResponse(telemetry, { routeId, method, startedAt, outcome: 'failed', messageId: null, error });\n // rethrown raw, so the caller catches the value the write threw\n throw caught;\n }\n}\n","import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\n// shapeshift aggregate errors nest, the cap bounds the recursion\nconst MAX_DEPTH = 8;\n\ninterface ShapeshiftLike {\n readonly message?: unknown;\n readonly errors?: unknown;\n readonly constraint?: unknown;\n readonly validator?: unknown;\n readonly expected?: unknown;\n readonly given?: unknown;\n}\n\nconst OPERATOR_WORD: Record<string, string> = {\n '<=': 'at most',\n '>=': 'at least',\n '<': 'fewer than',\n '>': 'more than'\n};\n\nconst KIND_WORD: Record<string, string> = {\n string: 'a string',\n number: 'a number',\n boolean: 'a boolean',\n bigint: 'a bigint',\n array: 'a list',\n tuple: 'a list',\n date: 'a date',\n object: 'an object'\n};\n\nfunction asRecord(value: unknown): ShapeshiftLike | null {\n return typeof value === 'object' && value !== null ? value : null;\n}\n\nfunction firstLine(message: unknown): string {\n if (typeof message !== 'string') return 'unknown validation failure';\n return message.split('\\n')[0] ?? message;\n}\n\n// strings over this limit render as a character count\nconst GIVEN_PREVIEW_LIMIT = 40;\n\nfunction gotPhrase(given: unknown): string {\n if (given === undefined) return 'nothing';\n if (given === null) return 'null';\n if (typeof given === 'string') {\n if (given.length === 0) return 'an empty string';\n if (given.length > GIVEN_PREVIEW_LIMIT) return `${given.length} characters`;\n return JSON.stringify(given);\n }\n if (Array.isArray(given)) return given.length === 0 ? 'an empty list' : `${given.length} items`;\n if (typeof given === 'number' || typeof given === 'bigint' || typeof given === 'boolean') return String(given);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- a null-prototype value has no constructor at runtime\n if (typeof given === 'object') return given.constructor?.name ?? 'an object';\n return typeof given;\n}\n\n// shapeshift constraint strings take the form 'expected.length >= 1' or 'expected <= 16777215'\nfunction needPhrase(expected: string, given: unknown): string | null {\n const bounds = [...expected.matchAll(/expected(\\.length)?\\s*(<=|>=|<|>)\\s*(\\d+)/g)];\n if (bounds.length === 0) return null;\n const phrases = bounds.map(([, lengthPart, operator, limit]) => {\n const word = OPERATOR_WORD[operator ?? ''] ?? operator ?? '';\n if (!lengthPart) return `${word} ${limit}`;\n const unit = typeof given === 'string' ? 'character' : 'item';\n return `${word} ${limit} ${Number(limit) === 1 ? unit : `${unit}s`}`;\n });\n return phrases.join(' and ');\n}\n\nfunction instanceName(expected: unknown): string {\n if (typeof expected === 'function' && expected.name) return expected.name;\n return 'specific class instance';\n}\n\nfunction describeLeaf(record: ShapeshiftLike): string {\n if (typeof record.constraint === 'string') {\n const need = typeof record.expected === 'string' ? needPhrase(record.expected, record.given) : null;\n if (need) return `need ${need}, got ${gotPhrase(record.given)}`;\n return `${firstLine(record.message)}${'given' in record ? ` (got ${gotPhrase(record.given)})` : ''}`;\n }\n if (typeof record.expected === 'function') {\n return `need a ${instanceName(record.expected)}, got ${gotPhrase(record.given)}`;\n }\n if (typeof record.validator === 'string') {\n const kind = KIND_WORD[record.validator.replace(/^s\\./, '').replace(/\\(.*$/, '')];\n if (kind) return `need ${kind}, got ${gotPhrase(record.given)}`;\n return `${firstLine(record.message)}, got ${gotPhrase(record.given)}`;\n }\n return firstLine(record.message);\n}\n\n// a concrete bound is picked first, then accepted instance classes, then the first branch\nfunction describeUnion(branches: unknown[], depth: number): string {\n const records: ShapeshiftLike[] = [];\n for (const branch of branches) {\n const record = asRecord(branch);\n if (record) records.push(record);\n }\n const bounded = records.find((record) => typeof record.constraint === 'string');\n if (bounded) return describeLeaf(bounded);\n\n const names: string[] = [];\n let allInstances = records.length > 0;\n for (const record of records) {\n if (typeof record.expected === 'function') names.push(instanceName(record.expected));\n else allInstances = false;\n }\n if (allInstances) {\n return `need a ${[...new Set(names)].join(' or ')}, got ${gotPhrase(records[0]?.given)}`;\n }\n return detailOf(branches[0], depth + 1);\n}\n\n// shapeshift nests errors as [key, inner] tuples\nfunction detailOf(value: unknown, depth: number): string {\n const record = asRecord(value);\n if (!record || depth >= MAX_DEPTH) return firstLine(record?.message);\n\n if (Array.isArray(record.errors) && record.errors.length > 0) {\n const errors = record.errors as unknown[];\n const [first] = errors;\n if (Array.isArray(first)) {\n const [key, inner] = first as [unknown, unknown];\n return `${String(key)}: ${detailOf(inner, depth + 1)}`;\n }\n return describeUnion(errors, depth);\n }\n\n return describeLeaf(record);\n}\n\n/**\n * Translates a shapeshift throw into an actionable message, keeping the original as `cause`. Any other\n * throw contributes its message as the detail.\n */\nexport function translateSerializationError(\n error: unknown,\n componentClass: string,\n index: number,\n routeId: string\n): SeedcordError<SeedcordErrorCode.ReplyComponentSerialization> {\n const detail = detailOf(error, 0);\n return new SeedcordError(SeedcordErrorCode.ReplyComponentSerialization, [componentClass, index, detail, routeId], {\n cause: error\n });\n}\n","import { TextDisplayBuilder } from '@discordjs/builders';\n\nimport { translateSerializationError } from './translateSerialization';\n\nimport type { ReplyResponse } from '@seedcord/types';\nimport type { APIMessageTopLevelComponent } from 'discord-api-types/v10';\n\n/** Serialized message data the transport wire writers consume. */\nexport interface SerializedReply<TNative = never> {\n readonly components: APIMessageTopLevelComponent[];\n readonly allowedMentions?: ReplyResponse['allowedMentions'];\n readonly files?: ReplyResponse<TNative>['files'];\n}\n\n/** Wraps a string in a TextDisplay component. */\nexport function serializeReply<TNative>(\n response: ReplyResponse<TNative> | string,\n routeId: string\n): SerializedReply<TNative> {\n if (typeof response === 'string') {\n try {\n return { components: [new TextDisplayBuilder().setContent(response).toJSON()] };\n } catch (error) {\n throw translateSerializationError(error, 'TextDisplayBuilder', 0, routeId);\n }\n }\n\n const components = response.components.map((component, index) => {\n try {\n return component.toJSON();\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- a null-prototype value has no constructor at runtime\n const name = component.constructor?.name;\n throw translateSerializationError(error, !name || name === 'Object' ? 'component' : name, index, routeId);\n }\n });\n\n return {\n components,\n ...(response.allowedMentions && { allowedMentions: response.allowedMentions }),\n ...(response.files && { files: response.files })\n };\n}\n","import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\nimport { checkAckLegality, sendTarget } from './ackLegality';\nimport { AckTrace } from './AckTrace';\nimport { attemptWrite, publishResponse } from './responseReport';\nimport { serializeReply } from './serializeReply';\nimport { translateSerializationError } from './translateSerialization';\n\nimport type { AckState, ReplyMethod } from './ackLegality';\nimport type { ReplyTelemetry } from './responseReport';\nimport type { SerializedReply } from './serializeReply';\nimport type { DeferOpts, ReplyResponse, SendOpts } from '@seedcord/types';\nimport type { ResponseOutcome } from '@subscribers/types/Subscriptions';\nimport type { APIModalInteractionResponseCallbackData } from 'discord-api-types/v10';\n\n/** The shape djs modal builders emit from `toJSON()`. */\nexport interface ModalLike {\n toJSON(): APIModalInteractionResponseCallbackData;\n}\n\n/**\n * Tracks acknowledgement state and throws a translated `SeedcordError` on an illegal verb before any\n * transport call. Verbs execute the legality check, control the transport wire writer, then update the\n * state and ack trace. Each transport binds `TMessage` to its created-message lens and supplies the\n * writers.\n */\nexport abstract class BaseReplySender<TMessage extends { id: string }, TNative = never> {\n private state: AckState;\n // the only ids a targeted edit accepts\n private readonly sent = new Set<string>();\n // the cause carries the first ack's stack so a double-ack reports both lines\n private ackedBy?: AckTrace;\n\n protected constructor(\n protected readonly routeId: string,\n initialState: AckState = 'unacked',\n // absent for getConfirmation, which builds a sender from an interaction alone and reaches no core\n private readonly telemetry?: ReplyTelemetry\n ) {\n this.state = initialState;\n }\n\n private report(method: ReplyMethod, startedAt: number, outcome: ResponseOutcome, messageId: string | null): void {\n publishResponse(this.telemetry, { routeId: this.routeId, method, startedAt, outcome, messageId });\n }\n\n private async attempt<Result>(\n method: ReplyMethod,\n startedAt: number,\n write: () => Promise<Result>\n ): Promise<Result> {\n return await attemptWrite(this.telemetry, this.routeId, method, startedAt, write);\n }\n\n public async reply(response: ReplyResponse<TNative> | string, opts?: SendOpts): Promise<TMessage> {\n this.checkLegality('reply');\n const startedAt = performance.now();\n const created = await this.attempt('reply', startedAt, () => this.writeReply(response, opts));\n // the callback already acked discord, so record replied before the message guard can throw\n this.transition('reply', 'replied');\n const message = this.remember(this.requireMessage(created, 'reply'));\n this.report('reply', startedAt, 'sent', message.id);\n return message;\n }\n\n public async defer(opts?: DeferOpts): Promise<void> {\n this.checkLegality('defer');\n const startedAt = performance.now();\n await this.attempt('defer', startedAt, () => this.writeDefer(opts));\n this.transition('defer', 'deferred-reply');\n this.report('defer', startedAt, 'sent', null);\n }\n\n public async deferUpdate(): Promise<void> {\n this.checkLegality('deferUpdate');\n const startedAt = performance.now();\n await this.attempt('deferUpdate', startedAt, () => this.writeDeferUpdate());\n this.transition('deferUpdate', 'deferred-update');\n this.report('deferUpdate', startedAt, 'sent', null);\n }\n\n /**\n * After a deferUpdate the state stays deferred-update, so the rewrite repeats. The returned message\n * is the source message, editable only through a bare `update` or `edit`. A targeted `edit` or `delete`\n * of it throws the foreign-target error.\n */\n public async update(response: ReplyResponse<TNative> | string): Promise<TMessage> {\n this.checkLegality('update');\n const startedAt = performance.now();\n // in deferred-update the source message is @original and the ack-legality check above already passed\n if (this.state === 'deferred-update') {\n const edited = await this.attempt('update', startedAt, () => this.editOriginal(response));\n this.report('update', startedAt, 'sent', edited.id);\n return edited;\n }\n const created = await this.attempt('update', startedAt, () => this.writeUpdate(response));\n this.transition('update', 'replied');\n const message = this.remember(this.requireMessage(created, 'update'));\n this.report('update', startedAt, 'sent', message.id);\n return message;\n }\n\n public async followUp(response: ReplyResponse<TNative> | string, opts?: SendOpts): Promise<TMessage> {\n this.checkLegality('followUp');\n const startedAt = performance.now();\n const created = await this.attempt('followUp', startedAt, () => this.writeFollowUp(response, opts));\n const message = this.remember(created);\n this.report('followUp', startedAt, 'sent', message.id);\n return message;\n }\n\n public edit(response: ReplyResponse<TNative> | string): Promise<TMessage>;\n public edit(target: TMessage, response: ReplyResponse<TNative> | string): Promise<TMessage>;\n public async edit(\n targetOrResponse: TMessage | ReplyResponse<TNative> | string,\n maybeResponse?: ReplyResponse<TNative> | string\n ): Promise<TMessage> {\n this.checkLegality('edit');\n const startedAt = performance.now();\n if (maybeResponse === undefined) {\n // justified: the overloads narrow targetOrResponse to a response once maybeResponse is absent\n const edited = await this.attempt('edit', startedAt, () =>\n this.editOriginal(targetOrResponse as ReplyResponse<TNative> | string)\n );\n this.report('edit', startedAt, 'sent', edited.id);\n return edited;\n }\n // justified: the overloads narrow targetOrResponse to a target message once maybeResponse is defined\n const target = targetOrResponse as TMessage;\n if (!this.sent.has(target.id)) {\n throw new SeedcordError(SeedcordErrorCode.ReplyForeignEditTarget, ['edit', target.id, this.routeId]);\n }\n const written = await this.attempt('edit', startedAt, () => this.writeEditTarget(target.id, maybeResponse));\n const message = this.remember(written);\n this.report('edit', startedAt, 'sent', message.id);\n return message;\n }\n\n public delete(): Promise<void>;\n public delete(target: TMessage): Promise<void>;\n public async delete(target?: TMessage): Promise<void> {\n this.checkLegality('delete');\n const startedAt = performance.now();\n if (target === undefined) {\n await this.attempt('delete', startedAt, () => this.writeDeleteOriginal());\n this.report('delete', startedAt, 'sent', null);\n return;\n }\n if (!this.sent.has(target.id)) {\n throw new SeedcordError(SeedcordErrorCode.ReplyForeignEditTarget, ['delete', target.id, this.routeId]);\n }\n await this.attempt('delete', startedAt, () => this.writeDeleteTarget(target.id));\n // evict so a later targeted edit of this id throws foreign\n this.sent.delete(target.id);\n this.report('delete', startedAt, 'sent', null);\n }\n\n /** Routes to the verb the current ack state permits. Every state has a route, so the illegal-ack throw is unreachable. */\n public async send(response: ReplyResponse<TNative> | string, opts?: SendOpts): Promise<TMessage> {\n const target = sendTarget(this.state);\n if (target === 'reply') return await this.reply(response, opts);\n if (target === 'edit') return await this.edit(response);\n return await this.followUp(response, opts);\n }\n\n /** Must be the initial response. */\n public async showModal(modal: ModalLike): Promise<void> {\n this.checkLegality('showModal');\n this.guardModalSource();\n let data: APIModalInteractionResponseCallbackData;\n try {\n data = modal.toJSON();\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- a null-prototype modal has no constructor at runtime\n const name = modal.constructor?.name;\n throw translateSerializationError(error, !name || name === 'Object' ? 'modal' : name, 0, this.routeId);\n }\n const startedAt = performance.now();\n await this.attempt('showModal', startedAt, () => this.writeModal(data));\n this.transition('showModal', 'replied');\n this.report('showModal', startedAt, 'sent', null);\n }\n\n protected serialize(response: ReplyResponse<TNative> | string): SerializedReply<TNative> {\n return serializeReply(response, this.routeId);\n }\n\n protected remember(created: TMessage): TMessage {\n this.sent.add(created.id);\n return created;\n }\n\n // a with_response callback always returns the created message, so this guards a wire-contract gap\n private requireMessage(created: TMessage | undefined, method: 'reply' | 'update'): TMessage {\n if (!created) throw new SeedcordError(SeedcordErrorCode.ReplyCallbackMissingMessage, [method, this.routeId]);\n return created;\n }\n\n private async editOriginal(response: ReplyResponse<TNative> | string): Promise<TMessage> {\n const edited = await this.writeEditOriginal(response);\n // after a deferUpdate the source message is @original, which this interaction did not send\n if (this.state !== 'deferred-update') this.remember(edited);\n return edited;\n }\n\n private checkLegality(method: ReplyMethod): void {\n checkAckLegality(method, this.state, this.routeId, this.ackedBy);\n }\n\n private transition(method: ReplyMethod, state: AckState): void {\n this.state = state;\n this.ackedBy = new AckTrace(method);\n }\n\n // gateway overrides this to reject a modal-submit source\n protected guardModalSource(): void {}\n\n protected abstract writeReply(\n response: ReplyResponse<TNative> | string,\n opts?: SendOpts\n ): Promise<TMessage | undefined>;\n protected abstract writeDefer(opts?: DeferOpts): Promise<void>;\n protected abstract writeDeferUpdate(): Promise<void>;\n protected abstract writeUpdate(response: ReplyResponse<TNative> | string): Promise<TMessage | undefined>;\n protected abstract writeFollowUp(response: ReplyResponse<TNative> | string, opts?: SendOpts): Promise<TMessage>;\n protected abstract writeEditOriginal(response: ReplyResponse<TNative> | string): Promise<TMessage>;\n protected abstract writeEditTarget(targetId: string, response: ReplyResponse<TNative> | string): Promise<TMessage>;\n protected abstract writeDeleteOriginal(): Promise<void>;\n protected abstract writeDeleteTarget(targetId: string): Promise<void>;\n protected abstract writeModal(data: APIModalInteractionResponseCallbackData): Promise<void>;\n}\n","/**\n * Drops duplicate fault reports inside a fixed window, so a recurring fault (a database outage on a\n * hot path) reports once per window and never floods the webhook.\n *\n * @internal\n */\nexport class FaultThrottle {\n // keyed by core so each bot gets its own window, and the entry is collected with the core\n private static readonly perCore = new WeakMap<object, FaultThrottle>();\n\n /**\n * The throttle for one bot instance.\n *\n * @internal\n */\n public static for(core: object): FaultThrottle {\n let throttle = FaultThrottle.perCore.get(core);\n if (!throttle) {\n throttle = new FaultThrottle();\n FaultThrottle.perCore.set(core, throttle);\n }\n return throttle;\n }\n\n private readonly lastReportedAt = new Map<string, number>();\n\n constructor(\n private readonly windowMs = 60_000,\n private readonly now: () => number = () => Date.now()\n ) {}\n\n /** Evicts the entry for this key if it has aged out. */\n public shouldReport(key: string): boolean {\n const last = this.lastReportedAt.get(key);\n if (last === undefined) return true;\n if (this.now() - last < this.windowMs) return false;\n\n this.lastReportedAt.delete(key);\n return true;\n }\n\n public markReported(key: string): void {\n this.lastReportedAt.set(key, this.now());\n }\n\n public clear(): void {\n this.lastReportedAt.clear();\n }\n}\n","import { timestampFromSnowflake } from '@seedcord/utils';\n\nimport { Notice } from '@stops/Notice';\nimport { Silence } from '@stops/Silence';\n\nimport type { InteractionRoutes } from '@src/metadataKeys';\nimport type { DispatchOutcome, SubscriptionData } from '@subscribers/types/Subscriptions';\n\n/**\n * Classifies a caught stop for `interactionDispatched` so a gate and a\n * handler label the same stop identically.\n *\n * @internal\n */\nexport function outcomeFor(caught: unknown): DispatchOutcome {\n if (caught instanceof Silence) return 'refused';\n if (caught instanceof Notice) return caught.report ? 'failed' : 'refused';\n return 'failed';\n}\n\n/** The values a dispatcher has once its handler chain settles. */\ninterface DispatchReport {\n readonly routeId: string;\n readonly interactionId: string;\n readonly kind: `${InteractionRoutes}`;\n readonly outcome: DispatchOutcome;\n /** True when no route matched and the unhandled default ran. */\n readonly fallback: boolean;\n /** `performance.now()` captured as the dispatch began. */\n readonly startedAt: number;\n /** {@link queuedMsFor} read at the same moment as `startedAt`. */\n readonly queuedMs: number;\n}\n\n/**\n * Discord's interaction creation to now, read from the snowflake. Called at dispatch entry, since\n * a later read would count the handler run into the queue time as well.\n *\n * @internal\n */\nexport function queuedMsFor(interactionId: string): number {\n // telemetry never breaks a dispatch, and BigInt() throws on a malformed id\n try {\n return Date.now() - timestampFromSnowflake(interactionId);\n } catch {\n return 0;\n }\n}\n\n/**\n * Builds the `interactionDispatched` payload both transports publish, so the two clocks are read the\n * same way on each.\n *\n * @internal\n */\nexport function dispatchedPayload(report: DispatchReport): SubscriptionData<'interactionDispatched'> {\n return {\n routeId: report.routeId,\n interactionId: report.interactionId,\n kind: report.kind,\n outcome: report.outcome,\n fallback: report.fallback,\n durationMs: performance.now() - report.startedAt,\n queuedMs: report.queuedMs\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,SAAgB,UAAU,aAAoC;CAC1D,KAAK,MAAM,CAAC,MAAM,QAAQ,OAAO,QAAQA,2CAAoB,GAAG;EAE5D,MAAM,SAAS,QAAQ,YAAY,KAAK,WAAW;EACnD,IAAI,QAAQ,QAAQ,OAAO,GAAG,KAAK,GAAG,OAAO,KAAK,GAAG;CACzD;CACA,OAAO;AACX;AAEA,eAAe,WAAW,MAA6B,KAAsB,SAAsC;CAC/G,MAAM,QAAQ,YAAY,IAAI;CAE9B,IAAI;EACA,MAAMC,wBAAS,MAAM,GAAG;CAC5B,UAAU;EACN,QAAQ,KAAK,MAAM,YAAY,IAAI,IAAI,KAAK;CAChD;AACJ;;;;;;AAOA,eAAsB,SAClB,OACA,KACA,SACa;CACb,IAAI;EACA,KAAK,MAAM,QAAQ,OACf,OAAO,UAAU,WAAW,MAAM,KAAK,OAAO,IAAIA,wBAAS,MAAM,GAAG;EAExE,MAAMC,0BAAW,GAAG;CACxB,UAAU;EACN,8BAAe,GAAG;CACtB;AACJ;AAIA,eAAsB,gBAClB,aACA,KACA,SACA,SACa;CAEb,MAAM,QAAQ,QAAQ,YAAYC,yCAAkB,WAAW;CAC/D,IAAI,CAAC,OAAO;CACZ,MAAM,SAAS,OAAO;EAAE,GAAG;EAAK,SAAS,WAAW,UAAU,WAAW;CAAE,GAAG,OAAO;AACzF;;;;AC5DA,MAAM,eAAe;AAGrB,IAAI;AACJ,SAAS,SAAiB;CACtB,eAAe,IAAIC,wBAAO,SAAS,EAAE,SAAS,QAAQ,CAAC;CACvD,OAAO;AACX;A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IAAI,kBAAkBC,uBAAQ,OAAO,OAAO,SAAS,WAAW;CAChE,OAAO;AACX;;;;;;;AAsBA,SAAgB,YAAY,eAA+B;CAEvD,IAAI;EACA,OAAO,KAAK,IAAI,gDAA2B,aAAa;CAC5D,QAAQ;EACJ,OAAO;CACX;AACJ;;;;;;;AAQA,SAAgB,kBAAkB,QAAmE;CACjG,OAAO;EACH,SAAS,OAAO;EAChB,eAAe,OAAO;EACtB,MAAM,OAAO;EACb,SAAS,OAAO;EAChB,UAAU,OAAO;EACjB,YAAY,YAAY,IAAI,IAAI,OAAO;EACvC,UAAU,OAAO;CACrB;AACJ"}
|
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { A as ModalLike, B as storeInteractionRoute, C as Gate, F as areRoutes, G as DecodedParams, I as contextMenuRouteOf, J as Promisable, K as CommandMeta, L as interactionRoutesOf, M as serializeReply, N as RoutableConstructor, R as selectMenuRouteOf, U as decodeFor, V as AnyCustomId, W as prefixOf, X as BuilderComponent, Y as IsNever, _ as pickNotice, c as FocusedField, i as AutocompletableNames, j as SerializedReply, k as BaseReplySender, lt as SlashOptionRegistry, m as PermissionNames, n as PageCursor, o as ChoiceValueOf, r as pageCursor, s as EntryFor, st as OptionKind, t as PAGE_MAX, tt as CommandInjector, v as GateFitsWith, w as GateContextBase, z as storeComponentRoute } from "./cursor-j5bRcn2O.mjs";
|
|
2
|
+
import { n as CommandBuilder, r as DeployResult } from "./basic-1hebYVcN.mjs";
|
|
3
|
+
import { A as AckState, B as InteractionRouteKeys, D as Notice, F as PublishDefault, H as MiddlewareMetadataKey, I as CommandMetadataKey, L as EventMetadataKey, M as checkAckLegality, N as sendTarget, O as ReplyTelemetry, P as AckTrace, R as GatedMetadataKey, S as DispatchOutcome, U as SubscribeMetadataKey, V as InteractionRoutes, W as WebhookUrlMetadataKey, a as PluginCtor, i as PluginArgs, j as ReplyMethod, k as reportedWrite, v as StoredSubscriberCtor, w as SubscriptionData, x as DefaultSubscriptions, y as SubscriberRegistration, z as InteractionMetadataKey } from "./Plugin-BZit5HUI.mjs";
|
|
4
|
+
import { n as contextMenuLeaves, t as ContextMenuLeaves } from "./contextMenuLeaves-f2rbyo83.mjs";
|
|
5
|
+
import { ContextMenuCommandBuilder, SlashCommandBuilder } from "@discordjs/builders";
|
|
6
|
+
import { ChannelType } from "discord-api-types/v10";
|
|
3
7
|
import { SeedcordErrorCode } from "@seedcord/errors";
|
|
4
8
|
import { SeedcordError } from "@seedcord/errors/internal";
|
|
5
|
-
import { ChannelType } from "discord-api-types/v10";
|
|
6
9
|
import { BotColor, DeferOpts, EpochMs, HmrAware, ReplyResponse, SendOpts } from "@seedcord/types";
|
|
7
10
|
import { DevChannel, SeedcordCliEvents, SeedcordFrameworkEvents } from "@seedcord/types/internal";
|
|
8
11
|
|
|
9
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/promisable.d.ts
|
|
10
|
-
/**
|
|
11
|
-
Create a type that represents either the value or the value wrapped in `PromiseLike`.
|
|
12
|
-
|
|
13
|
-
Use-cases:
|
|
14
|
-
- A function accepts a callback that may either return a value synchronously or may return a promised value.
|
|
15
|
-
- This type could be the return type of `Promise#then()`, `Promise#catch()`, and `Promise#finally()` callbacks.
|
|
16
|
-
|
|
17
|
-
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31394) if you want to have this type as a built-in in TypeScript.
|
|
18
|
-
|
|
19
|
-
@example
|
|
20
|
-
```
|
|
21
|
-
import type {Promisable} from 'type-fest';
|
|
22
|
-
|
|
23
|
-
async function logger(getLogEntry: () => Promisable<string>): Promise<void> {
|
|
24
|
-
const entry = await getLogEntry();
|
|
25
|
-
console.log(entry);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
await logger(() => 'foo');
|
|
29
|
-
await logger(() => Promise.resolve('bar'));
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
@category Async
|
|
33
|
-
*/
|
|
34
|
-
type Promisable<T> = T | PromiseLike<T>;
|
|
35
|
-
//#endregion
|
|
36
12
|
//#region src/components/botColorHolder.d.ts
|
|
37
13
|
declare function setBotColor(color: BotColor | undefined): void;
|
|
38
14
|
//#endregion
|
|
@@ -62,6 +38,38 @@ interface SlowGateMonitor {
|
|
|
62
38
|
}
|
|
63
39
|
declare function slowGateMonitor(): SlowGateMonitor | undefined;
|
|
64
40
|
//#endregion
|
|
41
|
+
//#region src/miscellaneous/guarded.d.ts
|
|
42
|
+
/**
|
|
43
|
+
* A backing record for a generated accessor. Null-prototype, on a plain object a key named `__proto__` sets
|
|
44
|
+
* the store's prototype and adds no entry.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
declare function accessorStore<Value>(): Record<string, Value>;
|
|
49
|
+
/** Empties a store in place, keeping the reference the accessor's Proxy wraps. @internal */
|
|
50
|
+
declare function clearStore(store: Record<string, unknown>): void;
|
|
51
|
+
/**
|
|
52
|
+
* Wraps a generated accessor's backing record so a read of an absent key throws. Handler modules import before
|
|
53
|
+
* startup fills the record, and an unguarded read there returns `undefined` and renders as an empty string.
|
|
54
|
+
*
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
declare function guardedAccessor<Value>(accessor: string, storage: Record<string, Value>): Record<string, Value>;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/miscellaneous/emojiConfig.d.ts
|
|
60
|
+
/** Narrows a configured emoji value to the `[name, guildId]` form. @internal */
|
|
61
|
+
declare function isEmojiTuple(value: unknown): value is readonly [string, string];
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/commands/slashRouteLeaves.d.ts
|
|
64
|
+
/**
|
|
65
|
+
* Collects the route keys of every executable slash leaf across a set of command builders, deduplicated
|
|
66
|
+
* because the same builder appears once per guild. The keys come from the same {@link routeLeavesOf} that
|
|
67
|
+
* `seedcord codegen` reads, so the boot-time check compares against the generated registry's keys.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
declare function slashRouteLeaves(commands: Iterable<SlashCommandBuilder | ContextMenuCommandBuilder>): Set<string>;
|
|
72
|
+
//#endregion
|
|
65
73
|
//#region src/hmr/devChannel.d.ts
|
|
66
74
|
/** @internal */
|
|
67
75
|
declare function setDevChannel(next: DevChannel<SeedcordFrameworkEvents, SeedcordCliEvents> | undefined): void;
|
|
@@ -129,6 +137,13 @@ declare class MissingPermissions extends Notice {
|
|
|
129
137
|
constructor(message: string | undefined, subject: string | null, missingPerms: readonly string[]);
|
|
130
138
|
render(): ReplyResponse;
|
|
131
139
|
}
|
|
140
|
+
declare class HasDangerousPermissions extends Notice {
|
|
141
|
+
subject: string;
|
|
142
|
+
dangerousPerms: readonly string[];
|
|
143
|
+
private readonly customLead;
|
|
144
|
+
constructor(message: string | undefined, subject: string, dangerousPerms: readonly string[]);
|
|
145
|
+
render(): ReplyResponse;
|
|
146
|
+
}
|
|
132
147
|
//#endregion
|
|
133
148
|
//#region src/stops/asError.d.ts
|
|
134
149
|
/** @internal */
|
|
@@ -229,16 +244,6 @@ type MemberGetter<Route extends keyof SlashOptionRegistry, Lens extends OptionLe
|
|
|
229
244
|
};
|
|
230
245
|
type SlashOptions<Route extends keyof SlashOptionRegistry, Lens extends OptionLens> = Getter<Route, Lens, 'string', 'getString'> & Getter<Route, Lens, 'integer', 'getInteger'> & Getter<Route, Lens, 'number', 'getNumber'> & Getter<Route, Lens, 'boolean', 'getBoolean'> & Getter<Route, Lens, 'user', 'getUser'> & Getter<Route, Lens, 'channel', 'getChannel'> & Getter<Route, Lens, 'role', 'getRole'> & Getter<Route, Lens, 'mentionable', 'getMentionable'> & Getter<Route, Lens, 'attachment', 'getAttachment'> & MemberGetter<Route, Lens>;
|
|
231
246
|
//#endregion
|
|
232
|
-
//#region src/pagination/cursor.d.ts
|
|
233
|
-
declare const PAGE_MAX = 1000000;
|
|
234
|
-
/** Page cursor for a paginator. */
|
|
235
|
-
type PageCursor<Prefix extends string> = CustomId<Prefix, {
|
|
236
|
-
page: CustomIdField<number>;
|
|
237
|
-
slot: CustomIdField<number>;
|
|
238
|
-
}>;
|
|
239
|
-
/** Build the page cursor for a paginator. */
|
|
240
|
-
declare function pageCursor<Prefix extends string>(prefix: Prefix): PageCursor<Prefix>;
|
|
241
|
-
//#endregion
|
|
242
247
|
//#region src/reply/flags.d.ts
|
|
243
248
|
/** IsComponentsV2 is unconditional, every framework reply is v2. */
|
|
244
249
|
declare function sendFlags(opts?: SendOpts): number;
|
|
@@ -313,5 +318,5 @@ declare function queuedMsFor(interactionId: string): number;
|
|
|
313
318
|
*/
|
|
314
319
|
declare function dispatchedPayload(report: DispatchReport): SubscriptionData<'interactionDispatched'>;
|
|
315
320
|
//#endregion
|
|
316
|
-
export { type AckState, AckTrace, type AnyCustomId, type AutocompletableNames, BaseReplySender, type ChoiceValueOf, type CommandMeta, CommandMetadataKey, ComponentDefsKey, type DecodedComponentRoute, type DecodedParams, type DefaultSubscriptions, type EntryFor, EventMetadataKey, FaultThrottle, type FocusedField, type GateFitsWith, GateNotice, type GateObserver, GatedMetadataKey, type HasComponentDefs, HmrManager, InteractionMetadataKey, InteractionRouteKeys, InteractionRoutes, type MatchArms, MiddlewareMetadataKey, MissingPermissions, MissingRole, type ModalLike, NeedsAny, NotAllowed, NotInDm, NotInGuild, NotOwner, NoticeCard, OnCooldown, type OptionLens, PAGE_MAX, type PageCursor, PermissionNames, type PluginArgs, type PluginCtor, PublishDefault, type ReplyMethod, type ReplyTelemetry, type RoutableConstructor, type SerializedReply, type SingleParams, type SlashOptions, type SlowGateMonitor, type StoredSubscriberCtor, SubscribeMetadataKey, type SubscriberRegistration, WebhookUrlMetadataKey, areRoutes, asError, checkAckLegality, contextMenuRouteOf, decodeComponentRoute, decodeFor, deferFlags, dispatchedPayload, getDevChannel, interactionRoutesOf, outcomeFor, pageCursor, pickNotice, prefixOf, queuedMsFor, reportedWrite, routeIdOf, runGates, runHandlerGates, selectMenuRouteOf, sendFlags, sendTarget, serializeReply, setBotColor, setDevChannel, slowGateMonitor, storeComponentRoute, storeInteractionRoute, translateSerializationError, wrapHot };
|
|
321
|
+
export { type AckState, AckTrace, type AnyCustomId, type AutocompletableNames, BaseReplySender, type ChoiceValueOf, type CommandBuilder, CommandInjector, type CommandMeta, CommandMetadataKey, ComponentDefsKey, type ContextMenuLeaves, type DecodedComponentRoute, type DecodedParams, type DefaultSubscriptions, type DeployResult, type EntryFor, EventMetadataKey, FaultThrottle, type FocusedField, type GateFitsWith, GateNotice, type GateObserver, GatedMetadataKey, type HasComponentDefs, HasDangerousPermissions, HmrManager, InteractionMetadataKey, InteractionRouteKeys, InteractionRoutes, type MatchArms, MiddlewareMetadataKey, MissingPermissions, MissingRole, type ModalLike, NeedsAny, NotAllowed, NotInDm, NotInGuild, NotOwner, NoticeCard, OnCooldown, type OptionLens, PAGE_MAX, type PageCursor, PermissionNames, type PluginArgs, type PluginCtor, PublishDefault, type ReplyMethod, type ReplyTelemetry, type RoutableConstructor, type SerializedReply, type SingleParams, type SlashOptions, type SlowGateMonitor, type StoredSubscriberCtor, SubscribeMetadataKey, type SubscriberRegistration, WebhookUrlMetadataKey, accessorStore, areRoutes, asError, checkAckLegality, clearStore, contextMenuLeaves, contextMenuRouteOf, decodeComponentRoute, decodeFor, deferFlags, dispatchedPayload, getDevChannel, guardedAccessor, interactionRoutesOf, isEmojiTuple, outcomeFor, pageCursor, pickNotice, prefixOf, queuedMsFor, reportedWrite, routeIdOf, runGates, runHandlerGates, selectMenuRouteOf, sendFlags, sendTarget, serializeReply, setBotColor, setDevChannel, slashRouteLeaves, slowGateMonitor, storeComponentRoute, storeInteractionRoute, translateSerializationError, wrapHot };
|
|
317
322
|
//# sourceMappingURL=internal.index.d.mts.map
|