@cpzxrobot/sdk 1.3.8 → 1.3.10
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/mobile_platform.js +4 -3
- package/dist/web_platform.js +1 -1
- package/mobile_platform.ts +4 -3
- package/package.json +1 -1
- package/web_platform.ts +1 -1
package/dist/mobile_platform.js
CHANGED
|
@@ -7,13 +7,14 @@ class MobilePlatform {
|
|
|
7
7
|
this.token = "";
|
|
8
8
|
this.appCode = "";
|
|
9
9
|
this.baseURL = "";
|
|
10
|
+
this.port = null;
|
|
10
11
|
// @ts-ignore
|
|
11
12
|
this.platform = window.flutter_inappwebview;
|
|
12
13
|
window.addEventListener('message', (event) => {
|
|
13
14
|
if (event.data == 'capturePort') {
|
|
14
|
-
|
|
15
|
-
if (port != null) {
|
|
16
|
-
port.onmessage = (event) => {
|
|
15
|
+
this.port = event.ports[0];
|
|
16
|
+
if (this.port != null) {
|
|
17
|
+
this.port.onmessage = (event) => {
|
|
17
18
|
if (event.data.id != undefined) {
|
|
18
19
|
const callback = this.sseCallbacks[event.data.id];
|
|
19
20
|
callback === null || callback === void 0 ? void 0 : callback(event.data.data);
|
package/dist/web_platform.js
CHANGED
|
@@ -69,7 +69,7 @@ class WebPlatform {
|
|
|
69
69
|
// 移除前缀 'data: '
|
|
70
70
|
var data = JSON.parse(line.split(": ")[1]);
|
|
71
71
|
//{"choices":[{"delta":{"content":" </"},"index":0}],"created":1741749068,"id":"chatcmpl-67ccb889154043f5874cbf3a64ec163e","model":"DeepSeek-R1","object":"chat.completion.chunk"}
|
|
72
|
-
fn === null || fn === void 0 ? void 0 : fn
|
|
72
|
+
fn === null || fn === void 0 ? void 0 : fn(data);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
catch (e) {
|
package/mobile_platform.ts
CHANGED
|
@@ -9,6 +9,7 @@ export class MobilePlatform implements PlatformInterface {
|
|
|
9
9
|
token: string = "";
|
|
10
10
|
appCode: string = "";
|
|
11
11
|
baseURL: string = "";
|
|
12
|
+
private port: MessagePort | null = null;
|
|
12
13
|
|
|
13
14
|
constructor() {
|
|
14
15
|
// @ts-ignore
|
|
@@ -16,9 +17,9 @@ export class MobilePlatform implements PlatformInterface {
|
|
|
16
17
|
|
|
17
18
|
window.addEventListener('message', (event) => {
|
|
18
19
|
if (event.data == 'capturePort') {
|
|
19
|
-
|
|
20
|
-
if (port != null) {
|
|
21
|
-
port.onmessage = (event: MessageEvent) => {
|
|
20
|
+
this.port = event.ports[0];
|
|
21
|
+
if (this.port != null) {
|
|
22
|
+
this.port.onmessage = (event: MessageEvent) => {
|
|
22
23
|
if (event.data.id != undefined) {
|
|
23
24
|
const callback = this.sseCallbacks[event.data.id];
|
|
24
25
|
callback?.(event.data.data);
|
package/package.json
CHANGED
package/web_platform.ts
CHANGED
|
@@ -79,7 +79,7 @@ export class WebPlatform implements PlatformInterface {
|
|
|
79
79
|
// 移除前缀 'data: '
|
|
80
80
|
var data = JSON.parse(line.split(": ")[1]);
|
|
81
81
|
//{"choices":[{"delta":{"content":" </"},"index":0}],"created":1741749068,"id":"chatcmpl-67ccb889154043f5874cbf3a64ec163e","model":"DeepSeek-R1","object":"chat.completion.chunk"}
|
|
82
|
-
fn?.
|
|
82
|
+
fn?.(data);
|
|
83
83
|
}
|
|
84
84
|
} catch (e) {
|
|
85
85
|
console.error("解析失败", e);
|