diff --git a/package.json b/package.json index 5849a2a..6802bba 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "main": "src/index.ts", "react-native": "src/index.ts", "types": "src/index.ts", - "private": false, + "private": true, "workspaces": ["packages/*"], "publishConfig": { "registry": "https://nexus.xuqinmin.com/repository/npm-hosted/" diff --git a/packages/common/package.json b/packages/common/package.json index 208806a..7033303 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -2,6 +2,7 @@ "name": "@xuqm/rn-common", "version": "0.2.0", "description": "XuqmGroup RN SDK — core: init, network, token management", + "license": "UNLICENSED", "main": "src/index.ts", "react-native": "src/index.ts", "types": "src/index.ts", diff --git a/packages/common/src/config.ts b/packages/common/src/config.ts index 93cf133..174e966 100644 --- a/packages/common/src/config.ts +++ b/packages/common/src/config.ts @@ -1,6 +1,6 @@ export interface XuqmInitOptions { appId: string - serverUrl: string // e.g. "https://dev.xuqinmin.com" — SDK fetches config from here + serverUrl: string // e.g. "http://192.168.116.9:8081" — SDK fetches config from here appKey?: string debug?: boolean } diff --git a/packages/common/src/constants.ts b/packages/common/src/constants.ts index ddd770b..0d02e60 100644 --- a/packages/common/src/constants.ts +++ b/packages/common/src/constants.ts @@ -4,9 +4,9 @@ * XuqmSDK.initialize(). These constants are kept only as fallback * references and for backward compatibility. */ -export const API_BASE_URL = 'https://dev.xuqinmin.com' +export const API_BASE_URL = 'http://192.168.116.9:8081' /** * @deprecated See API_BASE_URL. */ -export const IM_WS_URL = 'wss://dev.xuqinmin.com/ws/im' +export const IM_WS_URL = 'ws://192.168.116.9:8082/ws/im' diff --git a/packages/common/src/http.ts b/packages/common/src/http.ts index e4e83bf..8b1982c 100644 --- a/packages/common/src/http.ts +++ b/packages/common/src/http.ts @@ -42,6 +42,14 @@ export async function apiRequest( if (token) headers['Authorization'] = `Bearer ${token}` } + if (config.debug) { + console.debug('[XuqmSDK][HTTP] request', { + method: options.method ?? 'GET', + url, + hasBody: Boolean(options.body), + }) + } + const res = await fetch(url, { method: options.method ?? 'GET', headers, @@ -50,9 +58,24 @@ export async function apiRequest( if (!res.ok) { const err = await res.json().catch(() => ({ message: res.statusText })) + if (config.debug) { + console.debug('[XuqmSDK][HTTP] response', { + url, + status: res.status, + ok: false, + message: (err as { message?: string }).message ?? res.statusText, + }) + } throw new Error((err as { message?: string }).message ?? `HTTP ${res.status}`) } const json = await res.json() + if (config.debug) { + console.debug('[XuqmSDK][HTTP] response', { + url, + status: res.status, + ok: true, + }) + } return (json.data ?? json) as T } diff --git a/packages/common/src/sdk.ts b/packages/common/src/sdk.ts index 714dd0a..a79fce8 100644 --- a/packages/common/src/sdk.ts +++ b/packages/common/src/sdk.ts @@ -6,7 +6,7 @@ export const XuqmSDK = { * Recommended for production use. * * @param options.appId - Your application ID (from the tenant platform) - * @param options.serverUrl - Base URL of the tenant platform, e.g. "https://dev.xuqinmin.com" + * @param options.serverUrl - Base URL of the tenant platform, e.g. "http://192.168.116.9:8081" * @param options.appKey - Optional; defaults to appId * @param options.debug - Enable verbose logging */ @@ -38,7 +38,7 @@ export const XuqmSDK = { * Kept for backward compatibility; prefer initialize() for production use. * * @param options.appId - Your application ID (from the tenant platform) - * @param options.serverUrl - Base URL of the tenant platform, e.g. "https://dev.xuqinmin.com" + * @param options.serverUrl - Base URL of the tenant platform, e.g. "http://192.168.116.9:8081" * @param options.appKey - Optional; defaults to appId * @param options.debug - Enable verbose logging */ diff --git a/packages/im/package.json b/packages/im/package.json index 4cbbffa..85b82e0 100644 --- a/packages/im/package.json +++ b/packages/im/package.json @@ -2,6 +2,7 @@ "name": "@xuqm/rn-im", "version": "0.2.0", "description": "XuqmGroup RN SDK — IM module (single chat, group chat, 13 message types)", + "license": "UNLICENSED", "main": "src/index.ts", "react-native": "src/index.ts", "types": "src/index.ts", diff --git a/packages/im/src/upload.ts b/packages/im/src/upload.ts index aad1892..0e711f9 100644 --- a/packages/im/src/upload.ts +++ b/packages/im/src/upload.ts @@ -44,6 +44,15 @@ export async function uploadFile( } as unknown as Blob) } + if (config.debug) { + console.debug('[XuqmSDK][Upload] request', { + url: `${config.fileServiceUrl}/api/file/upload`, + filename, + mimeType, + hasThumbnail: Boolean(thumbnailUri), + }) + } + const response = await fetch(`${config.fileServiceUrl}/api/file/upload`, { method: 'POST', headers: { @@ -55,10 +64,23 @@ export async function uploadFile( if (!response.ok) { const text = await response.text().catch(() => '') + if (config.debug) { + console.debug('[XuqmSDK][Upload] response', { + status: response.status, + ok: false, + body: text, + }) + } throw new Error(`[uploadFile] Upload failed (${response.status}): ${text}`) } const json = await response.json() + if (config.debug) { + console.debug('[XuqmSDK][Upload] response', { + status: response.status, + ok: true, + }) + } // Server wraps result in ApiResponse { code, data, message } const data = json?.data ?? json diff --git a/packages/push/package.json b/packages/push/package.json index 82c56fa..6f1e940 100644 --- a/packages/push/package.json +++ b/packages/push/package.json @@ -2,6 +2,7 @@ "name": "@xuqm/rn-push", "version": "0.2.0", "description": "XuqmGroup RN SDK — Push module (device token registration)", + "license": "UNLICENSED", "main": "src/index.ts", "react-native": "src/index.ts", "types": "src/index.ts", diff --git a/packages/update/package.json b/packages/update/package.json index 9ab95c6..95445c4 100644 --- a/packages/update/package.json +++ b/packages/update/package.json @@ -2,6 +2,7 @@ "name": "@xuqm/rn-update", "version": "0.2.0", "description": "XuqmGroup RN SDK — Update module (App update, RN plugin hot-update)", + "license": "UNLICENSED", "main": "src/index.ts", "react-native": "src/index.ts", "types": "src/index.ts",