@axiom-lattice/client-sdk 1.0.44 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2426,14 +2426,14 @@ var WeChatClient = class extends AbstractClient {
2426
2426
  headers["x-tenant-id"] = this.tenantId;
2427
2427
  }
2428
2428
  const requestParams = this.buildStreamRequestParams(options);
2429
- const taskId = wx.request({
2429
+ const requestTask = wx.request({
2430
2430
  url: `${this.config.baseURL}${requestParams.url}`,
2431
2431
  method: requestParams.method,
2432
2432
  data: requestParams.body,
2433
2433
  header: headers,
2434
2434
  responseType: "text",
2435
2435
  enableChunked: true,
2436
- success: async () => {
2436
+ success: () => {
2437
2437
  },
2438
2438
  fail: (err) => {
2439
2439
  if (onError) {
@@ -2453,35 +2453,30 @@ var WeChatClient = class extends AbstractClient {
2453
2453
  onComplete();
2454
2454
  }
2455
2455
  }
2456
- },
2457
- // Using WeChat's chunked data capability
2458
- dataReceived: (res) => {
2459
- if (!res.data)
2460
- return;
2461
- const text = this.decodeUint8Array(res.data);
2462
- const lines = text.split("\n");
2463
- for (const line of lines) {
2464
- if (line.trim().startsWith("data: ")) {
2465
- try {
2466
- const eventData = JSON.parse(line.trim().slice(6));
2467
- onEvent(eventData);
2468
- } catch (error) {
2469
- if (onError) {
2470
- onError(
2471
- error instanceof Error ? error : new Error(String(error))
2472
- );
2473
- }
2456
+ }
2457
+ });
2458
+ requestTask.onChunkReceived((res) => {
2459
+ if (!res.data)
2460
+ return;
2461
+ const text = this.decodeUint8Array(res.data);
2462
+ const lines = text.split("\n");
2463
+ for (const line of lines) {
2464
+ if (line.trim().startsWith("data: ")) {
2465
+ try {
2466
+ const eventData = JSON.parse(line.trim().slice(6));
2467
+ onEvent(eventData);
2468
+ } catch (error) {
2469
+ if (onError) {
2470
+ onError(
2471
+ error instanceof Error ? error : new Error(String(error))
2472
+ );
2474
2473
  }
2475
2474
  }
2476
2475
  }
2477
2476
  }
2478
2477
  });
2479
2478
  return () => {
2480
- wx.abortRequest({
2481
- requestId: taskId,
2482
- success: () => console.log("Stream request aborted"),
2483
- fail: (err) => console.error("Failed to abort stream request:", err.errMsg)
2484
- });
2479
+ requestTask.abort();
2485
2480
  };
2486
2481
  }
2487
2482
  decodeUint8Array(uint8Array) {
@@ -2496,9 +2491,9 @@ var WeChatClient = class extends AbstractClient {
2496
2491
  ).join("");
2497
2492
  }
2498
2493
  /**
2499
- * 十六进制字符串转中文
2500
- * @param {String} hex 为十六进制字符串
2501
- * @return {String} 包含中文的字符串
2494
+ * Convert hexadecimal string to text (supports Chinese characters)
2495
+ * @param {String} hex - Hexadecimal string
2496
+ * @return {String} Decoded string including Chinese characters
2502
2497
  */
2503
2498
  hexToStr(hex) {
2504
2499
  let trimedStr = hex.trim();