@seedcord/core 0.9.2 → 0.9.3
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/README.md +2 -2
- package/dist/{Bus-Djm6688b.mjs → Bus-DUDafYDD.mjs} +15 -19
- package/dist/Bus-DUDafYDD.mjs.map +1 -0
- package/dist/{HmrModuleHandler-9AUfKXRl.mjs → HmrModuleHandler-DOAtah3j.mjs} +3 -5
- package/dist/HmrModuleHandler-DOAtah3j.mjs.map +1 -0
- package/dist/{Pluggable-D-xWcaIv.mjs → Pluggable-CXyUZIvT.mjs} +2 -8
- package/dist/{Pluggable-D-xWcaIv.mjs.map → Pluggable-CXyUZIvT.mjs.map} +1 -1
- package/dist/{Pluggable-aRzcpx4e.d.mts → Pluggable-CwKbLui3.d.mts} +3 -3
- package/dist/{Plugin-D01bBIFo.d.mts → Plugin-Dhx_ivqj.d.mts} +2 -2
- package/dist/{cursor-BPaPFTic.d.mts → cursor-BTU5bGoo.d.mts} +4 -151
- package/dist/{cursor-CFNKLVlk.mjs → cursor-DNFyo_BI.mjs} +2 -2
- package/dist/{cursor-CFNKLVlk.mjs.map → cursor-DNFyo_BI.mjs.map} +1 -1
- package/dist/hmr.index.d.mts +1 -2
- package/dist/hmr.index.mjs +1 -1
- package/dist/{index-BS1hH9Sh.d.mts → index-B_-EjyvS.d.mts} +6 -6
- package/dist/index.d.mts +40 -39
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/internal.index.d.mts +52 -51
- package/dist/internal.index.mjs +7 -8
- package/dist/internal.index.mjs.map +1 -1
- package/dist/node-internal.index.d.mts +14 -14
- package/dist/node-internal.index.mjs +8 -9
- package/dist/node-internal.index.mjs.map +1 -1
- package/dist/node.index.d.mts +1 -1
- package/dist/node.index.mjs +4 -5
- package/dist/node.index.mjs.map +1 -1
- package/dist/{phases-DJf12l5T.d.mts → phases-D_zQBXga.d.mts} +15 -25
- package/dist/plugin.index.d.mts +1 -1
- package/dist/{slashRouteLeaves-DTFHzCKN.mjs → slashRouteLeaves-D__G9vsr.mjs} +2 -2
- package/dist/slashRouteLeaves-D__G9vsr.mjs.map +1 -0
- package/dist/{subscribers-kAQQt_YP.mjs → subscribers-Bxut8U6g.mjs} +2 -2
- package/dist/{subscribers-kAQQt_YP.mjs.map → subscribers-Bxut8U6g.mjs.map} +1 -1
- package/dist/{basic-Dng__Ena.d.mts → types-BG0BimVr.d.mts} +2 -10
- package/package.json +12 -12
- package/dist/Bus-Djm6688b.mjs.map +0 -1
- package/dist/HmrModuleHandler-9AUfKXRl.mjs.map +0 -1
- package/dist/slashRouteLeaves-DTFHzCKN.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { A as serializeReply, B as AutocompleteRouteBrand, C as Gate, F as AnyMiddlewareCtor, G as MiddlewareKindsBrand, H as ComponentKindBrand, I as InteractionMiddlewareMetadata, K as SlashRouteBrand, M as EventDispatchResult, P as HandlerResult,
|
|
3
|
-
import { n as
|
|
4
|
-
import { i as Initializeable, o as PluginArgs, s as PluginCtor } from "./Plugin-
|
|
1
|
+
import { A as RegisteredCount, B as InteractionMetadataKey, C as AckState, D as AckTrace, E as sendTarget, F as CommandMetadataKey, G as WebhookUrlMetadataKey, H as InteractionRouteKeys, I as EventMetadataKey, K as Notice, L as EventMiddlewareMetadataKey, M as VerifyWebhooks, N as PublishDefault, O as RegisterDefaults, R as GatedMetadataKey, S as reportedWrite, T as checkAckLegality, U as MiddlewareKind, V as InteractionMiddlewareMetadataKey, W as SubscribeMetadataKey, a as StoredSubscriberCtor, c as registrationFor, d as DefaultSubscriptions, f as DispatchOutcome, i as Bus, j as UnregisterSubscriber, k as RegisterSubscriber, o as SubscriberRegistration, s as busLoggerOf, w as ReplyMethod, x as ReplyTelemetry, z as InteractionKind } from "./phases-D_zQBXga.mjs";
|
|
2
|
+
import { A as serializeReply, B as AutocompleteRouteBrand, C as Gate, F as AnyMiddlewareCtor, G as MiddlewareKindsBrand, H as ComponentKindBrand, I as InteractionMiddlewareMetadata, K as SlashRouteBrand, M as EventDispatchResult, P as HandlerResult, U as ContextMenuKindBrand, V as ComponentDefsBrand, W as ContextMenuNamesBrand, X as BuilderComponent, _ as pickNotice, at as SlashRouteEntry, c as FocusedField, et as CacheFor, i as AutocompletableNames, it as SlashRegistry, j as DispatchResult, k as SerializedReply, lt as NamesFor, m as PermissionNames, n as PageCursor, nt as RouteCache, o as ChoiceValueOf, ot as ContextMenuKind, q as CommandMeta, r as pageCursor, rt as SlashOption, s as EntryFor, st as MenuCacheFor, t as PAGE_MAX, tt as OptionKind, v as GateFitsWith, w as GateContextBase, z as interactionMiddlewareMetaOf } from "./cursor-BTU5bGoo.mjs";
|
|
3
|
+
import { n as DeployResult, t as CommandBuilder } from "./types-BG0BimVr.mjs";
|
|
4
|
+
import { i as Initializeable, o as PluginArgs, s as PluginCtor } from "./Plugin-Dhx_ivqj.mjs";
|
|
5
5
|
import { n as contextMenuLeaves, t as ContextMenuLeaves } from "./contextMenuLeaves-COzDYa6c.mjs";
|
|
6
6
|
import "reflect-metadata";
|
|
7
7
|
import { AnyCustomId, DecodedParams } from "@seedcord/custom-id";
|
|
@@ -12,6 +12,7 @@ import { SeedcordError } from "@seedcord/errors/internal";
|
|
|
12
12
|
import { Logger } from "@seedcord/logger";
|
|
13
13
|
import { DevChannel, SeedcordCliEvents, SeedcordFrameworkEvents } from "@seedcord/types/internal";
|
|
14
14
|
import { BotColor, DeferOpts, EpochMs, HmrAware, ReplyResponse, SendOpts } from "@seedcord/types";
|
|
15
|
+
import { Constructor, IsNever, Promisable } from "type-fest";
|
|
15
16
|
//#region src/dispatch/MiddlewareRegistry.d.ts
|
|
16
17
|
/**
|
|
17
18
|
* A decorated middleware reduced to what the registry orders and filters on. An absent `keys` puts the
|
|
@@ -30,7 +31,7 @@ interface MiddlewareRegistration<Key extends string> {
|
|
|
30
31
|
*/
|
|
31
32
|
type MiddlewareRegistrationOf<Ctor, Key extends string> = (ctor: Ctor) => MiddlewareRegistration<Key> | undefined;
|
|
32
33
|
/** @internal */
|
|
33
|
-
declare function interactionMiddleware(ctor: AnyMiddlewareCtor): MiddlewareRegistration<MiddlewareKind> | undefined;
|
|
34
|
+
export declare function interactionMiddleware(ctor: AnyMiddlewareCtor): MiddlewareRegistration<MiddlewareKind> | undefined;
|
|
34
35
|
/**
|
|
35
36
|
* Holds the middleware a transport loaded and keeps one chain per key. An interaction keys on its kind
|
|
36
37
|
* and an event on its name. Priority and the key filter behave the same on each.
|
|
@@ -40,7 +41,7 @@ declare function interactionMiddleware(ctor: AnyMiddlewareCtor): MiddlewareRegis
|
|
|
40
41
|
*
|
|
41
42
|
* @internal
|
|
42
43
|
*/
|
|
43
|
-
declare class MiddlewareRegistry<Ctor extends AnyMiddlewareCtor, Key extends string = MiddlewareKind> {
|
|
44
|
+
export declare class MiddlewareRegistry<Ctor extends AnyMiddlewareCtor, Key extends string = MiddlewareKind> {
|
|
44
45
|
private readonly registrationOf;
|
|
45
46
|
private readonly entries;
|
|
46
47
|
private chains;
|
|
@@ -58,20 +59,20 @@ declare class MiddlewareRegistry<Ctor extends AnyMiddlewareCtor, Key extends str
|
|
|
58
59
|
}
|
|
59
60
|
//#endregion
|
|
60
61
|
//#region src/components/botColorHolder.d.ts
|
|
61
|
-
declare function setBotColor(color: BotColor | undefined): void;
|
|
62
|
+
export declare function setBotColor(color: BotColor | undefined): void;
|
|
62
63
|
//#endregion
|
|
63
64
|
//#region src/decorators/interactionRoutes.d.ts
|
|
64
65
|
type RoutableConstructor = new (...args: never[]) => unknown;
|
|
65
|
-
declare function areRoutes(routes: unknown): routes is string[];
|
|
66
|
-
declare function interactionRoutesOf(constructor: RoutableConstructor): [InteractionKind, string[]][];
|
|
67
|
-
declare function storeInteractionRoute(route: InteractionKind, routes: string | readonly string[], constructor: RoutableConstructor): void;
|
|
68
|
-
declare function storeComponentRoute(route: InteractionKind, defs: readonly AnyCustomId[], constructor: RoutableConstructor): void;
|
|
69
|
-
declare function contextMenuRouteOf(kind: ContextMenuKind): InteractionKind;
|
|
66
|
+
export declare function areRoutes(routes: unknown): routes is string[];
|
|
67
|
+
export declare function interactionRoutesOf(constructor: RoutableConstructor): [InteractionKind, string[]][];
|
|
68
|
+
export declare function storeInteractionRoute(route: InteractionKind, routes: string | readonly string[], constructor: RoutableConstructor): void;
|
|
69
|
+
export declare function storeComponentRoute(route: InteractionKind, defs: readonly AnyCustomId[], constructor: RoutableConstructor): void;
|
|
70
|
+
export declare function contextMenuRouteOf(kind: ContextMenuKind): InteractionKind;
|
|
70
71
|
//#endregion
|
|
71
72
|
//#region src/gates/runGates.d.ts
|
|
72
73
|
type GateObserver = (gateName: string, elapsedMs: number) => void;
|
|
73
|
-
declare function runGates(gates: readonly Gate<GateContextBase>[], ctx: GateContextBase, observe?: GateObserver): Promise<void>;
|
|
74
|
-
declare function runHandlerGates(handlerCtor: object, ctx: GateContextBase, declaredRoute?: string, observe?: GateObserver): Promise<void>;
|
|
74
|
+
export declare function runGates(gates: readonly Gate<GateContextBase>[], ctx: GateContextBase, observe?: GateObserver): Promise<void>;
|
|
75
|
+
export declare function runHandlerGates(handlerCtor: object, ctx: GateContextBase, declaredRoute?: string, observe?: GateObserver): Promise<void>;
|
|
75
76
|
//#endregion
|
|
76
77
|
//#region src/gates/slowGate.d.ts
|
|
77
78
|
/**
|
|
@@ -82,21 +83,21 @@ interface SlowGateMonitor {
|
|
|
82
83
|
readonly observe: GateObserver;
|
|
83
84
|
report(declaredRoute: string | null): void;
|
|
84
85
|
}
|
|
85
|
-
declare function slowGateMonitor(): SlowGateMonitor | undefined;
|
|
86
|
+
export declare function slowGateMonitor(): SlowGateMonitor | undefined;
|
|
86
87
|
//#endregion
|
|
87
88
|
//#region src/miscellaneous/guarded.d.ts
|
|
88
|
-
declare function accessorStore<Value>(): Record<string, Value>;
|
|
89
|
-
declare function clearStore(store: Record<string, unknown>): void;
|
|
90
|
-
declare function guardedAccessor<Value>(accessor: string, storage: Record<string, Value>): Record<string, Value>;
|
|
89
|
+
export declare function accessorStore<Value>(): Record<string, Value>;
|
|
90
|
+
export declare function clearStore(store: Record<string, unknown>): void;
|
|
91
|
+
export declare function guardedAccessor<Value>(accessor: string, storage: Record<string, Value>): Record<string, Value>;
|
|
91
92
|
//#endregion
|
|
92
93
|
//#region src/miscellaneous/emojiConfig.d.ts
|
|
93
|
-
declare function isEmojiTuple(value: unknown): value is readonly [string, string];
|
|
94
|
+
export declare function isEmojiTuple(value: unknown): value is readonly [string, string];
|
|
94
95
|
//#endregion
|
|
95
96
|
//#region src/commands/isCommandClass.d.ts
|
|
96
97
|
/** @internal */
|
|
97
|
-
type CommandCtor =
|
|
98
|
+
type CommandCtor = Constructor<BuilderComponent<'command' | 'context_menu'>, never[]>;
|
|
98
99
|
/** @internal */
|
|
99
|
-
declare function isCommandClass(value: unknown): value is CommandCtor;
|
|
100
|
+
export declare function isCommandClass(value: unknown): value is CommandCtor;
|
|
100
101
|
//#endregion
|
|
101
102
|
//#region src/commands/slashRouteLeaves.d.ts
|
|
102
103
|
/**
|
|
@@ -106,16 +107,16 @@ declare function isCommandClass(value: unknown): value is CommandCtor;
|
|
|
106
107
|
*
|
|
107
108
|
* @internal
|
|
108
109
|
*/
|
|
109
|
-
declare function slashRouteLeaves(commands: Iterable<SlashCommandBuilder | ContextMenuCommandBuilder>): Set<string>;
|
|
110
|
+
export declare function slashRouteLeaves(commands: Iterable<SlashCommandBuilder | ContextMenuCommandBuilder>): Set<string>;
|
|
110
111
|
//#endregion
|
|
111
112
|
//#region src/hmr/devChannel.d.ts
|
|
112
113
|
/** @internal */
|
|
113
|
-
declare function setDevChannel(next: DevChannel<SeedcordFrameworkEvents, SeedcordCliEvents> | undefined): void;
|
|
114
|
+
export declare function setDevChannel(next: DevChannel<SeedcordFrameworkEvents, SeedcordCliEvents> | undefined): void;
|
|
114
115
|
/** @internal */
|
|
115
|
-
declare function getDevChannel(): DevChannel<SeedcordFrameworkEvents, SeedcordCliEvents> | undefined;
|
|
116
|
+
export declare function getDevChannel(): DevChannel<SeedcordFrameworkEvents, SeedcordCliEvents> | undefined;
|
|
116
117
|
//#endregion
|
|
117
118
|
//#region src/hmr/HmrManager.d.ts
|
|
118
|
-
declare class HmrManager {
|
|
119
|
+
export declare class HmrManager {
|
|
119
120
|
private readonly logger;
|
|
120
121
|
private readonly listeners;
|
|
121
122
|
/** @internal */
|
|
@@ -131,45 +132,45 @@ interface RawHot {
|
|
|
131
132
|
on(event: string, cb: (data: unknown) => void): void;
|
|
132
133
|
}
|
|
133
134
|
/** @internal */
|
|
134
|
-
declare function wrapHot<TSend, TRecv>(hot: RawHot): DevChannel<TSend, TRecv>;
|
|
135
|
+
export declare function wrapHot<TSend, TRecv>(hot: RawHot): DevChannel<TSend, TRecv>;
|
|
135
136
|
//#endregion
|
|
136
137
|
//#region src/notices/index.d.ts
|
|
137
|
-
declare abstract class GateNotice extends Notice {
|
|
138
|
+
export declare abstract class GateNotice extends Notice {
|
|
138
139
|
render(): ReplyResponse;
|
|
139
140
|
}
|
|
140
|
-
declare class NotOwner extends GateNotice {
|
|
141
|
+
export declare class NotOwner extends GateNotice {
|
|
141
142
|
constructor(message?: string);
|
|
142
143
|
}
|
|
143
|
-
declare class NotInGuild extends GateNotice {
|
|
144
|
+
export declare class NotInGuild extends GateNotice {
|
|
144
145
|
constructor(message?: string);
|
|
145
146
|
}
|
|
146
|
-
declare class NotInDm extends GateNotice {
|
|
147
|
+
export declare class NotInDm extends GateNotice {
|
|
147
148
|
constructor(message?: string);
|
|
148
149
|
}
|
|
149
|
-
declare class OnCooldown extends GateNotice {
|
|
150
|
+
export declare class OnCooldown extends GateNotice {
|
|
150
151
|
readonly resetAt: EpochMs;
|
|
151
152
|
constructor(resetAt: EpochMs, message?: string);
|
|
152
153
|
}
|
|
153
|
-
declare class NotAllowed extends Notice {
|
|
154
|
+
export declare class NotAllowed extends Notice {
|
|
154
155
|
constructor();
|
|
155
156
|
render(): ReplyResponse;
|
|
156
157
|
}
|
|
157
|
-
declare class NeedsAny extends Notice {
|
|
158
|
+
export declare class NeedsAny extends Notice {
|
|
158
159
|
private readonly summaries;
|
|
159
160
|
constructor(summaries: readonly string[]);
|
|
160
161
|
render(): ReplyResponse;
|
|
161
162
|
}
|
|
162
|
-
declare class MissingRole extends GateNotice {
|
|
163
|
+
export declare class MissingRole extends GateNotice {
|
|
163
164
|
constructor(message: string | undefined, roleId: string | null);
|
|
164
165
|
}
|
|
165
|
-
declare class MissingPermissions extends Notice {
|
|
166
|
+
export declare class MissingPermissions extends Notice {
|
|
166
167
|
private readonly subject;
|
|
167
168
|
private readonly missingPerms;
|
|
168
169
|
private readonly customLead;
|
|
169
170
|
constructor(message: string | undefined, subject: string | null, missingPerms: readonly string[]);
|
|
170
171
|
render(): ReplyResponse;
|
|
171
172
|
}
|
|
172
|
-
declare class HasDangerousPermissions extends Notice {
|
|
173
|
+
export declare class HasDangerousPermissions extends Notice {
|
|
173
174
|
private readonly subject;
|
|
174
175
|
private readonly dangerousPerms;
|
|
175
176
|
private readonly customLead;
|
|
@@ -179,10 +180,10 @@ declare class HasDangerousPermissions extends Notice {
|
|
|
179
180
|
//#endregion
|
|
180
181
|
//#region src/stops/asError.d.ts
|
|
181
182
|
/** @internal */
|
|
182
|
-
declare function asError(caught: unknown): Error;
|
|
183
|
+
export declare function asError(caught: unknown): Error;
|
|
183
184
|
//#endregion
|
|
184
185
|
//#region src/stops/NoticeCard.d.ts
|
|
185
|
-
declare class NoticeCard extends BuilderComponent<'container'> {
|
|
186
|
+
export declare class NoticeCard extends BuilderComponent<'container'> {
|
|
186
187
|
constructor(description: string, title?: string);
|
|
187
188
|
}
|
|
188
189
|
//#endregion
|
|
@@ -193,7 +194,7 @@ declare class NoticeCard extends BuilderComponent<'container'> {
|
|
|
193
194
|
*
|
|
194
195
|
* @internal
|
|
195
196
|
*/
|
|
196
|
-
declare const ComponentDefsKey: unique symbol;
|
|
197
|
+
export declare const ComponentDefsKey: unique symbol;
|
|
197
198
|
/**
|
|
198
199
|
* the phantom a component handler base carries. a route decorator constrains its argument to this, so
|
|
199
200
|
* passing different defs to the decorator and the handler's generic is a compile error. never set at runtime.
|
|
@@ -215,7 +216,7 @@ interface DecodedComponentRoute {
|
|
|
215
216
|
*
|
|
216
217
|
* @internal
|
|
217
218
|
*/
|
|
218
|
-
declare function decodeComponentRoute(handlerClass: {
|
|
219
|
+
export declare function decodeComponentRoute(handlerClass: {
|
|
219
220
|
name: string;
|
|
220
221
|
}, wire: string): DecodedComponentRoute;
|
|
221
222
|
/** @internal */
|
|
@@ -273,14 +274,14 @@ type MemberGetter<Route extends keyof SlashRegistry, Lens extends OptionLens> =
|
|
|
273
274
|
type SlashOptions<Route extends keyof SlashRegistry, 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>;
|
|
274
275
|
//#endregion
|
|
275
276
|
//#region src/reply/flags.d.ts
|
|
276
|
-
declare function sendFlags(opts?: SendOpts): number;
|
|
277
|
-
declare function deferFlags(opts?: DeferOpts): number;
|
|
277
|
+
export declare function sendFlags(opts?: SendOpts): number;
|
|
278
|
+
export declare function deferFlags(opts?: DeferOpts): number;
|
|
278
279
|
//#endregion
|
|
279
280
|
//#region src/reply/translateSerialization.d.ts
|
|
280
|
-
declare function translateSerializationError(error: unknown, componentClass: string, index: number, routeId: string): SeedcordError<SeedcordErrorCode.ReplyComponentSerialization>;
|
|
281
|
+
export declare function translateSerializationError(error: unknown, componentClass: string, index: number, routeId: string): SeedcordError<SeedcordErrorCode.ReplyComponentSerialization>;
|
|
281
282
|
//#endregion
|
|
282
283
|
//#region src/subscribers/ReportThrottle.d.ts
|
|
283
|
-
declare class ReportThrottle {
|
|
284
|
+
export declare class ReportThrottle {
|
|
284
285
|
private readonly windowMs;
|
|
285
286
|
private readonly now;
|
|
286
287
|
private static readonly perCore;
|
|
@@ -298,7 +299,7 @@ declare class ReportThrottle {
|
|
|
298
299
|
*
|
|
299
300
|
* @internal
|
|
300
301
|
*/
|
|
301
|
-
declare function outcomeFor(caught: unknown): Exclude<DispatchOutcome, 'handled'>;
|
|
302
|
+
export declare function outcomeFor(caught: unknown): Exclude<DispatchOutcome, 'handled'>;
|
|
302
303
|
interface DispatchReport {
|
|
303
304
|
readonly dispatchId: string;
|
|
304
305
|
readonly routeId: string;
|
|
@@ -320,22 +321,22 @@ interface DispatchReport {
|
|
|
320
321
|
*
|
|
321
322
|
* @internal
|
|
322
323
|
*/
|
|
323
|
-
declare function queuedMsFor(interactionId: string): number;
|
|
324
|
-
declare function reportDispatch(bus: Bus, report: DispatchReport): void;
|
|
324
|
+
export declare function queuedMsFor(interactionId: string): number;
|
|
325
|
+
export declare function reportDispatch(bus: Bus, report: DispatchReport): void;
|
|
325
326
|
//#endregion
|
|
326
327
|
//#region src/dispatch/runAfter.d.ts
|
|
327
328
|
interface Afterable<Result> {
|
|
328
329
|
after?(result: Result): Promise<void>;
|
|
329
330
|
}
|
|
330
331
|
/** @internal */
|
|
331
|
-
declare function resultFor(caught: unknown): DispatchResult;
|
|
332
|
+
export declare function resultFor(caught: unknown): DispatchResult;
|
|
332
333
|
/**
|
|
333
334
|
* Builds what an event middleware's `after()` receives. `handlers` is empty exactly when the chain
|
|
334
335
|
* stopped the event.
|
|
335
336
|
*
|
|
336
337
|
* @internal
|
|
337
338
|
*/
|
|
338
|
-
declare function eventResultFor(stopped: {
|
|
339
|
+
export declare function eventResultFor(stopped: {
|
|
339
340
|
caught: unknown;
|
|
340
341
|
} | null, handlers: readonly HandlerResult[]): EventDispatchResult;
|
|
341
342
|
/**
|
|
@@ -344,7 +345,7 @@ declare function eventResultFor(stopped: {
|
|
|
344
345
|
*
|
|
345
346
|
* @internal
|
|
346
347
|
*/
|
|
347
|
-
declare function runAfter<Result>(ran: readonly Afterable<Result>[], result: Result, logger: Logger): Promise<void>;
|
|
348
|
+
export declare function runAfter<Result>(ran: readonly Afterable<Result>[], result: Result, logger: Logger): Promise<void>;
|
|
348
349
|
//#endregion
|
|
349
|
-
export { type AckState, AckTrace, type AutocompletableNames, AutocompleteRouteBrand, type CacheFor, type ChoiceValueOf, type CommandBuilder, type CommandCtor, type CommandMeta, CommandMetadataKey, ComponentDefsBrand,
|
|
350
|
+
export { type AckState, AckTrace, type AutocompletableNames, AutocompleteRouteBrand, type CacheFor, type ChoiceValueOf, type CommandBuilder, type CommandCtor, type CommandMeta, CommandMetadataKey, ComponentDefsBrand, ComponentKindBrand, ContextMenuKindBrand, type ContextMenuLeaves, ContextMenuNamesBrand, type DecodedComponentRoute, type DefaultSubscriptions, type DeployResult, type EntryFor, EventMetadataKey, EventMiddlewareMetadataKey, type FocusedField, type GateFitsWith, type GateObserver, GatedMetadataKey, type HasComponentDefs, type Initializeable, InteractionMetadataKey, type InteractionMiddlewareMetadata, InteractionMiddlewareMetadataKey, InteractionRouteKeys, type MatchArms, type MenuCacheFor, MiddlewareKindsBrand, type MiddlewareRegistration, type MiddlewareRegistrationOf, type NamesFor, type OptionKind, type OptionLens, PAGE_MAX, type PageCursor, PermissionNames, type PluginArgs, type PluginCtor, PublishDefault, RegisterDefaults, RegisterSubscriber, RegisteredCount, type ReplyMethod, type ReplyTelemetry, type RoutableConstructor, type RouteCache, type SerializedReply, type SingleParams, type SlashOption, type SlashOptions, SlashRouteBrand, type SlashRouteEntry, type SlowGateMonitor, type StoredSubscriberCtor, SubscribeMetadataKey, type SubscriberRegistration, UnregisterSubscriber, VerifyWebhooks, WebhookUrlMetadataKey, busLoggerOf, checkAckLegality, contextMenuLeaves, interactionMiddlewareMetaOf, pageCursor, pickNotice, registrationFor, reportedWrite, sendTarget, serializeReply };
|
|
350
351
|
//# sourceMappingURL=internal.index.d.mts.map
|
package/dist/internal.index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { A as translateSerializationError, B as contextMenuRouteOf, C as NotInDm, E as OnCooldown, F as checkAckLegality, G as decodeComponentRoute, H as storeComponentRoute, I as sendTarget, K as NoticeCard, N as reportedWrite, P as AckTrace, R as interactionMiddlewareMetaOf, S as NotAllowed, T as NotOwner, U as storeInteractionRoute, V as interactionRoutesOf, W as ComponentDefsKey, _ as GateNotice, b as MissingRole, d as pickNotice, f as discardCommits, g as runCommits, h as runCheck, k as serializeReply, n as pageCursor, q as Notice, r as Silence, s as PermissionNames, t as PAGE_MAX, v as HasDangerousPermissions, w as NotInGuild, x as NeedsAny, y as MissingPermissions, z as areRoutes } from "./cursor-
|
|
2
|
-
import { C as InteractionRouteKeys, D as clearStore, E as accessorStore, N as setBotColor, O as guardedAccessor, S as InteractionMiddlewareMetadataKey, T as WebhookUrlMetadataKey, _ as EventMetadataKey, a as RegisterSubscriber, c as VerifyWebhooks, g as CommandMetadataKey, h as sendFlags, i as RegisterDefaults, k as contextMenuLeaves, m as deferFlags, n as busLoggerOf, o as RegisteredCount, p as ReportThrottle, s as UnregisterSubscriber, v as EventMiddlewareMetadataKey, w as SubscribeMetadataKey, x as InteractionMetadataKey, y as GatedMetadataKey } from "./Bus-
|
|
1
|
+
import { A as translateSerializationError, B as contextMenuRouteOf, C as NotInDm, E as OnCooldown, F as checkAckLegality, G as decodeComponentRoute, H as storeComponentRoute, I as sendTarget, K as NoticeCard, N as reportedWrite, P as AckTrace, R as interactionMiddlewareMetaOf, S as NotAllowed, T as NotOwner, U as storeInteractionRoute, V as interactionRoutesOf, W as ComponentDefsKey, _ as GateNotice, b as MissingRole, d as pickNotice, f as discardCommits, g as runCommits, h as runCheck, k as serializeReply, n as pageCursor, q as Notice, r as Silence, s as PermissionNames, t as PAGE_MAX, v as HasDangerousPermissions, w as NotInGuild, x as NeedsAny, y as MissingPermissions, z as areRoutes } from "./cursor-DNFyo_BI.mjs";
|
|
2
|
+
import { C as InteractionRouteKeys, D as clearStore, E as accessorStore, N as setBotColor, O as guardedAccessor, S as InteractionMiddlewareMetadataKey, T as WebhookUrlMetadataKey, _ as EventMetadataKey, a as RegisterSubscriber, c as VerifyWebhooks, g as CommandMetadataKey, h as sendFlags, i as RegisterDefaults, k as contextMenuLeaves, m as deferFlags, n as busLoggerOf, o as RegisteredCount, p as ReportThrottle, r as registrationFor, s as UnregisterSubscriber, v as EventMiddlewareMetadataKey, w as SubscribeMetadataKey, x as InteractionMetadataKey, y as GatedMetadataKey } from "./Bus-DUDafYDD.mjs";
|
|
3
3
|
import { n as asError, t as PublishDefault } from "./publishDefault-BuSZPbjT.mjs";
|
|
4
4
|
import { n as setDevChannel, t as getDevChannel } from "./devChannel-CQU7hq7Q.mjs";
|
|
5
|
-
import { n as isCommandClass, t as slashRouteLeaves } from "./slashRouteLeaves-
|
|
5
|
+
import { n as isCommandClass, t as slashRouteLeaves } from "./slashRouteLeaves-D__G9vsr.mjs";
|
|
6
6
|
import "reflect-metadata";
|
|
7
7
|
import { SeedcordErrorCode, paint } from "@seedcord/errors";
|
|
8
8
|
import { SeedcordError } from "@seedcord/errors/internal";
|
|
@@ -163,10 +163,9 @@ var HmrManager = class {
|
|
|
163
163
|
if (!import.meta.hot) return;
|
|
164
164
|
const channel = wrapHot(import.meta.hot);
|
|
165
165
|
setDevChannel(channel);
|
|
166
|
-
if (Envapter.isDevelopment || Envapter.isTest)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
166
|
+
if (!(Envapter.isDevelopment || Envapter.isTest)) return;
|
|
167
|
+
this.logger.debug("Enabled");
|
|
168
|
+
channel.on("seedcord:hmr", (payload) => void this.handleUpdate(payload));
|
|
170
169
|
}
|
|
171
170
|
/** @internal */
|
|
172
171
|
register(listener) {
|
|
@@ -275,5 +274,5 @@ async function runAfter(ran, result, logger) {
|
|
|
275
274
|
}
|
|
276
275
|
|
|
277
276
|
//#endregion
|
|
278
|
-
export { AckTrace, AutocompleteRouteBrand, CommandMetadataKey, ComponentDefsBrand, ComponentDefsKey, ComponentKindBrand, ContextMenuKindBrand, ContextMenuNamesBrand, EventMetadataKey, EventMiddlewareMetadataKey, GateNotice, GatedMetadataKey, HasDangerousPermissions, HmrManager, InteractionMetadataKey, InteractionMiddlewareMetadataKey, InteractionRouteKeys, MiddlewareKindsBrand, MiddlewareRegistry, MissingPermissions, MissingRole, NeedsAny, NotAllowed, NotInDm, NotInGuild, NotOwner, NoticeCard, OnCooldown, PAGE_MAX, PermissionNames, PublishDefault, RegisterDefaults, RegisterSubscriber, RegisteredCount, ReportThrottle, SlashRouteBrand, SubscribeMetadataKey, UnregisterSubscriber, VerifyWebhooks, WebhookUrlMetadataKey, accessorStore, areRoutes, asError, busLoggerOf, checkAckLegality, clearStore, contextMenuLeaves, contextMenuRouteOf, decodeComponentRoute, deferFlags, eventResultFor, getDevChannel, guardedAccessor, interactionMiddleware, interactionMiddlewareMetaOf, interactionRoutesOf, isCommandClass, isEmojiTuple, outcomeFor, pageCursor, pickNotice, queuedMsFor, reportDispatch, reportedWrite, resultFor, runAfter, runGates, runHandlerGates, sendFlags, sendTarget, serializeReply, setBotColor, setDevChannel, slashRouteLeaves, slowGateMonitor, storeComponentRoute, storeInteractionRoute, translateSerializationError, wrapHot };
|
|
277
|
+
export { AckTrace, AutocompleteRouteBrand, CommandMetadataKey, ComponentDefsBrand, ComponentDefsKey, ComponentKindBrand, ContextMenuKindBrand, ContextMenuNamesBrand, EventMetadataKey, EventMiddlewareMetadataKey, GateNotice, GatedMetadataKey, HasDangerousPermissions, HmrManager, InteractionMetadataKey, InteractionMiddlewareMetadataKey, InteractionRouteKeys, MiddlewareKindsBrand, MiddlewareRegistry, MissingPermissions, MissingRole, NeedsAny, NotAllowed, NotInDm, NotInGuild, NotOwner, NoticeCard, OnCooldown, PAGE_MAX, PermissionNames, PublishDefault, RegisterDefaults, RegisterSubscriber, RegisteredCount, ReportThrottle, SlashRouteBrand, SubscribeMetadataKey, UnregisterSubscriber, VerifyWebhooks, WebhookUrlMetadataKey, accessorStore, areRoutes, asError, busLoggerOf, checkAckLegality, clearStore, contextMenuLeaves, contextMenuRouteOf, decodeComponentRoute, deferFlags, eventResultFor, getDevChannel, guardedAccessor, interactionMiddleware, interactionMiddlewareMetaOf, interactionRoutesOf, isCommandClass, isEmojiTuple, outcomeFor, pageCursor, pickNotice, queuedMsFor, registrationFor, reportDispatch, reportedWrite, resultFor, runAfter, runGates, runHandlerGates, sendFlags, sendTarget, serializeReply, setBotColor, setDevChannel, slashRouteLeaves, slowGateMonitor, storeComponentRoute, storeInteractionRoute, translateSerializationError, wrapHot };
|
|
279
278
|
//# sourceMappingURL=internal.index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.index.mjs","names":["logger"],"sources":["../src/decorators/brands.ts","../src/dispatch/MiddlewareRegistry.ts","../src/gates/runGates.ts","../src/gates/slowGate.ts","../src/miscellaneous/emojiConfig.ts","../src/hmr/wrapHot.ts","../src/hmr/HmrManager.ts","../src/dispatch/dispatchReport.ts","../src/dispatch/runAfter.ts"],"sourcesContent":["// phantom, nothing assigns these at runtime\n\nexport const SlashRouteBrand: unique symbol = Symbol('seedcord:brand:slash-route');\nexport const AutocompleteRouteBrand: unique symbol = Symbol('seedcord:brand:autocomplete-route');\nexport const ContextMenuKindBrand: unique symbol = Symbol('seedcord:brand:context-menu-kind');\nexport const ContextMenuNamesBrand: unique symbol = Symbol('seedcord:brand:context-menu-names');\nexport const ComponentKindBrand: unique symbol = Symbol('seedcord:brand:component-kind');\nexport const ComponentDefsBrand: unique symbol = Symbol('seedcord:brand:component-defs');\nexport const MiddlewareKindsBrand: unique symbol = Symbol('seedcord:brand:middleware-kinds');\n","import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\nimport { interactionMiddlewareMetaOf } from '#decorators/middleware';\n\nimport type { AnyMiddlewareCtor } from '#decorators/middleware';\nimport type { MiddlewareKind } from '#src/metadataKeys';\n\n/**\n * A decorated middleware reduced to what the registry orders and filters on. An absent `keys` puts the\n * middleware in every chain.\n *\n * @internal\n */\nexport interface MiddlewareRegistration<Key extends string> {\n readonly priority: number;\n readonly keys?: readonly Key[];\n}\n\n/**\n * Reads a transport's decorator metadata off a class. Returns `undefined` for an undecorated one.\n *\n * @internal\n */\nexport type MiddlewareRegistrationOf<Ctor, Key extends string> = (\n ctor: Ctor\n) => MiddlewareRegistration<Key> | undefined;\n\n/** @internal */\nexport function interactionMiddleware(ctor: AnyMiddlewareCtor): MiddlewareRegistration<MiddlewareKind> | undefined {\n const metadata = interactionMiddlewareMetaOf(ctor);\n if (!metadata) return undefined;\n return { priority: metadata.priority, ...(metadata.kinds && { keys: metadata.kinds }) };\n}\n\ninterface Entry<Ctor, Key extends string> {\n readonly ctor: Ctor;\n readonly priority: number;\n readonly keys?: ReadonlySet<Key>;\n}\n\n/**\n * Holds the middleware a transport loaded and keeps one chain per key. An interaction keys on its kind\n * and an event on its name. Priority and the key filter behave the same on each.\n *\n * @typeParam Ctor - The transport's middleware constructor type.\n * @typeParam Key - The chain lookup key.\n *\n * @internal\n */\nexport class MiddlewareRegistry<Ctor extends AnyMiddlewareCtor, Key extends string = MiddlewareKind> {\n private readonly entries: Entry<Ctor, Key>[] = [];\n // an in-flight dispatch keeps walking the array chainFor gave it. never mutate one in place.\n private chains = new Map<Key, readonly Ctor[]>();\n\n public constructor(private readonly registrationOf: MiddlewareRegistrationOf<Ctor, Key>) {}\n\n /**\n * Adds a decorated middleware class and returns what it registered with. Returns `undefined` for an\n * undecorated class or one already registered.\n *\n * @throws A **SeedcordError** If another class with the same name is registered.\n */\n public register(ctor: Ctor): MiddlewareRegistration<Key> | undefined {\n const registration = this.registrationOf(ctor);\n if (!registration) return undefined;\n\n // a double import or an hmr re-scan registers the same class twice\n if (this.entries.some((entry) => entry.ctor === ctor)) return undefined;\n if (this.entries.some((entry) => entry.ctor.name === ctor.name)) {\n throw new SeedcordError(SeedcordErrorCode.DuplicateMiddleware, [ctor.name]);\n }\n\n this.entries.push({\n ctor,\n priority: registration.priority,\n ...(registration.keys && { keys: new Set(registration.keys) })\n });\n this.rebuild();\n return registration;\n }\n\n public unregister(ctor: Ctor): void {\n const index = this.entries.findIndex((entry) => entry.ctor === ctor);\n if (index === -1) return;\n this.entries.splice(index, 1);\n this.rebuild();\n }\n\n public chainFor(key: Key): readonly Ctor[] {\n const built = this.chains.get(key);\n if (built) return built;\n\n const chain = this.entries.filter((entry) => !entry.keys || entry.keys.has(key)).map((entry) => entry.ctor);\n this.chains.set(key, chain);\n return chain;\n }\n\n private rebuild(): void {\n // a stable sort keeps ties in registration order\n this.entries.sort((a, b) => a.priority - b.priority);\n this.chains = new Map();\n }\n}\n","import 'reflect-metadata';\n\nimport { GatedMetadataKey } from '#src/metadataKeys';\n\nimport { discardCommits, runCheck, runCommits } from './effects';\n\nimport type { Gate, GateContextBase } from './Gate';\n\n// a combinator (`and`/`or`) reports once under its joined name.\nexport type GateObserver = (gateName: string, elapsedMs: number) => void;\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// the first refusal throws out to the dispatcher boundary. an effect gate's commit runs once the\n// whole set passes, and observe never times the commit phase.\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\nexport async function runHandlerGates(\n handlerCtor: object,\n ctx: GateContextBase,\n declaredRoute?: 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, declaredRoute: declaredRoute ?? null }, observe);\n}\n","import { paint } from '@seedcord/errors';\nimport { Logger } 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(declaredRoute: 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(declaredRoute) {\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)} ${paint.mute(`${Math.round(reading.ms)}ms`)}`);\n const route = declaredRoute === null ? '' : ` for ${paint.sky.bold(declaredRoute)}`;\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\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/** @internal */\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, and 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 { paint } from '@seedcord/errors';\nimport { Logger } from '@seedcord/logger';\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.debug('Enabled');\n channel.on('seedcord:hmr', (payload) => void this.handleUpdate(payload));\n }\n }\n\n /** @internal */\n public register(listener: HmrAware): void {\n this.listeners.add(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 ${paint.sky.bold(listener.constructor.name)}`, error);\n }\n });\n\n await Promise.all(promises);\n }\n}\n","import { paint } from '@seedcord/errors';\nimport { Logger } from '@seedcord/logger';\nimport { timestampFromSnowflake } from '@seedcord/utils';\n\nimport { Notice } from '#stops/Notice';\nimport { Silence } from '#stops/Silence';\nimport { PublishDefault } from '#subscribers/publishDefault';\n\nimport type { InteractionKind } from '#src/metadataKeys';\nimport type { Bus } from '#subscribers/Bus';\nimport type { DispatchOutcome } from '#subscribers/types/Subscriptions';\n\nlet dispatchLogger: Logger | undefined;\nfunction logger(): Logger {\n dispatchLogger ??= new Logger('Dispatch', { channel: 'interactions' });\n return dispatchLogger;\n}\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): Exclude<DispatchOutcome, 'handled'> {\n if (caught instanceof Silence) return 'refused';\n if (caught instanceof Notice) return caught.report ? 'failed' : 'refused';\n return 'failed';\n}\n\ninterface DispatchReport {\n readonly dispatchId: string;\n readonly routeId: string;\n readonly interactionId: string;\n readonly kind: `${InteractionKind}`;\n readonly outcome: DispatchOutcome;\n /** True when no route matched and the unhandled default ran. */\n readonly fallback: boolean;\n readonly userId: string | null;\n readonly guildId: string | null;\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 // timestampFromSnowflake throws on a malformed id\n try {\n return Date.now() - timestampFromSnowflake(interactionId);\n } catch {\n return 0;\n }\n}\n\nexport function reportDispatch(bus: Bus, report: DispatchReport): void {\n const durationMs = performance.now() - report.startedAt;\n bus[PublishDefault]('interactionDispatched', {\n dispatchId: report.dispatchId,\n routeId: report.routeId,\n interactionId: report.interactionId,\n kind: report.kind,\n outcome: report.outcome,\n fallback: report.fallback,\n userId: report.userId,\n guildId: report.guildId,\n durationMs,\n queuedMs: report.queuedMs\n });\n\n // a throwing log sink must not stop the publish above\n logger().trace(\n `${paint.sky.bold(report.routeId)} ${report.outcome} ${paint.mute('in')} ${Math.round(durationMs)}ms`\n );\n}\n","import { asError } from '#stops/asError';\n\nimport { outcomeFor } from './dispatchReport';\n\nimport type { DispatchResult, EventDispatchResult, HandlerResult } from './dispatchResult';\nimport type { Logger } from '@seedcord/logger';\n\ninterface Afterable<Result> {\n after?(result: Result): Promise<void>;\n}\n\n/** @internal */\nexport function resultFor(caught: unknown): DispatchResult {\n return { outcome: outcomeFor(caught), caught };\n}\n\n/**\n * Builds what an event middleware's `after()` receives. `handlers` is empty exactly when the chain\n * stopped the event.\n *\n * @internal\n */\nexport function eventResultFor(\n stopped: { caught: unknown } | null,\n handlers: readonly HandlerResult[]\n): EventDispatchResult {\n if (!stopped) return { outcome: 'handled', handlers };\n return { ...resultFor(stopped.caught), handlers: [] };\n}\n\n/**\n * Calls `after()` on each middleware that ran, newest first. A throw inside one is logged. Every\n * remaining middleware still gets its call.\n *\n * @internal\n */\nexport async function runAfter<Result>(\n ran: readonly Afterable<Result>[],\n result: Result,\n logger: Logger\n): Promise<void> {\n for (let index = ran.length - 1; index >= 0; index--) {\n const middleware = ran[index];\n try {\n await middleware?.after?.(result);\n } catch (caught) {\n logger.error(`${middleware?.constructor.name ?? 'A middleware'} threw from after()`, asError(caught));\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAEA,MAAa,kBAAiC,OAAO,4BAA4B;AACjF,MAAa,yBAAwC,OAAO,mCAAmC;AAC/F,MAAa,uBAAsC,OAAO,kCAAkC;AAC5F,MAAa,wBAAuC,OAAO,mCAAmC;AAC9F,MAAa,qBAAoC,OAAO,+BAA+B;AACvF,MAAa,qBAAoC,OAAO,+BAA+B;AACvF,MAAa,uBAAsC,OAAO,iCAAiC;;;;;ACqB3F,SAAgB,sBAAsB,MAA6E;CAC/G,MAAM,WAAW,4BAA4B,IAAI;CACjD,IAAI,CAAC,UAAU,OAAO;CACtB,OAAO;EAAE,UAAU,SAAS;EAAU,GAAI,SAAS,SAAS,EAAE,MAAM,SAAS,MAAM;CAAG;AAC1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M,GAAG,YAAY,YAAY,QAAQ,eAAe,sBAAsB,QAAQ,MAAM,CAAC;EACxG;CACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"internal.index.mjs","names":["logger"],"sources":["../src/decorators/brands.ts","../src/dispatch/MiddlewareRegistry.ts","../src/gates/runGates.ts","../src/gates/slowGate.ts","../src/miscellaneous/emojiConfig.ts","../src/hmr/wrapHot.ts","../src/hmr/HmrManager.ts","../src/dispatch/dispatchReport.ts","../src/dispatch/runAfter.ts"],"sourcesContent":["// phantom, nothing assigns these at runtime\n\nexport const SlashRouteBrand: unique symbol = Symbol('seedcord:brand:slash-route');\nexport const AutocompleteRouteBrand: unique symbol = Symbol('seedcord:brand:autocomplete-route');\nexport const ContextMenuKindBrand: unique symbol = Symbol('seedcord:brand:context-menu-kind');\nexport const ContextMenuNamesBrand: unique symbol = Symbol('seedcord:brand:context-menu-names');\nexport const ComponentKindBrand: unique symbol = Symbol('seedcord:brand:component-kind');\nexport const ComponentDefsBrand: unique symbol = Symbol('seedcord:brand:component-defs');\nexport const MiddlewareKindsBrand: unique symbol = Symbol('seedcord:brand:middleware-kinds');\n","import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\nimport { interactionMiddlewareMetaOf } from '#decorators/middleware';\n\nimport type { AnyMiddlewareCtor } from '#decorators/middleware';\nimport type { MiddlewareKind } from '#src/metadataKeys';\n\n/**\n * A decorated middleware reduced to what the registry orders and filters on. An absent `keys` puts the\n * middleware in every chain.\n *\n * @internal\n */\nexport interface MiddlewareRegistration<Key extends string> {\n readonly priority: number;\n readonly keys?: readonly Key[];\n}\n\n/**\n * Reads a transport's decorator metadata off a class. Returns `undefined` for an undecorated one.\n *\n * @internal\n */\nexport type MiddlewareRegistrationOf<Ctor, Key extends string> = (\n ctor: Ctor\n) => MiddlewareRegistration<Key> | undefined;\n\n/** @internal */\nexport function interactionMiddleware(ctor: AnyMiddlewareCtor): MiddlewareRegistration<MiddlewareKind> | undefined {\n const metadata = interactionMiddlewareMetaOf(ctor);\n if (!metadata) return undefined;\n return { priority: metadata.priority, ...(metadata.kinds && { keys: metadata.kinds }) };\n}\n\ninterface Entry<Ctor, Key extends string> {\n readonly ctor: Ctor;\n readonly priority: number;\n readonly keys?: ReadonlySet<Key>;\n}\n\n/**\n * Holds the middleware a transport loaded and keeps one chain per key. An interaction keys on its kind\n * and an event on its name. Priority and the key filter behave the same on each.\n *\n * @typeParam Ctor - The transport's middleware constructor type.\n * @typeParam Key - The chain lookup key.\n *\n * @internal\n */\nexport class MiddlewareRegistry<Ctor extends AnyMiddlewareCtor, Key extends string = MiddlewareKind> {\n private readonly entries: Entry<Ctor, Key>[] = [];\n // an in-flight dispatch keeps walking the array chainFor gave it. never mutate one in place.\n private chains = new Map<Key, readonly Ctor[]>();\n\n public constructor(private readonly registrationOf: MiddlewareRegistrationOf<Ctor, Key>) {}\n\n /**\n * Adds a decorated middleware class and returns what it registered with. Returns `undefined` for an\n * undecorated class or one already registered.\n *\n * @throws A **SeedcordError** If another class with the same name is registered.\n */\n public register(ctor: Ctor): MiddlewareRegistration<Key> | undefined {\n const registration = this.registrationOf(ctor);\n if (!registration) return undefined;\n\n // a double import or an hmr re-scan registers the same class twice\n if (this.entries.some((entry) => entry.ctor === ctor)) return undefined;\n if (this.entries.some((entry) => entry.ctor.name === ctor.name)) {\n throw new SeedcordError(SeedcordErrorCode.DuplicateMiddleware, [ctor.name]);\n }\n\n this.entries.push({\n ctor,\n priority: registration.priority,\n ...(registration.keys && { keys: new Set(registration.keys) })\n });\n this.rebuild();\n return registration;\n }\n\n public unregister(ctor: Ctor): void {\n const index = this.entries.findIndex((entry) => entry.ctor === ctor);\n if (index === -1) return;\n this.entries.splice(index, 1);\n this.rebuild();\n }\n\n public chainFor(key: Key): readonly Ctor[] {\n const built = this.chains.get(key);\n if (built) return built;\n\n const chain = this.entries.filter((entry) => !entry.keys || entry.keys.has(key)).map((entry) => entry.ctor);\n this.chains.set(key, chain);\n return chain;\n }\n\n private rebuild(): void {\n // a stable sort keeps ties in registration order\n this.entries.sort((a, b) => a.priority - b.priority);\n this.chains = new Map();\n }\n}\n","import 'reflect-metadata';\n\nimport { GatedMetadataKey } from '#src/metadataKeys';\n\nimport { discardCommits, runCheck, runCommits } from './effects';\n\nimport type { Gate, GateContextBase } from './Gate';\n\n// a combinator (`and`/`or`) reports once under its joined name.\nexport type GateObserver = (gateName: string, elapsedMs: number) => void;\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// the first refusal throws out to the dispatcher boundary. an effect gate's commit runs once the\n// whole set passes, and observe never times the commit phase.\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\nexport async function runHandlerGates(\n handlerCtor: object,\n ctx: GateContextBase,\n declaredRoute?: 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, declaredRoute: declaredRoute ?? null }, observe);\n}\n","import { paint } from '@seedcord/errors';\nimport { Logger } 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(declaredRoute: 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(declaredRoute) {\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)} ${paint.mute(`${Math.round(reading.ms)}ms`)}`);\n const route = declaredRoute === null ? '' : ` for ${paint.sky.bold(declaredRoute)}`;\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\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/** @internal */\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, and 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 { paint } from '@seedcord/errors';\nimport { Logger } from '@seedcord/logger';\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 return;\n }\n\n this.logger.debug('Enabled');\n channel.on('seedcord:hmr', (payload) => void this.handleUpdate(payload));\n }\n\n /** @internal */\n public register(listener: HmrAware): void {\n this.listeners.add(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 ${paint.sky.bold(listener.constructor.name)}`, error);\n }\n });\n\n await Promise.all(promises);\n }\n}\n","import { paint } from '@seedcord/errors';\nimport { Logger } from '@seedcord/logger';\nimport { timestampFromSnowflake } from '@seedcord/utils';\n\nimport { Notice } from '#stops/Notice';\nimport { Silence } from '#stops/Silence';\nimport { PublishDefault } from '#subscribers/publishDefault';\n\nimport type { InteractionKind } from '#src/metadataKeys';\nimport type { Bus } from '#subscribers/Bus';\nimport type { DispatchOutcome } from '#subscribers/types/Subscriptions';\n\nlet dispatchLogger: Logger | undefined;\nfunction logger(): Logger {\n dispatchLogger ??= new Logger('Dispatch', { channel: 'interactions' });\n return dispatchLogger;\n}\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): Exclude<DispatchOutcome, 'handled'> {\n if (caught instanceof Silence) return 'refused';\n if (caught instanceof Notice) return caught.report ? 'failed' : 'refused';\n return 'failed';\n}\n\ninterface DispatchReport {\n readonly dispatchId: string;\n readonly routeId: string;\n readonly interactionId: string;\n readonly kind: `${InteractionKind}`;\n readonly outcome: DispatchOutcome;\n /** True when no route matched and the unhandled default ran. */\n readonly fallback: boolean;\n readonly userId: string | null;\n readonly guildId: string | null;\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 // timestampFromSnowflake throws on a malformed id\n try {\n return Date.now() - timestampFromSnowflake(interactionId);\n } catch {\n return 0;\n }\n}\n\nexport function reportDispatch(bus: Bus, report: DispatchReport): void {\n const durationMs = performance.now() - report.startedAt;\n bus[PublishDefault]('interactionDispatched', {\n dispatchId: report.dispatchId,\n routeId: report.routeId,\n interactionId: report.interactionId,\n kind: report.kind,\n outcome: report.outcome,\n fallback: report.fallback,\n userId: report.userId,\n guildId: report.guildId,\n durationMs,\n queuedMs: report.queuedMs\n });\n\n // a throwing log sink must not stop the publish above\n logger().trace(\n `${paint.sky.bold(report.routeId)} ${report.outcome} ${paint.mute('in')} ${Math.round(durationMs)}ms`\n );\n}\n","import { asError } from '#stops/asError';\n\nimport { outcomeFor } from './dispatchReport';\n\nimport type { DispatchResult, EventDispatchResult, HandlerResult } from './dispatchResult';\nimport type { Logger } from '@seedcord/logger';\n\ninterface Afterable<Result> {\n after?(result: Result): Promise<void>;\n}\n\n/** @internal */\nexport function resultFor(caught: unknown): DispatchResult {\n return { outcome: outcomeFor(caught), caught };\n}\n\n/**\n * Builds what an event middleware's `after()` receives. `handlers` is empty exactly when the chain\n * stopped the event.\n *\n * @internal\n */\nexport function eventResultFor(\n stopped: { caught: unknown } | null,\n handlers: readonly HandlerResult[]\n): EventDispatchResult {\n if (!stopped) return { outcome: 'handled', handlers };\n return { ...resultFor(stopped.caught), handlers: [] };\n}\n\n/**\n * Calls `after()` on each middleware that ran, newest first. A throw inside one is logged. Every\n * remaining middleware still gets its call.\n *\n * @internal\n */\nexport async function runAfter<Result>(\n ran: readonly Afterable<Result>[],\n result: Result,\n logger: Logger\n): Promise<void> {\n for (let index = ran.length - 1; index >= 0; index--) {\n const middleware = ran[index];\n try {\n await middleware?.after?.(result);\n } catch (caught) {\n logger.error(`${middleware?.constructor.name ?? 'A middleware'} threw from after()`, asError(caught));\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAEA,MAAa,kBAAiC,OAAO,4BAA4B;AACjF,MAAa,yBAAwC,OAAO,mCAAmC;AAC/F,MAAa,uBAAsC,OAAO,kCAAkC;AAC5F,MAAa,wBAAuC,OAAO,mCAAmC;AAC9F,MAAa,qBAAoC,OAAO,+BAA+B;AACvF,MAAa,qBAAoC,OAAO,+BAA+B;AACvF,MAAa,uBAAsC,OAAO,iCAAiC;;;;;ACqB3F,SAAgB,sBAAsB,MAA6E;CAC/G,MAAM,WAAW,4BAA4B,IAAI;CACjD,IAAI,CAAC,UAAU,OAAO;CACtB,OAAO;EAAE,UAAU,SAAS;EAAU,GAAI,SAAS,SAAS,EAAE,MAAM,SAAS,MAAM;CAAG;AAC1F;;;;;;;;;;AAiBA,IAAa,qBAAb,MAAqG;CAK7D;CAJpC,AAAiB,UAA8B,CAAC;CAEhD,AAAQ,yBAAS,IAAI,IAA0B;CAE/C,AAAO,YAAY,AAAiB,gBAAqD;EAArD;CAAsD;;;;;;;CAQ1F,AAAO,SAAS,MAAqD;EACjE,MAAM,eAAe,KAAK,eAAe,IAAI;EAC7C,IAAI,CAAC,cAAc,OAAO;EAG1B,IAAI,KAAK,QAAQ,MAAM,UAAU,MAAM,SAAS,IAAI,GAAG,OAAO;EAC9D,IAAI,KAAK,QAAQ,MAAM,UAAU,MAAM,KAAK,SAAS,KAAK,IAAI,GAC1D,MAAM,IAAI,cAAc,kBAAkB,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AAyB;EACzC,YAAY,OAAO;EACnB,SAAS,OAAO;EAChB,eAAe,OAAO;EACtB,MAAM,OAAO;EACb,SAAS,OAAO;EAChB,UAAU,OAAO;EACjB,QAAQ,OAAO;EACf,SAAS,OAAO;EAChB;EACA,UAAU,OAAO;CACrB,CAAC;CAGD,OAAO,CAAC,CAAC,MACL,GAAG,MAAM,IAAI,KAAK,OAAO,OAAO,EAAE,GAAG,OAAO,QAAQ,GAAG,MAAM,KAAK,IAAI,EAAE,GAAG,KAAK,MAAM,UAAU,EAAE,GACtG;AACJ;;;;;ACpEA,SAAgB,UAAU,QAAiC;CACvD,OAAO;EAAE,SAAS,WAAW,MAAM;EAAG;CAAO;AACjD;;;;;;;AAQA,SAAgB,eACZ,SACA,UACmB;CACnB,IAAI,CAAC,SAAS,OAAO;EAAE,SAAS;EAAW;CAAS;CACpD,OAAO;EAAE,GAAG,UAAU,QAAQ,MAAM;EAAG,UAAU,CAAC;CAAE;AACxD;;;;;;;AAQA,eAAsB,SAClB,KACA,QACA,QACa;CACb,KAAK,IAAI,QAAQ,IAAI,SAAS,GAAG,SAAS,GAAG,SAAS;EAClD,MAAM,aAAa,IAAI;EACvB,IAAI;GACA,MAAM,YAAY,QAAQ,MAAM;EACpC,SAAS,QAAQ;GACb,OAAO,MAAM,GAAG,YAAY,YAAY,QAAQ,eAAe,sBAAsB,QAAQ,MAAM,CAAC;EACxG;CACJ;AACJ"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { i as Bus, n as StartupPhase, r as CoreBase, t as ShutdownPhase } from "./phases-
|
|
2
|
-
import { n as
|
|
3
|
-
import "./index-
|
|
4
|
-
import { i as Initializeable } from "./Plugin-
|
|
1
|
+
import { i as Bus, n as StartupPhase, r as CoreBase, t as ShutdownPhase } from "./phases-D_zQBXga.mjs";
|
|
2
|
+
import { n as DeployResult, t as CommandBuilder } from "./types-BG0BimVr.mjs";
|
|
3
|
+
import "./index-B_-EjyvS.mjs";
|
|
4
|
+
import { i as Initializeable } from "./Plugin-Dhx_ivqj.mjs";
|
|
5
5
|
import { t as ContextMenuLeaves } from "./contextMenuLeaves-COzDYa6c.mjs";
|
|
6
|
-
import { a as LifecycleTask, i as CoordinatedShutdown, n as shutdownOf } from "./Pluggable-
|
|
6
|
+
import { a as LifecycleTask, i as CoordinatedShutdown, n as shutdownOf } from "./Pluggable-CwKbLui3.mjs";
|
|
7
7
|
import { Logger } from "@seedcord/logger";
|
|
8
8
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
9
9
|
import { HealthCheckConfig, HealthCheckOption, HmrAware, HmrUpdateEvent } from "@seedcord/types";
|
|
10
10
|
//#region src/node/Lifecycle/drainWindow.d.ts
|
|
11
|
-
declare const DRAIN_WINDOW_MS = 5000;
|
|
12
|
-
declare const DRAIN_TASK_TIMEOUT_MS: number;
|
|
13
|
-
declare function drainInFlight(inFlight: ReadonlySet<Promise<unknown>>, timeoutMs: number, logger: Logger, label: string): Promise<void>;
|
|
11
|
+
export declare const DRAIN_WINDOW_MS = 5000;
|
|
12
|
+
export declare const DRAIN_TASK_TIMEOUT_MS: number;
|
|
13
|
+
export declare function drainInFlight(inFlight: ReadonlySet<Promise<unknown>>, timeoutMs: number, logger: Logger, label: string): Promise<void>;
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/node/HealthCheck.d.ts
|
|
16
|
-
declare class HealthCheck {
|
|
16
|
+
export declare class HealthCheck {
|
|
17
17
|
readonly logger: Logger;
|
|
18
18
|
private readonly _port;
|
|
19
19
|
private readonly _host;
|
|
@@ -29,17 +29,17 @@ declare class HealthCheck {
|
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/node/HealthResponder.d.ts
|
|
32
|
-
declare class HealthResponder {
|
|
32
|
+
export declare class HealthResponder {
|
|
33
33
|
readonly path: string;
|
|
34
34
|
constructor(path?: string);
|
|
35
35
|
tryRespond(req: IncomingMessage, res: ServerResponse): boolean;
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
38
|
//#region src/node/Lifecycle/withTimeout.d.ts
|
|
39
|
-
declare function settleWithin(work: Promise<unknown>, timeoutMs: number): Promise<void>;
|
|
39
|
+
export declare function settleWithin(work: Promise<unknown>, timeoutMs: number): Promise<void>;
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/node/subscribers/SubscriberLoader.d.ts
|
|
42
|
-
declare class SubscriberLoader implements Initializeable, HmrAware {
|
|
42
|
+
export declare class SubscriberLoader implements Initializeable, HmrAware {
|
|
43
43
|
private readonly bus;
|
|
44
44
|
private readonly directory;
|
|
45
45
|
private isInitialized;
|
|
@@ -62,7 +62,7 @@ declare class SubscriberLoader implements Initializeable, HmrAware {
|
|
|
62
62
|
*
|
|
63
63
|
* @internal
|
|
64
64
|
*/
|
|
65
|
-
declare class CommandRegistry implements Initializeable, HmrAware {
|
|
65
|
+
export declare class CommandRegistry implements Initializeable, HmrAware {
|
|
66
66
|
private readonly core;
|
|
67
67
|
private readonly logger;
|
|
68
68
|
private isInitialised;
|
|
@@ -100,5 +100,5 @@ declare class CommandRegistry implements Initializeable, HmrAware {
|
|
|
100
100
|
contextMenuLeaves(): ContextMenuLeaves;
|
|
101
101
|
}
|
|
102
102
|
//#endregion
|
|
103
|
-
export {
|
|
103
|
+
export { type LifecycleTask, ShutdownPhase, StartupPhase, shutdownOf };
|
|
104
104
|
//# sourceMappingURL=node-internal.index.d.mts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as RegisterSubscriber, c as VerifyWebhooks, f as Subscriber, g as CommandMetadataKey, i as RegisterDefaults, k as contextMenuLeaves, n as busLoggerOf, o as RegisteredCount, r as registrationFor, s as UnregisterSubscriber, w as SubscribeMetadataKey } from "./Bus-
|
|
2
|
-
import { r as CommandInjector, t as ConfigGuilds } from "./subscribers-
|
|
1
|
+
import { a as RegisterSubscriber, c as VerifyWebhooks, f as Subscriber, g as CommandMetadataKey, i as RegisterDefaults, k as contextMenuLeaves, n as busLoggerOf, o as RegisteredCount, r as registrationFor, s as UnregisterSubscriber, w as SubscribeMetadataKey } from "./Bus-DUDafYDD.mjs";
|
|
2
|
+
import { r as CommandInjector, t as ConfigGuilds } from "./subscribers-Bxut8U6g.mjs";
|
|
3
3
|
import { t as PublishDefault } from "./publishDefault-BuSZPbjT.mjs";
|
|
4
4
|
import { n as StartupPhase, t as ShutdownPhase } from "./phases-BauKJOTT.mjs";
|
|
5
5
|
import { t as getDevChannel } from "./devChannel-CQU7hq7Q.mjs";
|
|
6
|
-
import { n as isCommandClass, t as slashRouteLeaves } from "./slashRouteLeaves-
|
|
7
|
-
import { t as HmrModuleHandler } from "./HmrModuleHandler-
|
|
8
|
-
import { i as settleWithin, n as shutdownOf, r as assertNodeVersion } from "./Pluggable-
|
|
6
|
+
import { n as isCommandClass, t as slashRouteLeaves } from "./slashRouteLeaves-D__G9vsr.mjs";
|
|
7
|
+
import { t as HmrModuleHandler } from "./HmrModuleHandler-DOAtah3j.mjs";
|
|
8
|
+
import { i as settleWithin, n as shutdownOf, r as assertNodeVersion } from "./Pluggable-CXyUZIvT.mjs";
|
|
9
9
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
|
10
10
|
import { Routes } from "discord-api-types/v10";
|
|
11
11
|
import { SeedcordErrorCode, paint } from "@seedcord/errors";
|
|
@@ -327,10 +327,9 @@ var CommandRegistry = class {
|
|
|
327
327
|
if (idx !== -1) this.globalCommands.splice(idx, 1);
|
|
328
328
|
} else for (const g of info.guilds) {
|
|
329
329
|
const arr = this.guildCommands.get(g);
|
|
330
|
-
if (arr)
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
330
|
+
if (!arr) continue;
|
|
331
|
+
const idx = arr.findIndex((c) => c.name === info.name);
|
|
332
|
+
if (idx !== -1) arr.splice(idx, 1);
|
|
334
333
|
}
|
|
335
334
|
this.ctorToCommand.delete(ctor);
|
|
336
335
|
}
|