From e0f844e5dc9bbd9b63a1066c6c93598d20c77855 Mon Sep 17 00:00:00 2001 From: josedario87 Date: Tue, 2 Dec 2025 18:04:07 -0600 Subject: [PATCH] fix: Corregir versiones de npm y imports ESM de Baileys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Downgrade a Nuxt 3.14.0 (Nuxt 4 no existe todavía) - Downgrade @nuxt/ui a ^3.0.0 - Downgrade Baileys a ^6.7.9 (versión estable) - Corregir imports ESM de Baileys en auth-state.ts y manager.ts - Remover compatibilityDate (específico de Nuxt 4) --- nuxt.config.ts | 33 ++++----------------------- package.json | 20 ++++++++-------- server/services/baileys/auth-state.ts | 3 ++- server/services/baileys/manager.ts | 10 ++++---- 4 files changed, 22 insertions(+), 44 deletions(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index a43e5cb..af65c9c 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,15 +1,13 @@ // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ ssr: true, - compatibilityDate: '2025-07-15', devtools: { enabled: true }, css: ['~/assets/css/main.css'], modules: ['@nuxt/image', '@nuxt/ui', '@vite-pwa/nuxt'], // Performance optimizations experimental: { - payloadExtraction: false, - viewTransition: true + payloadExtraction: false }, // Vite config @@ -23,21 +21,10 @@ export default defineNuxtConfig({ '.nucleoriofrio.com', 'whatsapp.nucleoriofrio.com' ] - }, - build: { - cssCodeSplit: true, - rollupOptions: { - output: { - manualChunks: { - 'vendor-ui': ['@nuxt/ui'] - } - } - } } }, app: { - baseURL: process.env.BASE_URL || '/', head: { title: 'WhatsApp Nucleo', link: [ @@ -55,7 +42,6 @@ export default defineNuxtConfig({ }, nitro: { - baseURL: process.env.BASE_URL || '/', experimental: { openAPI: true }, @@ -89,29 +75,18 @@ export default defineNuxtConfig({ display: 'standalone', background_color: '#075e54', theme_color: '#075e54', - launch_handler: { - client_mode: 'navigate-existing' - }, icons: [ { src: '/icons/icon-192.png', sizes: '192x192', type: 'image/png' }, - { src: '/icons/icon-512.png', sizes: '512x512', type: 'image/png' }, - { src: '/icons/icon-192-maskable.png', sizes: '192x192', type: 'image/png', purpose: 'maskable' }, - { src: '/icons/icon-512-maskable.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' } + { src: '/icons/icon-512.png', sizes: '512x512', type: 'image/png' } ] }, workbox: { globPatterns: ['**/*.{js,css,html,png,svg,webp,ico,json,woff2}'], navigateFallback: undefined, - cleanupOutdatedCaches: true, - maximumFileSizeToCacheInBytes: 4 * 1024 * 1024 - }, - client: { - installPrompt: true, - periodicSyncForUpdates: 3600 + cleanupOutdatedCaches: true }, devOptions: { - enabled: process.env.NODE_ENV === 'development', - type: 'module' + enabled: false } }, diff --git a/package.json b/package.json index 6addb29..4b41d78 100644 --- a/package.json +++ b/package.json @@ -10,20 +10,22 @@ "postinstall": "nuxt prepare" }, "dependencies": { - "@nuxt/image": "^1.11.0", - "@nuxt/ui": "^4.0.0", - "@vite-pwa/nuxt": "^0.9.1", - "@whiskeysockets/baileys": "^7.0.0-rc.9", - "nuxt": "^4.1.2", + "@hapi/boom": "^10.0.1", + "@nuxt/image": "^1.8.1", + "@nuxt/ui": "^3.0.0", + "@vite-pwa/nuxt": "^0.10.6", + "@whiskeysockets/baileys": "^6.7.9", + "nuxt": "^3.14.0", "pg": "^8.13.1", "pino": "^9.5.0", "qrcode": "^1.5.4", - "typescript": "^5.9.2", - "vue": "^3.5.22", - "vue-router": "^4.5.1" + "vue": "^3.5.13", + "vue-router": "^4.5.0" }, "devDependencies": { + "@types/node": "^22.10.1", "@types/pg": "^8.11.10", - "@types/qrcode": "^1.5.5" + "@types/qrcode": "^1.5.5", + "typescript": "^5.7.2" } } diff --git a/server/services/baileys/auth-state.ts b/server/services/baileys/auth-state.ts index a73b437..97f7c67 100644 --- a/server/services/baileys/auth-state.ts +++ b/server/services/baileys/auth-state.ts @@ -3,7 +3,8 @@ * Stores credentials and keys in the database instead of files */ import type { AuthenticationCreds, SignalDataTypeMap } from '@whiskeysockets/baileys' -import { initAuthCreds, BufferJSON, proto } from '@whiskeysockets/baileys' +import pkg from '@whiskeysockets/baileys' +const { initAuthCreds, BufferJSON, proto } = pkg import { query } from '../../utils/database' export interface PostgresAuthState { diff --git a/server/services/baileys/manager.ts b/server/services/baileys/manager.ts index 67a36f6..f4aef50 100644 --- a/server/services/baileys/manager.ts +++ b/server/services/baileys/manager.ts @@ -2,15 +2,15 @@ * BaileysManager - Manages multiple WhatsApp instances * Singleton pattern for managing all Baileys connections */ -import makeWASocket, { +import type { WASocket, BaileysEventMap } from '@whiskeysockets/baileys' +import pkg from '@whiskeysockets/baileys' +const { + default: makeWASocket, DisconnectReason, fetchLatestBaileysVersion, makeCacheableSignalKeyStore, - useMultiFileAuthState, - type WASocket, - type BaileysEventMap, Browsers -} from '@whiskeysockets/baileys' +} = pkg import { Boom } from '@hapi/boom' import { EventEmitter } from 'events' import QRCode from 'qrcode'