@cpzxrobot/sdk 1.3.14 → 1.3.16

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.
@@ -15,6 +15,7 @@ class MobilePlatform {
15
15
  this.port = event.ports[0];
16
16
  if (this.port != null) {
17
17
  this.port.onmessage = (event) => {
18
+ console.log("got message from flutter", JSON.stringify(event));
18
19
  if (event.data.id != undefined) {
19
20
  const callback = this.sseCallbacks[event.data.id];
20
21
  callback === null || callback === void 0 ? void 0 : callback(event.data.data);
@@ -109,12 +109,19 @@ class WebPlatform {
109
109
  var instance = this;
110
110
  return {
111
111
  get: async (url, config) => {
112
+ var _a;
112
113
  url = instance.processQueryParams(url, config);
113
114
  const response = await this.fetchWithAuth(url, {
114
115
  method: 'GET',
115
116
  headers: config === null || config === void 0 ? void 0 : config.headers
116
117
  });
117
- return { data: await response.json() };
118
+ //test content-type, if it is json, then parse it
119
+ if ((_a = response.headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
120
+ return { data: await response.json() };
121
+ }
122
+ else {
123
+ return response.blob();
124
+ }
118
125
  },
119
126
  post: async (url, data, config) => {
120
127
  const response = await this.fetchWithAuth(url, {
@@ -20,6 +20,7 @@ export class MobilePlatform implements PlatformInterface {
20
20
  this.port = event.ports[0];
21
21
  if (this.port != null) {
22
22
  this.port.onmessage = (event: MessageEvent) => {
23
+ console.log("got message from flutter",JSON.stringify(event));
23
24
  if (event.data.id != undefined) {
24
25
  const callback = this.sseCallbacks[event.data.id];
25
26
  callback?.(event.data.data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.14",
3
+ "version": "1.3.16",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/web_platform.ts CHANGED
@@ -122,7 +122,12 @@ export class WebPlatform implements PlatformInterface {
122
122
  method: 'GET',
123
123
  headers: config?.headers
124
124
  });
125
- return { data: await response.json() };
125
+ //test content-type, if it is json, then parse it
126
+ if (response.headers.get('Content-Type')?.includes('application/json')) {
127
+ return { data: await response.json() };
128
+ }else {
129
+ return response.blob();
130
+ }
126
131
  },
127
132
  post: async (url: string, data?: any, config?: any) => {
128
133
  const response = await this.fetchWithAuth(url, {