@mostfeatured/dbi 0.2.25 → 0.2.27

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/Components/HTMLComponentsV2/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAgB,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAsJ7G,MAAM,MAAM,2BAA2B,CAAC,UAAU,SAAS,cAAc,IAAI,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,YAAY,GAAG,sBAAsB,GAAG,gBAAgB,GAAG,cAAc,CAAC,GAAG;IAC/P;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,8BAA8B,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CACvE,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B,CAAA;AAED,MAAM,WAAW,+BAA+B;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAA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AI5B,OAAO,CAAC,eAAe,CAA+B;IAItD,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;QAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;KAAE,CAAC,CAAa;IAG1G,OAAO,CAAC,YAAY,CAA8B;gBAEtC,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,2BAA2B,CAAC,UAAU,CAAC;YAuCjE,oBAAoB;YAMpB,cAAc;IAmC5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAiF3B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAmG9B,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAQ;IAEtC,MAAM,CAAC,GAAG,GAAE,8BAAmC,GAAG,OAAO,CAAC,GAAG,CAAC;IA+B7E;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,GAAE,+BAAoC,GAAG,OAAO,CAAC,8BAA8B,CAAC;IA4H/G;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO;IAsBzD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,mBAAmB;IA2B3B;;OAEG;IACH,OAAO,CAAC,uCAAuC;IAwB/C;;OAEG;IACH,OAAO,CAAC,4BAA4B;IA+DpC;;;;;OAKG;IACH,UAAU,IAAI,MAAM;IAapB,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAM;CACvB"}
@@ -262,7 +262,7 @@ class DBIHTMLComponentsV2 extends Interaction_1.DBIBaseInteraction {
262
262
  return;
263
263
  }
264
264
  // Create handler context for modal submit
265
- const handlerContext = (0, svelteParser_1.createHandlerContext)(this.svelteComponentInfo.scriptContent, typeof currentState === 'object' ? currentState : {}, this, ctx, this._sourceDir);
265
+ const handlerContext = (0, svelteParser_1.createHandlerContext)(this.svelteComponentInfo.scriptContent, typeof currentState === 'object' ? currentState : {}, this, ctx, this._sourceDir, this.svelteComponentInfo.inlineHandlers);
266
266
  const handlerFn = handlerContext.handlers[handlerName];
267
267
  if (handlerFn && typeof handlerFn === 'function') {
268
268
  try {
@@ -288,7 +288,9 @@ class DBIHTMLComponentsV2 extends Interaction_1.DBIBaseInteraction {
288
288
  }
289
289
  }
290
290
  catch (error) {
291
- // Modal handler execution failed
291
+ // Re-throw the error so it's visible to the developer
292
+ console.error(`[DBI-Svelte] Modal handler "${handlerName}" failed:`, error);
293
+ throw error;
292
294
  }
293
295
  }
294
296
  }
@@ -309,7 +311,7 @@ class DBIHTMLComponentsV2 extends Interaction_1.DBIBaseInteraction {
309
311
  // This ensures each interaction has its own isolated state
310
312
  // Pass 'this' so handlers can access component methods like toJSON()
311
313
  // Pass ctx so handlers can access ctx.interaction, ctx.data, ctx.locale, etc.
312
- const handlerContext = (0, svelteParser_1.createHandlerContext)(this.svelteComponentInfo.scriptContent, typeof currentState === 'object' ? currentState : {}, this, ctx, this._sourceDir);
314
+ const handlerContext = (0, svelteParser_1.createHandlerContext)(this.svelteComponentInfo.scriptContent, typeof currentState === 'object' ? currentState : {}, this, ctx, this._sourceDir, this.svelteComponentInfo.inlineHandlers);
313
315
  const handlerFn = handlerContext.handlers[handlerInfo.handlerName];
314
316
  if (handlerFn && typeof handlerFn === 'function') {
315
317
  try {
@@ -363,7 +365,9 @@ class DBIHTMLComponentsV2 extends Interaction_1.DBIBaseInteraction {
363
365
  }
364
366
  }
365
367
  catch (error) {
366
- // Handler execution failed
368
+ // Re-throw the error so it's visible to the developer
369
+ console.error(`[DBI-Svelte] Handler "${handlerInfo.handlerName}" failed:`, error);
370
+ throw error;
367
371
  }
368
372
  }
369
373
  }
@@ -467,7 +471,7 @@ class DBIHTMLComponentsV2 extends Interaction_1.DBIBaseInteraction {
467
471
  message: message,
468
472
  }
469
473
  };
470
- const handlerContext = (0, svelteParser_1.createHandlerContext)(this.svelteComponentInfo.scriptContent, data, this, fakeCtx, this._sourceDir);
474
+ const handlerContext = (0, svelteParser_1.createHandlerContext)(this.svelteComponentInfo.scriptContent, data, this, fakeCtx, this._sourceDir, this.svelteComponentInfo.inlineHandlers);
471
475
  // Store the context for lifecycle management
472
476
  this._activeContexts.set(refId, handlerContext);
473
477
  // Wrap $unRef to call onDestroy when ref is deleted
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/Components/HTMLComponentsV2/index.ts"],"names":[],"mappings":";;;;AAEA,mDAA6G;AAC7G,qCAAiD;AACjD,qDAA4G;AAC5G,iDAAkG;AAClG,oDAAoB;AAEpB;;GAEG;AACH,SAAS,oBAAoB,CAAC,KAAU,EAAE,MAAe,EAAE,aAAsB;IAC/E,0DAA0D;IAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC;IAEzC,kGAAkG;IAClG,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAE5F,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,KAAK,CAAC,CAAC,oCAAoC;IACpD,CAAC;IAED,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;IAEnE,uDAAuD;IACvD,mGAAmG;IACnG,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE1D,0CAA0C;IAC1C,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,WAAW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,EAAE,CAAC;YACpD,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACjC,KAAK,EAAE,CAAC;QACV,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,QAAQ,GAAW,EAAE,CAAC;CACvB;AA9oBD,kDA8oBC","sourcesContent":["import { NamespaceEnums } from \"../../../../generated/namespaceData\";\r\nimport { DBI } from \"../../../DBI\";\r\nimport { DBIBaseInteraction, DBIRateLimit, IDBIBaseExecuteCtx, TDBIReferencedData } from \"../../Interaction\";\r\nimport { parseHTMLComponentsV2 } from \"./parser\";\r\nimport { renderSvelteComponent, renderSvelteComponentFromFile, SvelteRenderResult } from \"./svelteRenderer\";\r\nimport { parseSvelteComponent, createHandlerContext, HandlerContextResult } from \"./svelteParser\";\r\nimport fs from \"fs\";\r\n\r\n/**\r\n * Parse Discord API error and provide helpful context about which HTML element caused the error\r\n */\r\nfunction parseDiscordAPIError(error: any, source?: string, componentName?: string): Error {\r\n // Check if it's a Discord API error with form body issues\r\n const message = error.message || '';\r\n const rawError = error.rawError || error;\r\n\r\n // Extract the path from error message like \"data.components[0].components[0].accessory.media.url\"\r\n const pathMatch = message.match(/data\\.components(\\[[^\\]]+\\](?:\\.[^\\[\\s\\[]+|\\[[^\\]]+\\])*)/);\r\n\r\n if (!pathMatch) {\r\n return error; // Not a parseable Discord API error\r\n }\r\n\r\n const errorPath = pathMatch[1];\r\n const errorCode = message.match(/\\[([A-Z_]+)\\]/)?.[1] || 'UNKNOWN';\r\n\r\n // Parse the path to understand the component structure\r\n // e.g., \"[0].components[0].accessory.media.url\" -> component index 0, child 0, accessory.media.url\r\n const parts = errorPath.split(/\\.|\\[|\\]/).filter(Boolean);\r\n\r\n // Build a human-readable path description\r\n let description = '';\r\n let elementHint = '';\r\n let currentPath = [];\r\n\r\n for (let i = 0; i < parts.length; i++) {\r\n const part = parts[i];\r\n if (!isNaN(Number(part))) {\r\n currentPath.push(`[${part}]`);\r\n } else {\r\n currentPath.push(part);\r\n\r\n // Provide hints based on known Discord component structure\r\n if (part === 'accessory') {\r\n elementHint = '<section> element\\'s accessory (thumbnail/button)';\r\n } else if (part === 'media') {\r\n elementHint = '<thumbnail> or <media-gallery> element';\r\n } else if (part === 'url') {\r\n elementHint = 'media URL attribute';\r\n } else if (part === 'components') {\r\n // Skip, it's container\r\n } else if (part === 'content') {\r\n elementHint = 'text content of a <text-display> element';\r\n } else if (part === 'label') {\r\n elementHint = 'label attribute of a <button> or <option>';\r\n } else if (part === 'custom_id') {\r\n elementHint = 'name attribute of an interactive element';\r\n } else if (part === 'placeholder') {\r\n elementHint = 'placeholder attribute of a select menu';\r\n } else if (part === 'title') {\r\n elementHint = 'title attribute of a <modal> or <section>';\r\n } else if (part === 'options') {\r\n elementHint = '<option> elements inside a <string-select>';\r\n } else if (part === 'value') {\r\n elementHint = 'value attribute of an <option> or <text-input>';\r\n } else if (part === 'description') {\r\n elementHint = 'description attribute of an <option>';\r\n }\r\n }\r\n }\r\n\r\n // Map error codes to helpful messages\r\n const errorMessages: Record<string, string> = {\r\n 'BASE_TYPE_REQUIRED': 'This field is required but was empty or undefined',\r\n 'STRING_TYPE_REQUIRED': 'This field must be a string',\r\n 'NUMBER_TYPE_REQUIRED': 'This field must be a number',\r\n 'BOOLEAN_TYPE_REQUIRED': 'This field must be a boolean',\r\n 'INVALID_URL': 'The URL provided is not valid',\r\n 'MAX_LENGTH': 'The value exceeds the maximum allowed length',\r\n 'MIN_LENGTH': 'The value is shorter than the minimum required length',\r\n 'CHOICE_NOT_FOUND': 'The selected value is not in the list of options',\r\n };\r\n\r\n const errorExplanation = errorMessages[errorCode] || `Error code: ${errorCode}`;\r\n\r\n // Build the enhanced error message\r\n let enhancedMessage = `\r\n╔══════════════════════════════════════════════════════════════╗\r\n║ Discord API Error - Invalid Component Data ║\r\n╚══════════════════════════════════════════════════════════════╝\r\n\r\n📍 Component: ${componentName || 'unknown'}\r\n📍 Error Path: data.components${errorPath}\r\n📍 Error Code: ${errorCode}\r\n\r\n❌ ${errorExplanation}\r\n${elementHint ? `\\n💡 This error is likely in: ${elementHint}` : ''}\r\n\r\n🔍 What to check:\r\n`;\r\n\r\n // Add specific suggestions based on error type\r\n if (errorPath.includes('media.url')) {\r\n enhancedMessage += ` • Make sure the image/media URL is provided and valid\r\n • Check that the data property used for the image exists\r\n • Example: <thumbnail media={product?.image}> - is product.image defined?\r\n`;\r\n } else if (errorPath.includes('accessory')) {\r\n enhancedMessage += ` • The <section> element requires valid content in its accessory\r\n • If using <thumbnail>, ensure the media URL is valid\r\n`;\r\n } else if (errorPath.includes('content')) {\r\n enhancedMessage += ` • Text content cannot be empty or undefined\r\n • Check your template expressions like {variable?.property}\r\n`;\r\n } else if (errorPath.includes('options')) {\r\n enhancedMessage += ` • Select menu options must have valid value and label\r\n • Each <option> needs: value=\"...\" and text content\r\n`;\r\n } else if (errorPath.includes('label') || errorPath.includes('custom_id')) {\r\n enhancedMessage += ` • Interactive elements (buttons, selects) need valid labels/names\r\n • Check that text content and name attributes are not empty\r\n`;\r\n }\r\n\r\n // If we have source, try to highlight relevant section\r\n if (source && elementHint) {\r\n const elementType = elementHint.match(/<(\\w+-?\\w*)>/)?.[1];\r\n if (elementType) {\r\n const elementRegex = new RegExp(`<${elementType}[^>]*>`, 'g');\r\n const matches = source.match(elementRegex);\r\n if (matches && matches.length > 0) {\r\n enhancedMessage += `\\n📝 Found ${matches.length} <${elementType}> element(s) in template:`;\r\n matches.slice(0, 3).forEach((m, i) => {\r\n enhancedMessage += `\\n ${i + 1}. ${m.substring(0, 80)}${m.length > 80 ? '...' : ''}`;\r\n });\r\n if (matches.length > 3) {\r\n enhancedMessage += `\\n ... and ${matches.length - 3} more`;\r\n }\r\n }\r\n }\r\n }\r\n\r\n const enhancedError = new Error(enhancedMessage);\r\n (enhancedError as any).originalError = error;\r\n (enhancedError as any).type = 'discord-api-error';\r\n (enhancedError as any).path = errorPath;\r\n (enhancedError as any).code = errorCode;\r\n\r\n return enhancedError;\r\n}\r\n\r\nexport type TDBIHTMLComponentsV2Omitted<TNamespace extends NamespaceEnums> = Omit<DBIHTMLComponentsV2<TNamespace>, \"type\" | \"dbi\" | \"toJSON\" | \"description\" | \"send\" | \"destroy\" | \"destroyAll\" | \"__lastRenderModals__\" | \"_pendingModals\" | \"_initPromise\"> & {\r\n /**\r\n * Use 'svelte' for Svelte 5 components, 'eta' for Eta templates (default)\r\n */\r\n mode?: 'svelte' | 'eta';\r\n /**\r\n * Callback executed when the component interaction is triggered\r\n */\r\n onExecute?: (ctx: IDBIHTMLComponentsV2ExecuteCtx<TNamespace>) => void;\r\n};\r\n\r\nexport type TDBIHTMLComponentsV2ToJSONArgs = {\r\n data?: Record<string, any>;\r\n}\r\n\r\nexport interface TDBIHTMLComponentsV2SendOptions {\r\n data?: Record<string, any>;\r\n flags?: string[];\r\n content?: string;\r\n ephemeral?: boolean;\r\n /** If true, uses interaction.reply(). If false or unset, auto-detects based on target type */\r\n reply?: boolean;\r\n /** If true, uses interaction.followUp() instead of reply() */\r\n followUp?: boolean;\r\n}\r\n\r\n/**\r\n * Result object returned by send() method\r\n * Includes the Discord message and a render() method for manual re-rendering\r\n */\r\nexport interface TDBIHTMLComponentsV2SendResult {\r\n /** The Discord message object returned from send/reply/followUp */\r\n message: any;\r\n /** The data object with reactive state (includes $ref) */\r\n data: Record<string, any>;\r\n /** Manually trigger a re-render of the component */\r\n render: () => Promise<void>;\r\n /** Destroy this component instance (clears intervals, timers, removes ref) */\r\n destroy: () => boolean;\r\n}\r\n\r\nexport interface IDBIHTMLComponentsV2ExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport class DBIHTMLComponentsV2<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n template?: string;\r\n file?: string;\r\n mode: 'svelte' | 'eta' = 'eta';\r\n private svelteComponentInfo: any = null;\r\n private _userOnExecute?: (ctx: IDBIHTMLComponentsV2ExecuteCtx<TNamespace>) => void;\r\n /** The directory of the source file (used for resolving relative imports) */\r\n private _sourceDir?: string;\r\n\r\n // Store handler contexts per ref for lifecycle management\r\n // Key: ref id, Value: handlerContext with lifecycle hooks\r\n private _activeContexts: Map<string, any> = new Map();\r\n\r\n // Store pending modal promises for await showModal() support\r\n // Key: modal customId, Value: { resolve, reject } functions\r\n _pendingModals: Map<string, { resolve: (result: any) => void; reject: (error: any) => void }> = new Map();\r\n\r\n // Track initialization promise\r\n private _initPromise: Promise<void> | null = null;\r\n\r\n constructor(dbi: DBI<TNamespace>, args: TDBIHTMLComponentsV2Omitted<TNamespace>) {\r\n // Store user's onExecute callback before passing to super\r\n const userOnExecute = (args as any).onExecute;\r\n\r\n // Remove onExecute from args so it doesn't override the class method\r\n const argsWithoutOnExecute = { ...args };\r\n delete (argsWithoutOnExecute as any).onExecute;\r\n\r\n super(dbi, {\r\n ...(argsWithoutOnExecute as any),\r\n type: \"HTMLComponentsV2\",\r\n });\r\n this.template = args.template || (args.file ? fs.readFileSync(args.file, \"utf-8\") : undefined);\r\n this.file = args.file;\r\n this.name = args.name;\r\n this.handlers = args.handlers || [];\r\n this.mode = args.mode || 'eta';\r\n\r\n // Store source directory for resolving relative imports in Svelte components\r\n if (this.file) {\r\n const path = require(\"path\");\r\n this._sourceDir = path.dirname(path.resolve(this.file));\r\n }\r\n\r\n // Store user's onExecute callback if provided\r\n if (userOnExecute) {\r\n this._userOnExecute = userOnExecute;\r\n }\r\n\r\n // Pre-extract Svelte handlers at registration time (lazy loaded)\r\n if (this.mode === 'svelte' && this.template) {\r\n // Store the promise so we can await it in _handleExecute\r\n this._initPromise = this._initSvelteComponent();\r\n }\r\n\r\n // Re-assign onExecute method after super() call because parent class sets it to undefined\r\n this.onExecute = this._handleExecute.bind(this);\r\n }\r\n\r\n private async _initSvelteComponent() {\r\n if (this.template && !this.svelteComponentInfo) {\r\n this.svelteComponentInfo = await parseSvelteComponent(this.template);\r\n }\r\n }\r\n\r\n private async _handleExecute(ctx: IDBIHTMLComponentsV2ExecuteCtx<TNamespace>) {\r\n // Wait for Svelte component initialization if not yet completed\r\n if (this._initPromise) {\r\n await this._initPromise;\r\n }\r\n\r\n // Call user's onExecute callback first if provided\r\n if (this._userOnExecute) {\r\n this._userOnExecute(ctx);\r\n }\r\n\r\n // If using Svelte mode, find and execute the handler\r\n if (this.mode === 'svelte' && this.svelteComponentInfo) {\r\n const [elementName, ...handlerData] = ctx.data;\r\n\r\n if (typeof elementName === 'string') {\r\n // Check if this is a modal submit (elementName is the modal id)\r\n const modalHandlerInfo = this.svelteComponentInfo.modalHandlers.get(elementName);\r\n\r\n if (modalHandlerInfo) {\r\n // This is a modal submit - execute the onsubmit handler (or just resolve promise if no handler)\r\n this._executeModalSubmit(ctx, elementName, modalHandlerInfo.onsubmitHandler, handlerData);\r\n return;\r\n }\r\n\r\n // Find the handler info for this element (button, select, etc.)\r\n const handlerInfo = this.svelteComponentInfo.handlers.get(elementName);\r\n\r\n if (handlerInfo) {\r\n this._executeElementHandler(ctx, handlerInfo, handlerData);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Execute a modal submit handler\r\n */\r\n private _executeModalSubmit(\r\n ctx: IDBIHTMLComponentsV2ExecuteCtx<TNamespace>,\r\n modalId: string,\r\n handlerName: string | undefined,\r\n handlerData: any[]\r\n ) {\r\n // Extract current state from handlerData (refs that were passed)\r\n const currentState = handlerData[0] || {} as Record<string, any>;\r\n\r\n // Get ref id for lifecycle tracking (if available)\r\n const refId = (currentState as any)?.$ref || null;\r\n\r\n // Extract all field values from modal interaction (text inputs, selects, file uploads, etc.)\r\n const modalInteraction = ctx.interaction as any;\r\n const fields = this._extractModalFields(modalInteraction);\r\n\r\n // Check if there's a pending promise for this modal (from await showModal())\r\n // Use the modal's customId to find the pending promise\r\n const pendingKey = modalInteraction.customId;\r\n const pendingModal = this._pendingModals.get(pendingKey);\r\n\r\n if (pendingModal) {\r\n // Resolve the promise with fields and interaction\r\n pendingModal.resolve({\r\n fields,\r\n interaction: modalInteraction,\r\n ctx: ctx\r\n });\r\n this._pendingModals.delete(pendingKey);\r\n }\r\n\r\n // If no onsubmit handler defined, just return (promise-based usage)\r\n if (!handlerName) {\r\n return;\r\n }\r\n\r\n // Create handler context for modal submit\r\n const handlerContext = createHandlerContext(\r\n this.svelteComponentInfo!.scriptContent,\r\n typeof currentState === 'object' ? currentState : {},\r\n this,\r\n ctx,\r\n this._sourceDir\r\n );\r\n\r\n const handlerFn = handlerContext.handlers[handlerName];\r\n\r\n if (handlerFn && typeof handlerFn === 'function') {\r\n try {\r\n // Store context for lifecycle management\r\n if (refId) {\r\n const existingContext = this._activeContexts.get(refId);\r\n if (existingContext && existingContext.destroyCallbacks) {\r\n handlerContext.destroyCallbacks.push(...existingContext.destroyCallbacks);\r\n }\r\n this._activeContexts.set(refId, handlerContext);\r\n }\r\n\r\n handlerContext.setInHandler(true);\r\n\r\n try {\r\n // Call handler with ctx and fields object\r\n handlerFn.call(this, handlerContext.wrappedCtx, fields, ...handlerData.slice(1));\r\n } finally {\r\n handlerContext.setInHandler(false);\r\n }\r\n\r\n handlerContext.runEffects();\r\n\r\n if (handlerContext.hasPendingRender()) {\r\n handlerContext.flushRender();\r\n }\r\n } catch (error) {\r\n // Modal handler execution failed\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Execute an element handler (button, select, etc.)\r\n */\r\n private _executeElementHandler(\r\n ctx: IDBIHTMLComponentsV2ExecuteCtx<TNamespace>,\r\n handlerInfo: any,\r\n handlerData: any[]\r\n ) {\r\n // Extract current state from handlerData (refs that were passed)\r\n // The second element in data array contains the current state\r\n const currentState = handlerData[0] || {} as Record<string, any>;\r\n\r\n // Get ref id for lifecycle tracking (if available)\r\n const refId = (currentState as any)?.$ref || null;\r\n\r\n // Check if this is first execution for this ref\r\n const isFirstExecution = refId && !this._activeContexts.has(refId);\r\n\r\n // Get existing context if any (to preserve lifecycle callbacks like intervals)\r\n const existingContext = refId ? this._activeContexts.get(refId) : null;\r\n\r\n // Create a NEW handler context for each execution with the current state\r\n // This ensures each interaction has its own isolated state\r\n // Pass 'this' so handlers can access component methods like toJSON()\r\n // Pass ctx so handlers can access ctx.interaction, ctx.data, ctx.locale, etc.\r\n const handlerContext = createHandlerContext(\r\n this.svelteComponentInfo!.scriptContent,\r\n typeof currentState === 'object' ? currentState : {},\r\n this,\r\n ctx,\r\n this._sourceDir\r\n );\r\n\r\n const handlerFn = handlerContext.handlers[handlerInfo.handlerName];\r\n\r\n if (handlerFn && typeof handlerFn === 'function') {\r\n try {\r\n // Store context for lifecycle management\r\n if (refId) {\r\n // If there's an existing context, transfer its destroy callbacks to the new context\r\n // This preserves intervals/timers created in onMount\r\n if (existingContext && existingContext.destroyCallbacks) {\r\n // Merge existing destroy callbacks (don't run them!)\r\n handlerContext.destroyCallbacks.push(...existingContext.destroyCallbacks);\r\n }\r\n\r\n this._activeContexts.set(refId, handlerContext);\r\n\r\n // Wrap $unRef to call onDestroy when ref is deleted (only wrap once)\r\n const stateObj = currentState as any;\r\n if (stateObj.$unRef && !stateObj.__unRefWrapped__) {\r\n const originalUnRef = stateObj.$unRef.bind(stateObj);\r\n stateObj.$unRef = () => {\r\n // Run destroy callbacks before unref\r\n const ctx = this._activeContexts.get(refId);\r\n if (ctx && ctx.runDestroy) {\r\n ctx.runDestroy();\r\n }\r\n this._activeContexts.delete(refId);\r\n return originalUnRef();\r\n };\r\n stateObj.__unRefWrapped__ = true;\r\n }\r\n }\r\n\r\n // Run onMount callbacks only on first execution\r\n if (isFirstExecution && handlerContext.runMount) {\r\n handlerContext.runMount();\r\n }\r\n\r\n // Mark that we're inside handler execution (prevents auto-render during handler)\r\n handlerContext.setInHandler(true);\r\n\r\n try {\r\n // Bind 'this' to the DBIHTMLComponentsV2 instance so handlers can use this.toJSON()\r\n // Pass wrappedCtx so handlers use the proxy-wrapped ctx that tracks interaction calls\r\n // This ensures __asyncInteractionCalled__ flag is set when handler calls ctx.interaction.reply() etc.\r\n handlerFn.call(this, handlerContext.wrappedCtx, ...handlerData.slice(1));\r\n } finally {\r\n // Always reset handler execution flag\r\n handlerContext.setInHandler(false);\r\n }\r\n\r\n // Run effects after handler execution (state may have changed)\r\n handlerContext.runEffects();\r\n\r\n // If there are pending data changes and no interaction method was called,\r\n // flush the render now (synchronously uses interaction.update)\r\n if (handlerContext.hasPendingRender()) {\r\n handlerContext.flushRender();\r\n }\r\n } catch (error) {\r\n // Handler execution failed\r\n }\r\n }\r\n }\r\n\r\n // Store last render's modals for showModal() to access\r\n // Note: Used internally by handler context, not truly private\r\n __lastRenderModals__: Map<string, any> | null = null;\r\n\r\n override async toJSON(arg: TDBIHTMLComponentsV2ToJSONArgs = {}): Promise<any> {\r\n if (this.mode === 'svelte' && this.template) {\r\n // Render Svelte component\r\n const result = await renderSvelteComponent(\r\n this.dbi as any,\r\n this.template,\r\n this.name,\r\n {\r\n data: arg.data,\r\n ttl: this.ttl\r\n }\r\n );\r\n\r\n // Store modals for showModal() to access\r\n this.__lastRenderModals__ = result.modals;\r\n\r\n return result.components;\r\n } else {\r\n // Use Eta template parsing (default)\r\n return parseHTMLComponentsV2(\r\n this.dbi as any,\r\n this.template!,\r\n this.name,\r\n {\r\n data: arg.data,\r\n ttl: this.ttl\r\n }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Send the component to an interaction or channel and initialize lifecycle hooks (onMount)\r\n * This is the recommended way to send Svelte components with intervals/timers\r\n * \r\n * @param target - Discord interaction or channel to send to\r\n * @param options - Send options including data, flags, content\r\n * \r\n * @example\r\n * ```ts\r\n * const showcase = dbi.interaction(\"product-showcase\");\r\n * \r\n * // Send as interaction reply\r\n * await showcase.send(interaction, { data: { count: 0 } });\r\n * \r\n * // Send to a channel directly\r\n * const result = await showcase.send(channel, { data: { count: 0 } });\r\n * \r\n * // Send as followUp (if already replied)\r\n * const result = await showcase.send(interaction, { data: { count: 0 }, followUp: true });\r\n * \r\n * // Manual re-render from outside\r\n * await result.render();\r\n * ```\r\n */\r\n async send(target: any, options: TDBIHTMLComponentsV2SendOptions = {}): Promise<TDBIHTMLComponentsV2SendResult> {\r\n // Wait for Svelte component initialization if not yet completed\r\n if (this._initPromise) {\r\n await this._initPromise;\r\n }\r\n\r\n const { data = {}, flags = [\"IsComponentsV2\"], content, ephemeral, reply, followUp } = options;\r\n\r\n // Render components (toJSON is async) - this also creates $ref in data if not present\r\n const components = await this.toJSON({ data });\r\n\r\n // Build message options\r\n const messageOptions: any = { components, flags };\r\n if (content) messageOptions.content = content;\r\n if (ephemeral) messageOptions.flags = [...flags, \"Ephemeral\"];\r\n\r\n // Detect target type and send accordingly\r\n let message: any;\r\n const isInteraction = target.reply && target.user; // Interactions have both reply method and user property\r\n const isChannel = target.send && !target.user; // Channels have send but no user\r\n\r\n try {\r\n if (isInteraction) {\r\n if (followUp) {\r\n message = await target.followUp(messageOptions);\r\n } else {\r\n message = await target.reply(messageOptions);\r\n }\r\n } else if (isChannel) {\r\n message = await target.send(messageOptions);\r\n } else {\r\n throw new Error(\"Invalid target: must be an interaction or channel\");\r\n }\r\n } catch (error: any) {\r\n // Check if it's a Discord API error and enhance it with helpful context\r\n if (error.code || error.rawError || (error.message && error.message.includes('Invalid Form Body'))) {\r\n const source = this.file ? fs.readFileSync(this.file, 'utf-8') : this.template;\r\n throw parseDiscordAPIError(error, source, this.name);\r\n }\r\n throw error;\r\n }\r\n\r\n // If Svelte mode, create initial handler context and run onMount\r\n // After toJSON, data.$ref is guaranteed to exist (created in renderSvelteComponent)\r\n if (this.mode === 'svelte' && this.svelteComponentInfo && data.$ref) {\r\n const refId = data.$ref;\r\n\r\n // Create handler context with a fake ctx that has the message\r\n const fakeCtx = {\r\n interaction: {\r\n replied: true,\r\n deferred: false,\r\n message: message,\r\n }\r\n };\r\n\r\n const handlerContext = createHandlerContext(\r\n this.svelteComponentInfo.scriptContent,\r\n data,\r\n this,\r\n fakeCtx,\r\n this._sourceDir\r\n );\r\n\r\n // Store the context for lifecycle management\r\n this._activeContexts.set(refId, handlerContext);\r\n\r\n // Wrap $unRef to call onDestroy when ref is deleted\r\n if (data.$unRef) {\r\n const originalUnRef = data.$unRef.bind(data);\r\n data.$unRef = () => {\r\n if (handlerContext.runDestroy) {\r\n handlerContext.runDestroy();\r\n }\r\n this._activeContexts.delete(refId);\r\n return originalUnRef();\r\n };\r\n }\r\n\r\n // Run onMount callbacks\r\n handlerContext.runMount();\r\n\r\n // Run initial effects\r\n handlerContext.runEffects();\r\n\r\n // Return result object with render() method for manual re-rendering\r\n const component = this;\r\n return {\r\n message,\r\n data,\r\n render: async () => {\r\n // Run pre-render callbacks (async)\r\n await handlerContext.runPreRender();\r\n\r\n // Re-render the component\r\n const components = await component.toJSON({ data });\r\n await message.edit({\r\n components,\r\n flags: [\"IsComponentsV2\"],\r\n });\r\n\r\n // Run after-render callbacks\r\n handlerContext.runAfterRender();\r\n },\r\n destroy: () => component.destroy(data)\r\n } as TDBIHTMLComponentsV2SendResult;\r\n }\r\n\r\n // For non-Svelte mode, return simple result object\r\n return {\r\n message,\r\n data,\r\n render: async () => {\r\n const components = await this.toJSON({ data });\r\n await message.edit({\r\n components,\r\n flags: [\"IsComponentsV2\"],\r\n });\r\n },\r\n destroy: () => this.destroy(data)\r\n } as TDBIHTMLComponentsV2SendResult;\r\n }\r\n\r\n /**\r\n * Destroy a component instance by ref ID or data object\r\n * This runs onDestroy callbacks (clears intervals/timers) and removes the ref\r\n * \r\n * @param refOrData - Either a ref ID string or the data object with $ref\r\n * @returns true if destroyed, false if not found\r\n * \r\n * @example\r\n * ```ts\r\n * // Destroy by data object\r\n * showcase.destroy(data);\r\n * \r\n * // Destroy by ref ID\r\n * showcase.destroy(data.$ref);\r\n * \r\n * // Destroy all active instances of this component\r\n * showcase.destroyAll();\r\n * ```\r\n */\r\n destroy(refOrData: string | Record<string, any>): boolean {\r\n const refId = typeof refOrData === 'string' ? refOrData : refOrData?.$ref;\r\n\r\n if (!refId) {\r\n return false;\r\n }\r\n\r\n const context = this._activeContexts.get(refId);\r\n if (context) {\r\n // Run destroy callbacks (clears intervals, timers, etc.)\r\n if (context.runDestroy) {\r\n context.runDestroy();\r\n }\r\n this._activeContexts.delete(refId);\r\n }\r\n\r\n // Also delete from DBI refs store\r\n this.dbi.data.refs.delete(refId);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Extract all field values from a modal interaction\r\n * Supports text inputs, select menus (string, user, role, mentionable, channel), and file uploads\r\n * \r\n * Returns an object where keys are the custom_id of each component and values are:\r\n * - For text inputs: string value\r\n * - For string selects: string[] of selected values\r\n * - For user selects: string[] of user IDs\r\n * - For role selects: string[] of role IDs\r\n * - For mentionable selects: { users: string[], roles: string[] }\r\n * - For channel selects: string[] of channel IDs\r\n * - For file uploads: attachment objects array\r\n */\r\n private _extractModalFields(modalInteraction: any): Record<string, any> {\r\n const fields: Record<string, any> = {};\r\n\r\n // Handle classic text input fields via ModalSubmitFields\r\n if (modalInteraction.fields && modalInteraction.fields.fields) {\r\n for (const [customId, field] of modalInteraction.fields.fields) {\r\n // Text input - field.value is the string\r\n // For select menus, value might be an array\r\n fields[customId] = field.values || field.value;\r\n }\r\n }\r\n\r\n // Handle new modal components from interaction.data.components\r\n // The new modal structure uses Label wrappers with nested components\r\n const data = modalInteraction.data || (modalInteraction as any).data;\r\n if (data && data.components) {\r\n this._extractFieldsFromComponents(data.components, fields);\r\n }\r\n\r\n // Also check for components directly on the interaction (some Discord.js versions)\r\n if (modalInteraction.components && Array.isArray(modalInteraction.components)) {\r\n this._extractFieldsFromInteractionComponents(modalInteraction.components, fields);\r\n }\r\n\r\n return fields;\r\n }\r\n\r\n /**\r\n * Extract fields from Discord.js style interaction components (ActionRow objects)\r\n */\r\n private _extractFieldsFromInteractionComponents(components: any[], fields: Record<string, any>) {\r\n for (const row of components) {\r\n // ActionRow has components property\r\n const rowComponents = row.components || [];\r\n for (const component of rowComponents) {\r\n const customId = component.customId || component.custom_id || component.id;\r\n if (!customId) continue;\r\n\r\n // Check component type\r\n const type = component.type;\r\n\r\n // Text Input (type 4)\r\n if (type === 4 || component.value !== undefined) {\r\n fields[customId] = component.value || '';\r\n }\r\n\r\n // Select menus (types 3, 5, 6, 7, 8) - check for values array\r\n if (component.values !== undefined) {\r\n fields[customId] = component.values;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Recursively extract field values from component structure\r\n */\r\n private _extractFieldsFromComponents(components: any[], fields: Record<string, any>) {\r\n for (const component of components) {\r\n const type = component.type;\r\n // Support both custom_id and id for backward compatibility\r\n const customId = component.custom_id || component.id;\r\n\r\n // Type 18 = Label/Field - can have nested component or components\r\n if (type === 18) {\r\n if (component.component) {\r\n this._extractFieldsFromComponents([component.component], fields);\r\n }\r\n if (component.components) {\r\n this._extractFieldsFromComponents(component.components, fields);\r\n }\r\n continue;\r\n }\r\n\r\n // Type 1 = Action Row - has nested components array\r\n if (type === 1 && component.components) {\r\n this._extractFieldsFromComponents(component.components, fields);\r\n continue;\r\n }\r\n\r\n if (!customId) continue;\r\n\r\n switch (type) {\r\n case 4: // Text Input\r\n fields[customId] = component.value || '';\r\n break;\r\n\r\n case 3: // String Select\r\n fields[customId] = component.values || [];\r\n break;\r\n\r\n case 5: // User Select\r\n fields[customId] = component.values || [];\r\n break;\r\n\r\n case 6: // Role Select\r\n fields[customId] = component.values || [];\r\n break;\r\n\r\n case 7: // Mentionable Select - can have both users and roles\r\n // Discord returns resolved data for mentionables\r\n fields[customId] = {\r\n values: component.values || [],\r\n users: component.resolved?.users ? Object.keys(component.resolved.users) : [],\r\n roles: component.resolved?.roles ? Object.keys(component.resolved.roles) : []\r\n };\r\n break;\r\n\r\n case 8: // Channel Select\r\n fields[customId] = component.values || [];\r\n break;\r\n\r\n case 19: // File Upload\r\n // File uploads come through as attachments\r\n fields[customId] = component.attachments || [];\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Destroy all active instances of this component\r\n * Useful for cleanup when the bot shuts down or component is unloaded\r\n * \r\n * @returns Number of instances destroyed\r\n */\r\n destroyAll(): number {\r\n let count = 0;\r\n for (const [refId, context] of this._activeContexts) {\r\n if (context.runDestroy) {\r\n context.runDestroy();\r\n }\r\n this.dbi.data.refs.delete(refId);\r\n count++;\r\n }\r\n this._activeContexts.clear();\r\n return count;\r\n }\r\n\r\n handlers?: any[] = [];\r\n}"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/Components/HTMLComponentsV2/index.ts"],"names":[],"mappings":";;;;AAEA,mDAA6G;AAC7G,qCAAiD;AACjD,qDAA4G;AAC5G,iDAAkG;AAClG,oDAAoB;AAEpB;;GAEG;AACH,SAAS,oBAAoB,CAAC,KAAU,EAAE,MAAe,EAAE,aAAsB;IAC/E,0DAA0D;IAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC;IAEzC,kGAAkG;IAClG,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAE5F,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,KAAK,CAAC,CAAC,oCAAoC;IACpD,CAAC;IAED,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;IAEnE,uDAAuD;IACvD,mGAAmG;IACnG,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE1D,0CAA0C;IAC1C,IAAI,WAAW,GAA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AAG,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC;oBAC1C,MAAM;gBAER,KAAK,EAAE,EAAE,cAAc;oBACrB,2CAA2C;oBAC3C,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,WAAW,IAAI,EAAE,CAAC;oBAC/C,MAAM;YACV,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,UAAU;QACR,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACpD,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACjC,KAAK,EAAE,CAAC;QACV,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,QAAQ,GAAW,EAAE,CAAC;CACvB;AArpBD,kDAqpBC","sourcesContent":["import { NamespaceEnums } from \"../../../../generated/namespaceData\";\r\nimport { DBI } from \"../../../DBI\";\r\nimport { DBIBaseInteraction, DBIRateLimit, IDBIBaseExecuteCtx, TDBIReferencedData } from \"../../Interaction\";\r\nimport { parseHTMLComponentsV2 } from \"./parser\";\r\nimport { renderSvelteComponent, renderSvelteComponentFromFile, SvelteRenderResult } from \"./svelteRenderer\";\r\nimport { parseSvelteComponent, createHandlerContext, HandlerContextResult } from \"./svelteParser\";\r\nimport fs from \"fs\";\r\n\r\n/**\r\n * Parse Discord API error and provide helpful context about which HTML element caused the error\r\n */\r\nfunction parseDiscordAPIError(error: any, source?: string, componentName?: string): Error {\r\n // Check if it's a Discord API error with form body issues\r\n const message = error.message || '';\r\n const rawError = error.rawError || error;\r\n\r\n // Extract the path from error message like \"data.components[0].components[0].accessory.media.url\"\r\n const pathMatch = message.match(/data\\.components(\\[[^\\]]+\\](?:\\.[^\\[\\s\\[]+|\\[[^\\]]+\\])*)/);\r\n\r\n if (!pathMatch) {\r\n return error; // Not a parseable Discord API error\r\n }\r\n\r\n const errorPath = pathMatch[1];\r\n const errorCode = message.match(/\\[([A-Z_]+)\\]/)?.[1] || 'UNKNOWN';\r\n\r\n // Parse the path to understand the component structure\r\n // e.g., \"[0].components[0].accessory.media.url\" -> component index 0, child 0, accessory.media.url\r\n const parts = errorPath.split(/\\.|\\[|\\]/).filter(Boolean);\r\n\r\n // Build a human-readable path description\r\n let description = '';\r\n let elementHint = '';\r\n let currentPath = [];\r\n\r\n for (let i = 0; i < parts.length; i++) {\r\n const part = parts[i];\r\n if (!isNaN(Number(part))) {\r\n currentPath.push(`[${part}]`);\r\n } else {\r\n currentPath.push(part);\r\n\r\n // Provide hints based on known Discord component structure\r\n if (part === 'accessory') {\r\n elementHint = '<section> element\\'s accessory (thumbnail/button)';\r\n } else if (part === 'media') {\r\n elementHint = '<thumbnail> or <media-gallery> element';\r\n } else if (part === 'url') {\r\n elementHint = 'media URL attribute';\r\n } else if (part === 'components') {\r\n // Skip, it's container\r\n } else if (part === 'content') {\r\n elementHint = 'text content of a <text-display> element';\r\n } else if (part === 'label') {\r\n elementHint = 'label attribute of a <button> or <option>';\r\n } else if (part === 'custom_id') {\r\n elementHint = 'name attribute of an interactive element';\r\n } else if (part === 'placeholder') {\r\n elementHint = 'placeholder attribute of a select menu';\r\n } else if (part === 'title') {\r\n elementHint = 'title attribute of a <modal> or <section>';\r\n } else if (part === 'options') {\r\n elementHint = '<option> elements inside a <string-select>';\r\n } else if (part === 'value') {\r\n elementHint = 'value attribute of an <option> or <text-input>';\r\n } else if (part === 'description') {\r\n elementHint = 'description attribute of an <option>';\r\n }\r\n }\r\n }\r\n\r\n // Map error codes to helpful messages\r\n const errorMessages: Record<string, string> = {\r\n 'BASE_TYPE_REQUIRED': 'This field is required but was empty or undefined',\r\n 'STRING_TYPE_REQUIRED': 'This field must be a string',\r\n 'NUMBER_TYPE_REQUIRED': 'This field must be a number',\r\n 'BOOLEAN_TYPE_REQUIRED': 'This field must be a boolean',\r\n 'INVALID_URL': 'The URL provided is not valid',\r\n 'MAX_LENGTH': 'The value exceeds the maximum allowed length',\r\n 'MIN_LENGTH': 'The value is shorter than the minimum required length',\r\n 'CHOICE_NOT_FOUND': 'The selected value is not in the list of options',\r\n };\r\n\r\n const errorExplanation = errorMessages[errorCode] || `Error code: ${errorCode}`;\r\n\r\n // Build the enhanced error message\r\n let enhancedMessage = `\r\n╔══════════════════════════════════════════════════════════════╗\r\n║ Discord API Error - Invalid Component Data ║\r\n╚══════════════════════════════════════════════════════════════╝\r\n\r\n📍 Component: ${componentName || 'unknown'}\r\n📍 Error Path: data.components${errorPath}\r\n📍 Error Code: ${errorCode}\r\n\r\n❌ ${errorExplanation}\r\n${elementHint ? `\\n💡 This error is likely in: ${elementHint}` : ''}\r\n\r\n🔍 What to check:\r\n`;\r\n\r\n // Add specific suggestions based on error type\r\n if (errorPath.includes('media.url')) {\r\n enhancedMessage += ` • Make sure the image/media URL is provided and valid\r\n • Check that the data property used for the image exists\r\n • Example: <thumbnail media={product?.image}> - is product.image defined?\r\n`;\r\n } else if (errorPath.includes('accessory')) {\r\n enhancedMessage += ` • The <section> element requires valid content in its accessory\r\n • If using <thumbnail>, ensure the media URL is valid\r\n`;\r\n } else if (errorPath.includes('content')) {\r\n enhancedMessage += ` • Text content cannot be empty or undefined\r\n • Check your template expressions like {variable?.property}\r\n`;\r\n } else if (errorPath.includes('options')) {\r\n enhancedMessage += ` • Select menu options must have valid value and label\r\n • Each <option> needs: value=\"...\" and text content\r\n`;\r\n } else if (errorPath.includes('label') || errorPath.includes('custom_id')) {\r\n enhancedMessage += ` • Interactive elements (buttons, selects) need valid labels/names\r\n • Check that text content and name attributes are not empty\r\n`;\r\n }\r\n\r\n // If we have source, try to highlight relevant section\r\n if (source && elementHint) {\r\n const elementType = elementHint.match(/<(\\w+-?\\w*)>/)?.[1];\r\n if (elementType) {\r\n const elementRegex = new RegExp(`<${elementType}[^>]*>`, 'g');\r\n const matches = source.match(elementRegex);\r\n if (matches && matches.length > 0) {\r\n enhancedMessage += `\\n📝 Found ${matches.length} <${elementType}> element(s) in template:`;\r\n matches.slice(0, 3).forEach((m, i) => {\r\n enhancedMessage += `\\n ${i + 1}. ${m.substring(0, 80)}${m.length > 80 ? '...' : ''}`;\r\n });\r\n if (matches.length > 3) {\r\n enhancedMessage += `\\n ... and ${matches.length - 3} more`;\r\n }\r\n }\r\n }\r\n }\r\n\r\n const enhancedError = new Error(enhancedMessage);\r\n (enhancedError as any).originalError = error;\r\n (enhancedError as any).type = 'discord-api-error';\r\n (enhancedError as any).path = errorPath;\r\n (enhancedError as any).code = errorCode;\r\n\r\n return enhancedError;\r\n}\r\n\r\nexport type TDBIHTMLComponentsV2Omitted<TNamespace extends NamespaceEnums> = Omit<DBIHTMLComponentsV2<TNamespace>, \"type\" | \"dbi\" | \"toJSON\" | \"description\" | \"send\" | \"destroy\" | \"destroyAll\" | \"__lastRenderModals__\" | \"_pendingModals\" | \"_initPromise\"> & {\r\n /**\r\n * Use 'svelte' for Svelte 5 components, 'eta' for Eta templates (default)\r\n */\r\n mode?: 'svelte' | 'eta';\r\n /**\r\n * Callback executed when the component interaction is triggered\r\n */\r\n onExecute?: (ctx: IDBIHTMLComponentsV2ExecuteCtx<TNamespace>) => void;\r\n};\r\n\r\nexport type TDBIHTMLComponentsV2ToJSONArgs = {\r\n data?: Record<string, any>;\r\n}\r\n\r\nexport interface TDBIHTMLComponentsV2SendOptions {\r\n data?: Record<string, any>;\r\n flags?: string[];\r\n content?: string;\r\n ephemeral?: boolean;\r\n /** If true, uses interaction.reply(). If false or unset, auto-detects based on target type */\r\n reply?: boolean;\r\n /** If true, uses interaction.followUp() instead of reply() */\r\n followUp?: boolean;\r\n}\r\n\r\n/**\r\n * Result object returned by send() method\r\n * Includes the Discord message and a render() method for manual re-rendering\r\n */\r\nexport interface TDBIHTMLComponentsV2SendResult {\r\n /** The Discord message object returned from send/reply/followUp */\r\n message: any;\r\n /** The data object with reactive state (includes $ref) */\r\n data: Record<string, any>;\r\n /** Manually trigger a re-render of the component */\r\n render: () => Promise<void>;\r\n /** Destroy this component instance (clears intervals, timers, removes ref) */\r\n destroy: () => boolean;\r\n}\r\n\r\nexport interface IDBIHTMLComponentsV2ExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport class DBIHTMLComponentsV2<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n template?: string;\r\n file?: string;\r\n mode: 'svelte' | 'eta' = 'eta';\r\n private svelteComponentInfo: any = null;\r\n private _userOnExecute?: (ctx: IDBIHTMLComponentsV2ExecuteCtx<TNamespace>) => void;\r\n /** The directory of the source file (used for resolving relative imports) */\r\n private _sourceDir?: string;\r\n\r\n // Store handler contexts per ref for lifecycle management\r\n // Key: ref id, Value: handlerContext with lifecycle hooks\r\n private _activeContexts: Map<string, any> = new Map();\r\n\r\n // Store pending modal promises for await showModal() support\r\n // Key: modal customId, Value: { resolve, reject } functions\r\n _pendingModals: Map<string, { resolve: (result: any) => void; reject: (error: any) => void }> = new Map();\r\n\r\n // Track initialization promise\r\n private _initPromise: Promise<void> | null = null;\r\n\r\n constructor(dbi: DBI<TNamespace>, args: TDBIHTMLComponentsV2Omitted<TNamespace>) {\r\n // Store user's onExecute callback before passing to super\r\n const userOnExecute = (args as any).onExecute;\r\n\r\n // Remove onExecute from args so it doesn't override the class method\r\n const argsWithoutOnExecute = { ...args };\r\n delete (argsWithoutOnExecute as any).onExecute;\r\n\r\n super(dbi, {\r\n ...(argsWithoutOnExecute as any),\r\n type: \"HTMLComponentsV2\",\r\n });\r\n this.template = args.template || (args.file ? fs.readFileSync(args.file, \"utf-8\") : undefined);\r\n this.file = args.file;\r\n this.name = args.name;\r\n this.handlers = args.handlers || [];\r\n this.mode = args.mode || 'eta';\r\n\r\n // Store source directory for resolving relative imports in Svelte components\r\n if (this.file) {\r\n const path = require(\"path\");\r\n this._sourceDir = path.dirname(path.resolve(this.file));\r\n }\r\n\r\n // Store user's onExecute callback if provided\r\n if (userOnExecute) {\r\n this._userOnExecute = userOnExecute;\r\n }\r\n\r\n // Pre-extract Svelte handlers at registration time (lazy loaded)\r\n if (this.mode === 'svelte' && this.template) {\r\n // Store the promise so we can await it in _handleExecute\r\n this._initPromise = this._initSvelteComponent();\r\n }\r\n\r\n // Re-assign onExecute method after super() call because parent class sets it to undefined\r\n this.onExecute = this._handleExecute.bind(this);\r\n }\r\n\r\n private async _initSvelteComponent() {\r\n if (this.template && !this.svelteComponentInfo) {\r\n this.svelteComponentInfo = await parseSvelteComponent(this.template);\r\n }\r\n }\r\n\r\n private async _handleExecute(ctx: IDBIHTMLComponentsV2ExecuteCtx<TNamespace>) {\r\n // Wait for Svelte component initialization if not yet completed\r\n if (this._initPromise) {\r\n await this._initPromise;\r\n }\r\n\r\n // Call user's onExecute callback first if provided\r\n if (this._userOnExecute) {\r\n this._userOnExecute(ctx);\r\n }\r\n\r\n // If using Svelte mode, find and execute the handler\r\n if (this.mode === 'svelte' && this.svelteComponentInfo) {\r\n const [elementName, ...handlerData] = ctx.data;\r\n\r\n if (typeof elementName === 'string') {\r\n // Check if this is a modal submit (elementName is the modal id)\r\n const modalHandlerInfo = this.svelteComponentInfo.modalHandlers.get(elementName);\r\n\r\n if (modalHandlerInfo) {\r\n // This is a modal submit - execute the onsubmit handler (or just resolve promise if no handler)\r\n this._executeModalSubmit(ctx, elementName, modalHandlerInfo.onsubmitHandler, handlerData);\r\n return;\r\n }\r\n\r\n // Find the handler info for this element (button, select, etc.)\r\n const handlerInfo = this.svelteComponentInfo.handlers.get(elementName);\r\n\r\n if (handlerInfo) {\r\n this._executeElementHandler(ctx, handlerInfo, handlerData);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Execute a modal submit handler\r\n */\r\n private _executeModalSubmit(\r\n ctx: IDBIHTMLComponentsV2ExecuteCtx<TNamespace>,\r\n modalId: string,\r\n handlerName: string | undefined,\r\n handlerData: any[]\r\n ) {\r\n // Extract current state from handlerData (refs that were passed)\r\n const currentState = handlerData[0] || {} as Record<string, any>;\r\n\r\n // Get ref id for lifecycle tracking (if available)\r\n const refId = (currentState as any)?.$ref || null;\r\n\r\n // Extract all field values from modal interaction (text inputs, selects, file uploads, etc.)\r\n const modalInteraction = ctx.interaction as any;\r\n const fields = this._extractModalFields(modalInteraction);\r\n\r\n // Check if there's a pending promise for this modal (from await showModal())\r\n // Use the modal's customId to find the pending promise\r\n const pendingKey = modalInteraction.customId;\r\n const pendingModal = this._pendingModals.get(pendingKey);\r\n\r\n if (pendingModal) {\r\n // Resolve the promise with fields and interaction\r\n pendingModal.resolve({\r\n fields,\r\n interaction: modalInteraction,\r\n ctx: ctx\r\n });\r\n this._pendingModals.delete(pendingKey);\r\n }\r\n\r\n // If no onsubmit handler defined, just return (promise-based usage)\r\n if (!handlerName) {\r\n return;\r\n }\r\n\r\n // Create handler context for modal submit\r\n const handlerContext = createHandlerContext(\r\n this.svelteComponentInfo!.scriptContent,\r\n typeof currentState === 'object' ? currentState : {},\r\n this,\r\n ctx,\r\n this._sourceDir,\r\n this.svelteComponentInfo!.inlineHandlers\r\n );\r\n\r\n const handlerFn = handlerContext.handlers[handlerName];\r\n\r\n if (handlerFn && typeof handlerFn === 'function') {\r\n try {\r\n // Store context for lifecycle management\r\n if (refId) {\r\n const existingContext = this._activeContexts.get(refId);\r\n if (existingContext && existingContext.destroyCallbacks) {\r\n handlerContext.destroyCallbacks.push(...existingContext.destroyCallbacks);\r\n }\r\n this._activeContexts.set(refId, handlerContext);\r\n }\r\n\r\n handlerContext.setInHandler(true);\r\n\r\n try {\r\n // Call handler with ctx and fields object\r\n handlerFn.call(this, handlerContext.wrappedCtx, fields, ...handlerData.slice(1));\r\n } finally {\r\n handlerContext.setInHandler(false);\r\n }\r\n\r\n handlerContext.runEffects();\r\n\r\n if (handlerContext.hasPendingRender()) {\r\n handlerContext.flushRender();\r\n }\r\n } catch (error) {\r\n // Re-throw the error so it's visible to the developer\r\n console.error(`[DBI-Svelte] Modal handler \"${handlerName}\" failed:`, error);\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Execute an element handler (button, select, etc.)\r\n */\r\n private _executeElementHandler(\r\n ctx: IDBIHTMLComponentsV2ExecuteCtx<TNamespace>,\r\n handlerInfo: any,\r\n handlerData: any[]\r\n ) {\r\n // Extract current state from handlerData (refs that were passed)\r\n // The second element in data array contains the current state\r\n const currentState = handlerData[0] || {} as Record<string, any>;\r\n\r\n // Get ref id for lifecycle tracking (if available)\r\n const refId = (currentState as any)?.$ref || null;\r\n\r\n // Check if this is first execution for this ref\r\n const isFirstExecution = refId && !this._activeContexts.has(refId);\r\n\r\n // Get existing context if any (to preserve lifecycle callbacks like intervals)\r\n const existingContext = refId ? this._activeContexts.get(refId) : null;\r\n\r\n // Create a NEW handler context for each execution with the current state\r\n // This ensures each interaction has its own isolated state\r\n // Pass 'this' so handlers can access component methods like toJSON()\r\n // Pass ctx so handlers can access ctx.interaction, ctx.data, ctx.locale, etc.\r\n const handlerContext = createHandlerContext(\r\n this.svelteComponentInfo!.scriptContent,\r\n typeof currentState === 'object' ? currentState : {},\r\n this,\r\n ctx,\r\n this._sourceDir,\r\n this.svelteComponentInfo!.inlineHandlers\r\n );\r\n\r\n const handlerFn = handlerContext.handlers[handlerInfo.handlerName];\r\n\r\n if (handlerFn && typeof handlerFn === 'function') {\r\n try {\r\n // Store context for lifecycle management\r\n if (refId) {\r\n // If there's an existing context, transfer its destroy callbacks to the new context\r\n // This preserves intervals/timers created in onMount\r\n if (existingContext && existingContext.destroyCallbacks) {\r\n // Merge existing destroy callbacks (don't run them!)\r\n handlerContext.destroyCallbacks.push(...existingContext.destroyCallbacks);\r\n }\r\n\r\n this._activeContexts.set(refId, handlerContext);\r\n\r\n // Wrap $unRef to call onDestroy when ref is deleted (only wrap once)\r\n const stateObj = currentState as any;\r\n if (stateObj.$unRef && !stateObj.__unRefWrapped__) {\r\n const originalUnRef = stateObj.$unRef.bind(stateObj);\r\n stateObj.$unRef = () => {\r\n // Run destroy callbacks before unref\r\n const ctx = this._activeContexts.get(refId);\r\n if (ctx && ctx.runDestroy) {\r\n ctx.runDestroy();\r\n }\r\n this._activeContexts.delete(refId);\r\n return originalUnRef();\r\n };\r\n stateObj.__unRefWrapped__ = true;\r\n }\r\n }\r\n\r\n // Run onMount callbacks only on first execution\r\n if (isFirstExecution && handlerContext.runMount) {\r\n handlerContext.runMount();\r\n }\r\n\r\n // Mark that we're inside handler execution (prevents auto-render during handler)\r\n handlerContext.setInHandler(true);\r\n\r\n try {\r\n // Bind 'this' to the DBIHTMLComponentsV2 instance so handlers can use this.toJSON()\r\n // Pass wrappedCtx so handlers use the proxy-wrapped ctx that tracks interaction calls\r\n // This ensures __asyncInteractionCalled__ flag is set when handler calls ctx.interaction.reply() etc.\r\n handlerFn.call(this, handlerContext.wrappedCtx, ...handlerData.slice(1));\r\n } finally {\r\n // Always reset handler execution flag\r\n handlerContext.setInHandler(false);\r\n }\r\n\r\n // Run effects after handler execution (state may have changed)\r\n handlerContext.runEffects();\r\n\r\n // If there are pending data changes and no interaction method was called,\r\n // flush the render now (synchronously uses interaction.update)\r\n if (handlerContext.hasPendingRender()) {\r\n handlerContext.flushRender();\r\n }\r\n } catch (error) {\r\n // Re-throw the error so it's visible to the developer\r\n console.error(`[DBI-Svelte] Handler \"${handlerInfo.handlerName}\" failed:`, error);\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n // Store last render's modals for showModal() to access\r\n // Note: Used internally by handler context, not truly private\r\n __lastRenderModals__: Map<string, any> | null = null;\r\n\r\n override async toJSON(arg: TDBIHTMLComponentsV2ToJSONArgs = {}): Promise<any> {\r\n if (this.mode === 'svelte' && this.template) {\r\n // Render Svelte component\r\n const result = await renderSvelteComponent(\r\n this.dbi as any,\r\n this.template,\r\n this.name,\r\n {\r\n data: arg.data,\r\n ttl: this.ttl\r\n }\r\n );\r\n\r\n // Store modals for showModal() to access\r\n this.__lastRenderModals__ = result.modals;\r\n\r\n return result.components;\r\n } else {\r\n // Use Eta template parsing (default)\r\n return parseHTMLComponentsV2(\r\n this.dbi as any,\r\n this.template!,\r\n this.name,\r\n {\r\n data: arg.data,\r\n ttl: this.ttl\r\n }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Send the component to an interaction or channel and initialize lifecycle hooks (onMount)\r\n * This is the recommended way to send Svelte components with intervals/timers\r\n * \r\n * @param target - Discord interaction or channel to send to\r\n * @param options - Send options including data, flags, content\r\n * \r\n * @example\r\n * ```ts\r\n * const showcase = dbi.interaction(\"product-showcase\");\r\n * \r\n * // Send as interaction reply\r\n * await showcase.send(interaction, { data: { count: 0 } });\r\n * \r\n * // Send to a channel directly\r\n * const result = await showcase.send(channel, { data: { count: 0 } });\r\n * \r\n * // Send as followUp (if already replied)\r\n * const result = await showcase.send(interaction, { data: { count: 0 }, followUp: true });\r\n * \r\n * // Manual re-render from outside\r\n * await result.render();\r\n * ```\r\n */\r\n async send(target: any, options: TDBIHTMLComponentsV2SendOptions = {}): Promise<TDBIHTMLComponentsV2SendResult> {\r\n // Wait for Svelte component initialization if not yet completed\r\n if (this._initPromise) {\r\n await this._initPromise;\r\n }\r\n\r\n const { data = {}, flags = [\"IsComponentsV2\"], content, ephemeral, reply, followUp } = options;\r\n\r\n // Render components (toJSON is async) - this also creates $ref in data if not present\r\n const components = await this.toJSON({ data });\r\n\r\n // Build message options\r\n const messageOptions: any = { components, flags };\r\n if (content) messageOptions.content = content;\r\n if (ephemeral) messageOptions.flags = [...flags, \"Ephemeral\"];\r\n\r\n // Detect target type and send accordingly\r\n let message: any;\r\n const isInteraction = target.reply && target.user; // Interactions have both reply method and user property\r\n const isChannel = target.send && !target.user; // Channels have send but no user\r\n\r\n try {\r\n if (isInteraction) {\r\n if (followUp) {\r\n message = await target.followUp(messageOptions);\r\n } else {\r\n message = await target.reply(messageOptions);\r\n }\r\n } else if (isChannel) {\r\n message = await target.send(messageOptions);\r\n } else {\r\n throw new Error(\"Invalid target: must be an interaction or channel\");\r\n }\r\n } catch (error: any) {\r\n // Check if it's a Discord API error and enhance it with helpful context\r\n if (error.code || error.rawError || (error.message && error.message.includes('Invalid Form Body'))) {\r\n const source = this.file ? fs.readFileSync(this.file, 'utf-8') : this.template;\r\n throw parseDiscordAPIError(error, source, this.name);\r\n }\r\n throw error;\r\n }\r\n\r\n // If Svelte mode, create initial handler context and run onMount\r\n // After toJSON, data.$ref is guaranteed to exist (created in renderSvelteComponent)\r\n if (this.mode === 'svelte' && this.svelteComponentInfo && data.$ref) {\r\n const refId = data.$ref;\r\n\r\n // Create handler context with a fake ctx that has the message\r\n const fakeCtx = {\r\n interaction: {\r\n replied: true,\r\n deferred: false,\r\n message: message,\r\n }\r\n };\r\n\r\n const handlerContext = createHandlerContext(\r\n this.svelteComponentInfo.scriptContent,\r\n data,\r\n this,\r\n fakeCtx,\r\n this._sourceDir,\r\n this.svelteComponentInfo.inlineHandlers\r\n );\r\n\r\n // Store the context for lifecycle management\r\n this._activeContexts.set(refId, handlerContext);\r\n\r\n // Wrap $unRef to call onDestroy when ref is deleted\r\n if (data.$unRef) {\r\n const originalUnRef = data.$unRef.bind(data);\r\n data.$unRef = () => {\r\n if (handlerContext.runDestroy) {\r\n handlerContext.runDestroy();\r\n }\r\n this._activeContexts.delete(refId);\r\n return originalUnRef();\r\n };\r\n }\r\n\r\n // Run onMount callbacks\r\n handlerContext.runMount();\r\n\r\n // Run initial effects\r\n handlerContext.runEffects();\r\n\r\n // Return result object with render() method for manual re-rendering\r\n const component = this;\r\n return {\r\n message,\r\n data,\r\n render: async () => {\r\n // Run pre-render callbacks (async)\r\n await handlerContext.runPreRender();\r\n\r\n // Re-render the component\r\n const components = await component.toJSON({ data });\r\n await message.edit({\r\n components,\r\n flags: [\"IsComponentsV2\"],\r\n });\r\n\r\n // Run after-render callbacks\r\n handlerContext.runAfterRender();\r\n },\r\n destroy: () => component.destroy(data)\r\n } as TDBIHTMLComponentsV2SendResult;\r\n }\r\n\r\n // For non-Svelte mode, return simple result object\r\n return {\r\n message,\r\n data,\r\n render: async () => {\r\n const components = await this.toJSON({ data });\r\n await message.edit({\r\n components,\r\n flags: [\"IsComponentsV2\"],\r\n });\r\n },\r\n destroy: () => this.destroy(data)\r\n } as TDBIHTMLComponentsV2SendResult;\r\n }\r\n\r\n /**\r\n * Destroy a component instance by ref ID or data object\r\n * This runs onDestroy callbacks (clears intervals/timers) and removes the ref\r\n * \r\n * @param refOrData - Either a ref ID string or the data object with $ref\r\n * @returns true if destroyed, false if not found\r\n * \r\n * @example\r\n * ```ts\r\n * // Destroy by data object\r\n * showcase.destroy(data);\r\n * \r\n * // Destroy by ref ID\r\n * showcase.destroy(data.$ref);\r\n * \r\n * // Destroy all active instances of this component\r\n * showcase.destroyAll();\r\n * ```\r\n */\r\n destroy(refOrData: string | Record<string, any>): boolean {\r\n const refId = typeof refOrData === 'string' ? refOrData : refOrData?.$ref;\r\n\r\n if (!refId) {\r\n return false;\r\n }\r\n\r\n const context = this._activeContexts.get(refId);\r\n if (context) {\r\n // Run destroy callbacks (clears intervals, timers, etc.)\r\n if (context.runDestroy) {\r\n context.runDestroy();\r\n }\r\n this._activeContexts.delete(refId);\r\n }\r\n\r\n // Also delete from DBI refs store\r\n this.dbi.data.refs.delete(refId);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Extract all field values from a modal interaction\r\n * Supports text inputs, select menus (string, user, role, mentionable, channel), and file uploads\r\n * \r\n * Returns an object where keys are the custom_id of each component and values are:\r\n * - For text inputs: string value\r\n * - For string selects: string[] of selected values\r\n * - For user selects: string[] of user IDs\r\n * - For role selects: string[] of role IDs\r\n * - For mentionable selects: { users: string[], roles: string[] }\r\n * - For channel selects: string[] of channel IDs\r\n * - For file uploads: attachment objects array\r\n */\r\n private _extractModalFields(modalInteraction: any): Record<string, any> {\r\n const fields: Record<string, any> = {};\r\n\r\n // Handle classic text input fields via ModalSubmitFields\r\n if (modalInteraction.fields && modalInteraction.fields.fields) {\r\n for (const [customId, field] of modalInteraction.fields.fields) {\r\n // Text input - field.value is the string\r\n // For select menus, value might be an array\r\n fields[customId] = field.values || field.value;\r\n }\r\n }\r\n\r\n // Handle new modal components from interaction.data.components\r\n // The new modal structure uses Label wrappers with nested components\r\n const data = modalInteraction.data || (modalInteraction as any).data;\r\n if (data && data.components) {\r\n this._extractFieldsFromComponents(data.components, fields);\r\n }\r\n\r\n // Also check for components directly on the interaction (some Discord.js versions)\r\n if (modalInteraction.components && Array.isArray(modalInteraction.components)) {\r\n this._extractFieldsFromInteractionComponents(modalInteraction.components, fields);\r\n }\r\n\r\n return fields;\r\n }\r\n\r\n /**\r\n * Extract fields from Discord.js style interaction components (ActionRow objects)\r\n */\r\n private _extractFieldsFromInteractionComponents(components: any[], fields: Record<string, any>) {\r\n for (const row of components) {\r\n // ActionRow has components property\r\n const rowComponents = row.components || [];\r\n for (const component of rowComponents) {\r\n const customId = component.customId || component.custom_id || component.id;\r\n if (!customId) continue;\r\n\r\n // Check component type\r\n const type = component.type;\r\n\r\n // Text Input (type 4)\r\n if (type === 4 || component.value !== undefined) {\r\n fields[customId] = component.value || '';\r\n }\r\n\r\n // Select menus (types 3, 5, 6, 7, 8) - check for values array\r\n if (component.values !== undefined) {\r\n fields[customId] = component.values;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Recursively extract field values from component structure\r\n */\r\n private _extractFieldsFromComponents(components: any[], fields: Record<string, any>) {\r\n for (const component of components) {\r\n const type = component.type;\r\n // Support both custom_id and id for backward compatibility\r\n const customId = component.custom_id || component.id;\r\n\r\n // Type 18 = Label/Field - can have nested component or components\r\n if (type === 18) {\r\n if (component.component) {\r\n this._extractFieldsFromComponents([component.component], fields);\r\n }\r\n if (component.components) {\r\n this._extractFieldsFromComponents(component.components, fields);\r\n }\r\n continue;\r\n }\r\n\r\n // Type 1 = Action Row - has nested components array\r\n if (type === 1 && component.components) {\r\n this._extractFieldsFromComponents(component.components, fields);\r\n continue;\r\n }\r\n\r\n if (!customId) continue;\r\n\r\n switch (type) {\r\n case 4: // Text Input\r\n fields[customId] = component.value || '';\r\n break;\r\n\r\n case 3: // String Select\r\n fields[customId] = component.values || [];\r\n break;\r\n\r\n case 5: // User Select\r\n fields[customId] = component.values || [];\r\n break;\r\n\r\n case 6: // Role Select\r\n fields[customId] = component.values || [];\r\n break;\r\n\r\n case 7: // Mentionable Select - can have both users and roles\r\n // Discord returns resolved data for mentionables\r\n fields[customId] = {\r\n values: component.values || [],\r\n users: component.resolved?.users ? Object.keys(component.resolved.users) : [],\r\n roles: component.resolved?.roles ? Object.keys(component.resolved.roles) : []\r\n };\r\n break;\r\n\r\n case 8: // Channel Select\r\n fields[customId] = component.values || [];\r\n break;\r\n\r\n case 19: // File Upload\r\n // File uploads come through as attachments\r\n fields[customId] = component.attachments || [];\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Destroy all active instances of this component\r\n * Useful for cleanup when the bot shuts down or component is unloaded\r\n * \r\n * @returns Number of instances destroyed\r\n */\r\n destroyAll(): number {\r\n let count = 0;\r\n for (const [refId, context] of this._activeContexts) {\r\n if (context.runDestroy) {\r\n context.runDestroy();\r\n }\r\n this.dbi.data.refs.delete(refId);\r\n count++;\r\n }\r\n this._activeContexts.clear();\r\n return count;\r\n }\r\n\r\n handlers?: any[] = [];\r\n}"]}
@@ -3,6 +3,10 @@ export interface SvelteHandlerInfo {
3
3
  handlerName: string;
4
4
  eventType: string;
5
5
  element: string;
6
+ /** If this is an inline handler, contains the extracted source code */
7
+ inlineCode?: string;
8
+ /** Whether this handler is an inline arrow function or function expression */
9
+ isInline?: boolean;
6
10
  }
7
11
  export interface ModalHandlerInfo {
8
12
  modalId: string;
@@ -25,6 +29,8 @@ export interface SvelteComponentInfo {
25
29
  propsWithDefaults: string[];
26
30
  /** Function names declared in the script */
27
31
  declaredFunctions: string[];
32
+ /** Inline handler code extracted from template (keyed by generated handler name) */
33
+ inlineHandlers: Map<string, string>;
28
34
  }
29
35
  /**
30
36
  * Parse a Svelte component and extract event handlers
@@ -62,6 +68,7 @@ export interface HandlerContextResult {
62
68
  * Create a handler context from script content
63
69
  * This evaluates the Svelte script and returns the handler functions and effects
64
70
  * @param sourceDir - The directory of the source file (used for resolving relative imports)
71
+ * @param inlineHandlers - Map of inline handler names to their source code (extracted from template)
65
72
  */
66
- export declare function createHandlerContext(scriptContent: string, initialData?: Record<string, any>, component?: any, ctx?: any, sourceDir?: string): HandlerContextResult;
73
+ export declare function createHandlerContext(scriptContent: string, initialData?: Record<string, any>, component?: any, ctx?: any, sourceDir?: string, inlineHandlers?: Map<string, string>): HandlerContextResult;
67
74
  //# sourceMappingURL=svelteParser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"svelteParser.d.ts","sourceRoot":"","sources":["../../../../../src/types/Components/HTMLComponentsV2/svelteParser.ts"],"names":[],"mappings":"AA+DA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,cAAc,GAAG,aAAa,GAAG,mBAAmB,GAAG,cAAc,GAAG,eAAe,CAAC;IAC9F,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACzC,gDAAgD;IAChD,aAAa,EAAE,GAAG,CAAC,MAAM,EA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I,CAAC,CAAC;IAClC,cAAc,EAAE,MAAM,IAAI,CAAC;IAE3B,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvC,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AA2GD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAiwBvK"}
1
+ {"version":3,"file":"svelteParser.d.ts","sourceRoot":"","sources":["../../../../../src/types/Components/HTMLComponentsV2/svelteParser.ts"],"names":[],"mappings":"AA+DA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,cAAc,GAAG,aAAa,GAAG,mBAAmB,GAAG,cAAc,GAAG,eAAe,CAAC;IAC9F,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACzC,gDAAgD;IAChD,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,C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AM,IAAI,CAAC;IACvB,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,cAAc,EAAE,MAAM,IAAI,CAAC;IAE3B,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvC,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AA2GD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,oBAAoB,CAgwB7M"}
@@ -109,6 +109,9 @@ ${nextLine ? `${lineNum + 1} | ${nextLine}` : ''}
109
109
  // We'll inject these into the source after the walk
110
110
  const elementsNeedingNames = [];
111
111
  let autoNameCounter = 0;
112
+ // Track inline handlers (arrow functions or function expressions in event attributes)
113
+ const inlineHandlers = new Map();
114
+ let inlineHandlerCounter = 0;
112
115
  // Walk through HTML nodes to find event handlers
113
116
  walkSvelteAst(ast.html || ast.fragment, (node) => {
114
117
  if (node.type === "Element" || node.type === "InlineComponent" || node.type === "RegularElement" || node.type === "Component") {
@@ -185,6 +188,8 @@ ${nextLine ? `${lineNum + 1} | ${nextLine}` : ''}
185
188
  }
186
189
  }
187
190
  let handlerName = "";
191
+ let inlineCode;
192
+ let isInline = false;
188
193
  if (attr.type === "Attribute" && Array.isArray(attr.value)) {
189
194
  const exprValue = attr.value.find((v) => v.type === "ExpressionTag" || v.type === "MustacheTag");
190
195
  if (exprValue && exprValue.expression) {
@@ -194,6 +199,16 @@ ${nextLine ? `${lineNum + 1} | ${nextLine}` : ''}
194
199
  else if (exprValue.expression.type === "CallExpression" && exprValue.expression.callee) {
195
200
  handlerName = exprValue.expression.callee.name;
196
201
  }
202
+ else if (exprValue.expression.type === "ArrowFunctionExpression" || exprValue.expression.type === "FunctionExpression") {
203
+ // Inline arrow function or function expression - extract the code
204
+ isInline = true;
205
+ handlerName = `__inline_handler_${inlineHandlerCounter++}`;
206
+ // Extract the source code from the expression
207
+ const expr = exprValue.expression;
208
+ if (expr.start !== undefined && expr.end !== undefined) {
209
+ inlineCode = source.substring(expr.start, expr.end);
210
+ }
211
+ }
197
212
  }
198
213
  }
199
214
  else if (attr.expression) {
@@ -206,9 +221,23 @@ ${nextLine ? `${lineNum + 1} | ${nextLine}` : ''}
206
221
  else if (attr.expression.type === "MemberExpression") {
207
222
  handlerName = extractMemberExpressionName(attr.expression);
208
223
  }
224
+ else if (attr.expression.type === "ArrowFunctionExpression" || attr.expression.type === "FunctionExpression") {
225
+ // Inline arrow function or function expression - extract the code
226
+ isInline = true;
227
+ handlerName = `__inline_handler_${inlineHandlerCounter++}`;
228
+ // Extract the source code from the expression
229
+ const expr = attr.expression;
230
+ if (expr.start !== undefined && expr.end !== undefined) {
231
+ inlineCode = source.substring(expr.start, expr.end);
232
+ }
233
+ }
209
234
  }
210
235
  if (handlerName) {
211
- foundHandler = { eventType, handlerName };
236
+ foundHandler = { eventType, handlerName, inlineCode, isInline };
237
+ // If it's an inline handler, store the code
238
+ if (isInline && inlineCode) {
239
+ inlineHandlers.set(handlerName, inlineCode);
240
+ }
212
241
  break;
213
242
  }
214
243
  }
@@ -252,6 +281,8 @@ ${nextLine ? `${lineNum + 1} | ${nextLine}` : ''}
252
281
  handlerName: foundHandler.handlerName,
253
282
  eventType: foundHandler.eventType,
254
283
  element: node.name.toLowerCase(),
284
+ inlineCode: foundHandler.inlineCode,
285
+ isInline: foundHandler.isInline,
255
286
  });
256
287
  }
257
288
  });
@@ -304,7 +335,8 @@ ${nextLine ? `${lineNum + 1} | ${nextLine}` : ''}
304
335
  processedSource,
305
336
  declaredProps,
306
337
  propsWithDefaults,
307
- declaredFunctions
338
+ declaredFunctions,
339
+ inlineHandlers
308
340
  };
309
341
  }
310
342
  /**
@@ -451,7 +483,11 @@ function validateSvelteComponent(componentInfo, data = {}, componentName = 'unkn
451
483
  }
452
484
  }
453
485
  // 3. Check for undefined handlers referenced in elements
486
+ // Skip inline handlers (they are extracted from template, not defined in script)
454
487
  for (const [elementName, handlerInfo] of componentInfo.handlers) {
488
+ // Skip inline handlers - they are defined in the template, not the script
489
+ if (handlerInfo.isInline)
490
+ continue;
455
491
  if (!componentInfo.declaredFunctions.includes(handlerInfo.handlerName)) {
456
492
  warnings.push({
457
493
  type: 'undefined-handler',
@@ -625,8 +661,9 @@ function loadModules(imports, sourceDir) {
625
661
  * Create a handler context from script content
626
662
  * This evaluates the Svelte script and returns the handler functions and effects
627
663
  * @param sourceDir - The directory of the source file (used for resolving relative imports)
664
+ * @param inlineHandlers - Map of inline handler names to their source code (extracted from template)
628
665
  */
629
- function createHandlerContext(scriptContent, initialData = {}, component, ctx, sourceDir) {
666
+ function createHandlerContext(scriptContent, initialData = {}, component, ctx, sourceDir, inlineHandlers) {
630
667
  const handlers = {};
631
668
  const effects = [];
632
669
  try {
@@ -759,7 +796,8 @@ function createHandlerContext(scriptContent, initialData = {}, component, ctx, s
759
796
  try {
760
797
  await __preRenderCallbacks__[i]();
761
798
  } catch (err) {
762
- // Pre-render callback failed
799
+ console.error("[DBI-Svelte] Pre-render callback failed:", err);
800
+ throw err;
763
801
  }
764
802
  }
765
803
  }
@@ -770,7 +808,8 @@ function createHandlerContext(scriptContent, initialData = {}, component, ctx, s
770
808
  try {
771
809
  __afterRenderCallbacks__[i]();
772
810
  } catch (err) {
773
- // After-render callback failed
811
+ console.error("[DBI-Svelte] After-render callback failed:", err);
812
+ throw err;
774
813
  }
775
814
  }
776
815
  }
@@ -974,7 +1013,8 @@ function createHandlerContext(scriptContent, initialData = {}, component, ctx, s
974
1013
  __runAfterRender__();
975
1014
  return result;
976
1015
  } catch (err) {
977
- // Silently fail
1016
+ console.error("[DBI-Svelte] Render failed:", err);
1017
+ throw err;
978
1018
  }
979
1019
  }
980
1020
 
@@ -1258,7 +1298,8 @@ function createHandlerContext(scriptContent, initialData = {}, component, ctx, s
1258
1298
  __destroyCallbacks__.push(result);
1259
1299
  }
1260
1300
  } catch (err) {
1261
- // Mount callback failed
1301
+ console.error("[DBI-Svelte] onMount callback failed:", err);
1302
+ throw err;
1262
1303
  }
1263
1304
  }
1264
1305
  }
@@ -1269,7 +1310,8 @@ function createHandlerContext(scriptContent, initialData = {}, component, ctx, s
1269
1310
  try {
1270
1311
  __destroyCallbacks__[i]();
1271
1312
  } catch (err) {
1272
- // Destroy callback failed
1313
+ console.error("[DBI-Svelte] onDestroy callback failed:", err);
1314
+ throw err;
1273
1315
  }
1274
1316
  }
1275
1317
  // Clear pending timeouts
@@ -1285,8 +1327,34 @@ function createHandlerContext(scriptContent, initialData = {}, component, ctx, s
1285
1327
  }
1286
1328
 
1287
1329
  ${processedScript}
1330
+
1331
+ // Inline handlers from template (extracted arrow functions/function expressions)
1332
+ ${Array.from(inlineHandlers || new Map()).map(([name, code]) => {
1333
+ // Wrap the inline code as a named function
1334
+ // If it's an arrow function, convert to regular function for proper 'this' binding
1335
+ if (code.trim().startsWith('async')) {
1336
+ // async arrow function or async function
1337
+ if (code.includes('=>')) {
1338
+ // async arrow function: async (ctx) => { ... } or async () => { ... }
1339
+ return `var ${name} = ${code};`;
1340
+ }
1341
+ else {
1342
+ // async function expression: async function(ctx) { ... }
1343
+ return `var ${name} = ${code};`;
1344
+ }
1345
+ }
1346
+ else if (code.includes('=>')) {
1347
+ // Regular arrow function: (ctx) => { ... } or () => { ... }
1348
+ return `var ${name} = ${code};`;
1349
+ }
1350
+ else {
1351
+ // Regular function expression: function(ctx) { ... }
1352
+ return `var ${name} = ${code};`;
1353
+ }
1354
+ }).join('\n')}
1355
+
1288
1356
  return {
1289
- handlers: { ${functionNames.length > 0 ? functionNames.join(", ") : ''} },
1357
+ handlers: { ${[...functionNames, ...Array.from(inlineHandlers || new Map()).map(([name]) => name)].filter(Boolean).join(", ")} },
1290
1358
  effects: __effects__,
1291
1359
  hasPendingRender: __hasPendingRender__,
1292
1360
  flushRender: __syncFlushRender__,
@@ -1349,38 +1417,10 @@ function createHandlerContext(scriptContent, initialData = {}, component, ctx, s
1349
1417
  };
1350
1418
  }
1351
1419
  catch (error) {
1352
- // Log the error for debugging
1420
+ // Re-throw the error so it's visible to the developer
1353
1421
  console.error("[DBI-Svelte] createHandlerContext failed:", error);
1422
+ throw error;
1354
1423
  }
1355
- // Function to run all effects (fallback)
1356
- const runEffects = () => {
1357
- for (const effect of effects) {
1358
- try {
1359
- effect();
1360
- }
1361
- catch (error) {
1362
- // Effect failed
1363
- }
1364
- }
1365
- };
1366
- return {
1367
- handlers,
1368
- effects,
1369
- runEffects,
1370
- hasPendingRender: () => false,
1371
- flushRender: () => Promise.resolve(),
1372
- wrappedCtx: ctx,
1373
- mountCallbacks: [],
1374
- destroyCallbacks: [],
1375
- preRenderCallbacks: [],
1376
- afterRenderCallbacks: [],
1377
- runMount: () => { },
1378
- runDestroy: () => { },
1379
- runPreRender: async () => { },
1380
- runAfterRender: () => { },
1381
- setInHandler: () => { },
1382
- render: () => Promise.resolve()
1383
- };
1384
1424
  }
1385
1425
  /**
1386
1426
  * Extract $effect callback bodies from script content