@seedcord/core 0.3.1 → 0.4.1

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.
Files changed (38) hide show
  1. package/dist/{Bus-BvF4VShN.mjs → Bus-yJGE6Fs2.mjs} +111 -92
  2. package/dist/Bus-yJGE6Fs2.mjs.map +1 -0
  3. package/dist/Pluggable-BI_LQuPm.mjs +280 -0
  4. package/dist/Pluggable-BI_LQuPm.mjs.map +1 -0
  5. package/dist/Pluggable-bFCmT4oB.d.mts +148 -0
  6. package/dist/{Plugin-D9ykXA5g.mjs → Plugin-B0SRHzMX.mjs} +7 -3
  7. package/dist/Plugin-B0SRHzMX.mjs.map +1 -0
  8. package/dist/{Plugin-CQ9IEj5X.d.mts → Plugin-BW2JH2_h.d.mts} +2 -2
  9. package/dist/{cursor-BANzac53.d.mts → cursor-CO_MTgdZ.d.mts} +8 -252
  10. package/dist/{cursor-CuoA9cRh.mjs → cursor-CaT051ii.mjs} +307 -425
  11. package/dist/cursor-CaT051ii.mjs.map +1 -0
  12. package/dist/{index-rt8rZg4d.d.mts → index-CvneCObW.d.mts} +2 -2
  13. package/dist/index.d.mts +78 -19
  14. package/dist/index.mjs +223 -21
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/internal.index.d.mts +13 -6
  17. package/dist/internal.index.mjs +8 -455
  18. package/dist/internal.index.mjs.map +1 -1
  19. package/dist/node-internal.index.d.mts +6 -133
  20. package/dist/node-internal.index.mjs +16 -473
  21. package/dist/node-internal.index.mjs.map +1 -1
  22. package/dist/node.index.d.mts +2 -0
  23. package/dist/node.index.mjs +256 -0
  24. package/dist/node.index.mjs.map +1 -0
  25. package/dist/{phases-hBxMCD2V.d.mts → phases-C5Steaa2.d.mts} +151 -119
  26. package/dist/plugin.index.d.mts +1 -1
  27. package/dist/plugin.index.mjs +1 -1
  28. package/dist/publishDefault-D826XXDQ.mjs +14 -0
  29. package/dist/publishDefault-D826XXDQ.mjs.map +1 -0
  30. package/dist/{slashRouteLeaves-De1SxqnX.mjs → slashRouteLeaves-BQmbFm-S.mjs} +10 -2
  31. package/dist/slashRouteLeaves-BQmbFm-S.mjs.map +1 -0
  32. package/dist/{subscribers-wnMyNYZd.mjs → subscribers-DVa-Pr45.mjs} +3 -3
  33. package/dist/{subscribers-wnMyNYZd.mjs.map → subscribers-DVa-Pr45.mjs.map} +1 -1
  34. package/package.json +19 -12
  35. package/dist/Bus-BvF4VShN.mjs.map +0 -1
  36. package/dist/Plugin-D9ykXA5g.mjs.map +0 -1
  37. package/dist/cursor-CuoA9cRh.mjs.map +0 -1
  38. package/dist/slashRouteLeaves-De1SxqnX.mjs.map +0 -1
@@ -1,76 +1,12 @@
1
+ import { i as Bus, n as StartupPhase, r as CoreBase, t as ShutdownPhase } from "./phases-C5Steaa2.mjs";
1
2
  import { n as CommandBuilder, r as DeployResult } from "./basic-Dng__Ena.mjs";
2
- import { i as Bus, n as StartupPhase, r as CoreBase, t as ShutdownPhase } from "./phases-hBxMCD2V.mjs";
3
- import "./index-rt8rZg4d.mjs";
4
- import { a as PluginCtor, d as Transport, f as TransportAssert, i as PluginArgs, l as Runtime, n as Initializeable, o as PluginLike, s as ChannelKeyAssert, t as CoreParamAssert, u as RuntimeAssert } from "./Plugin-CQ9IEj5X.mjs";
3
+ import "./index-CvneCObW.mjs";
4
+ import { n as Initializeable } from "./Plugin-BW2JH2_h.mjs";
5
5
  import { t as ContextMenuLeaves } from "./contextMenuLeaves-COzDYa6c.mjs";
6
+ import { a as LifecycleTask, i as CoordinatedShutdown, n as shutdownOf } from "./Pluggable-bFCmT4oB.mjs";
6
7
  import { Logger } from "@seedcord/logger";
7
- import { REST } from "@discordjs/rest";
8
8
  import { IncomingMessage, ServerResponse } from "node:http";
9
- import { Config, HealthCheckConfig, HealthCheckOption, HmrAware, HmrUpdateEvent, IRateLimiter } from "@seedcord/types";
10
- //#region src/node/Lifecycle/LifecycleTypes.d.ts
11
- interface LifecycleTask {
12
- name: string;
13
- task: () => Promise<void>;
14
- timeout: number;
15
- }
16
- //#endregion
17
- //#region src/node/Lifecycle/CoordinatedLifecycle.d.ts
18
- declare abstract class CoordinatedLifecycle<TPhase extends number> {
19
- protected readonly phaseOrder: TPhase[];
20
- protected readonly phaseEnum: Record<number, string>;
21
- protected readonly logger: Logger;
22
- protected readonly tasksMap: Map<TPhase, LifecycleTask[]>;
23
- protected constructor(loggerName: string, phaseOrder: TPhase[], phaseEnum: Record<number, string>);
24
- addTask(phase: TPhase, taskName: string, task: () => Promise<void>, timeoutMs: number): void;
25
- removeTask(phase: TPhase, taskName: string): boolean;
26
- protected runPhase(phase: TPhase): Promise<void>;
27
- protected runTaskWithTimeout(phase: TPhase, task: LifecycleTask): Promise<void>;
28
- protected isAborted(): boolean;
29
- protected abstract canAddTask(): boolean;
30
- protected abstract canRemoveTask(): boolean;
31
- protected abstract getTaskType(): string;
32
- protected abstract executeTasksInPhase(phase: TPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
33
- }
34
- //#endregion
35
- //#region src/node/Lifecycle/CoordinatedShutdown.d.ts
36
- declare class CoordinatedShutdown extends CoordinatedLifecycle<ShutdownPhase> {
37
- private isShuttingDown;
38
- private hasShutdown;
39
- private exitCode;
40
- private onSigTerm;
41
- private onSigInt;
42
- private startupGate?;
43
- constructor();
44
- protected canAddTask(): boolean;
45
- protected canRemoveTask(): boolean;
46
- protected getTaskType(): string;
47
- protected executeTasksInPhase(phase: ShutdownPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
48
- private registerSignalHandlers;
49
- /** @internal */
50
- removeSignalHandlers(): void;
51
- /** @internal run() awaits this so boot finishes registering its dispose tasks first */
52
- gateOnStartup(settled: Promise<void>): void;
53
- addTask(phase: ShutdownPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
54
- removeTask(phase: ShutdownPhase, taskName: string): boolean;
55
- run(exitCode?: number, exitProcess?: boolean): Promise<void>;
56
- }
57
- //#endregion
58
- //#region src/node/Lifecycle/CoordinatedStartup.d.ts
59
- declare class CoordinatedStartup extends CoordinatedLifecycle<StartupPhase> {
60
- private isStartingUp;
61
- private hasStarted;
62
- constructor();
63
- addTask(phase: StartupPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
64
- protected canAddTask(): boolean;
65
- protected canRemoveTask(): boolean;
66
- protected getTaskType(): string;
67
- protected executeTasksInPhase(phase: StartupPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
68
- run(): Promise<void>;
69
- protected isAborted(): boolean;
70
- abort(): void;
71
- get isReady(): boolean;
72
- }
73
- //#endregion
9
+ import { HealthCheckConfig, HealthCheckOption, HmrAware, HmrUpdateEvent } from "@seedcord/types";
74
10
  //#region src/node/HealthCheck.d.ts
75
11
  declare class HealthCheck {
76
12
  readonly logger: Logger;
@@ -94,68 +30,6 @@ declare class HealthResponder {
94
30
  tryRespond(req: IncomingMessage, res: ServerResponse): boolean;
95
31
  }
96
32
  //#endregion
97
- //#region src/node/Pluggable.d.ts
98
- /**
99
- * Base class for a plugin host, a transport `Seedcord` class.
100
- *
101
- * You attach plugins while configuring the bot. Within one startup phase, their `init()` calls run
102
- * one after another in attach order.
103
- */
104
- declare abstract class Pluggable<BotT extends Transport, BotRt extends Runtime> implements CoreBase {
105
- abstract readonly config: Config;
106
- abstract readonly rest: REST;
107
- abstract readonly applicationId: string;
108
- abstract readonly rateLimiter: IRateLimiter;
109
- abstract readonly bus: Bus;
110
- /** @see {@link CoordinatedShutdown} */
111
- readonly shutdown: CoordinatedShutdown;
112
- /** @see {@link CoordinatedStartup} */
113
- readonly startup: CoordinatedStartup;
114
- protected isInitialized: boolean;
115
- protected startFailed: boolean;
116
- protected readonly plugins: PluginLike[];
117
- private readonly pluginLogger;
118
- private readonly attachments;
119
- private readonly completedInits;
120
- private readonly disposePhases;
121
- private pluginTasksRegistered;
122
- private static isInstantiated;
123
- private static liveShutdown?;
124
- constructor(shutdown: CoordinatedShutdown, startup: CoordinatedStartup);
125
- /** @internal */
126
- protected init(): Promise<this>;
127
- /** @internal codegen reads these to emit the `Core` augmentation */
128
- get pluginKeys(): readonly string[];
129
- /** @internal so the next host can construct */
130
- protected static reset(): void;
131
- /**
132
- * Attaches a plugin under `key`. Read the instance back as `core[key]`. `seedcord codegen`
133
- * writes the `Core` augmentation that types it there.
134
- *
135
- * Startup runs each plugin's `init()` in attach order within its phase.
136
- *
137
- * Attaching a plugin whose `transport` or `runtime` differs from this host fails to compile.
138
- * Your constructor takes `CoreBase` as its first parameter (you don't need to pass it though).
139
- * A narrower one fails to compile here.
140
- *
141
- * @param key - Also the channel the plugin logs on. Reserved channel names throw.
142
- * @param args - Whatever your constructor takes after the host.
143
- * @throws A **SeedcordError** if you attach after the bot has started. A taken or reserved key throws too.
144
- * @example
145
- * ```ts
146
- * seedcord.attach('db', Mongoose, { uri: 'mongodb://...', name: 'seedcord', dir: ... });
147
- * ```
148
- */
149
- attach<Key extends string, Ctor extends PluginCtor>(this: this, key: ChannelKeyAssert<Key>, Plugin: Ctor & TransportAssert<InstanceType<Ctor>, BotT> & RuntimeAssert<InstanceType<Ctor>, BotRt> & CoreParamAssert<Ctor>, ...args: PluginArgs<Ctor>): this & Record<Key, InstanceType<Ctor>>;
150
- private registerPluginTasks;
151
- private runInits;
152
- private registerReadyTask;
153
- private registerDisposeTask;
154
- private runDisposals;
155
- private disposeCompleted;
156
- private rollback;
157
- }
158
- //#endregion
159
33
  //#region src/node/Lifecycle/withTimeout.d.ts
160
34
  declare function settleWithin(work: Promise<unknown>, timeoutMs: number): Promise<void>;
161
35
  //#endregion
@@ -206,7 +80,6 @@ declare class CommandRegistry implements Initializeable, HmrAware {
206
80
  /** @internal */
207
81
  onHmr(event: HmrUpdateEvent): Promise<void>;
208
82
  private loadCommands;
209
- private isCommandClass;
210
83
  private registerCommand;
211
84
  private unregisterCommand;
212
85
  /** @internal */
@@ -220,5 +93,5 @@ declare class CommandRegistry implements Initializeable, HmrAware {
220
93
  contextMenuLeaves(): ContextMenuLeaves;
221
94
  }
222
95
  //#endregion
223
- export { CommandRegistry, CoordinatedShutdown, CoordinatedStartup, HealthCheck, HealthResponder, type LifecycleTask, Pluggable, ShutdownPhase, StartupPhase, SubscriberLoader, settleWithin };
96
+ export { CommandRegistry, HealthCheck, HealthResponder, type LifecycleTask, ShutdownPhase, StartupPhase, SubscriberLoader, settleWithin, shutdownOf };
224
97
  //# sourceMappingURL=node-internal.index.d.mts.map