@arcscord/discord-ui-core 0.2.0-beta.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,37 @@
1
1
  # Changelog
2
2
 
3
- ## 0.2.0 — initial core extraction (unreleased)
3
+ ## 0.3.0
4
+
5
+ ### Added
6
+
7
+ - Convert received Discord API messages, channels, threads and resolved entities
8
+ through the optional `@arcscord/discord-ui-core/discord-api` entry.
9
+ - Add video, audio, voice-note and sticker display models, including waveform,
10
+ duration, poster and unsupported sticker-format metadata.
11
+ - Add viewer-supplied mentioned-message state, semantic highlight tokens and
12
+ author server tags with optional badge images.
13
+ - Share user, mention and message interaction contracts across the adapters.
14
+ - Update `discord-api-types` to the `0.38.60` baseline.
15
+
16
+ ### Migration from 0.2.x
17
+
18
+ - `MessageContentView.media` and `GalleryView.items` accept images and videos.
19
+ Custom renderers must narrow `MessageMediaView` before reading image-only data.
20
+ - `MessageContentView.attachments` accepts `FileView | AudioView`. Handle the
21
+ audio branch before passing file values to a file renderer.
22
+ - `fromDiscordMessage` classifies recognized audio attachments as audio and moves
23
+ recognized video attachments into `media`. Review custom attachment filters.
24
+ - Adapters using these contracts require Core `^0.3.0`. Publish and approve this
25
+ Core version before staging React `0.4.0`, Vue `0.2.0` or Svelte `0.1.0`.
26
+
27
+ ## 0.2.0 — initial core extraction
4
28
 
5
29
  - Extract framework-independent display models, callback contracts, configuration
6
30
  defaults, URL/date/select helpers, theme tokens and scoped CSS from the React package.
7
31
  - Add renderer-neutral Markdown blocks, Unicode emoji segments and optional code
8
32
  highlighting tokens through separate entries.
33
+ - Allow applications to permit specific HTTP(S) media sources when remote media
34
+ is disabled.
9
35
  - Introduce independent core versions and `core-vX.Y.Z` release tags. React keeps
10
36
  its public imports and depends on a compatible core range.
11
37
  - No Vue, Angular or Svelte renderer is included or claimed compatible.
package/README.md CHANGED
@@ -1,12 +1,22 @@
1
1
  # @arcscord/discord-ui-core
2
2
 
3
3
  Framework-independent Discord display models, content processing, themes and styles.
4
- This checkout prepares the first core version, **0.2.0**. Registry availability is
5
- separate from local build and tarball validation.
6
4
 
7
5
  The core does not render components or depend on React, Vue, Angular or Svelte.
8
- Use `@arcscord/discord-ui` for the existing React renderer. The native Vue adapter is `@arcscord/discord-ui-vue`. Angular and Svelte
9
- adapters remain future work.
6
+ The renderer packages are `@arcscord/discord-ui` for React, `@arcscord/discord-ui-vue`
7
+ for Vue and `@arcscord/discord-ui-svelte` for Svelte.
8
+
9
+ ## Installation
10
+
11
+ Install the core directly to use its framework-independent APIs. Each adapter
12
+ installs the core as a dependency.
13
+
14
+ ```sh
15
+ pnpm add @arcscord/discord-ui-core
16
+ ```
17
+
18
+ Check the [npm versions](https://www.npmjs.com/package/@arcscord/discord-ui-core?activeTab=versions)
19
+ to see which release the `latest` tag selects.
10
20
 
11
21
  ## Public entries
12
22
 
@@ -16,6 +26,7 @@ adapters remain future work.
16
26
  | `@arcscord/discord-ui-core/themes` | Presets, `defineTheme`, `resolveTheme`, `themeStyle`, token mapping and types |
17
27
  | `@arcscord/discord-ui-core/markdown` | `parseMarkdown` and serializable block/node types |
18
28
  | `@arcscord/discord-ui-core/emoji` | `isUnicodeEmoji`, `segmentUnicodeEmoji` and text/emoji segment types |
29
+ | `@arcscord/discord-ui-core/discord-api` | Convert received Discord API v10 data into display models |
19
30
  | `@arcscord/discord-ui-core/highlight` | Optional `highlightCode` and token types |
20
31
  | `@arcscord/discord-ui-core/styles.css` | Complete, scoped stylesheet with Light/Ash/Dark presets |
21
32
 
@@ -44,6 +55,89 @@ void blocks;
44
55
  void cssVariables;
45
56
  ```
46
57
 
58
+ ## Convert received Discord data
59
+
60
+ `fromDiscordMessage` converts complete Discord API v10 message objects into
61
+ `MessageView` for the rendering adapters. Use `fromDiscordMessageComponents` for a component
62
+ array on its own and pass `{ attachments }` to resolve `attachment://` URLs.
63
+ `fromDiscordUser`, `fromDiscordRole` and `fromDiscordChannel` convert entity
64
+ identities. Unnamed channels and unknown channel types return `undefined`.
65
+
66
+ Both message helpers accept `selectEntities`, keyed by the menu's Discord
67
+ `custom_id`. Each entry can provide `users`, `roles` and `channels` as display
68
+ models. Entity menus start with an empty list when those choices are absent.
69
+ The host authorizes access, supplies mention lookups and handles interactions.
70
+ The message helper uses available data and omits unsupported nodes, including
71
+ media references it cannot resolve. The adapters render image and video galleries, audio files, voice notes, PNG/APNG/GIF stickers and file links. Lottie stickers have an explicit unsupported-format state.
72
+
73
+ ### With discord.js v14
74
+
75
+ If you already have a discord.js `Message`, each component's `toJSON()` returns
76
+ API-shaped data. It works directly for a component preview. For `attachment://`
77
+ references, also supply the raw message's `attachments` array. If you only need
78
+ a user preview, use the `User` display properties directly. Both paths use the
79
+ objects you already have.
80
+
81
+ ```ts
82
+ import type { UserView } from "@arcscord/discord-ui-core";
83
+ import type { Message, User } from "discord.js";
84
+ import { fromDiscordMessageComponents } from "@arcscord/discord-ui-core/discord-api";
85
+ import { UserFlags } from "discord.js";
86
+
87
+ export function messageComponents(message: Message) {
88
+ return fromDiscordMessageComponents(message.components.map(component => component.toJSON()));
89
+ }
90
+
91
+ export function userView(user: User): UserView {
92
+ return {
93
+ id: user.id,
94
+ username: user.username,
95
+ displayName: user.displayName,
96
+ avatarUrl: user.displayAvatarURL(),
97
+ bot: user.bot,
98
+ verified: user.flags?.has(UserFlags.VerifiedBot) ?? false,
99
+ };
100
+ }
101
+ ```
102
+
103
+ For full message previews, use raw `MESSAGE_CREATE` packets or REST.
104
+ `Message#toJSON()` returns discord.js fields such as `authorId` and
105
+ `createdTimestamp`, and `User#toJSON()` uses `globalName` and `flags`.
106
+ The raw converters expect Discord API fields such as `author` and `timestamp`.
107
+ If you already have a `Message`, pass its `channelId` and `id` to `readMessage`
108
+ below to retrieve the raw response. The REST method returns `unknown`, so the
109
+ example types responses from those known routes. Reconstruct a full message
110
+ before converting a partial update. Only the bot needs discord.js.
111
+
112
+ ```ts
113
+ import type { MessageView } from "@arcscord/discord-ui-core";
114
+ import type { GatewayDispatchPayload, RESTGetAPIChannelMessageResult, RESTGetAPIUserResult } from "discord-api-types/v10";
115
+ import type { Client } from "discord.js";
116
+ import { fromDiscordMessage, fromDiscordUser } from "@arcscord/discord-ui-core/discord-api";
117
+ import { Events, Routes } from "discord.js";
118
+
119
+ export function watchMessages(client: Client, onMessage: (message: MessageView) => void) {
120
+ client.on(Events.Raw, (packet: GatewayDispatchPayload) => {
121
+ if (packet.t === "MESSAGE_CREATE")
122
+ onMessage(fromDiscordMessage(packet.d));
123
+ });
124
+ }
125
+
126
+ export async function readMessage(client: Client, channelId: string, messageId: string) {
127
+ const data = await client.rest.get(Routes.channelMessage(channelId, messageId)) as RESTGetAPIChannelMessageResult;
128
+ return fromDiscordMessage(data);
129
+ }
130
+
131
+ export async function readUser(client: Client, userId: string) {
132
+ const data = await client.rest.get(Routes.user(userId)) as RESTGetAPIUserResult;
133
+ return fromDiscordUser(data);
134
+ }
135
+ ```
136
+
137
+ The payload reflects the bot's permissions and Gateway intents. For example,
138
+ Discord can withhold message content, attachments, embeds and components. See
139
+ the [Discord message resource](https://docs.discord.com/developers/resources/message).
140
+
47
141
  ## Renderer boundary
48
142
 
49
143
  `parseMarkdown` returns text/list blocks containing nested nodes, entity IDs,
@@ -93,3 +187,12 @@ See the repository's
93
187
  MIT. Adapted parsing, highlighting and styles retain upstream notices in
94
188
  [THIRD_PARTY_NOTICES](./THIRD_PARTY_NOTICES). Twemoji graphics are not bundled or
95
189
  loaded implicitly; hosts supplying graphics retain their attribution obligations.
190
+
191
+ ## Mentioned messages
192
+
193
+ Set `MessageView.mentioned` to `true` for the current viewer's highlighted
194
+ messages. Rendering adapters also expose `MessageFrame.mentioned` for composed
195
+ layouts. The host supplies the flag; Markdown mention tokens and API conversion
196
+ leave it unset. The highlight uses its hover background on hover and keyboard focus. Ephemeral appearance takes precedence
197
+ when both flags are true. Theme overrides accept `mentionedBackground`, `mentionedHover` and
198
+ `mentionedBorder`.
@@ -1,4 +1,222 @@
1
- import { i as ThemeOverrides, n as ThemeInput } from "./themes-yWxS4t7J.mjs";
1
+ /** Serializable reaction state owned by the consuming application. */
2
+ type ReactionView = {
3
+ id: string;
4
+ emoji: {
5
+ name: string;
6
+ image?: string;
7
+ };
8
+ count: number;
9
+ me?: boolean;
10
+ };
11
+ type ReactionToggleHandler = (messageId: string, reactionId: string) => void;
12
+ /** A thread summary never embeds its conversation recursively. */
13
+ type ThreadSummaryView = {
14
+ id: string;
15
+ name: string;
16
+ messageCount: number;
17
+ lastMessage?: {
18
+ author: MessageAuthor;
19
+ content: string;
20
+ timestamp: string;
21
+ };
22
+ };
23
+ type ThreadMessageView = MessageMetadata & MessageContentView & {
24
+ thread?: never;
25
+ };
26
+ type ThreadView = {
27
+ id: string;
28
+ name: string;
29
+ parentMessageId: string;
30
+ /** Replies only; the starter remains in the channel's messages. */
31
+ messages: readonly ThreadMessageView[];
32
+ };
33
+ /** Colors use six-digit hex values; omitted values are generated from the author. */
34
+ type AvatarFallback = {
35
+ background?: string;
36
+ letter?: string;
37
+ color?: string;
38
+ };
39
+ /** A server tag shown after the author name; `badgeUrl` is an optional small image. */
40
+ type AuthorTag = {
41
+ text: string;
42
+ badgeUrl?: string;
43
+ };
44
+ /** Display metadata supplied by the application, without Discord API calls. */
45
+ type MessageAuthor = {
46
+ id: string;
47
+ displayName: string;
48
+ avatarUrl?: string;
49
+ avatarFallback?: AvatarFallback;
50
+ bot?: boolean;
51
+ verified?: boolean;
52
+ color?: string;
53
+ tag?: AuthorTag;
54
+ };
55
+ /** Plain text is the first supported body; richer variants will extend this union. */
56
+ type TextMessageBody = {
57
+ kind: "text";
58
+ content: string;
59
+ };
60
+ /** A resolved, plain-text reply snapshot, or an unavailable original message. */
61
+ type MessageReplyView = {
62
+ kind?: "message";
63
+ messageId: string;
64
+ } & ({
65
+ unavailable: true;
66
+ author?: never;
67
+ content?: never;
68
+ } | {
69
+ unavailable?: false;
70
+ author: MessageAuthor;
71
+ content: string;
72
+ });
73
+ /** The invoking user and slash command, supplied by the host application. */
74
+ type InteractionReplyView = {
75
+ kind: "interaction";
76
+ author: MessageAuthor;
77
+ /** Command name without the leading slash; may include a subcommand. */
78
+ commandName: string;
79
+ };
80
+ type ReplyView = MessageReplyView | InteractionReplyView;
81
+ /** Serializable display data. This is not a Discord send-payload validator. */
82
+ type MessageMetadata = {
83
+ id: string;
84
+ author: MessageAuthor;
85
+ /** Explicit ISO 8601 timestamp including a timezone; no implicit local clock. */
86
+ timestamp: string;
87
+ reactions?: readonly ReactionView[];
88
+ reply?: ReplyView;
89
+ /** Shows the edited marker; omitted is equivalent to false. */
90
+ edited?: boolean;
91
+ /** Display-only visibility hint. The host controls access to private data. */
92
+ ephemeral?: boolean;
93
+ /** Highlights a mention of the viewer, as resolved by the host application. */
94
+ mentioned?: boolean;
95
+ };
96
+ type MessageContentView = ({
97
+ body: TextMessageBody | MarkdownMessageBody;
98
+ media?: readonly MessageMediaView[];
99
+ attachments?: readonly (FileView | AudioView)[];
100
+ stickers?: readonly StickerView[];
101
+ embeds?: readonly EmbedView[];
102
+ components?: readonly ActionRowView[];
103
+ } | {
104
+ body: ComponentsV2Body;
105
+ media?: never;
106
+ attachments?: never;
107
+ stickers?: never;
108
+ embeds?: never;
109
+ components?: never;
110
+ });
111
+ type MessageView = MessageMetadata & MessageContentView & {
112
+ thread?: ThreadSummaryView;
113
+ };
114
+ /** An ordered, serializable snapshot of a text channel, without transport state. */
115
+ type ChannelViewModel = {
116
+ id: string;
117
+ name: string;
118
+ topic?: string;
119
+ messages: readonly MessageView[];
120
+ threads?: readonly ThreadView[];
121
+ };
122
+ type EntityView = {
123
+ name: string;
124
+ color?: string;
125
+ };
126
+ /** A reusable resolved Discord role, for selectors, mentions and member lists. */
127
+ type RoleView = EntityView & {
128
+ id: string;
129
+ };
130
+ /** Reuse the same identity/avatar/app fields as message authors. */
131
+ type UserView = Pick<MessageAuthor, "id" | "displayName" | "avatarUrl" | "bot" | "verified"> & {
132
+ username?: string;
133
+ status?: "online" | "idle" | "dnd" | "offline";
134
+ };
135
+ type ChannelType = 0 | 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16;
136
+ /** Channel identity with the metadata needed for Discord's channel icons. */
137
+ type ChannelEntityView = Pick<ChannelViewModel, "id" | "name"> & {
138
+ channelType: ChannelType;
139
+ locked?: boolean;
140
+ rules?: boolean;
141
+ };
142
+ type MessageEntities = {
143
+ users?: Record<string, EntityView>;
144
+ channels?: Record<string, EntityView>;
145
+ roles?: Record<string, Omit<RoleView, "id">>;
146
+ emojis?: Record<string, {
147
+ name: string;
148
+ image: string;
149
+ }>;
150
+ commands?: Record<string, EntityView>;
151
+ };
152
+ type MediaView = {
153
+ id: string;
154
+ url: string;
155
+ alt: string;
156
+ spoiler?: boolean;
157
+ width?: number;
158
+ height?: number;
159
+ };
160
+ /** A directly playable video source, supplied by the host. */
161
+ type VideoView = {
162
+ kind: "video";
163
+ id: string;
164
+ url: string;
165
+ alt: string;
166
+ spoiler?: boolean;
167
+ width?: number;
168
+ height?: number;
169
+ posterUrl?: string;
170
+ durationSeconds?: number;
171
+ };
172
+ type MessageMediaView = MediaView | VideoView;
173
+ type AudioView = {
174
+ kind: "audio";
175
+ id: string;
176
+ url: string;
177
+ name: string;
178
+ size?: string;
179
+ spoiler?: boolean;
180
+ durationSeconds?: number;
181
+ voice?: boolean;
182
+ /** Normalized amplitude samples between zero and one. */
183
+ waveform?: readonly number[];
184
+ };
185
+ type StickerView = {
186
+ id: string;
187
+ name: string;
188
+ format: "png" | "apng" | "gif" | "lottie";
189
+ url: string;
190
+ };
191
+ type EmbedView = {
192
+ id: string;
193
+ title?: string;
194
+ url?: string;
195
+ description?: string;
196
+ color?: string;
197
+ author?: {
198
+ name: string;
199
+ url?: string;
200
+ iconUrl?: string;
201
+ };
202
+ thumbnail?: MediaView;
203
+ image?: MediaView;
204
+ fields?: readonly {
205
+ id: string;
206
+ name: string;
207
+ value: string;
208
+ inline?: boolean;
209
+ }[];
210
+ footer?: {
211
+ text: string;
212
+ iconUrl?: string;
213
+ };
214
+ timestamp?: string;
215
+ };
216
+ type MarkdownMessageBody = {
217
+ kind: "markdown";
218
+ content: string;
219
+ };
2
220
  type TextDisplayView = {
3
221
  id: string;
4
222
  kind: "text-display";
@@ -169,7 +387,7 @@ type SectionView = {
169
387
  type GalleryView = {
170
388
  id: string;
171
389
  kind: "media-gallery";
172
- items: readonly MediaView[];
390
+ items: readonly MessageMediaView[];
173
391
  };
174
392
  type SeparatorView = {
175
393
  id: string;
@@ -200,245 +418,4 @@ type ComponentsV2Body = {
200
418
  kind: "components-v2";
201
419
  components: readonly MessageComponent[];
202
420
  };
203
- /** Serializable reaction state owned by the consuming application. */
204
- type ReactionView = {
205
- id: string;
206
- emoji: {
207
- name: string;
208
- image?: string;
209
- };
210
- count: number;
211
- me?: boolean;
212
- };
213
- type ReactionToggleHandler = (messageId: string, reactionId: string) => void;
214
- /** A thread summary never embeds its conversation recursively. */
215
- type ThreadSummaryView = {
216
- id: string;
217
- name: string;
218
- messageCount: number;
219
- lastMessage?: {
220
- author: MessageAuthor;
221
- content: string;
222
- timestamp: string;
223
- };
224
- };
225
- type ThreadMessageView = MessageMetadata & MessageContentView & {
226
- thread?: never;
227
- };
228
- type ThreadView = {
229
- id: string;
230
- name: string;
231
- parentMessageId: string;
232
- /** Replies only; the starter remains in the channel's messages. */
233
- messages: readonly ThreadMessageView[];
234
- };
235
- /** Colors use six-digit hex values; omitted values are generated from the author. */
236
- type AvatarFallback = {
237
- background?: string;
238
- letter?: string;
239
- color?: string;
240
- };
241
- /** Display metadata supplied by the application, without Discord API calls. */
242
- type MessageAuthor = {
243
- id: string;
244
- displayName: string;
245
- avatarUrl?: string;
246
- avatarFallback?: AvatarFallback;
247
- bot?: boolean;
248
- verified?: boolean;
249
- color?: string;
250
- };
251
- /** Plain text is the first supported body; richer variants will extend this union. */
252
- type TextMessageBody = {
253
- kind: "text";
254
- content: string;
255
- };
256
- /** A resolved, plain-text reply snapshot, or an unavailable original message. */
257
- type MessageReplyView = {
258
- kind?: "message";
259
- messageId: string;
260
- } & ({
261
- unavailable: true;
262
- author?: never;
263
- content?: never;
264
- } | {
265
- unavailable?: false;
266
- author: MessageAuthor;
267
- content: string;
268
- });
269
- /** The invoking user and slash command, supplied by the host application. */
270
- type InteractionReplyView = {
271
- kind: "interaction";
272
- author: MessageAuthor;
273
- /** Command name without the leading slash; may include a subcommand. */
274
- commandName: string;
275
- };
276
- type ReplyView = MessageReplyView | InteractionReplyView;
277
- /** Serializable display data. This is not a Discord send-payload validator. */
278
- type MessageMetadata = {
279
- id: string;
280
- author: MessageAuthor;
281
- /** Explicit ISO 8601 timestamp including a timezone; no implicit local clock. */
282
- timestamp: string;
283
- reactions?: readonly ReactionView[];
284
- reply?: ReplyView;
285
- /** Shows the edited marker; omitted is equivalent to false. */
286
- edited?: boolean;
287
- /** Display-only visibility hint. The host controls access to private data. */
288
- ephemeral?: boolean;
289
- };
290
- type MessageContentView = ({
291
- body: TextMessageBody | MarkdownMessageBody;
292
- media?: readonly MediaView[];
293
- attachments?: readonly FileView[];
294
- embeds?: readonly EmbedView[];
295
- components?: readonly ActionRowView[];
296
- } | {
297
- body: ComponentsV2Body;
298
- media?: never;
299
- attachments?: never;
300
- embeds?: never;
301
- components?: never;
302
- });
303
- type MessageView = MessageMetadata & MessageContentView & {
304
- thread?: ThreadSummaryView;
305
- };
306
- /** An ordered, serializable snapshot of a text channel, without transport state. */
307
- type ChannelViewModel = {
308
- id: string;
309
- name: string;
310
- topic?: string;
311
- messages: readonly MessageView[];
312
- threads?: readonly ThreadView[];
313
- };
314
- type EntityView = {
315
- name: string;
316
- color?: string;
317
- };
318
- /** A reusable resolved Discord role, for selectors, mentions and member lists. */
319
- type RoleView = EntityView & {
320
- id: string;
321
- };
322
- /** Reuse the same identity/avatar/app fields as message authors. */
323
- type UserView = Pick<MessageAuthor, "id" | "displayName" | "avatarUrl" | "bot" | "verified"> & {
324
- username?: string;
325
- status?: "online" | "idle" | "dnd" | "offline";
326
- };
327
- type ChannelType = 0 | 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16;
328
- /** Channel identity with the metadata needed for Discord's channel icons. */
329
- type ChannelEntityView = Pick<ChannelViewModel, "id" | "name"> & {
330
- channelType: ChannelType;
331
- locked?: boolean;
332
- rules?: boolean;
333
- };
334
- type MessageEntities = {
335
- users?: Record<string, EntityView>;
336
- channels?: Record<string, EntityView>;
337
- roles?: Record<string, Omit<RoleView, "id">>;
338
- emojis?: Record<string, {
339
- name: string;
340
- image: string;
341
- }>;
342
- commands?: Record<string, EntityView>;
343
- };
344
- type MediaView = {
345
- id: string;
346
- url: string;
347
- alt: string;
348
- spoiler?: boolean;
349
- width?: number;
350
- height?: number;
351
- };
352
- type EmbedView = {
353
- id: string;
354
- title?: string;
355
- url?: string;
356
- description?: string;
357
- color?: string;
358
- author?: {
359
- name: string;
360
- url?: string;
361
- iconUrl?: string;
362
- };
363
- thumbnail?: MediaView;
364
- image?: MediaView;
365
- fields?: readonly {
366
- id: string;
367
- name: string;
368
- value: string;
369
- inline?: boolean;
370
- }[];
371
- footer?: {
372
- text: string;
373
- iconUrl?: string;
374
- };
375
- timestamp?: string;
376
- };
377
- type MarkdownMessageBody = {
378
- kind: "markdown";
379
- content: string;
380
- };
381
- type UILabels = {
382
- selectPlaceholder?: string;
383
- channelSelectPlaceholder?: string;
384
- removeSelection?: string;
385
- selectNoResults?: string;
386
- selectNoOptions?: string;
387
- userOnline?: string;
388
- userIdle?: string;
389
- userDnd?: string;
390
- userOffline?: string;
391
- commandOptions: string;
392
- commandReady: string;
393
- removeArgument: string;
394
- slashCommands: string;
395
- cancelCommand: string;
396
- chooseValue: string;
397
- edited: string;
398
- reply: string;
399
- replyUnavailable: string;
400
- interactionReply: string;
401
- interactionUsed: string;
402
- ephemeralNotice: string;
403
- dismissMessage: string;
404
- downloadFile: string;
405
- reactions: string;
406
- thread: string;
407
- openThread: string;
408
- closeThread: string;
409
- threadMessageSingular: string;
410
- threadMessagePlural: string;
411
- threadNoRecentMessages: string;
412
- messages: string;
413
- emptyChannel: string;
414
- messagePlaceholder: string;
415
- sendMessage: string;
416
- spoiler: string;
417
- showSpoiler: string;
418
- hideSpoiler: string;
419
- mediaUnavailable: string;
420
- invalidTimestamp: string;
421
- };
422
- /** Twemoji files are served as `${baseUrl}/${codepoints}.svg`; no CDN is implicit. */
423
- type UnicodeEmojiOptions = {
424
- mode: "native";
425
- } | {
426
- mode: "twemoji";
427
- baseUrl: string;
428
- };
429
- type BaseDisplayOptions = {
430
- theme: ThemeInput;
431
- tokens?: ThemeOverrides;
432
- locale: string;
433
- timeZone: string;
434
- referenceTime?: string;
435
- entities: MessageEntities;
436
- allowRemoteMedia: boolean;
437
- /** HTTP(S) origins, directories or exact paths allowed when remote media is disabled. */
438
- remoteMediaAllowlist?: readonly string[];
439
- unicodeEmoji?: UnicodeEmojiOptions;
440
- labels: UILabels;
441
- };
442
- declare const defaultDisplayOptions: BaseDisplayOptions;
443
- export { SelectValuesByMessage as $, ButtonView as A, LinkButtonView as B, TextMessageBody as C, ReactionToggleHandler as D, ThreadView as E, ComponentsV2Body as F, RoleSelectMenuView as G, MessageButtonView as H, ContainerChild as I, SelectChannelType as J, RoleSelectOptionView as K, ContainerView as L, ChannelSelectOptionView as M, ComponentHandlers as N, ReactionView as O, ComponentInteractionContext as P, SelectValues as Q, FileView as R, ReplyView as S, ThreadSummaryView as T, MessageComponent as U, MentionableSelectMenuView as V, PremiumButtonView as W, SelectMenuView as X, SelectDefaultValue as Y, SelectOptionView as Z, MessageAuthor as _, EmbedView as a, UserSelectMenuView as at, MessageReplyView as b, MessageEntities as c, EntityView as d, SeparatorView as et, RoleView as f, InteractionReplyView as g, AvatarFallback as h, defaultDisplayOptions as i, ThumbnailView as it, ChannelSelectMenuView as j, ActionRowView as k, ChannelEntityView as l, ChannelViewModel as m, UILabels as n, StringSelectOptionView as nt, MarkdownMessageBody as o, UserSelectOptionView as ot, UserView as p, SectionView as q, UnicodeEmojiOptions as r, TextDisplayView as rt, MediaView as s, BaseDisplayOptions as t, StringSelectMenuView as tt, ChannelType as u, MessageContentView as v, ThreadMessageView as w, MessageView as x, MessageMetadata as y, GalleryView as z };
444
- //# sourceMappingURL=display-options-CDOCAill.d.mts.map
421
+ export { MessageReplyView as $, ThumbnailView as A, VideoView as B, SelectOptionView as C, StringSelectMenuView as D, SeparatorView as E, MarkdownMessageBody as F, UserView as G, ChannelType as H, MediaView as I, AvatarFallback as J, ChannelViewModel as K, MessageEntities as L, UserSelectOptionView as M, AudioView as N, StringSelectOptionView as O, EmbedView as P, MessageMetadata as Q, MessageMediaView as R, SelectMenuView as S, SelectValuesByMessage as T, EntityView as U, ChannelEntityView as V, RoleView as W, MessageAuthor as X, InteractionReplyView as Y, MessageContentView as Z, RoleSelectMenuView as _, ComponentHandlers as a, ThreadView as at, SelectChannelType as b, ContainerChild as c, GalleryView as d, MessageView as et, LinkButtonView as f, PremiumButtonView as g, MessageComponent as h, ChannelSelectOptionView as i, ThreadSummaryView as it, UserSelectMenuView as j, TextDisplayView as k, ContainerView as l, MessageButtonView as m, ButtonView as n, TextMessageBody as nt, ComponentInteractionContext as o, ReactionToggleHandler as ot, MentionableSelectMenuView as p, AuthorTag as q, ChannelSelectMenuView as r, ThreadMessageView as rt, ComponentsV2Body as s, ReactionView as st, ActionRowView as t, ReplyView as tt, FileView as u, RoleSelectOptionView as v, SelectValues as w, SelectDefaultValue as x, SectionView as y, StickerView as z };
@@ -0,0 +1,26 @@
1
+ import { APIAttachment, APIMessage, APIMessageTopLevelComponent, APIPartialChannel, APIRole, APIUser, GatewayMessageCreateDispatchData } from "discord-api-types/v10";
2
+ import { G as UserView, V as ChannelEntityView, W as RoleView, et as MessageView, h as MessageComponent } from "./components-D6NgWu9m.mjs";
3
+ type DiscordMessageConversionOptions = {
4
+ /** Available choices for each entity select, keyed by its Discord custom_id. */
5
+ selectEntities?: Readonly<Record<string, {
6
+ users?: readonly UserView[];
7
+ roles?: readonly RoleView[];
8
+ channels?: readonly ChannelEntityView[];
9
+ } | undefined>>;
10
+ };
11
+ type DiscordComponentConversionOptions = DiscordMessageConversionOptions & {
12
+ /** Attachments supplied by the containing message for attachment:// references. */
13
+ attachments?: readonly APIAttachment[];
14
+ };
15
+ /** Convert a message's component array in order, omitting unsupported nodes. */
16
+ export declare function fromDiscordMessageComponents(components: readonly APIMessageTopLevelComponent[], options?: DiscordComponentConversionOptions): MessageComponent[];
17
+ /** Convert a Discord user to identity data for authors, avatars and entity menus. */
18
+ export declare function fromDiscordUser(user: APIUser): UserView;
19
+ /** Convert a role's name and primary display color. */
20
+ export declare function fromDiscordRole(role: Pick<APIRole, "id" | "name" | "color"> & Partial<Pick<APIRole, "colors">>): RoleView;
21
+ /** Convert a named channel identity. Unnamed or unsupported channels return undefined. */
22
+ export declare function fromDiscordChannel(channel: APIPartialChannel): ChannelEntityView | undefined;
23
+ type DiscordMessageInput = APIMessage & Pick<GatewayMessageCreateDispatchData, "guild_id" | "member">;
24
+ /** Convert a complete REST message or Gateway MESSAGE_CREATE payload to a display snapshot. */
25
+ export declare function fromDiscordMessage(message: DiscordMessageInput, options?: DiscordMessageConversionOptions): MessageView;
26
+ export type { DiscordComponentConversionOptions, DiscordMessageConversionOptions };