qsh-webview-sdk 2.3.9 → 2.4.0

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/README.md CHANGED
@@ -588,37 +588,6 @@ qsh.createBLEConnection({
588
588
  });
589
589
  ```
590
590
 
591
-
592
- ### 微信分享(仅 APP)
593
-
594
- ```javascript
595
- // 分享到微信
596
- qsh.shareToWeixin({
597
- type: 'webpage', // 分享类型:text, image, webpage, music, video
598
- title: '分享标题',
599
- description: '分享描述',
600
- webpageUrl: 'https://example.com',
601
- imageUrl: 'https://example.com/image.jpg',
602
- success: () => console.log('分享成功'),
603
- fail: (err) => console.error('分享失败:', err)
604
- });
605
- ```
606
-
607
- ### 文件选择(仅 APP)
608
-
609
- ```javascript
610
- // 选择文件
611
- qsh.chooseFile({
612
- type: 'all', // 文件类型:all, image, video, audio, file
613
- count: 1,
614
- success: (res) => {
615
- console.log('文件路径:', res.tempFilePaths);
616
- console.log('文件信息:', res.tempFiles);
617
- },
618
- fail: (err) => console.error(err)
619
- });
620
- ```
621
-
622
591
  ### 地图选择位置(仅 APP)
623
592
 
624
593
  ```javascript
@@ -696,8 +665,8 @@ qsh.manualShare({
696
665
  fail: (err) => console.error('分享失败:', err)
697
666
  });
698
667
  ```
699
- 对于isPublic:true时 用户点击分享的内容后会直接从基座首页跳转到h5Url, 对于isPublic:false时,基座完成登录流程后会携带参数h5Url=encodeURIComponent${h5Url}跳转到配置的h5首页
700
- 此方法会销毁当前H5页面并返回小程序基座,基座会将 h5Url 自动包装为小程序 webview 落地页
668
+ 对于isPublic:true时 用户点击分享的内容后会直接从基座首页跳转到h5Url, 对于isPublic:false时,基座完成登录流程后会携带参数h5Url=${encodeURIComponent(h5Url)}跳转到业务配置的h5首页, 在h5首页获取code和h5Url后根据需要自行处理登录逻辑和跳转
669
+ 此方法会销毁当前H5页面并返回小程序基座
701
670
 
702
671
  ## License
703
672
 
package/dist/index.d.ts CHANGED
@@ -301,6 +301,8 @@ declare namespace UniWebView {
301
301
  kind: "web" | "text" | "image";
302
302
  scene?: 0 | 1 | ShareUniversalScene;
303
303
  payload: ShareUniversalPayload;
304
+ /** 原样透传给宿主 message 的自定义字段,不参与 SDK 默认分享参数组装 */
305
+ rowCustom?: any;
304
306
  success?: (res: ShareResult) => void;
305
307
  fail?: (error: any) => void;
306
308
  complete?: () => void;
@@ -328,6 +330,8 @@ declare namespace UniWebView {
328
330
 
329
331
  interface ShareMiniProgramCardOptions {
330
332
  payload: ShareMiniProgramCardPayload;
333
+ /** 原样透传给宿主 message 的自定义字段,不参与 SDK 默认分享参数组装 */
334
+ rowCustom?: any;
331
335
  success?: (res: ShareResult) => void;
332
336
  fail?: (error: any) => void;
333
337
  complete?: () => void;
@@ -4029,8 +4029,8 @@ function Tt(t, e = "share") {
4029
4029
  throw { errMsg: `当前微信小程序容器未注入 postMessage 能力,无法发起 ${e}`, code: "MINIPROGRAM_BRIDGE_UNAVAILABLE" };
4030
4030
  r.postMessage({ data: t });
4031
4031
  }
4032
- function li(t) {
4033
- return { type: "qsh_api_call", api: "shareDirected", params: { miniProgramShare: oi(t) }, timestamp: Date.now() };
4032
+ function li(t, e) {
4033
+ return { type: "qsh_api_call", api: "shareDirected", params: { miniProgramShare: oi(t), rowCustom: e }, timestamp: Date.now() };
4034
4034
  }
4035
4035
  function fi(t = {}) {
4036
4036
  if (!t || typeof t != "object")
@@ -4071,8 +4071,8 @@ function hi(t) {
4071
4071
  }
4072
4072
  };
4073
4073
  }
4074
- function mi(t) {
4075
- return { type: "qsh_api_call", api: "shareMiniProgramCard", params: { miniProgramShare: gi(t) }, timestamp: Date.now() };
4074
+ function mi(t, e) {
4075
+ return { type: "qsh_api_call", api: "shareMiniProgramCard", params: { miniProgramShare: gi(t), rowCustom: e }, timestamp: Date.now() };
4076
4076
  }
4077
4077
  function pi(t) {
4078
4078
  return y(this, null, function* () {
@@ -4082,45 +4082,48 @@ function pi(t) {
4082
4082
  });
4083
4083
  }
4084
4084
  function bt(t = {}) {
4085
- return f.safeExecute(() => {
4086
- var s, o, d, u, m, C, M, $, ce, R, F;
4087
- let e;
4088
- try {
4089
- e = ai(t);
4090
- } catch (w) {
4091
- return (s = t.fail) == null || s.call(t, w), Promise.reject(w);
4092
- }
4093
- const r = H(!0);
4094
- try {
4095
- e = si(e, r);
4096
- } catch (w) {
4097
- return (o = e.fail) == null || o.call(e, w), (d = e.complete) == null || d.call(e, w), Promise.reject(w);
4098
- }
4099
- const n = ii(r);
4100
- if (r.isAppPlus)
4101
- return ui(e).then((w) => {
4102
- var ue, je;
4103
- const B = p(g({}, (w == null ? void 0 : w.data) || {}), { hint: n });
4104
- return (ue = e.success) == null || ue.call(e, B), (je = e.complete) == null || je.call(e, B), B;
4105
- }).catch((w) => {
4106
- var B, ue;
4107
- return (B = e.fail) == null || B.call(e, w), (ue = e.complete) == null || ue.call(e, w), Promise.reject(w);
4108
- });
4109
- if (r.isWeixinMiniProgram)
4085
+ return f.safeExecute(
4086
+ () => {
4087
+ var s, o, d, u, m, C, M, $, ce, R, F;
4088
+ let e;
4110
4089
  try {
4111
- Tt(li(e), "shareDirected");
4112
- const w = { success: !0, hint: n };
4113
- return (u = e.success) == null || u.call(e, w), (m = e.complete) == null || m.call(e, w), Promise.resolve(w);
4090
+ e = ai(t);
4114
4091
  } catch (w) {
4115
- return (C = e.fail) == null || C.call(e, w), (M = e.complete) == null || M.call(e, w), Promise.reject(w);
4092
+ return (s = t.fail) == null || s.call(t, w), Promise.reject(w);
4116
4093
  }
4117
- if (r.type === "h5" && !r.isUniAppWebView && !r.isOfflineWebview) {
4118
- const w = { errMsg: "当前页面不在宿主 WebView 中,无法分享。请在 unified-platform-app 内打开该 H5 再重试。", code: "NOT_IN_CONTAINER" };
4119
- return ($ = e.fail) == null || $.call(e, w), (ce = e.complete) == null || ce.call(e, w), Promise.reject(w);
4120
- }
4121
- const i = { errMsg: "当前环境暂不支持 shareDirected,请在 App 或微信小程序容器内使用。", code: "ENV_NOT_SUPPORTED" };
4122
- return (R = e.fail) == null || R.call(e, i), (F = e.complete) == null || F.call(e, i), Promise.reject(i);
4123
- }, { context: "shareDirected", options: t });
4094
+ const r = H(!0);
4095
+ try {
4096
+ e = si(e, r);
4097
+ } catch (w) {
4098
+ return (o = e.fail) == null || o.call(e, w), (d = e.complete) == null || d.call(e, w), Promise.reject(w);
4099
+ }
4100
+ const n = ii(r);
4101
+ if (r.isAppPlus)
4102
+ return ui(e).then((w) => {
4103
+ var ue, je;
4104
+ const B = p(g({}, (w == null ? void 0 : w.data) || {}), { hint: n });
4105
+ return (ue = e.success) == null || ue.call(e, B), (je = e.complete) == null || je.call(e, B), B;
4106
+ }).catch((w) => {
4107
+ var B, ue;
4108
+ return (B = e.fail) == null || B.call(e, w), (ue = e.complete) == null || ue.call(e, w), Promise.reject(w);
4109
+ });
4110
+ if (r.isWeixinMiniProgram)
4111
+ try {
4112
+ Tt(li(e, t.rowCustom), "shareDirected");
4113
+ const w = { success: !0, hint: n };
4114
+ return (u = e.success) == null || u.call(e, w), (m = e.complete) == null || m.call(e, w), Promise.resolve(w);
4115
+ } catch (w) {
4116
+ return (C = e.fail) == null || C.call(e, w), (M = e.complete) == null || M.call(e, w), Promise.reject(w);
4117
+ }
4118
+ if (r.type === "h5" && !r.isUniAppWebView && !r.isOfflineWebview) {
4119
+ const w = { errMsg: "当前页面不在宿主 WebView 中,无法分享。请在 unified-platform-app 内打开该 H5 再重试。", code: "NOT_IN_CONTAINER" };
4120
+ return ($ = e.fail) == null || $.call(e, w), (ce = e.complete) == null || ce.call(e, w), Promise.reject(w);
4121
+ }
4122
+ const i = { errMsg: "当前环境暂不支持 shareDirected,请在 App 或微信小程序容器内使用。", code: "ENV_NOT_SUPPORTED" };
4123
+ return (R = e.fail) == null || R.call(e, i), (F = e.complete) == null || F.call(e, i), Promise.reject(i);
4124
+ },
4125
+ { context: "shareDirected", options: t }
4126
+ );
4124
4127
  }
4125
4128
  function wi(t = {}) {
4126
4129
  return new Promise((e, r) => {
@@ -4128,42 +4131,45 @@ function wi(t = {}) {
4128
4131
  });
4129
4132
  }
4130
4133
  function vt(t = {}) {
4131
- return f.safeExecute(() => {
4132
- var s, o, d, u, m, C, M, $, ce;
4133
- let e;
4134
- try {
4135
- e = fi(t);
4136
- } catch (R) {
4137
- return (s = t.fail) == null || s.call(t, R), Promise.reject(R);
4138
- }
4139
- const r = H(!0);
4140
- if (r.isAppPlus)
4141
- try {
4142
- e = di(e);
4143
- } catch (R) {
4144
- return (o = e.fail) == null || o.call(e, R), (d = e.complete) == null || d.call(e, R), Promise.reject(R);
4145
- }
4146
- const n = r.isWeixinMiniProgram ? "已同步小程序卡片内容,请点击右上角“···”后发送给朋友。" : "正在拉起微信发送给朋友面板,请继续完成小程序卡片分享。";
4147
- if (r.isAppPlus)
4148
- return pi(e).then((R) => {
4149
- var w, B;
4150
- const F = p(g({}, R || {}), { hint: n });
4151
- return (w = e.success) == null || w.call(e, F), (B = e.complete) == null || B.call(e, F), F;
4152
- }).catch((R) => {
4153
- var F, w;
4154
- return (F = e.fail) == null || F.call(e, R), (w = e.complete) == null || w.call(e, R), Promise.reject(R);
4155
- });
4156
- if (r.isWeixinMiniProgram)
4134
+ return f.safeExecute(
4135
+ () => {
4136
+ var s, o, d, u, m, C, M, $, ce;
4137
+ let e;
4157
4138
  try {
4158
- Tt(mi(e), "shareMiniProgramCard");
4159
- const R = { success: !0, hint: n };
4160
- return (u = e.success) == null || u.call(e, R), (m = e.complete) == null || m.call(e, R), Promise.resolve(R);
4139
+ e = fi(t);
4161
4140
  } catch (R) {
4162
- return (C = e.fail) == null || C.call(e, R), (M = e.complete) == null || M.call(e, R), Promise.reject(R);
4141
+ return (s = t.fail) == null || s.call(t, R), Promise.reject(R);
4163
4142
  }
4164
- const i = { errMsg: "当前环境暂不支持 shareMiniProgramCard,请在 App 或微信小程序容器内使用。", code: "ENV_NOT_SUPPORTED" };
4165
- return ($ = e.fail) == null || $.call(e, i), (ce = e.complete) == null || ce.call(e, i), Promise.reject(i);
4166
- }, { context: "shareMiniProgramCard", options: t });
4143
+ const r = H(!0);
4144
+ if (r.isAppPlus)
4145
+ try {
4146
+ e = di(e);
4147
+ } catch (R) {
4148
+ return (o = e.fail) == null || o.call(e, R), (d = e.complete) == null || d.call(e, R), Promise.reject(R);
4149
+ }
4150
+ const n = r.isWeixinMiniProgram ? "已同步小程序卡片内容,请点击右上角“···”后发送给朋友。" : "正在拉起微信发送给朋友面板,请继续完成小程序卡片分享。";
4151
+ if (r.isAppPlus)
4152
+ return pi(e).then((R) => {
4153
+ var w, B;
4154
+ const F = p(g({}, R || {}), { hint: n });
4155
+ return (w = e.success) == null || w.call(e, F), (B = e.complete) == null || B.call(e, F), F;
4156
+ }).catch((R) => {
4157
+ var F, w;
4158
+ return (F = e.fail) == null || F.call(e, R), (w = e.complete) == null || w.call(e, R), Promise.reject(R);
4159
+ });
4160
+ if (r.isWeixinMiniProgram)
4161
+ try {
4162
+ Tt(mi(e, t.rowCustom), "shareMiniProgramCard");
4163
+ const R = { success: !0, hint: n };
4164
+ return (u = e.success) == null || u.call(e, R), (m = e.complete) == null || m.call(e, R), Promise.resolve(R);
4165
+ } catch (R) {
4166
+ return (C = e.fail) == null || C.call(e, R), (M = e.complete) == null || M.call(e, R), Promise.reject(R);
4167
+ }
4168
+ const i = { errMsg: "当前环境暂不支持 shareMiniProgramCard,请在 App 或微信小程序容器内使用。", code: "ENV_NOT_SUPPORTED" };
4169
+ return ($ = e.fail) == null || $.call(e, i), (ce = e.complete) == null || ce.call(e, i), Promise.reject(i);
4170
+ },
4171
+ { context: "shareMiniProgramCard", options: t }
4172
+ );
4167
4173
  }
4168
4174
  function Ei(t = {}) {
4169
4175
  return new Promise((e, r) => {