@cpzxrobot/sdk 1.2.90 → 1.2.92
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.js +6 -0
- package/index.ts +8 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -69,6 +69,7 @@ class Cpzxrobot {
|
|
|
69
69
|
this.ai = new ai_gateway_1.AiGateway(this);
|
|
70
70
|
this.construction = new construction_gateway_1.ConstructionGateway(this);
|
|
71
71
|
this.system = new system_gateway_1.SystemGateway(this);
|
|
72
|
+
this.sseCallbacks = {};
|
|
72
73
|
//获取当前浏览器的域名
|
|
73
74
|
this.ready = new Promise((resolve, reject) => {
|
|
74
75
|
this.resolveReady = resolve;
|
|
@@ -414,6 +415,7 @@ class Cpzxrobot {
|
|
|
414
415
|
getAsSse: async function (url, fn, config) {
|
|
415
416
|
var randomId = Math.random().toString(36).substring(2);
|
|
416
417
|
that.sseCallbacks[randomId] = fn;
|
|
418
|
+
console.log("getAsSse", url, fn, randomId);
|
|
417
419
|
await platform.callHandler("axios_getAsSse", url, config, randomId);
|
|
418
420
|
delete that.sseCallbacks[randomId];
|
|
419
421
|
},
|
|
@@ -439,6 +441,7 @@ class Cpzxrobot {
|
|
|
439
441
|
}
|
|
440
442
|
window.addEventListener('message', (event) => {
|
|
441
443
|
if (event.data == 'capturePort') {
|
|
444
|
+
console.log("capturePort", event);
|
|
442
445
|
if (event.ports[0] != null) {
|
|
443
446
|
this.messagePort = event.ports[0];
|
|
444
447
|
this.messagePort.onmessage = (event) => {
|
|
@@ -449,6 +452,9 @@ class Cpzxrobot {
|
|
|
449
452
|
};
|
|
450
453
|
}
|
|
451
454
|
}
|
|
455
|
+
else {
|
|
456
|
+
console.log("message", event);
|
|
457
|
+
}
|
|
452
458
|
}, false);
|
|
453
459
|
}
|
|
454
460
|
else {
|
package/index.ts
CHANGED
|
@@ -79,7 +79,9 @@ export class Cpzxrobot {
|
|
|
79
79
|
ai: AiGateway = new AiGateway(this);
|
|
80
80
|
construction: ConstructionGateway = new ConstructionGateway(this);
|
|
81
81
|
system: SystemGateway = new SystemGateway(this);
|
|
82
|
-
sseCallbacks:
|
|
82
|
+
sseCallbacks: {
|
|
83
|
+
[key: string]: (data: any) => void;
|
|
84
|
+
} = {};
|
|
83
85
|
|
|
84
86
|
|
|
85
87
|
constructor(appCode: string) {
|
|
@@ -453,6 +455,7 @@ export class Cpzxrobot {
|
|
|
453
455
|
getAsSse: async function (url, fn, config?) {
|
|
454
456
|
var randomId = Math.random().toString(36).substring(2);
|
|
455
457
|
that.sseCallbacks[randomId] = fn;
|
|
458
|
+
console.log("getAsSse", url, fn, randomId);
|
|
456
459
|
await platform.callHandler("axios_getAsSse", url, config, randomId);
|
|
457
460
|
delete that.sseCallbacks[randomId];
|
|
458
461
|
},
|
|
@@ -481,6 +484,7 @@ export class Cpzxrobot {
|
|
|
481
484
|
}
|
|
482
485
|
window.addEventListener('message', (event) => {
|
|
483
486
|
if (event.data == 'capturePort') {
|
|
487
|
+
console.log("capturePort", event);
|
|
484
488
|
if (event.ports[0] != null) {
|
|
485
489
|
this.messagePort = event.ports[0];
|
|
486
490
|
this.messagePort.onmessage = (event) => {
|
|
@@ -490,7 +494,10 @@ export class Cpzxrobot {
|
|
|
490
494
|
}
|
|
491
495
|
};
|
|
492
496
|
}
|
|
497
|
+
} else {
|
|
498
|
+
console.log("message", event);
|
|
493
499
|
}
|
|
500
|
+
|
|
494
501
|
}, false);
|
|
495
502
|
} else {
|
|
496
503
|
if (this.isLocalDomain(domain)) {
|