@cpzxrobot/sdk 1.2.89 → 1.2.91
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 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -112,6 +112,7 @@ class Cpzxrobot {
|
|
|
112
112
|
const streamWithAuth = async (input, init, fn) => {
|
|
113
113
|
const headers = new Headers(init === null || init === void 0 ? void 0 : init.headers);
|
|
114
114
|
headers.set('Authorization', this.token);
|
|
115
|
+
headers.set('Miniapp-Code', this.appCode);
|
|
115
116
|
const response = await fetch(baseURL + input.toString(), Object.assign(Object.assign({}, init), { headers }));
|
|
116
117
|
var reader = response.body.getReader();
|
|
117
118
|
const decoder = new TextDecoder("utf-8");
|
|
@@ -411,6 +412,7 @@ class Cpzxrobot {
|
|
|
411
412
|
return platform.callHandler("axios_upload", url, option);
|
|
412
413
|
},
|
|
413
414
|
getAsSse: async function (url, fn, config) {
|
|
415
|
+
console.log("getAsSse", url, fn);
|
|
414
416
|
var randomId = Math.random().toString(36).substring(2);
|
|
415
417
|
that.sseCallbacks[randomId] = fn;
|
|
416
418
|
await platform.callHandler("axios_getAsSse", url, config, randomId);
|
|
@@ -438,6 +440,7 @@ class Cpzxrobot {
|
|
|
438
440
|
}
|
|
439
441
|
window.addEventListener('message', (event) => {
|
|
440
442
|
if (event.data == 'capturePort') {
|
|
443
|
+
console.log("capturePort", event);
|
|
441
444
|
if (event.ports[0] != null) {
|
|
442
445
|
this.messagePort = event.ports[0];
|
|
443
446
|
this.messagePort.onmessage = (event) => {
|
|
@@ -448,6 +451,9 @@ class Cpzxrobot {
|
|
|
448
451
|
};
|
|
449
452
|
}
|
|
450
453
|
}
|
|
454
|
+
else {
|
|
455
|
+
console.log("message", event);
|
|
456
|
+
}
|
|
451
457
|
}, false);
|
|
452
458
|
}
|
|
453
459
|
else {
|
package/index.ts
CHANGED
|
@@ -133,6 +133,7 @@ export class Cpzxrobot {
|
|
|
133
133
|
const streamWithAuth = async (input: RequestInfo, init?: RequestInit, fn?: Function) => {
|
|
134
134
|
const headers = new Headers(init?.headers);
|
|
135
135
|
headers.set('Authorization', this.token);
|
|
136
|
+
headers.set('Miniapp-Code', this.appCode);
|
|
136
137
|
const response = await fetch(baseURL + input.toString(), {
|
|
137
138
|
...init,
|
|
138
139
|
headers
|
|
@@ -445,11 +446,12 @@ export class Cpzxrobot {
|
|
|
445
446
|
config.preview = true;
|
|
446
447
|
}
|
|
447
448
|
return platform.callHandler("axios_getAndSave", url, config);
|
|
448
|
-
},
|
|
449
|
+
},
|
|
449
450
|
upload: function (url, option) {
|
|
450
451
|
return platform.callHandler("axios_upload", url, option);
|
|
451
452
|
},
|
|
452
453
|
getAsSse: async function (url, fn, config?) {
|
|
454
|
+
console.log("getAsSse", url, fn);
|
|
453
455
|
var randomId = Math.random().toString(36).substring(2);
|
|
454
456
|
that.sseCallbacks[randomId] = fn;
|
|
455
457
|
await platform.callHandler("axios_getAsSse", url, config, randomId);
|
|
@@ -463,7 +465,7 @@ export class Cpzxrobot {
|
|
|
463
465
|
window.flutter_inappwebview.callHandler != null
|
|
464
466
|
) {
|
|
465
467
|
this.platformReady = Promise.resolve(true);
|
|
466
|
-
} else {
|
|
468
|
+
} else {
|
|
467
469
|
this.platformReady = new Promise<boolean>((resolve, reject) => {
|
|
468
470
|
window.addEventListener(
|
|
469
471
|
"flutterInAppWebViewPlatformReady",
|
|
@@ -480,6 +482,7 @@ export class Cpzxrobot {
|
|
|
480
482
|
}
|
|
481
483
|
window.addEventListener('message', (event) => {
|
|
482
484
|
if (event.data == 'capturePort') {
|
|
485
|
+
console.log("capturePort", event);
|
|
483
486
|
if (event.ports[0] != null) {
|
|
484
487
|
this.messagePort = event.ports[0];
|
|
485
488
|
this.messagePort.onmessage = (event) => {
|
|
@@ -489,7 +492,10 @@ export class Cpzxrobot {
|
|
|
489
492
|
}
|
|
490
493
|
};
|
|
491
494
|
}
|
|
495
|
+
}else{
|
|
496
|
+
console.log("message", event);
|
|
492
497
|
}
|
|
498
|
+
|
|
493
499
|
}, false);
|
|
494
500
|
} else {
|
|
495
501
|
if (this.isLocalDomain(domain)) {
|