fix(ImClient): make sendSync/scheduleReconnect safe when SDK not initialized
ImClient.sendSync() called getConfig() which throws when init() hasn't been called, breaking headless usage (e.g. platform event listeners). Now wraps the call in a try-catch and skips the sync frame if appKey is unavailable. Same fix for scheduleReconnect's debug log. Also: add vite-plugin-dts to generate TypeScript declarations on every build, fixing the missing dist/index.d.ts that broke IDE type resolution. Bump to 0.2.3. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
父节点
a68550e576
当前提交
df7557b77f
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@xuqm/vue3-sdk",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"description": "XuqmGroup Vue3 SDK — IM & platform integration for web",
|
||||
"private": false,
|
||||
"publishConfig": {
|
||||
@ -21,7 +21,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "vite build --watch",
|
||||
"build": "tsc --emitDeclarationOnly && vite build",
|
||||
"build": "vite build",
|
||||
"type-check": "tsc --noEmit",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
|
||||
@ -227,7 +227,8 @@ export class ImClient {
|
||||
|
||||
private sendSync(): void {
|
||||
if (this.ws?.readyState !== WebSocket.OPEN) return
|
||||
const config = getConfig()
|
||||
const config = (() => { try { return getConfig() } catch { return null } })()
|
||||
if (!config?.appKey) return
|
||||
this.ws.send(
|
||||
buildStompFrame(
|
||||
'SEND',
|
||||
@ -261,7 +262,8 @@ export class ImClient {
|
||||
|
||||
private scheduleReconnect(): void {
|
||||
if (this.destroyed) return
|
||||
if (getConfig().debug) {
|
||||
const debug = (() => { try { return getConfig().debug } catch { return false } })()
|
||||
if (debug) {
|
||||
console.log(`[ImClient] reconnect in ${this.reconnectDelay}ms`)
|
||||
}
|
||||
this.reconnectTimer = setTimeout(() => {
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import dts from 'vite-plugin-dts'
|
||||
import { resolve } from 'path'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
dts({ include: ['src'], insertTypesEntry: true }),
|
||||
],
|
||||
build: {
|
||||
lib: {
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户