@mostfeatured/dbi 0.2.11 → 0.2.12

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/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "tslib": "^2.6.3"
16
16
  },
17
17
  "name": "@mostfeatured/dbi",
18
- "version": "0.2.11",
18
+ "version": "0.2.12",
19
19
  "main": "dist/src/index.js",
20
20
  "types": "dist/src/index.d.ts",
21
21
  "typesVersions": {
@@ -100,9 +100,10 @@ function parseStringSelect(dbi: DBI<NamespaceEnums>, dbiName: string, stringSele
100
100
  let minValues = parseInt(stringSelect.getAttribute("min-values"));
101
101
  let maxValues = parseInt(stringSelect.getAttribute("max-values"));
102
102
 
103
- let options = Array.from(stringSelect.querySelectorAll("option")).map(option => {
103
+ // Support both <option> and <select-option> elements (Svelte may output either)
104
+ let options = Array.from(stringSelect.querySelectorAll("option, select-option")).map(option => {
104
105
  return {
105
- label: getCleanTextContent(option),
106
+ label: option.getAttribute("label") || getCleanTextContent(option),
106
107
  value: option.getAttribute("value"),
107
108
  description: option.getAttribute("description"),
108
109
  emoji: option.getAttribute("emoji"),
@@ -125,7 +126,8 @@ function parseNonStringSelect(dbi: DBI<NamespaceEnums>, dbiName: string, userSel
125
126
  let minValues = parseInt(userSelect.getAttribute("min-values"));
126
127
  let maxValues = parseInt(userSelect.getAttribute("max-values"));
127
128
 
128
- let options = Array.from(userSelect.querySelectorAll("option")).map(option => {
129
+ // Support both <option> and <select-option> elements (Svelte may output either)
130
+ let options = Array.from(userSelect.querySelectorAll("option, select-option")).map(option => {
129
131
  return {
130
132
  id: getCleanTextContent(option) || option.getAttribute("id"),
131
133
  type: option.getAttribute("type")
@@ -264,14 +266,19 @@ function parseElement(dbi: DBI<NamespaceEnums>, dbiName: string, element: Elemen
264
266
  case "BUTTON":
265
267
  return parseButton(dbi, dbiName, element);
266
268
  case "STRING-SELECT":
269
+ case "STRING-SELECT-MENU":
267
270
  return parseStringSelect(dbi, dbiName, element);
268
271
  case "USER-SELECT":
272
+ case "USER-SELECT-MENU":
269
273
  return parseNonStringSelect(dbi, dbiName, element, ComponentType.UserSelect);
270
274
  case "ROLE-SELECT":
275
+ case "ROLE-SELECT-MENU":
271
276
  return parseNonStringSelect(dbi, dbiName, element, ComponentType.RoleSelect);
272
277
  case "MENTIONABLE-SELECT":
278
+ case "MENTIONABLE-SELECT-MENU":
273
279
  return parseNonStringSelect(dbi, dbiName, element, ComponentType.MentionableSelect);
274
280
  case "CHANNEL-SELECT":
281
+ case "CHANNEL-SELECT-MENU":
275
282
  return parseNonStringSelect(dbi, dbiName, element, ComponentType.ChannelSelect);
276
283
  case "SECTION":
277
284
  return parseSection(dbi, dbiName, element);
@@ -87,8 +87,8 @@ export async function renderSvelteComponent(
87
87
  if (attrs.includes('data-1:')) return match;
88
88
  return `<button${attrs} data-1:ref="${stateRefId}">`;
89
89
  });
90
- // Also handle select elements
91
- html = html.replace(/<(string-select|user-select|role-select|channel-select|mentionable-select)([^>]*name="[^"]*"[^>]*)>/g, (match, tag, attrs) => {
90
+ // Also handle select elements (with optional -menu suffix for Svelte compatibility)
91
+ html = html.replace(/<(string-select(?:-menu)?|user-select(?:-menu)?|role-select(?:-menu)?|channel-select(?:-menu)?|mentionable-select(?:-menu)?)([^>]*name="[^"]*"[^>]*)>/g, (match, tag, attrs) => {
92
92
  if (attrs.includes('data-1:')) return match;
93
93
  return `<${tag}${attrs} data-1:ref="${stateRefId}">`;
94
94
  });
package/test/index.ts CHANGED
@@ -3,7 +3,7 @@ import path from "path";
3
3
 
4
4
  const dbi = createDBI("svelte", {
5
5
  discord: {
6
- token: "YOUR_BOT_TOKEN_HERE",
6
+ token: process.env.DISCORD_TOKEN || "",
7
7
  options: {
8
8
  intents: [
9
9
  "GuildMessages",