@jolibox/implement 1.1.16-beta.4 → 1.1.16-beta.6

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.
@@ -25,11 +25,5 @@ export declare function createFetch(createMethod: 'createRequestTaskSync', opera
25
25
  }): Fetch;
26
26
  export declare function parseJSON(data: string): any;
27
27
  export declare function normalizeData(data: unknown, contentType?: string): string | ArrayBuffer;
28
- export declare const sendRequestBodyToNative: (data: unknown, contentType: string) => {
29
- errMsg: string;
30
- errNo?: number;
31
- data: {
32
- requestId: string;
33
- };
34
- };
28
+ export declare const sendRequestBodyToNative: (data: unknown, contentType: string) => Promise<void>;
35
29
  export {};
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.1.16-beta.4 clean
3
+ > @jolibox/implement@1.1.16-beta.6 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.16-beta.4 build:esm
7
+ > @jolibox/implement@1.1.16-beta.6 build:esm
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
9
9
 
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@jolibox/implement",
3
3
  "description": "This project is Jolibox JS-SDk implement for Native && H5",
4
- "version": "1.1.16-beta.4",
4
+ "version": "1.1.16-beta.6",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@jolibox/common": "1.1.16-beta.4",
10
- "@jolibox/types": "1.1.16-beta.4",
11
- "@jolibox/native-bridge": "1.1.16-beta.4",
9
+ "@jolibox/common": "1.1.16-beta.6",
10
+ "@jolibox/types": "1.1.16-beta.6",
11
+ "@jolibox/native-bridge": "1.1.16-beta.6",
12
12
  "localforage": "1.10.0",
13
13
  "@jolibox/ui": "1.0.0",
14
14
  "web-vitals": "4.2.4"
@@ -1,4 +1,4 @@
1
- import { isString, logger, Deferred, isObject, hostEmitter, isUndefined } from '@jolibox/common';
1
+ import { isString, logger, Deferred, isObject, hostEmitter, isUndefined, uuidv4 } from '@jolibox/common';
2
2
  import { reportNetworkAPI } from './report';
3
3
  import { RequestFrom } from './types';
4
4
  import { FetchResponse, FetchOptions } from './types';
@@ -246,7 +246,7 @@ const normalizeRequestBody = (
246
246
  data: unknown,
247
247
  contentType = 'application/json'
248
248
  ): {
249
- body: JSON | string;
249
+ body: string;
250
250
  dataType: 'json' | 'text';
251
251
  } => {
252
252
  if (isUndefined(data) || data instanceof ArrayBuffer) {
@@ -269,7 +269,7 @@ const normalizeRequestBody = (
269
269
  typeof data === 'object'
270
270
  ) {
271
271
  return {
272
- body: JSON.parse(JSON.stringify(data)),
272
+ body: JSON.stringify(data),
273
273
  dataType: 'json'
274
274
  };
275
275
  }
@@ -280,9 +280,11 @@ const normalizeRequestBody = (
280
280
  };
281
281
  };
282
282
 
283
- export const sendRequestBodyToNative = (data: unknown, contentType: string) => {
283
+ export const sendRequestBodyToNative = async (data: unknown, contentType: string) => {
284
284
  const { body, dataType } = normalizeRequestBody(data, contentType);
285
- return invokeNative('sendRequestBodySync', {
285
+ const requestId = uuidv4();
286
+ await invokeNative('sendRequestBodyAsync', {
287
+ requestId,
286
288
  body,
287
289
  dataType
288
290
  });
@@ -5,9 +5,7 @@ import { context } from '@/common/context';
5
5
  /**
6
6
  * inner fetch
7
7
  */
8
- const defaultHeaders: Record<string, string> = {
9
- // 'x-user-agent': xUserAgent()
10
- };
8
+ const defaultHeaders: Record<string, string> = {};
11
9
  if (context.hostUserInfo?.token) {
12
10
  defaultHeaders['x-joli-token'] = context.hostUserInfo.token;
13
11
  }