@seedcord/core 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/{Bus-BVwmKc-A.mjs → Bus-dGy6xq3F.mjs} +88 -85
  2. package/dist/Bus-dGy6xq3F.mjs.map +1 -0
  3. package/dist/{Pluggable-DFNUIlJM.d.mts → Pluggable-BKe2uCa0.d.mts} +3 -3
  4. package/dist/{Pluggable-Cf5-WWmW.mjs → Pluggable-CtMiOP3p.mjs} +4 -4
  5. package/dist/{Pluggable-Cf5-WWmW.mjs.map → Pluggable-CtMiOP3p.mjs.map} +1 -1
  6. package/dist/{Plugin-C6oMqWf8.mjs → Plugin-BJfRk0s_.mjs} +4 -4
  7. package/dist/{Plugin-C6oMqWf8.mjs.map → Plugin-BJfRk0s_.mjs.map} +1 -1
  8. package/dist/{Plugin-CG9pWbPF.d.mts → Plugin-iAaWcLaD.d.mts} +2 -2
  9. package/dist/{cursor-BcRfmTSo.d.mts → cursor-8Y2zpF-Y.d.mts} +5 -224
  10. package/dist/{cursor-GBUYz3jk.mjs → cursor-BkI9lxy2.mjs} +9 -498
  11. package/dist/cursor-BkI9lxy2.mjs.map +1 -0
  12. package/dist/{index-ZzdQafFv.d.mts → index-CD8l15aZ.d.mts} +2 -2
  13. package/dist/index.d.mts +99 -17
  14. package/dist/index.mjs +148 -16
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/internal.index.d.mts +15 -7
  17. package/dist/internal.index.mjs +11 -11
  18. package/dist/internal.index.mjs.map +1 -1
  19. package/dist/node-internal.index.d.mts +4 -4
  20. package/dist/node-internal.index.mjs +7 -7
  21. package/dist/node.index.d.mts +1 -1
  22. package/dist/node.index.mjs +2 -2
  23. package/dist/{phases-F8yvPd60.d.mts → phases-D0a8BV9Z.d.mts} +60 -57
  24. package/dist/plugin.index.d.mts +1 -1
  25. package/dist/plugin.index.mjs +1 -1
  26. package/dist/{publishDefault-D826XXDQ.mjs → publishDefault-BuSZPbjT.mjs} +2 -2
  27. package/dist/{publishDefault-D826XXDQ.mjs.map → publishDefault-BuSZPbjT.mjs.map} +1 -1
  28. package/dist/{slashRouteLeaves-CbYRwqMY.mjs → slashRouteLeaves-C1msUE9Q.mjs} +2 -2
  29. package/dist/{slashRouteLeaves-CbYRwqMY.mjs.map → slashRouteLeaves-C1msUE9Q.mjs.map} +1 -1
  30. package/dist/{subscribers-CGGQkUfM.mjs → subscribers-A8lNU5yM.mjs} +3 -3
  31. package/dist/{subscribers-CGGQkUfM.mjs.map → subscribers-A8lNU5yM.mjs.map} +1 -1
  32. package/package.json +11 -10
  33. package/dist/Bus-BVwmKc-A.mjs.map +0 -1
  34. package/dist/cursor-GBUYz3jk.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { n as StartupPhase, r as CoreBase, t as ShutdownPhase } from "./phases-F8yvPd60.mjs";
1
+ import { n as StartupPhase, r as CoreBase, t as ShutdownPhase } from "./phases-D0a8BV9Z.mjs";
2
2
  import { Logger } from "@seedcord/logger";
3
3
  import { FrameworkChannel, HmrAware, HmrUpdateEvent, Tail, TypedExclude } from "@seedcord/types";
4
4
  //#region src/plugin/brands.d.ts
@@ -190,4 +190,4 @@ type CoreParamTooNarrow = Record<'this plugin constructor must take CoreBase as
190
190
  type CoreParamAssert<Ctor extends PluginCtor> = CoreBase extends ConstructorParameters<Ctor>[0] ? unknown : CoreParamTooNarrow;
191
191
  //#endregion
192
192
  export { PluginCtor as a, PluginOptions as c, Transport as d, TransportAssert as f, PluginArgs as i, Runtime as l, Initializeable as n, PluginLike as o, PluginLifecycleSpec as p, Plugin as r, ChannelKeyAssert as s, CoreParamAssert as t, RuntimeAssert as u };
193
- //# sourceMappingURL=Plugin-CG9pWbPF.d.mts.map
193
+ //# sourceMappingURL=Plugin-iAaWcLaD.d.mts.map
@@ -1,8 +1,9 @@
1
+ import { H as Notice, r as CoreBase } from "./phases-D0a8BV9Z.mjs";
1
2
  import { t as Constructor } from "./basic-Dng__Ena.mjs";
2
- import { b as Notice, r as CoreBase, z as InteractionRoutes } from "./phases-F8yvPd60.mjs";
3
3
  import "reflect-metadata";
4
+ import { CustomId, CustomIdField } from "@seedcord/custom-id";
4
5
  import { ActionRowBuilder, ButtonBuilder, ChannelSelectMenuBuilder, CheckboxBuilder, CheckboxGroupBuilder, CheckboxGroupOptionBuilder, ContainerBuilder, ContextMenuCommandBuilder, EmbedBuilder, FileBuilder, FileUploadBuilder, LabelBuilder, MediaGalleryBuilder, MentionableSelectMenuBuilder, ModalBuilder, RadioGroupBuilder, RadioGroupOptionBuilder, RoleSelectMenuBuilder, SectionBuilder, SeparatorBuilder, SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, TextDisplayBuilder, TextInputBuilder, UserSelectMenuBuilder } from "@discordjs/builders";
5
- import { APIMessageTopLevelComponent, ApplicationCommandType, ChannelType, Snowflake } from "discord-api-types/v10";
6
+ import { APIMessageTopLevelComponent, ApplicationCommandType, ChannelType } from "discord-api-types/v10";
6
7
  import { ReplyResponse } from "@seedcord/types";
7
8
  //#region src/registries/ContextMenuRegistry.d.ts
8
9
  /** The two context-menu command kinds Discord defines. */
@@ -263,30 +264,6 @@ type B = IsTrueFixed<never>;
263
264
  */
264
265
  type IsNever<T> = [T] extends [never] ? true : false;
265
266
  //#endregion
266
- //#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/non-empty-tuple.d.ts
267
- /**
268
- Matches any non-empty tuple.
269
-
270
- @example
271
- ```
272
- import type {NonEmptyTuple} from 'type-fest';
273
-
274
- const sum = (...numbers: NonEmptyTuple<number>) => numbers.reduce((total, value) => total + value, 0);
275
-
276
- sum(1, 2, 3);
277
- // Ok
278
-
279
- // @ts-expect-error
280
- sum();
281
- // Error: Expected at least 1 arguments, but got 0.
282
- ```
283
-
284
- @see {@link RequireAtLeastOne} for objects
285
-
286
- @category Array
287
- */
288
- type NonEmptyTuple<T = unknown> = readonly [T, ...T[]];
289
- //#endregion
290
267
  //#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/promisable.d.ts
291
268
  /**
292
269
  Create a type that represents either the value or the value wrapped in `PromiseLike`.
@@ -348,202 +325,6 @@ declare function RegisterCommand(scope: 'global'): (ctor: CommandCtor) => void;
348
325
  */
349
326
  declare function RegisterCommand(scope: 'guild', guilds: string[]): (ctor: CommandCtor) => void;
350
327
  //#endregion
351
- //#region src/customId/Field.d.ts
352
- /**
353
- * One field in a customId shape, its wire kind plus the type it decodes to.
354
- *
355
- * @internal
356
- */
357
- interface CustomIdField<Decoded> {
358
- /** Which wire encoding this field uses. */
359
- readonly kind: 'snowflake' | 'uuid' | 'int' | 'bool' | 'oneOf' | 'string';
360
- /** Lower bound, for a bounded int field. */
361
- readonly min?: number;
362
- /** Upper bound, for a bounded int field. */
363
- readonly max?: number;
364
- /** The allowed values, for a oneOf field. */
365
- readonly choices?: readonly string[];
366
- /** Whether this field also carries null. */
367
- readonly nullable?: boolean;
368
- /** Phantom only, carries the decoded type and is never set at runtime. */
369
- readonly decoded?: Decoded;
370
- }
371
- /**
372
- * The set of fields a customId carries, keyed by name.
373
- *
374
- * @internal
375
- */
376
- type CustomIdShape = Record<string, CustomIdField<unknown>>;
377
- /**
378
- * The decoded result, each field name mapped to its decoded type.
379
- *
380
- * @internal
381
- */
382
- type DecodedParams<Shape extends CustomIdShape> = { [Name in keyof Shape]: Shape[Name] extends CustomIdField<infer Decoded> ? Decoded : never; };
383
- //#endregion
384
- //#region src/customId/CustomId.d.ts
385
- /** Per-field options every {@link CustomId} chain method takes. */
386
- interface FieldOptions<Nullable extends boolean = boolean> {
387
- /**
388
- * Whether the field also carries null. A nullable field costs one extra slot on the wire.
389
- *
390
- * @defaultValue `false`
391
- */
392
- nullable?: Nullable;
393
- }
394
- type Nullish<Decoded, Nullable extends boolean> = Nullable extends true ? Decoded | null : Decoded;
395
- /** Strip the layout hash off the routeKey to recover the stable prefix the controller routes by. @internal */
396
- declare function prefixOf(wire: string): string;
397
- /**
398
- * A typed customId. The single source of truth shared by the component that mints it and the handler
399
- * that reads it. This gives you typed reads on the `.customId` field in components. Values are packed
400
- * into a compact wire string, which fits more of them inside Discord's 100-char limit.
401
- *
402
- * @typeParam Prefix - The stable route prefix, e.g. 'approve'.
403
- * @typeParam Shape - The accumulated fields, filled in by the chain.
404
- *
405
- * @example
406
- * ```ts
407
- * const ApproveId = new CustomId('approve')
408
- * .snowflake('userId')
409
- * .oneOf('action', ['approve', 'deny']);
410
- *
411
- * // Set the custom id on a button when creating it.
412
- * new ButtonBuilder().setCustomId(ApproveId.encode({ userId: '123', action: 'approve' }));
413
- *
414
- * // in the handler, userId comes back a string
415
- * const { userId, action } = this.params; // userId: string, action: 'approve' | 'deny'
416
- * await this.event.guild?.members.fetch(userId);
417
- * ```
418
- */
419
- declare class CustomId<Prefix extends string, Shape extends CustomIdShape = {}> {
420
- /** The stable route prefix, e.g. 'approve'. */
421
- readonly prefix: Prefix;
422
- /** The field definitions accumulated by the chain, keyed by name. */
423
- readonly shape: Shape;
424
- /** The prefix plus a short hash of the shape, the part of the wire before the colon. */
425
- readonly routeKey: string;
426
- constructor(prefix: Prefix, shape?: Shape);
427
- private add;
428
- /**
429
- * Add a Discord ID field, decoded as a string (the `Snowflake` type from discord-api-types).
430
- *
431
- * @example
432
- * ```ts
433
- * new CustomId('ban').snowflake('userId');
434
- * ```
435
- */
436
- snowflake<Name extends string, const Nullable extends boolean = false>(name: Name, opts?: FieldOptions<Nullable>): CustomId<Prefix, Shape & Record<Name, CustomIdField<Nullish<Snowflake, Nullable>>>>;
437
- /**
438
- * Add a UUID field, decoded as a lowercase uuid string.
439
- *
440
- * @example
441
- * ```ts
442
- * new CustomId('ticket').uuid('ticketId');
443
- * ```
444
- */
445
- uuid<Name extends string, const Nullable extends boolean = false>(name: Name, opts?: FieldOptions<Nullable>): CustomId<Prefix, Shape & Record<Name, CustomIdField<Nullish<string, Nullable>>>>;
446
- /**
447
- * Add an integer field with no bounds, for a value up to 2^53.
448
- *
449
- * @example
450
- * ```ts
451
- * new CustomId('shop').int('amount');
452
- * ```
453
- */
454
- int<Name extends string, const Nullable extends boolean = false>(name: Name, opts?: FieldOptions<Nullable>): CustomId<Prefix, Shape & Record<Name, CustomIdField<Nullish<number, Nullable>>>>;
455
- /**
456
- * Add an integer field bounded by min and max, so it packs into fewer characters on the wire.
457
- *
458
- * @example
459
- * ```ts
460
- * new CustomId('paginate').int('page', 1, 50);
461
- * ```
462
- */
463
- int<Name extends string, const Nullable extends boolean = false>(name: Name, min: number, max: number, opts?: FieldOptions<Nullable>): CustomId<Prefix, Shape & Record<Name, CustomIdField<Nullish<number, Nullable>>>>;
464
- /**
465
- * Add a boolean flag.
466
- *
467
- * @example
468
- * ```ts
469
- * new CustomId('settings').bool('silent');
470
- * ```
471
- */
472
- bool<Name extends string, const Nullable extends boolean = false>(name: Name, opts?: FieldOptions<Nullable>): CustomId<Prefix, Shape & Record<Name, CustomIdField<Nullish<boolean, Nullable>>>>;
473
- /**
474
- * Add a field that is one value from a fixed list, decoded as the literal union. No `as const` needed.
475
- *
476
- * @example
477
- * ```ts
478
- * new CustomId('poll').oneOf('choice', ['yes', 'no', 'abstain']);
479
- * ```
480
- */
481
- oneOf<Name extends string, const Choices extends NonEmptyTuple<string>, const Nullable extends boolean = false>(name: Name, choices: Choices, opts?: FieldOptions<Nullable>): CustomId<Prefix, Shape & Record<Name, CustomIdField<Nullish<Choices[number], Nullable>>>>;
482
- /**
483
- * Add a free short text field. Avoid it where possible. It cannot be packed, which makes it the most
484
- * expensive field on the wire.
485
- *
486
- * @example
487
- * ```ts
488
- * new CustomId('note').str('message');
489
- * ```
490
- */
491
- str<Name extends string, const Nullable extends boolean = false>(name: Name, opts?: FieldOptions<Nullable>): CustomId<Prefix, Shape & Record<Name, CustomIdField<Nullish<string, Nullable>>>>;
492
- /**
493
- * Mint a wire string from values. Throws if a value is out of its field's range or the wire is over 100 chars.
494
- *
495
- * @param values - One value per field, typed by the chain.
496
- * @returns The wire string to put on the component's customId.
497
- */
498
- encode(values: DecodedParams<Shape>): string;
499
- /**
500
- * Read a wire string back into values.
501
- *
502
- * - This will refuse with a default Notice when the shape changed since the wire was minted.
503
- * - Or refuse with a different default Notice on a corrupt or foreign wire.
504
- *
505
- * @param wire - The customId string from the interaction.
506
- * @returns The decoded values, typed by the chain.
507
- */
508
- decode(wire: string): DecodedParams<Shape>;
509
- /** True if this wire was minted from this customId's prefix, ignoring the shape hash. */
510
- owns(wire: string): boolean;
511
- }
512
- /** @internal */
513
- type AnyCustomId = CustomId<string, CustomIdShape>;
514
- /**
515
- * The outcome of decoding a wire against several customIds, the matched prefix paired with its values.
516
- *
517
- * @internal
518
- */
519
- type DecodedRoute<Defs extends readonly AnyCustomId[]> = { [Index in keyof Defs]: Defs[Index] extends AnyCustomId ? {
520
- readonly prefix: Defs[Index]['prefix'];
521
- readonly params: DecodedParams<Defs[Index]['shape']>;
522
- } : never; }[number];
523
- /** @internal */
524
- declare function decodeFor<Defs extends readonly AnyCustomId[]>(defs: Defs, wire: string): DecodedRoute<Defs>;
525
- //#endregion
526
- //#region src/decorators/interactionRoutes.d.ts
527
- /** The select menu kinds the select route decorators take. */
528
- declare enum SelectMenuKind {
529
- String = "string",
530
- User = "user",
531
- Role = "role",
532
- Channel = "channel",
533
- Mentionable = "mentionable"
534
- }
535
- type RoutableConstructor = new (...args: never[]) => unknown;
536
- declare function areRoutes(routes: unknown): routes is string[];
537
- /**
538
- * every stored route kind and its route strings on a decorated constructor. the build's manifest
539
- * emitter reads the same pairs.
540
- */
541
- declare function interactionRoutesOf(constructor: RoutableConstructor): [InteractionRoutes, string[]][];
542
- declare function storeInteractionRoute(route: InteractionRoutes, routes: string | readonly string[], constructor: RoutableConstructor): void;
543
- declare function storeComponentRoute(route: InteractionRoutes, defs: readonly AnyCustomId[], constructor: RoutableConstructor): void;
544
- declare function selectMenuRouteOf(kind: SelectMenuKind): InteractionRoutes;
545
- declare function contextMenuRouteOf(kind: ContextMenuKind): InteractionRoutes;
546
- //#endregion
547
328
  //#region src/decorators/brands.d.ts
548
329
  declare const SlashRouteBrand: unique symbol;
549
330
  declare const AutocompleteRouteBrand: unique symbol;
@@ -983,5 +764,5 @@ type PageCursor<Prefix extends string> = CustomId<Prefix, {
983
764
  /** Build the page cursor for a paginator. */
984
765
  declare function pageCursor<Prefix extends string>(prefix: Prefix): PageCursor<Prefix>;
985
766
  //#endregion
986
- export { Promisable as $, serializeReply as A, contextMenuRouteOf as B, Gate as C, defineEffectGate as D, RequiredOf as E, ContextMenuNamesBrand as F, AnyCustomId as G, selectMenuRouteOf as H, SlashRouteBrand as I, decodeFor as J, CustomId as K, RoutableConstructor as L, ComponentDefsBrand as M, ComponentKindBrand as N, defineGate as O, ContextMenuKindBrand as P, RegisterCommand as Q, SelectMenuKind as R, EffectGate as S, GuildPermissionsContext as T, storeComponentRoute as U, interactionRoutesOf as V, storeInteractionRoute as W, DecodedParams as X, prefixOf as Y, CommandMeta as Z, pickNotice as _, AutocompleteOptions as a, CacheFor as at, JoinNames as b, FocusedField as c, SlashOption as ct, RequirePermissionsOptions as d, ContextMenuKind as dt, IsNever as et, RequireRole as f, MenuCacheFor as ft, GateNoticeOptions as g, PermissionScope as h, UserContextMenuRegistry as ht, AutocompletableNames as i, RowType as it, AutocompleteRouteBrand as j, SerializedReply as k, RequireBotPermissions as l, SlashRegistry as lt, PermissionNames as m, NamesFor as mt, PageCursor as n, RowComponent as nt, ChoiceValueOf as o, OptionKind as ot, RequireRoleOptions as p, MessageContextMenuRegistry as pt, FieldOptions as q, pageCursor as r, BuilderType as rt, EntryFor as s, RouteCache as st, PAGE_MAX as t, BuilderComponent as tt, RequirePermissions as u, SlashRouteEntry as ut, GateFitsWith as v, GateContextBase as w, TwoOrMore as x, IntersectRequired as y, areRoutes as z };
987
- //# sourceMappingURL=cursor-BcRfmTSo.d.mts.map
767
+ export { MessageContextMenuRegistry as $, serializeReply as A, IsNever as B, Gate as C, defineEffectGate as D, RequiredOf as E, ContextMenuNamesBrand as F, CacheFor as G, RowComponent as H, SlashRouteBrand as I, SlashOption as J, OptionKind as K, CommandMeta as L, ComponentDefsBrand as M, ComponentKindBrand as N, defineGate as O, ContextMenuKindBrand as P, MenuCacheFor as Q, RegisterCommand as R, EffectGate as S, GuildPermissionsContext as T, BuilderType as U, BuilderComponent as V, RowType as W, SlashRouteEntry as X, SlashRegistry as Y, ContextMenuKind as Z, pickNotice as _, AutocompleteOptions as a, JoinNames as b, FocusedField as c, RequirePermissionsOptions as d, NamesFor as et, RequireRole as f, GateNoticeOptions as g, PermissionScope as h, AutocompletableNames as i, AutocompleteRouteBrand as j, SerializedReply as k, RequireBotPermissions as l, PermissionNames as m, PageCursor as n, ChoiceValueOf as o, RequireRoleOptions as p, RouteCache as q, pageCursor as r, EntryFor as s, PAGE_MAX as t, UserContextMenuRegistry as tt, RequirePermissions as u, GateFitsWith as v, GateContextBase as w, TwoOrMore as x, IntersectRequired as y, Promisable as z };
768
+ //# sourceMappingURL=cursor-8Y2zpF-Y.d.mts.map