@conecli/cone-render 0.10.1-isv2.1 → 0.10.1-isv2.4

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.
Files changed (111) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/environmentType.ts +1 -1
  4. package/dist/common/index.h5.ts +1 -1
  5. package/dist/common/index.jd.ts +1 -1
  6. package/dist/common/index.ts +1 -1
  7. package/dist/common/index.weapp.ts +1 -1
  8. package/dist/common/jssdk.ts +1 -1
  9. package/dist/common/pageType.ts +1 -1
  10. package/dist/common/sgmCustomCode.ts +1 -1
  11. package/dist/common/token/index.h5.ts +1 -1
  12. package/dist/common/token/token.jd.ts +1 -1
  13. package/dist/common/wxappApi.ts +1 -1
  14. package/dist/components/ErrorBoundary.tsx +1 -1
  15. package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
  16. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  17. package/dist/components/base/CountDown/index.module.scss +49 -44
  18. package/dist/components/base/CountDown/index.tsx +1 -1
  19. package/dist/components/base/CustomScrollView/index-back.tsx +1 -0
  20. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  21. package/dist/components/base/CustomVideo/common.ts +1 -0
  22. package/dist/components/base/CustomVideo/index.tsx +1 -1
  23. package/dist/components/base/Dialog/index.module.scss +11 -0
  24. package/dist/components/base/ExposureSmart/index.h5.module.scss +12 -2
  25. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  26. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  27. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  28. package/dist/components/base/InViewRender/index.tsx +1 -1
  29. package/dist/components/base/InViewRender/index.weapp.tsx +1 -1
  30. package/dist/components/base/ItemViewExposureSmart/index.module.scss +2 -2
  31. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  32. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  33. package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
  34. package/dist/components/base/LazyLoadImage/index.h5.module.scss +11 -3
  35. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  36. package/dist/components/base/LazyLoadImage/index.tsx +1 -1
  37. package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
  38. package/dist/components/base/NetworkDataError/index.module.scss +3 -0
  39. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  40. package/dist/components/base/Price/Base/index.tsx +1 -1
  41. package/dist/components/base/Price/Double/index.module.scss +8 -0
  42. package/dist/components/base/Price/Double/index.tsx +1 -1
  43. package/dist/components/debug/DebugLayout/index.module.scss +2 -2
  44. package/dist/components/decorate/DecorateFloorModule/index.module.scss +11 -0
  45. package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
  46. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  47. package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
  48. package/dist/components/floorItem.jd.tsx +1 -1
  49. package/dist/components/floorItem.tsx +1 -1
  50. package/dist/components/floorItem.weapp.tsx +1 -1
  51. package/dist/components/isv/Floor/index.tsx +1 -1
  52. package/dist/components/remoteFloorItem.tsx +1 -1
  53. package/dist/interface/common.ts +1 -1
  54. package/dist/interface/component.ts +1 -1
  55. package/dist/interface/jumpEventReport.ts +1 -1
  56. package/dist/interface/service.ts +1 -1
  57. package/dist/jumpEventReport/base.ts +1 -1
  58. package/dist/jumpEventReport/const.ts +1 -1
  59. package/dist/jumpEventReport/index.jd.ts +1 -1
  60. package/dist/jumpEventReport/index.weapp.ts +1 -1
  61. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  62. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  63. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  64. package/dist/jumpEventReport/web/report.ts +1 -1
  65. package/dist/jumpEventReport/web.base.ts +1 -1
  66. package/dist/jumpEventReport/web.jd.ts +1 -1
  67. package/dist/jumpEventReport/web.jdb.ts +1 -1
  68. package/dist/jumpEventReport/web.jdjch.ts +1 -1
  69. package/dist/jumpEventReport/web.jxwxapp.ts +1 -1
  70. package/dist/jumpEventReport/web.pc.ts +1 -1
  71. package/dist/jumpEventReport/web.tjapp.ts +1 -1
  72. package/dist/jumpEventReport/web.tjm.ts +1 -1
  73. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  74. package/dist/libs/taroAppReport.js +2 -2
  75. package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -52
  76. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  77. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  78. package/dist/open/api/device.ts +1 -1
  79. package/dist/open/api/environment.ts +1 -1
  80. package/dist/open/api/request.ts +1 -1
  81. package/dist/open/api/shopMember.ts +1 -1
  82. package/dist/open/api/util.ts +1 -1
  83. package/dist/open/components/index.ts +1 -1
  84. package/dist/sass/app.h5.scss +275 -221
  85. package/dist/sass/base.scss +183 -137
  86. package/dist/service/fetchGateway.ts +1 -1
  87. package/dist/service/fetchGateway.weapp.ts +1 -0
  88. package/dist/service/http/colorSign.ts +1 -1
  89. package/dist/service/http/const.ts +1 -1
  90. package/dist/service/http/h5Http.ts +1 -0
  91. package/dist/service/http/index.h5.ts +1 -0
  92. package/dist/service/requestServer.h5.ts +1 -0
  93. package/dist/service/requestServer.ts +1 -1
  94. package/dist/service/requestServer.weapp.ts +1 -0
  95. package/dist/utils/connectNativeJsBridge.ts +1 -1
  96. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  97. package/dist/utils/h5Utils.ts +1 -1
  98. package/dist/utils/index.h5.ts +1 -1
  99. package/dist/utils/index.ts +1 -1
  100. package/dist/utils/index.weapp.ts +1 -1
  101. package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
  102. package/dist/utils/jumpExtMapUtil.ts +1 -0
  103. package/dist/utils/log.ts +1 -0
  104. package/dist/utils/sColor.js +1 -0
  105. package/dist/utils/sgmCodeUtils.ts +1 -1
  106. package/dist/utils/taroRenderUtil.ts +1 -1
  107. package/dist/utils/utils.ts +1 -1
  108. package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
  109. package/dist/wxapp/common/user_info.js +1 -1
  110. package/package.json +158 -135
  111. package/dist/utils/memberFormatUtils.js +0 -1
@@ -0,0 +1 @@
1
+ import Taro from '@tarojs/taro';
2
  isSupportHybridHttpRequest,
1
3
  draInterfaceCustomReport,
2
4
  draBusinessCustomReport,
3
5
  jsonHeader = 'application/json;charset=utf-8',
4
6
  formDataHeader = 'application/x-www-form-urlencoded',
5
7
  HYBRID: 'httpRequest_hybrid',
6
8
  TARO: 'httpRequest_taro',
7
9
  #requestTimeStamp: number;
8
10
  #responseTimeStamp: number;
9
11
  #getResTimeStamp: number;
10
12
  #reportType: string;
11
13
  #callbackFunction: string;
12
14
 
13
15
  async request({
14
16
  url,
15
17
  method = 'POST',
16
18
  timeout = 7000,
17
19
  isColorVerify = false,
18
20
  ...otherOptions
19
21
  }): Promise<Taro.request.SuccessCallbackResult<any>> {
20
22
  const { header: otherHeader, ...otherOpts } = otherOptions;
21
23
  const header = {
22
24
  'content-type':
23
25
  method === 'POST'
24
26
  ? RequestHeaderContentType.formDataHeader
25
27
  : RequestHeaderContentType.jsonHeader,
26
28
  ...otherHeader,
27
29
  };
28
30
  let getRequestUrl = url;
29
31
  let requestTask;
30
32
  const data = otherOpts?.data;
31
33
  const isGatewayRequest = url === this.api.apiFunc && typeof data === 'object';
32
34
  if (isGatewayRequest) {
33
35
  getRequestUrl = this._handleSpecialGatewayUrl(url);
34
36
  const shouldUseHybridRequest = this._shouldUseHybridRequest(data);
35
37
  if (shouldUseHybridRequest && window?.XWebView && window?.XWebView?.callNative) {
36
38
  requestTask = this._hybridRequest(getRequestUrl, data);
37
39
  } else {
38
40
  otherOpts.data = await this._prepareGatewayReqData(data, isColorVerify);
39
41
  requestTask = this._taroRequest(getRequestUrl, otherOpts, method, timeout, header);
40
42
  }
41
43
  } else {
42
44
  requestTask = this._taroRequest(getRequestUrl, otherOpts, method, timeout, header);
43
45
  }
44
46
  const requestTimeoutPromise = new Promise<ServiceInterFace.RequestPromiseRes>((resolve) => {
45
47
  setTimeout(() => {
46
48
  resolve({
47
49
  statusCode: 500,
48
50
  resTimeoutState: true,
49
51
  errMsg: 'request timeout',
50
52
  });
51
53
  }, timeout);
52
54
  });
53
55
  return Promise.race([requestTask, requestTimeoutPromise]).then((res: any) => {
54
56
  if (res && res.statusCode === 500 && res.resTimeoutState) {
55
57
  if (this.#reportType === HTTP_REQUEST_TYPE.HYBRID) {
56
58
  this._clearFunction(this.#callbackFunction);
57
59
  } else {
58
60
  requestTask.abort && requestTask.abort();
59
61
  }
60
62
  }
61
63
  this._handleReportInterfaceError(url, data, timeout, res);
62
64
  return res;
63
65
  });
64
66
  }
65
67
 
66
68
  _handleSpecialGatewayUrl(url: string): string {
67
69
  if (isPc && window.location.hostname.includes('.jd.hk')) {
68
70
  return this.api.hkApiFunc;
69
71
  }
70
72
  if (
71
73
  isJdApp &&
72
74
  window?.shopGlobalSwitch?.dualProtocol &&
73
75
  !window.location.href.includes('jshopx_vconsole')
74
76
  ) {
75
77
  return window?.shopGlobalSwitch?.dualProtocol?.apiTestApp || url;
76
78
  }
77
79
  return url;
78
80
  }
79
81
 
80
82
  _shouldUseHybridRequest(data: any): boolean {
81
83
  try {
82
84
  const isWhxFunctionId = /^whx\_/.test(data?.functionId);
83
85
  const isGlobalOpenHybirdHttpRequest =
84
86
  window?.shopGlobalSwitch?.openHybirdHttpRequest === 'true';
85
87
  if (
86
88
  !isJdApp ||
87
89
  !isSupportHybridHttpRequest ||
88
90
  !isGlobalOpenHybirdHttpRequest ||
89
91
  isWhxFunctionId ||
90
92
  isJdAndHarmonyDevice
91
93
  ) {
92
94
  return false;
93
95
  }
94
96
  const configData = global.getDynamicConfig('hybridHttpSwitch');
95
97
  const { globalOn = false, grayscale = {} } = configData || {};
96
98
  const buildType = process.env.BUILD_TYPE || '';
97
99
  const isInvokeGray = globalOn || grayscale[buildType];
98
100
  console.log(
99
101
  '使用hybrid请求是否命中灰度,isInvokeGray:',
100
102
  isInvokeGray,
101
103
  '获取mpaas配置hybridHttpSwitch原始数据configData',
102
104
  configData,
103
105
  );
104
106
  const hasWindowXWebView = !!window.XWebView;
105
107
  return isInvokeGray && hasWindowXWebView;
106
108
  } catch (e) {
107
109
  console.log('获取是否使用Hybrid请求出错,e:', e);
108
110
  return false;
109
111
  }
110
112
  }
111
113
 
112
114
  _hybridRequest(url: string, data: any): Promise<any> {
113
115
  return new Promise((resolve, reject) => {
114
116
  try {
115
117
  const changeCurrentUrl = url.startsWith('//') ? `https:${url}` : url;
116
118
  const { functionId, body, ...otherH5Param } = data;
117
119
  const reqParams = {
118
120
  url: isIosDevice ? `${changeCurrentUrl}/` : changeCurrentUrl,
119
121
  functionId: functionId,
120
122
  body: body,
121
123
  headerType: '0',
122
124
  param: {
123
125
  ...otherH5Param,
124
126
  },
125
127
  header: {
126
128
  Referer: window.location.origin,
127
129
  },
128
130
  };
129
131
  const callbackFunction = this._generateCallbackFunction();
130
132
  this.#callbackFunction = callbackFunction;
131
133
  this.#requestTimeStamp = Date.now();
132
134
  this.#reportType = HTTP_REQUEST_TYPE.HYBRID;
133
135
  window.XWebView.callNative(
134
136
  'ColorQueryPlugin',
135
137
  'colorRequest',
136
138
  JSON.stringify(reqParams),
137
139
  callbackFunction,
138
140
  '1',
139
141
  );
140
142
  window[callbackFunction] = (result) => {
141
143
  this.#responseTimeStamp = Date.now();
142
144
  try {
143
145
  const resultObj = typeof result === 'string' ? JSON.parse(result) : result;
144
146
  resolve(resultObj);
145
147
  } catch (error) {
146
148
  const errMsg = 'hybrid网络请求JSON解析失败, error: ' + error;
147
149
  draBusinessCustomReport({
148
150
  type: `${HTTP_REQUEST_TYPE.HYBRID}_jsonParseError`,
149
151
  errMsg,
150
152
  result,
151
153
  });
152
154
  reject({ errMsg });
153
155
  }
154
156
  this._clearFunction(callbackFunction);
155
157
  };
156
158
  } catch (error) {
157
159
  reject({
158
160
  errMsg: 'hybrid网络请求,App下调用window.XWebView.callNative出错, error: ' + error,
159
161
  });
160
162
  }
161
163
  });
162
164
  }
163
165
 
164
166
  _generateCallbackFunction() {
165
167
  return `hybridHttpRequestCallback_${Date.now()}_${Math.ceil(Math.random() * 100000)}`;
166
168
  }
167
169
 
168
170
  _clearFunction(functionName: string) {
169
171
  try {
170
172
  delete window[functionName];
171
173
  } catch (e) {
172
174
  window[functionName] = undefined;
173
175
  }
174
176
  }
175
177
 
176
178
  async _prepareGatewayReqData(data: any, isColorVerify: boolean): Promise<any> {
177
179
  const { functionId } = data;
178
180
  console.log('获取当前是否需要color加固', isColorVerify, functionId);
179
181
  if (isColorVerify) {
180
182
  const { h5st } = await colorSign.paramsSign(data);
181
183
  h5st && (data.h5st = encodeURI(h5st));
182
184
  console.log(`${functionId}的apiReq_h5st===>:${h5st}`);
183
185
  }
184
186
  const { jsToken } = await colorSign.getFmInfo();
185
187
  console.log(`${functionId}的api jsToken指纹===>:${jsToken}`);
186
188
  jsToken && (data['x-api-eid-token'] = jsToken);
187
189
  return data;
188
190
  }
189
191
 
190
192
  _taroRequest(
191
193
  url: string,
192
194
  otherOpts: any,
193
195
  method: string,
194
196
  timeout: number,
195
197
  header: string,
196
198
  ): Promise<any> {
197
199
  const reqParam = {
198
200
  url,
199
201
  method,
200
202
  timeout,
201
203
  header,
202
204
  credentials: 'include',
203
205
  ...otherOpts,
204
206
  };
205
207
  this.#requestTimeStamp = Date.now();
206
208
  this.#reportType = HTTP_REQUEST_TYPE.TARO;
207
209
  return Taro.request(reqParam);
208
210
  }
209
211
 
210
212
  _reportRequestTime(url: string, data: any): void {
211
213
  this.#getResTimeStamp = Date.now();
212
214
  if (this.#reportType === HTTP_REQUEST_TYPE.TARO) {
213
215
  this.#responseTimeStamp = this.#getResTimeStamp;
214
216
  }
215
217
  draInterfaceCustomReport(
216
218
  {
217
219
  type: `${this.#reportType}_consumeTime`,
218
220
  url,
219
221
  functionId: data?.functionId,
220
222
  requestTimeStamp: this.#requestTimeStamp,
221
223
  responseTimeStamp: this.#responseTimeStamp,
222
224
  errMsg: `使用${this.#reportType}调用接口请求响应耗时`,
223
225
  source: 'remote',
224
226
  },
225
227
  {
226
228
  consumeTime: `${this.#responseTimeStamp - this.#requestTimeStamp}ms`,
227
229
  getResTime: `${this.#getResTimeStamp - this.#requestTimeStamp}ms`,
228
230
  },
229
231
  );
230
232
  }
231
233
 
232
234
  _handleReportInterfaceError(url: string, reqData: any, timeOut: any, res: any): void {
233
235
  const source = 'remote';
234
236
  const requestType = this.#reportType;
235
237
  let errorType = '';
236
238
  let subMsg = '';
237
239
  let reportFlag = false;
238
240
  if (res) {
239
241
  const { statusCode, data, status, resTimeoutState } = res;
240
242
  if (statusCode === 500 && resTimeoutState) {
241
243
  reportFlag = true;
242
244
  errorType = 'timeout';
243
245
  subMsg = `接口请求超时${timeOut}ms`;
244
246
  } else if ((statusCode === 200 || status === '0') && data) {
245
247
  const resCode = Object.prototype.hasOwnProperty.call(data, 'code') ? Number(data.code) : -1;
246
248
  const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
247
249
  ? Number(data.subCode)
248
250
  : -1;
249
251
  const isSuccess =
250
252
  data.success === true ||
251
253
  data.isSuccess ||
252
254
  resCode === 0 ||
253
255
  resCode === 200 ||
254
256
  subCode === 0;
255
257
  if (!isSuccess && resCode !== 3) {
256
258
  reportFlag = true;
257
259
  errorType = 'dataError';
258
260
  subMsg = '接口请求返回数据异常';
259
261
  }
260
262
  } else {
261
263
  reportFlag = true;
262
264
  errorType = 'statusError';
263
265
  subMsg = '接口请求错误,h5请求statusCode非200,或hybrid请求status非0,或未返回data字段';
264
266
  }
265
267
  }
266
268
  reportFlag &&
267
269
  draInterfaceCustomReport({
268
270
  subMsg,
269
271
  url,
270
272
  source,
271
273
  requestType,
272
274
  errorType,
273
275
  functionId: reqData?.functionId,
274
276
  appid: reqData?.appId,
275
277
  client: reqData?.client,
276
278
  clientVersion: reqData?.clientVersion,
277
279
  statusCode: res?.statusCode,
278
280
  status: res?.status,
279
281
  code: res?.data?.code || res?.data?.subCode,
280
282
  errMsg: res?.errMsg || res?.msg || res?.message || res?.data?.echo,
281
283
  originReqDataStr: JSON.stringify(reqData),
282
284
  originResDataStr: JSON.stringify(res),
283
285
  });
284
286
  }
@@ -0,0 +1 @@
1
+ import H5Http from "./h5Http"