@seedcord/core 0.1.0-next.7 → 0.1.0-next.8
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-D6nBjwaE.d.mts} +150 -8
- package/dist/{index-Dueqztyy.d.mts → index-Cr4-VV4u.d.mts} +3 -3
- package/dist/index.cjs +361 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +237 -38
- package/dist/index.mjs +321 -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-B1G6_LlK.cjs → subscribers-BSJoyKNN.cjs} +4 -4
- package/dist/{subscribers-B1G6_LlK.cjs.map → subscribers-BSJoyKNN.cjs.map} +1 -1
- package/dist/{subscribers-DYqFVP1X.mjs → subscribers-DuxdM2cS.mjs} +4 -4
- package/dist/{subscribers-DYqFVP1X.mjs.map → subscribers-DuxdM2cS.mjs.map} +1 -1
- package/package.json +4 -4
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FrameworkChannel, Logger } from "@seedcord/logger";
|
|
2
2
|
import { TypedEventEmitter } from "@seedcord/event-emitter";
|
|
3
|
-
import {
|
|
3
|
+
import { REST } from "@discordjs/rest";
|
|
4
|
+
import { Config, EventFrequency, HmrAware, HmrUpdateEvent, IRateLimiter, RenderContext, ReplyResponse, Tail, TypedExclude } from "@seedcord/types";
|
|
4
5
|
import { UUID } from "node:crypto";
|
|
5
6
|
|
|
6
7
|
//#region src/metadataKeys.d.ts
|
|
@@ -384,116 +385,17 @@ declare class Bus extends TypedEventEmitter<SubscriptionTuples> {
|
|
|
384
385
|
interface CoreBase {
|
|
385
386
|
/** Transports narrow this to their own config type. */
|
|
386
387
|
readonly config: Config;
|
|
388
|
+
/**
|
|
389
|
+
* Discord REST client. On gateway this is the discord.js client's own, and it carries no token
|
|
390
|
+
* until the Login phase. On http the token is set by `start()`.
|
|
391
|
+
*/
|
|
392
|
+
readonly rest: REST;
|
|
387
393
|
/** Sliding-window rate limiting, the `Cooldown` gate's backend and a public direct-use API. */
|
|
388
394
|
readonly rateLimiter: IRateLimiter;
|
|
389
395
|
/** Publish and subscribe to framework and application events. */
|
|
390
396
|
readonly bus: Bus;
|
|
391
397
|
}
|
|
392
398
|
//#endregion
|
|
393
|
-
//#region src/plugin/options.d.ts
|
|
394
|
-
/** A capability a plugin declares through `needs`, each surfacing a typed `ctx` field. */
|
|
395
|
-
type PluginNeed = 'client' | 'token' | 'rest';
|
|
396
|
-
/**
|
|
397
|
-
* The options a plugin declares as its `Plugin<Opts>` type argument. Authors write unions for `needs`,
|
|
398
|
-
* e.g. `needs: 'token' | 'rest'`.
|
|
399
|
-
*/
|
|
400
|
-
interface PluginOptions {
|
|
401
|
-
/**
|
|
402
|
-
* Which transport the plugin runs on. `'any'` attaches to either one.
|
|
403
|
-
* @defaultValue 'any'
|
|
404
|
-
*/
|
|
405
|
-
transport?: 'gateway' | 'http' | 'any';
|
|
406
|
-
/**
|
|
407
|
-
* Which runtime the plugin runs on. `'any'` attaches to either one.
|
|
408
|
-
* @defaultValue 'any'
|
|
409
|
-
*/
|
|
410
|
-
runtime?: 'server' | 'edge' | 'any';
|
|
411
|
-
/** Capabilities the plugin requests, each a typed `ctx` field. */
|
|
412
|
-
needs?: PluginNeed;
|
|
413
|
-
}
|
|
414
|
-
/** @internal */
|
|
415
|
-
type TransportOf<Opts extends PluginOptions> = undefined extends Opts['transport'] ? 'any' : NonNullable<Opts['transport']>;
|
|
416
|
-
/** @internal */
|
|
417
|
-
type RuntimeOf<Opts extends PluginOptions> = undefined extends Opts['runtime'] ? 'any' : NonNullable<Opts['runtime']>;
|
|
418
|
-
/** @internal */
|
|
419
|
-
type NeedsOf<Opts extends PluginOptions> = undefined extends Opts['needs'] ? never : NonNullable<Opts['needs']>;
|
|
420
|
-
/** @internal the transport a bot runs */
|
|
421
|
-
type Transport = TypedExclude<NonNullable<PluginOptions['transport']>, 'any'>;
|
|
422
|
-
/** @internal the runtime a bot runs */
|
|
423
|
-
type Runtime = TypedExclude<NonNullable<PluginOptions['runtime']>, 'any'>;
|
|
424
|
-
type TransportMismatch<PluginT extends string, BotT extends string> = Record<`this plugin declares transport '${PluginT}' but this bot runs '${BotT}'`, never>;
|
|
425
|
-
type RuntimeMismatch<PluginRt extends string, BotRt extends string> = Record<`this plugin declares runtime '${PluginRt}' but this bot runs '${BotRt}'`, never>;
|
|
426
|
-
type EdgePluginsUnsupported = Record<'an edge bot takes no plugins until edge support ships after v1', never>;
|
|
427
|
-
/** @internal */
|
|
428
|
-
type ChannelKeyAssert<Key extends string> = Key extends FrameworkChannel ? `'${Key}' is a channel the framework logs on. Pick another plugin key.` : Key;
|
|
429
|
-
type BrandTransport<Plug> = Plug extends {
|
|
430
|
-
readonly __transport?: infer T extends string;
|
|
431
|
-
} ? T : 'any';
|
|
432
|
-
type BrandRuntime<Plug> = Plug extends {
|
|
433
|
-
readonly __runtime?: infer R extends string;
|
|
434
|
-
} ? R : 'any';
|
|
435
|
-
/** @internal */
|
|
436
|
-
type TransportAssert<Plug, BotT extends Transport> = BrandTransport<Plug> extends 'any' | BotT ? unknown : TransportMismatch<BrandTransport<Plug>, BotT>;
|
|
437
|
-
/** @internal */
|
|
438
|
-
type RuntimeAssert<Plug, BotRt extends Runtime> = 'edge' extends BotRt ? EdgePluginsUnsupported : BrandRuntime<Plug> extends 'any' | BotRt ? unknown : RuntimeMismatch<BrandRuntime<Plug>, BotRt>;
|
|
439
|
-
//#endregion
|
|
440
|
-
//#region src/plugin/context.d.ts
|
|
441
|
-
/**
|
|
442
|
-
* The type each `ctx` capability resolves to. Empty in core, each transport augments it through
|
|
443
|
-
* declaration merging.
|
|
444
|
-
*
|
|
445
|
-
* @example
|
|
446
|
-
* ```typescript
|
|
447
|
-
* declare module '@seedcord/core' {
|
|
448
|
-
* interface PluginCapabilityTypes {
|
|
449
|
-
* client: Client;
|
|
450
|
-
* rest: REST;
|
|
451
|
-
* }
|
|
452
|
-
* }
|
|
453
|
-
* ```
|
|
454
|
-
*/
|
|
455
|
-
interface PluginCapabilityTypes {}
|
|
456
|
-
type CapabilityType<Key extends PluginNeed, Fallback> = Key extends keyof PluginCapabilityTypes ? PluginCapabilityTypes[Key] : Fallback;
|
|
457
|
-
type CapabilityValue<TNeeds extends PluginNeed, Key extends PluginNeed, Value> = Key extends TNeeds ? Value : never;
|
|
458
|
-
/**
|
|
459
|
-
* The framework surface a plugin reads through `this.ctx`, typed by its declared `needs`.
|
|
460
|
-
*
|
|
461
|
-
* Always available: `config` and `store`. Each capability resolves to its value only when
|
|
462
|
-
* the plugin declared that key, otherwise `never`. The logger comes from `this.logger`.
|
|
463
|
-
*
|
|
464
|
-
* @typeParam TNeeds - The plugin's declared `needs` union.
|
|
465
|
-
*/
|
|
466
|
-
interface PluginContext<TNeeds extends PluginNeed = never> {
|
|
467
|
-
readonly config: Config;
|
|
468
|
-
readonly store: Store<'charge'>;
|
|
469
|
-
readonly client: CapabilityValue<TNeeds, 'client', CapabilityType<'client', unknown>>;
|
|
470
|
-
readonly token: CapabilityValue<TNeeds, 'token', string>;
|
|
471
|
-
/**
|
|
472
|
-
* The REST client. On http, the client has no token until the Ready phase, so a call from
|
|
473
|
-
* `init()` sends without a token and returns a 401.
|
|
474
|
-
*/
|
|
475
|
-
readonly rest: CapabilityValue<TNeeds, 'rest', CapabilityType<'rest', unknown>>;
|
|
476
|
-
}
|
|
477
|
-
/** @internal */
|
|
478
|
-
type StoredPluginContext = Pick<PluginContext, 'config' | 'store'> & {
|
|
479
|
-
client?: unknown;
|
|
480
|
-
token?: string | undefined;
|
|
481
|
-
rest?: unknown;
|
|
482
|
-
};
|
|
483
|
-
/**
|
|
484
|
-
* The capability arms a transport supplies from its own Bot/client. `attach` merges them into each
|
|
485
|
-
* plugin's ctx.
|
|
486
|
-
*
|
|
487
|
-
* @internal
|
|
488
|
-
*/
|
|
489
|
-
interface PluginCapabilities {
|
|
490
|
-
readonly client?: unknown;
|
|
491
|
-
readonly token?: string | undefined;
|
|
492
|
-
readonly rest?: unknown;
|
|
493
|
-
}
|
|
494
|
-
/** @internal unset until attach installs the built ctx */
|
|
495
|
-
declare const pluginContextSlot: unique symbol;
|
|
496
|
-
//#endregion
|
|
497
399
|
//#region src/lifecycle/phases.d.ts
|
|
498
400
|
/**
|
|
499
401
|
* Startup phases, in run order.
|
|
@@ -501,7 +403,7 @@ declare const pluginContextSlot: unique symbol;
|
|
|
501
403
|
declare enum StartupPhase {
|
|
502
404
|
/** Nothing connected. Plugin init runs here by default. */
|
|
503
405
|
Configuration = 1,
|
|
504
|
-
/** The gateway session opens
|
|
406
|
+
/** The gateway session opens, and http runs its REST-only startup work. */
|
|
505
407
|
Login = 2,
|
|
506
408
|
/** Handlers are live and interactions dispatch. */
|
|
507
409
|
Ready = 3
|
|
@@ -553,6 +455,44 @@ interface ResolvedPluginLifecycleSpec {
|
|
|
553
455
|
};
|
|
554
456
|
}
|
|
555
457
|
//#endregion
|
|
458
|
+
//#region src/plugin/options.d.ts
|
|
459
|
+
/** The options a plugin declares as its `Plugin<Opts>` type argument. */
|
|
460
|
+
interface PluginOptions {
|
|
461
|
+
/**
|
|
462
|
+
* Which transport the plugin runs on. `'any'` attaches to either one.
|
|
463
|
+
* @defaultValue 'any'
|
|
464
|
+
*/
|
|
465
|
+
transport?: 'gateway' | 'http' | 'any';
|
|
466
|
+
/**
|
|
467
|
+
* Which runtime the plugin runs on. `'any'` attaches to either one.
|
|
468
|
+
* @defaultValue 'any'
|
|
469
|
+
*/
|
|
470
|
+
runtime?: 'server' | 'edge' | 'any';
|
|
471
|
+
}
|
|
472
|
+
/** @internal */
|
|
473
|
+
type TransportOf<Opts extends PluginOptions> = undefined extends Opts['transport'] ? 'any' : NonNullable<Opts['transport']>;
|
|
474
|
+
/** @internal */
|
|
475
|
+
type RuntimeOf<Opts extends PluginOptions> = undefined extends Opts['runtime'] ? 'any' : NonNullable<Opts['runtime']>;
|
|
476
|
+
/** @internal the transport a bot runs */
|
|
477
|
+
type Transport = TypedExclude<NonNullable<PluginOptions['transport']>, 'any'>;
|
|
478
|
+
/** @internal the runtime a bot runs */
|
|
479
|
+
type Runtime = TypedExclude<NonNullable<PluginOptions['runtime']>, 'any'>;
|
|
480
|
+
type TransportMismatch<PluginT extends string, BotT extends string> = Record<`this plugin declares transport '${PluginT}' but this bot runs '${BotT}'`, never>;
|
|
481
|
+
type RuntimeMismatch<PluginRt extends string, BotRt extends string> = Record<`this plugin declares runtime '${PluginRt}' but this bot runs '${BotRt}'`, never>;
|
|
482
|
+
type EdgePluginsUnsupported = Record<'an edge bot takes no plugins until edge support ships after v1', never>;
|
|
483
|
+
/** @internal */
|
|
484
|
+
type ChannelKeyAssert<Key extends string> = Key extends FrameworkChannel ? `'${Key}' is a channel the framework logs on. Pick another plugin key.` : Key;
|
|
485
|
+
type BrandTransport<Plug> = Plug extends {
|
|
486
|
+
readonly __transport?: infer T extends string;
|
|
487
|
+
} ? T : 'any';
|
|
488
|
+
type BrandRuntime<Plug> = Plug extends {
|
|
489
|
+
readonly __runtime?: infer R extends string;
|
|
490
|
+
} ? R : 'any';
|
|
491
|
+
/** @internal */
|
|
492
|
+
type TransportAssert<Plug, BotT extends Transport> = BrandTransport<Plug> extends 'any' | BotT ? unknown : TransportMismatch<BrandTransport<Plug>, BotT>;
|
|
493
|
+
/** @internal */
|
|
494
|
+
type RuntimeAssert<Plug, BotRt extends Runtime> = 'edge' extends BotRt ? EdgePluginsUnsupported : BrandRuntime<Plug> extends 'any' | BotRt ? unknown : RuntimeMismatch<BrandRuntime<Plug>, BotRt>;
|
|
495
|
+
//#endregion
|
|
556
496
|
//#region src/plugin/Plugin.d.ts
|
|
557
497
|
interface Initializeable {
|
|
558
498
|
init(): Promise<void>;
|
|
@@ -561,7 +501,7 @@ interface Initializeable {
|
|
|
561
501
|
declare const resolvedSpecSlot: unique symbol;
|
|
562
502
|
/**
|
|
563
503
|
* Base class for Seedcord plugins. A subclass declares its options as the `Opts` type argument,
|
|
564
|
-
* implements `init()`, and reads the framework surface through `this.
|
|
504
|
+
* implements `init()`, and reads the framework surface through `this.core`.
|
|
565
505
|
*
|
|
566
506
|
* @typeParam Opts - The plugin's declared {@link PluginOptions}.
|
|
567
507
|
* @typeParam TCore - The host type `this.core` resolves to. Each transport binds it to its own `Core`.
|
|
@@ -574,15 +514,11 @@ declare abstract class Plugin<Opts extends PluginOptions = {}, TCore extends Cor
|
|
|
574
514
|
readonly __runtime?: RuntimeOf<Opts>;
|
|
575
515
|
/** @internal */
|
|
576
516
|
readonly [resolvedSpecSlot]: ResolvedPluginLifecycleSpec;
|
|
577
|
-
/**
|
|
578
|
-
[pluginContextSlot]?: StoredPluginContext;
|
|
579
|
-
/** Logs under the plugin's class name, on the channel its attach key names. */
|
|
517
|
+
/** Logs under the plugin's class name, on the channel its attach key sets. */
|
|
580
518
|
readonly logger: Logger;
|
|
581
519
|
constructor(host: CoreBase, spec?: PluginLifecycleSpec);
|
|
582
520
|
/** The host, typed to the transport whose `Plugin` base this class extends. */
|
|
583
521
|
protected get core(): TCore;
|
|
584
|
-
/** The framework surface, available from `init()` onward. Throws if read before `attach` finalizes it. */
|
|
585
|
-
protected get ctx(): PluginContext<NeedsOf<Opts>>;
|
|
586
522
|
abstract init(): Promise<void>;
|
|
587
523
|
/**
|
|
588
524
|
* Runs in the startup Ready phase, after `init()`. The gateway client is logged in by this phase,
|
|
@@ -592,8 +528,7 @@ declare abstract class Plugin<Opts extends PluginOptions = {}, TCore extends Cor
|
|
|
592
528
|
/** Runs during teardown, only when `init()` resolved. */
|
|
593
529
|
dispose?(): Promise<void>;
|
|
594
530
|
/**
|
|
595
|
-
*
|
|
596
|
-
* plugin class and the reason.
|
|
531
|
+
* Throws a `SeedcordError` that contains the plugin class name and the reason.
|
|
597
532
|
*
|
|
598
533
|
* @param reason - Why the options are invalid.
|
|
599
534
|
*/
|
|
@@ -607,7 +542,7 @@ declare abstract class Plugin<Opts extends PluginOptions = {}, TCore extends Cor
|
|
|
607
542
|
protected registerCriticalFiles(patterns: string[]): void;
|
|
608
543
|
}
|
|
609
544
|
/** @internal */
|
|
610
|
-
type PluginLike = Pick<Plugin, 'init' | 'ready' | 'dispose' | 'logger' | 'onHmr' | typeof resolvedSpecSlot
|
|
545
|
+
type PluginLike = Pick<Plugin, 'init' | 'ready' | 'dispose' | 'logger' | 'onHmr' | typeof resolvedSpecSlot>;
|
|
611
546
|
/** @internal */
|
|
612
547
|
type PluginCtor<TPlugin extends PluginLike = PluginLike> = new (...args: any[]) => TPlugin;
|
|
613
548
|
/** @internal */
|
|
@@ -616,5 +551,5 @@ type CoreParamTooNarrow = Record<'this plugin constructor must take CoreBase as
|
|
|
616
551
|
/** @internal */
|
|
617
552
|
type CoreParamAssert<Ctor extends PluginCtor> = CoreBase extends ConstructorParameters<Ctor>[0] ? unknown : CoreParamTooNarrow;
|
|
618
553
|
//#endregion
|
|
619
|
-
export {
|
|
620
|
-
//# sourceMappingURL=Plugin-
|
|
554
|
+
export { AckState as A, InteractionRouteKeys as B, FaultSource as C, Notice as D, Subscriptions as E, PublishDefault as F, MiddlewareMetadataKey as H, CommandMetadataKey as I, EventMetadataKey as L, checkAckLegality as M, sendTarget as N, ReplyTelemetry as O, AckTrace as P, GatedMetadataKey as R, DispatchOutcome as S, SubscriptionKey as T, SubscribeMetadataKey as U, InteractionRoutes as V, WebhookUrlMetadataKey as W, Bus as _, PluginCtor as a, Subscriber as b, PluginOptions as c, Transport as d, TransportAssert as f, CoreBase as g, StartupPhase as h, PluginArgs as i, ReplyMethod as j, reportedWrite as k, Runtime as l, ShutdownPhase as m, Initializeable as n, PluginLike as o, PluginLifecycleSpec as p, Plugin as r, ChannelKeyAssert as s, CoreParamAssert as t, RuntimeAssert as u, StoredSubscriberCtor as v, SubscriptionData as w, DefaultSubscriptions as x, SubscriberRegistration as y, InteractionMetadataKey as z };
|
|
555
|
+
//# sourceMappingURL=Plugin-BZit5HUI.d.mts.map
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
const require_phases = require('./phases-
|
|
1
|
+
const require_phases = require('./phases-DcuDHoQl.cjs');
|
|
2
2
|
const require_devChannel = require('./devChannel-CoCmAVDx.cjs');
|
|
3
|
+
let _seedcord_logger = require("@seedcord/logger");
|
|
3
4
|
let _seedcord_errors = require("@seedcord/errors");
|
|
4
5
|
let _seedcord_errors_internal = require("@seedcord/errors/internal");
|
|
5
|
-
let _seedcord_logger = require("@seedcord/logger");
|
|
6
|
-
|
|
7
|
-
//#region src/plugin/context.ts
|
|
8
|
-
/** @internal unset until attach installs the built ctx */
|
|
9
|
-
const pluginContextSlot = Symbol("seedcord.plugin.ctx");
|
|
10
|
-
/** @internal */
|
|
11
|
-
function readPluginContext(holder) {
|
|
12
|
-
const ctx = holder[pluginContextSlot];
|
|
13
|
-
if (!ctx) throw new _seedcord_errors_internal.SeedcordError(_seedcord_errors.SeedcordErrorCode.PluginContextBeforeInit, [holder.constructor.name]);
|
|
14
|
-
return ctx;
|
|
15
|
-
}
|
|
16
|
-
/** @internal */
|
|
17
|
-
function finalizePluginContext(holder, ctx) {
|
|
18
|
-
holder[pluginContextSlot] = ctx;
|
|
19
|
-
}
|
|
20
6
|
|
|
21
|
-
//#endregion
|
|
22
7
|
//#region src/plugin/lifecycle.ts
|
|
23
8
|
const DEFAULT_INIT_TIMEOUT_MS = 15e3;
|
|
24
9
|
const DEFAULT_READY_TIMEOUT_MS = 15e3;
|
|
@@ -49,7 +34,7 @@ function resolveLifecycleSpec(spec, pluginName) {
|
|
|
49
34
|
const resolvedSpecSlot = Symbol("seedcord.plugin.spec");
|
|
50
35
|
/**
|
|
51
36
|
* Base class for Seedcord plugins. A subclass declares its options as the `Opts` type argument,
|
|
52
|
-
* implements `init()`, and reads the framework surface through `this.
|
|
37
|
+
* implements `init()`, and reads the framework surface through `this.core`.
|
|
53
38
|
*
|
|
54
39
|
* @typeParam Opts - The plugin's declared {@link PluginOptions}.
|
|
55
40
|
* @typeParam TCore - The host type `this.core` resolves to. Each transport binds it to its own `Core`.
|
|
@@ -58,9 +43,7 @@ var Plugin = class {
|
|
|
58
43
|
host;
|
|
59
44
|
/** @internal */
|
|
60
45
|
[resolvedSpecSlot];
|
|
61
|
-
/**
|
|
62
|
-
[pluginContextSlot];
|
|
63
|
-
/** Logs under the plugin's class name, on the channel its attach key names. */
|
|
46
|
+
/** Logs under the plugin's class name, on the channel its attach key sets. */
|
|
64
47
|
logger;
|
|
65
48
|
constructor(host, spec) {
|
|
66
49
|
this.host = host;
|
|
@@ -71,13 +54,8 @@ var Plugin = class {
|
|
|
71
54
|
get core() {
|
|
72
55
|
return this.host;
|
|
73
56
|
}
|
|
74
|
-
/** The framework surface, available from `init()` onward. Throws if read before `attach` finalizes it. */
|
|
75
|
-
get ctx() {
|
|
76
|
-
return readPluginContext(this);
|
|
77
|
-
}
|
|
78
57
|
/**
|
|
79
|
-
*
|
|
80
|
-
* plugin class and the reason.
|
|
58
|
+
* Throws a `SeedcordError` that contains the plugin class name and the reason.
|
|
81
59
|
*
|
|
82
60
|
* @param reason - Why the options are invalid.
|
|
83
61
|
*/
|
|
@@ -108,16 +86,10 @@ Object.defineProperty(exports, 'Plugin', {
|
|
|
108
86
|
return Plugin;
|
|
109
87
|
}
|
|
110
88
|
});
|
|
111
|
-
Object.defineProperty(exports, 'finalizePluginContext', {
|
|
112
|
-
enumerable: true,
|
|
113
|
-
get: function () {
|
|
114
|
-
return finalizePluginContext;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
89
|
Object.defineProperty(exports, 'resolvedLifecycleSpecOf', {
|
|
118
90
|
enumerable: true,
|
|
119
91
|
get: function () {
|
|
120
92
|
return resolvedLifecycleSpecOf;
|
|
121
93
|
}
|
|
122
94
|
});
|
|
123
|
-
//# sourceMappingURL=Plugin-
|
|
95
|
+
//# sourceMappingURL=Plugin-BlkhHNRm.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Plugin-BlkhHNRm.cjs","names":["SeedcordError","SeedcordErrorCode","Logger","SeedcordError","SeedcordErrorCode"],"sources":["../src/plugin/lifecycle.ts","../src/plugin/Plugin.ts"],"sourcesContent":["import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\nimport { ShutdownPhase, StartupPhase } from '@src/lifecycle/phases';\n\n/**\n * The lifecycle a plugin declares through `super(host, spec)`. Unset fields resolve to the base\n * defaults. `ready` runs at a fixed `StartupPhase.Ready`, so it takes only a timeout.\n */\nexport interface PluginLifecycleSpec {\n init?: { phase?: StartupPhase; timeout?: number };\n ready?: { timeout?: number };\n dispose?: { phase?: ShutdownPhase; timeout?: number };\n}\n\n/** @internal */\nexport interface ResolvedPluginLifecycleSpec {\n readonly init: { readonly phase: StartupPhase; readonly timeout: number };\n readonly ready: { readonly timeout: number };\n readonly dispose: { readonly phase: ShutdownPhase; readonly timeout: number };\n}\n\nconst DEFAULT_INIT_TIMEOUT_MS = 15_000;\nconst DEFAULT_READY_TIMEOUT_MS = 15_000;\nconst DEFAULT_DISPOSE_TIMEOUT_MS = 10_000;\n\nfunction timeoutOf(\n field: 'init' | 'ready' | 'dispose',\n declared: number | undefined,\n fallback: number,\n pluginName: string\n): number {\n if (declared === undefined) return fallback;\n if (!Number.isFinite(declared) || declared <= 0) {\n throw new SeedcordError(SeedcordErrorCode.PluginOptionsRejected, [\n pluginName,\n `lifecycle ${field}.timeout must be a positive number of milliseconds`\n ]);\n }\n return declared;\n}\n\n/** @internal */\nexport function resolveLifecycleSpec(\n spec: PluginLifecycleSpec | undefined,\n pluginName: string\n): ResolvedPluginLifecycleSpec {\n return {\n init: {\n phase: spec?.init?.phase ?? StartupPhase.Configuration,\n timeout: timeoutOf('init', spec?.init?.timeout, DEFAULT_INIT_TIMEOUT_MS, pluginName)\n },\n ready: {\n timeout: timeoutOf('ready', spec?.ready?.timeout, DEFAULT_READY_TIMEOUT_MS, pluginName)\n },\n dispose: {\n phase: spec?.dispose?.phase ?? ShutdownPhase.Disconnect,\n timeout: timeoutOf('dispose', spec?.dispose?.timeout, DEFAULT_DISPOSE_TIMEOUT_MS, pluginName)\n }\n };\n}\n","import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\nimport { Logger } from '@seedcord/logger';\n\nimport { getDevChannel } from '@hmr/devChannel';\n\nimport { resolveLifecycleSpec } from './lifecycle';\n\nimport type { ResolvedPluginLifecycleSpec, PluginLifecycleSpec } from './lifecycle';\nimport type { TransportOf, PluginOptions, RuntimeOf } from './options';\nimport type { CoreBase } from '@interfaces/CoreBase';\nimport type { Tail, HmrAware, HmrUpdateEvent } from '@seedcord/types';\n\nexport interface Initializeable {\n init(): Promise<void>;\n}\n\n/** @internal */\nconst resolvedSpecSlot = Symbol('seedcord.plugin.spec');\n\n/**\n * Base class for Seedcord plugins. A subclass declares its options as the `Opts` type argument,\n * implements `init()`, and reads the framework surface through `this.core`.\n *\n * @typeParam Opts - The plugin's declared {@link PluginOptions}.\n * @typeParam TCore - The host type `this.core` resolves to. Each transport binds it to its own `Core`.\n */\nexport abstract class Plugin<Opts extends PluginOptions = {}, TCore extends CoreBase = CoreBase>\n implements Initializeable, HmrAware\n{\n /** @internal phantom, never set at runtime */\n declare readonly __transport?: TransportOf<Opts>;\n /** @internal phantom, never set at runtime */\n declare readonly __runtime?: RuntimeOf<Opts>;\n\n /** @internal */\n readonly [resolvedSpecSlot]: ResolvedPluginLifecycleSpec;\n\n /** Logs under the plugin's class name, on the channel its attach key sets. */\n public readonly logger: Logger;\n\n // CoreBase here keeps the augmented Core out of ConstructorParameters, which attach reads\n constructor(\n private readonly host: CoreBase,\n spec?: PluginLifecycleSpec\n ) {\n this.logger = new Logger(this.constructor.name);\n this[resolvedSpecSlot] = resolveLifecycleSpec(spec, this.constructor.name);\n }\n\n /** The host, typed to the transport whose `Plugin` base this class extends. */\n protected get core(): TCore {\n // justified: each transport binds TCore to the Core its own host satisfies\n return this.host as TCore;\n }\n\n abstract init(): Promise<void>;\n\n /**\n * Runs in the startup Ready phase, after `init()`. The gateway client is logged in by this phase,\n * and the http host runs its server-bind and health tasks in the same phase.\n */\n ready?(): Promise<void>;\n\n /** Runs during teardown, only when `init()` resolved. */\n dispose?(): Promise<void>;\n\n /**\n * Throws a `SeedcordError` that contains the plugin class name and the reason.\n *\n * @param reason - Why the options are invalid.\n */\n protected rejectOptions(reason: string): never {\n throw new SeedcordError(SeedcordErrorCode.PluginOptionsRejected, [this.constructor.name, reason]);\n }\n\n /** Override to reload plugin state on an HMR update. */\n public onHmr(_event: HmrUpdateEvent): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Registers critical file patterns that should trigger a full restart when changed in Dev HMR.\n * @param patterns - Glob patterns relative to the project root\n */\n protected registerCriticalFiles(patterns: string[]): void {\n getDevChannel()?.send('seedcord:register-critical-files', { patterns });\n }\n}\n\n/** @internal */\nexport function resolvedLifecycleSpecOf(plugin: PluginLike): ResolvedPluginLifecycleSpec {\n return plugin[resolvedSpecSlot];\n}\n\nexport type { PluginLifecycleSpec } from './lifecycle';\nexport type { PluginOptions } from './options';\n\n// a bound of Plugin<{}> rejects every plugin that declares an option, since Plugin<A> and Plugin<B>\n// are mutually unassignable. every member here must stay Opts-independent.\n/** @internal */\nexport type PluginLike = Pick<Plugin, 'init' | 'ready' | 'dispose' | 'logger' | 'onHmr' | typeof resolvedSpecSlot>;\n\n// a `CoreBase` first parameter rejects a narrowing ctor on its own, and it also collapses\n// `InstanceType<Ctor>` to `PluginLike` at every attach call. CoreParamAssert checks it instead.\n/** @internal */\nexport type PluginCtor<TPlugin extends PluginLike = PluginLike> = new (...args: any[]) => TPlugin;\n\n/** @internal */\nexport type PluginArgs<Ctor extends PluginCtor> = Tail<ConstructorParameters<Ctor>>;\n\ntype CoreParamTooNarrow = Record<\n 'this plugin constructor must take CoreBase as its first parameter and read the transport Core off this.core',\n never\n>;\n\n// a narrowed first parameter fails `CoreBase extends Param`\n/** @internal */\nexport type CoreParamAssert<Ctor extends PluginCtor> = CoreBase extends ConstructorParameters<Ctor>[0]\n ? unknown\n : CoreParamTooNarrow;\n"],"mappings":";;;;;;;AAsBA,MAAM,0BAA0B;AAChC,MAAM,2BAA2B;AACjC,MAAM,6BAA6B;AAEnC,SAAS,UACL,OACA,UACA,UACA,YACM;CACN,IAAI,aAAa,QAAW,OAAO;CACnC,IAAI,CAAC,OAAO,SAAS,QAAQ,KAAK,YAAY,GAC1C,MAAM,IAAIA,wCAAcC,mCAAkB,uBAAuB,CAC7D,YACA,aAAa,MAAM,mDACvB,CAAC;CAEL,OAAO;AACX;;AAGA,SAAgB,qBACZ,MACA,YAC2B;CAC3B,OAAO;EACH,MAAM;GACF,OAAO,MAAM,MAAM;GACnB,SAAS,UAAU,QAAQ,MAAM,MAAM,SAAS,yBAAyB,UAAU;EACvF;EACA,OAAO,EACH,SAAS,UAAU,SAAS,MAAM,OAAO,SAAS,0BAA0B,UAAU,EAC1F;EACA,SAAS;GACL,OAAO,MAAM,SAAS;GACtB,SAAS,UAAU,WAAW,MAAM,SAAS,SAAS,4BAA4B,UAAU;EAChG;CACJ;AACJ;;;;;AC1CA,MAAM,mBAAmB,OAAO,sBAAsB;;;;;;;;AAStD,IAAsB,SAAtB,MAEA;CAcyB;;CAPrB,CAAU;;CAGV,AAAgB;CAGhB,YACI,AAAiB,MACjB,MACF;EAFmB;EAGjB,KAAK,SAAS,IAAIC,wBAAO,KAAK,YAAY,IAAI;EAC9C,KAAK,oBAAoB,qBAAqB,MAAM,KAAK,YAAY,IAAI;CAC7E;;CAGA,IAAc,OAAc;EAExB,OAAO,KAAK;CAChB;;;;;;CAkBA,AAAU,cAAc,QAAuB;EAC3C,MAAM,IAAIC,wCAAcC,mCAAkB,uBAAuB,CAAC,KAAK,YAAY,MAAM,MAAM,CAAC;CACpG;;CAGA,AAAO,MAAM,QAAuC;EAChD,OAAO,QAAQ,QAAQ;CAC3B;;;;;CAMA,AAAU,sBAAsB,UAA0B;EACtD,iCAAc,CAAC,EAAE,KAAK,oCAAoC,EAAE,SAAS,CAAC;CAC1E;AACJ;;AAGA,SAAgB,wBAAwB,QAAiD;CACrF,OAAO,OAAO;AAClB"}
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
import { n as StartupPhase, t as ShutdownPhase } from "./phases-
|
|
1
|
+
import { n as StartupPhase, t as ShutdownPhase } from "./phases-BauKJOTT.mjs";
|
|
2
2
|
import { t as getDevChannel } from "./devChannel-CQU7hq7Q.mjs";
|
|
3
|
+
import { Logger } from "@seedcord/logger";
|
|
3
4
|
import { SeedcordErrorCode } from "@seedcord/errors";
|
|
4
5
|
import { SeedcordError } from "@seedcord/errors/internal";
|
|
5
|
-
import { Logger } from "@seedcord/logger";
|
|
6
|
-
|
|
7
|
-
//#region src/plugin/context.ts
|
|
8
|
-
/** @internal unset until attach installs the built ctx */
|
|
9
|
-
const pluginContextSlot = Symbol("seedcord.plugin.ctx");
|
|
10
|
-
/** @internal */
|
|
11
|
-
function readPluginContext(holder) {
|
|
12
|
-
const ctx = holder[pluginContextSlot];
|
|
13
|
-
if (!ctx) throw new SeedcordError(SeedcordErrorCode.PluginContextBeforeInit, [holder.constructor.name]);
|
|
14
|
-
return ctx;
|
|
15
|
-
}
|
|
16
|
-
/** @internal */
|
|
17
|
-
function finalizePluginContext(holder, ctx) {
|
|
18
|
-
holder[pluginContextSlot] = ctx;
|
|
19
|
-
}
|
|
20
6
|
|
|
21
|
-
//#endregion
|
|
22
7
|
//#region src/plugin/lifecycle.ts
|
|
23
8
|
const DEFAULT_INIT_TIMEOUT_MS = 15e3;
|
|
24
9
|
const DEFAULT_READY_TIMEOUT_MS = 15e3;
|
|
@@ -49,7 +34,7 @@ function resolveLifecycleSpec(spec, pluginName) {
|
|
|
49
34
|
const resolvedSpecSlot = Symbol("seedcord.plugin.spec");
|
|
50
35
|
/**
|
|
51
36
|
* Base class for Seedcord plugins. A subclass declares its options as the `Opts` type argument,
|
|
52
|
-
* implements `init()`, and reads the framework surface through `this.
|
|
37
|
+
* implements `init()`, and reads the framework surface through `this.core`.
|
|
53
38
|
*
|
|
54
39
|
* @typeParam Opts - The plugin's declared {@link PluginOptions}.
|
|
55
40
|
* @typeParam TCore - The host type `this.core` resolves to. Each transport binds it to its own `Core`.
|
|
@@ -58,9 +43,7 @@ var Plugin = class {
|
|
|
58
43
|
host;
|
|
59
44
|
/** @internal */
|
|
60
45
|
[resolvedSpecSlot];
|
|
61
|
-
/**
|
|
62
|
-
[pluginContextSlot];
|
|
63
|
-
/** Logs under the plugin's class name, on the channel its attach key names. */
|
|
46
|
+
/** Logs under the plugin's class name, on the channel its attach key sets. */
|
|
64
47
|
logger;
|
|
65
48
|
constructor(host, spec) {
|
|
66
49
|
this.host = host;
|
|
@@ -71,13 +54,8 @@ var Plugin = class {
|
|
|
71
54
|
get core() {
|
|
72
55
|
return this.host;
|
|
73
56
|
}
|
|
74
|
-
/** The framework surface, available from `init()` onward. Throws if read before `attach` finalizes it. */
|
|
75
|
-
get ctx() {
|
|
76
|
-
return readPluginContext(this);
|
|
77
|
-
}
|
|
78
57
|
/**
|
|
79
|
-
*
|
|
80
|
-
* plugin class and the reason.
|
|
58
|
+
* Throws a `SeedcordError` that contains the plugin class name and the reason.
|
|
81
59
|
*
|
|
82
60
|
* @param reason - Why the options are invalid.
|
|
83
61
|
*/
|
|
@@ -102,5 +80,5 @@ function resolvedLifecycleSpecOf(plugin) {
|
|
|
102
80
|
}
|
|
103
81
|
|
|
104
82
|
//#endregion
|
|
105
|
-
export { resolvedLifecycleSpecOf as n,
|
|
106
|
-
//# sourceMappingURL=Plugin-
|
|
83
|
+
export { resolvedLifecycleSpecOf as n, Plugin as t };
|
|
84
|
+
//# sourceMappingURL=Plugin-CDAV7P9l.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Plugin-CDAV7P9l.mjs","names":[],"sources":["../src/plugin/lifecycle.ts","../src/plugin/Plugin.ts"],"sourcesContent":["import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\nimport { ShutdownPhase, StartupPhase } from '@src/lifecycle/phases';\n\n/**\n * The lifecycle a plugin declares through `super(host, spec)`. Unset fields resolve to the base\n * defaults. `ready` runs at a fixed `StartupPhase.Ready`, so it takes only a timeout.\n */\nexport interface PluginLifecycleSpec {\n init?: { phase?: StartupPhase; timeout?: number };\n ready?: { timeout?: number };\n dispose?: { phase?: ShutdownPhase; timeout?: number };\n}\n\n/** @internal */\nexport interface ResolvedPluginLifecycleSpec {\n readonly init: { readonly phase: StartupPhase; readonly timeout: number };\n readonly ready: { readonly timeout: number };\n readonly dispose: { readonly phase: ShutdownPhase; readonly timeout: number };\n}\n\nconst DEFAULT_INIT_TIMEOUT_MS = 15_000;\nconst DEFAULT_READY_TIMEOUT_MS = 15_000;\nconst DEFAULT_DISPOSE_TIMEOUT_MS = 10_000;\n\nfunction timeoutOf(\n field: 'init' | 'ready' | 'dispose',\n declared: number | undefined,\n fallback: number,\n pluginName: string\n): number {\n if (declared === undefined) return fallback;\n if (!Number.isFinite(declared) || declared <= 0) {\n throw new SeedcordError(SeedcordErrorCode.PluginOptionsRejected, [\n pluginName,\n `lifecycle ${field}.timeout must be a positive number of milliseconds`\n ]);\n }\n return declared;\n}\n\n/** @internal */\nexport function resolveLifecycleSpec(\n spec: PluginLifecycleSpec | undefined,\n pluginName: string\n): ResolvedPluginLifecycleSpec {\n return {\n init: {\n phase: spec?.init?.phase ?? StartupPhase.Configuration,\n timeout: timeoutOf('init', spec?.init?.timeout, DEFAULT_INIT_TIMEOUT_MS, pluginName)\n },\n ready: {\n timeout: timeoutOf('ready', spec?.ready?.timeout, DEFAULT_READY_TIMEOUT_MS, pluginName)\n },\n dispose: {\n phase: spec?.dispose?.phase ?? ShutdownPhase.Disconnect,\n timeout: timeoutOf('dispose', spec?.dispose?.timeout, DEFAULT_DISPOSE_TIMEOUT_MS, pluginName)\n }\n };\n}\n","import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\nimport { Logger } from '@seedcord/logger';\n\nimport { getDevChannel } from '@hmr/devChannel';\n\nimport { resolveLifecycleSpec } from './lifecycle';\n\nimport type { ResolvedPluginLifecycleSpec, PluginLifecycleSpec } from './lifecycle';\nimport type { TransportOf, PluginOptions, RuntimeOf } from './options';\nimport type { CoreBase } from '@interfaces/CoreBase';\nimport type { Tail, HmrAware, HmrUpdateEvent } from '@seedcord/types';\n\nexport interface Initializeable {\n init(): Promise<void>;\n}\n\n/** @internal */\nconst resolvedSpecSlot = Symbol('seedcord.plugin.spec');\n\n/**\n * Base class for Seedcord plugins. A subclass declares its options as the `Opts` type argument,\n * implements `init()`, and reads the framework surface through `this.core`.\n *\n * @typeParam Opts - The plugin's declared {@link PluginOptions}.\n * @typeParam TCore - The host type `this.core` resolves to. Each transport binds it to its own `Core`.\n */\nexport abstract class Plugin<Opts extends PluginOptions = {}, TCore extends CoreBase = CoreBase>\n implements Initializeable, HmrAware\n{\n /** @internal phantom, never set at runtime */\n declare readonly __transport?: TransportOf<Opts>;\n /** @internal phantom, never set at runtime */\n declare readonly __runtime?: RuntimeOf<Opts>;\n\n /** @internal */\n readonly [resolvedSpecSlot]: ResolvedPluginLifecycleSpec;\n\n /** Logs under the plugin's class name, on the channel its attach key sets. */\n public readonly logger: Logger;\n\n // CoreBase here keeps the augmented Core out of ConstructorParameters, which attach reads\n constructor(\n private readonly host: CoreBase,\n spec?: PluginLifecycleSpec\n ) {\n this.logger = new Logger(this.constructor.name);\n this[resolvedSpecSlot] = resolveLifecycleSpec(spec, this.constructor.name);\n }\n\n /** The host, typed to the transport whose `Plugin` base this class extends. */\n protected get core(): TCore {\n // justified: each transport binds TCore to the Core its own host satisfies\n return this.host as TCore;\n }\n\n abstract init(): Promise<void>;\n\n /**\n * Runs in the startup Ready phase, after `init()`. The gateway client is logged in by this phase,\n * and the http host runs its server-bind and health tasks in the same phase.\n */\n ready?(): Promise<void>;\n\n /** Runs during teardown, only when `init()` resolved. */\n dispose?(): Promise<void>;\n\n /**\n * Throws a `SeedcordError` that contains the plugin class name and the reason.\n *\n * @param reason - Why the options are invalid.\n */\n protected rejectOptions(reason: string): never {\n throw new SeedcordError(SeedcordErrorCode.PluginOptionsRejected, [this.constructor.name, reason]);\n }\n\n /** Override to reload plugin state on an HMR update. */\n public onHmr(_event: HmrUpdateEvent): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Registers critical file patterns that should trigger a full restart when changed in Dev HMR.\n * @param patterns - Glob patterns relative to the project root\n */\n protected registerCriticalFiles(patterns: string[]): void {\n getDevChannel()?.send('seedcord:register-critical-files', { patterns });\n }\n}\n\n/** @internal */\nexport function resolvedLifecycleSpecOf(plugin: PluginLike): ResolvedPluginLifecycleSpec {\n return plugin[resolvedSpecSlot];\n}\n\nexport type { PluginLifecycleSpec } from './lifecycle';\nexport type { PluginOptions } from './options';\n\n// a bound of Plugin<{}> rejects every plugin that declares an option, since Plugin<A> and Plugin<B>\n// are mutually unassignable. every member here must stay Opts-independent.\n/** @internal */\nexport type PluginLike = Pick<Plugin, 'init' | 'ready' | 'dispose' | 'logger' | 'onHmr' | typeof resolvedSpecSlot>;\n\n// a `CoreBase` first parameter rejects a narrowing ctor on its own, and it also collapses\n// `InstanceType<Ctor>` to `PluginLike` at every attach call. CoreParamAssert checks it instead.\n/** @internal */\nexport type PluginCtor<TPlugin extends PluginLike = PluginLike> = new (...args: any[]) => TPlugin;\n\n/** @internal */\nexport type PluginArgs<Ctor extends PluginCtor> = Tail<ConstructorParameters<Ctor>>;\n\ntype CoreParamTooNarrow = Record<\n 'this plugin constructor must take CoreBase as its first parameter and read the transport Core off this.core',\n never\n>;\n\n// a narrowed first parameter fails `CoreBase extends Param`\n/** @internal */\nexport type CoreParamAssert<Ctor extends PluginCtor> = CoreBase extends ConstructorParameters<Ctor>[0]\n ? unknown\n : CoreParamTooNarrow;\n"],"mappings":";;;;;;;AAsBA,MAAM,0BAA0B;AAChC,MAAM,2BAA2B;AACjC,MAAM,6BAA6B;AAEnC,SAAS,UACL,OACA,UACA,UACA,YACM;CACN,IAAI,aAAa,QAAW,OAAO;CACnC,IAAI,CAAC,OAAO,SAAS,QAAQ,KAAK,YAAY,GAC1C,MAAM,IAAI,cAAc,kBAAkB,uBAAuB,CAC7D,YACA,aAAa,MAAM,mDACvB,CAAC;CAEL,OAAO;AACX;;AAGA,SAAgB,qBACZ,MACA,YAC2B;CAC3B,OAAO;EACH,MAAM;GACF,OAAO,MAAM,MAAM;GACnB,SAAS,UAAU,QAAQ,MAAM,MAAM,SAAS,yBAAyB,UAAU;EACvF;EACA,OAAO,EACH,SAAS,UAAU,SAAS,MAAM,OAAO,SAAS,0BAA0B,UAAU,EAC1F;EACA,SAAS;GACL,OAAO,MAAM,SAAS;GACtB,SAAS,UAAU,WAAW,MAAM,SAAS,SAAS,4BAA4B,UAAU;EAChG;CACJ;AACJ;;;;;AC1CA,MAAM,mBAAmB,OAAO,sBAAsB;;;;;;;;AAStD,IAAsB,SAAtB,MAEA;CAcyB;;CAPrB,CAAU;;CAGV,AAAgB;CAGhB,YACI,AAAiB,MACjB,MACF;EAFmB;EAGjB,KAAK,SAAS,IAAI,OAAO,KAAK,YAAY,IAAI;EAC9C,KAAK,oBAAoB,qBAAqB,MAAM,KAAK,YAAY,IAAI;CAC7E;;CAGA,IAAc,OAAc;EAExB,OAAO,KAAK;CAChB;;;;;;CAkBA,AAAU,cAAc,QAAuB;EAC3C,MAAM,IAAI,cAAc,kBAAkB,uBAAuB,CAAC,KAAK,YAAY,MAAM,MAAM,CAAC;CACpG;;CAGA,AAAO,MAAM,QAAuC;EAChD,OAAO,QAAQ,QAAQ;CAC3B;;;;;CAMA,AAAU,sBAAsB,UAA0B;EACtD,cAAc,CAAC,EAAE,KAAK,oCAAoC,EAAE,SAAS,CAAC;CAC1E;AACJ;;AAGA,SAAgB,wBAAwB,QAAiD;CACrF,OAAO,OAAO;AAClB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ContextMenuCommandBuilder, SlashCommandBuilder } from "@discordjs/builders";
|
|
2
|
+
import { APIApplicationCommand } from "discord-api-types/v10";
|
|
3
|
+
|
|
4
|
+
//#region src/commands/types.d.ts
|
|
5
|
+
/** @internal */
|
|
6
|
+
type CommandBuilder = SlashCommandBuilder | ContextMenuCommandBuilder;
|
|
7
|
+
/** The commands Discord returns from each scope's deploy, keyed by command id. @internal */
|
|
8
|
+
interface DeployResult {
|
|
9
|
+
global: Map<string, APIApplicationCommand>;
|
|
10
|
+
guilds: Map<string, Map<string, APIApplicationCommand>>;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/basic.d.ts
|
|
14
|
+
/**
|
|
15
|
+
Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
16
|
+
|
|
17
|
+
@category Class
|
|
18
|
+
*/
|
|
19
|
+
type Constructor<T, Arguments extends unknown[] = any[]> = new (...arguments_: Arguments) => T;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { CommandBuilder as n, DeployResult as r, Constructor as t };
|
|
22
|
+
//# sourceMappingURL=basic-1hebYVcN.d.mts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ContextMenuCommandBuilder, SlashCommandBuilder } from "@discordjs/builders";
|
|
2
|
+
|
|
3
|
+
//#region src/commands/contextMenuLeaves.d.ts
|
|
4
|
+
/** The registered context-menu command names, split by kind. @internal */
|
|
5
|
+
interface ContextMenuLeaves {
|
|
6
|
+
readonly user: Set<string>;
|
|
7
|
+
readonly message: Set<string>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Collects the names of every registered context-menu command across a set of command builders, deduplicated
|
|
11
|
+
* because the same builder appears once per guild. A user and a message command can share a name, so the two
|
|
12
|
+
* kinds stay in separate sets.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
declare function contextMenuLeaves(commands: Iterable<SlashCommandBuilder | ContextMenuCommandBuilder>): ContextMenuLeaves;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { contextMenuLeaves as n, ContextMenuLeaves as t };
|
|
19
|
+
//# sourceMappingURL=contextMenuLeaves-f2rbyo83.d.mts.map
|