@kbapp/market-partner-sdk 0.0.5 → 0.0.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.
- package/dist/index.es.js +129 -126
- package/dist/index.umd.js +1 -1
- package/dist/util/filter-undefined-properties.d.ts +3 -5
- package/examples/index.html +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
function R(e) {
|
|
2
|
+
if (Object.prototype.toString.call(e) !== "[object Object]")
|
|
3
|
+
return e;
|
|
4
|
+
const n = {};
|
|
5
|
+
return Object.keys(e).forEach((o) => {
|
|
6
|
+
const r = e[o];
|
|
7
|
+
r != null && (n[o] = Object.prototype.toString.call(r) === "[object Object]" ? R(r) : r);
|
|
8
|
+
}), n;
|
|
9
|
+
}
|
|
1
10
|
const l = class l {
|
|
2
|
-
constructor(
|
|
3
|
-
this.errorCode =
|
|
11
|
+
constructor(n) {
|
|
12
|
+
this.errorCode = n.errorCode, this.errorMsg = n.errorMsg;
|
|
4
13
|
}
|
|
5
14
|
};
|
|
6
15
|
l.UNKNOWN = new l({
|
|
@@ -17,46 +26,46 @@ l.UNKNOWN = new l({
|
|
|
17
26
|
errorMsg: "请在开吧app内执行"
|
|
18
27
|
});
|
|
19
28
|
let f = l;
|
|
20
|
-
const
|
|
21
|
-
const e = (t,
|
|
29
|
+
const k = () => {
|
|
30
|
+
const e = (t, s, i) => {
|
|
22
31
|
var a = "";
|
|
23
|
-
typeof
|
|
24
|
-
var
|
|
25
|
-
if (typeof
|
|
32
|
+
typeof s == "function" && (i = s, s = {});
|
|
33
|
+
var c = { data: s === void 0 ? null : s };
|
|
34
|
+
if (typeof i == "function") {
|
|
26
35
|
var v = "dscb" + window.dscb++;
|
|
27
|
-
window[v] =
|
|
36
|
+
window[v] = i, c._dscbstub = v;
|
|
28
37
|
}
|
|
29
|
-
if (
|
|
38
|
+
if (c = JSON.stringify(c), window.flutter_inappwebview ? window.flutter_inappwebview.callHandler && (a = window.flutter_inappwebview.callHandler("" + t, c)) : (window._dswk || navigator.userAgent.indexOf("_dsbridge") != -1) && (a = prompt("_flutterDsbridge=" + t, c)), a instanceof Promise)
|
|
30
39
|
return a;
|
|
31
40
|
try {
|
|
32
41
|
return JSON.parse(a || "{}").data;
|
|
33
42
|
} catch {
|
|
34
43
|
console.error("callHandle异常,JSON.parse错误");
|
|
35
44
|
}
|
|
36
|
-
},
|
|
37
|
-
const t = [],
|
|
38
|
-
|
|
39
|
-
e.apply(window,
|
|
45
|
+
}, n = () => window.navigator.userAgent.includes("Android") ? window.flutter_inappwebview && window.flutter_inappwebview._platformReady : !0, o = (() => {
|
|
46
|
+
const t = [], s = setInterval(() => {
|
|
47
|
+
n() && (clearInterval(s), t.forEach((i) => {
|
|
48
|
+
e.apply(window, i);
|
|
40
49
|
}), t.length = 0);
|
|
41
50
|
}, 500);
|
|
42
|
-
return (...
|
|
43
|
-
t.push(
|
|
51
|
+
return (...i) => {
|
|
52
|
+
t.push(i);
|
|
44
53
|
};
|
|
45
54
|
})();
|
|
46
|
-
var
|
|
55
|
+
var r = {
|
|
47
56
|
default: void 0,
|
|
48
57
|
// for typescript
|
|
49
|
-
callHandler: function(t,
|
|
50
|
-
return
|
|
58
|
+
callHandler: function(t, s, i) {
|
|
59
|
+
return n() ? e(t, s, i) : o(t, s, i);
|
|
51
60
|
},
|
|
52
|
-
register: function(t,
|
|
53
|
-
var a =
|
|
61
|
+
register: function(t, s, i) {
|
|
62
|
+
var a = i ? window._dsaf : window._dsf;
|
|
54
63
|
window._dsInit || (window._dsInit = !0, setTimeout(function() {
|
|
55
|
-
|
|
56
|
-
}, 0)), typeof
|
|
64
|
+
r.callHandler("_dsb.dsinit");
|
|
65
|
+
}, 0)), typeof s == "object" ? a._obs[t] = s : a[t] = s;
|
|
57
66
|
},
|
|
58
|
-
registerHandler: function(t,
|
|
59
|
-
this.register(t,
|
|
67
|
+
registerHandler: function(t, s) {
|
|
68
|
+
this.register(t, s, !0);
|
|
60
69
|
}
|
|
61
70
|
};
|
|
62
71
|
return (function() {
|
|
@@ -71,119 +80,119 @@ const T = () => {
|
|
|
71
80
|
_obs: {}
|
|
72
81
|
},
|
|
73
82
|
dscb: 0,
|
|
74
|
-
jsBridge:
|
|
75
|
-
_handleMessageFromNative: function(
|
|
76
|
-
var a = JSON.parse(
|
|
77
|
-
id:
|
|
83
|
+
jsBridge: r,
|
|
84
|
+
_handleMessageFromNative: function(i) {
|
|
85
|
+
var a = JSON.parse(i.data), c = {
|
|
86
|
+
id: i.callbackId,
|
|
78
87
|
complete: !0
|
|
79
|
-
}, v = this._dsf[
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
a.push(function(
|
|
83
|
-
|
|
84
|
-
}),
|
|
88
|
+
}, v = this._dsf[i.method], _ = this._dsaf[i.method], S = function(E, m) {
|
|
89
|
+
c.data = E.apply(m, a), r.callHandler("_dsb.returnValue", c);
|
|
90
|
+
}, O = function(E, m) {
|
|
91
|
+
a.push(function(I, T) {
|
|
92
|
+
c.data = I, c.complete = T !== !1, r.callHandler("_dsb.returnValue", c);
|
|
93
|
+
}), E.apply(m, a);
|
|
85
94
|
};
|
|
86
95
|
if (v)
|
|
87
96
|
S(v, this._dsf);
|
|
88
97
|
else if (_)
|
|
89
|
-
|
|
98
|
+
O(_, this._dsaf);
|
|
90
99
|
else {
|
|
91
|
-
var A =
|
|
100
|
+
var A = i.method.split(".");
|
|
92
101
|
if (A.length < 2) return;
|
|
93
|
-
var
|
|
102
|
+
var b = A.pop(), N = A.join("."), g = this._dsf._obs, y = g[N] || {}, w = y[b];
|
|
94
103
|
if (w && typeof w == "function") {
|
|
95
104
|
S(w, y);
|
|
96
105
|
return;
|
|
97
106
|
}
|
|
98
|
-
if (g = this._dsaf._obs, y = g[
|
|
99
|
-
|
|
107
|
+
if (g = this._dsaf._obs, y = g[N] || {}, w = y[b], w && typeof w == "function") {
|
|
108
|
+
O(w, y);
|
|
100
109
|
return;
|
|
101
110
|
}
|
|
102
111
|
}
|
|
103
112
|
}
|
|
104
113
|
};
|
|
105
|
-
for (var
|
|
106
|
-
window[
|
|
114
|
+
for (var s in t)
|
|
115
|
+
window[s] = t[s];
|
|
107
116
|
}
|
|
108
|
-
})(),
|
|
109
|
-
}, P = ((e) => /(kb)/i.test(e) ?
|
|
110
|
-
registerHandler(
|
|
117
|
+
})(), r;
|
|
118
|
+
}, P = ((e) => /(kb)/i.test(e) ? k() : {
|
|
119
|
+
registerHandler(n, o) {
|
|
111
120
|
throw f.UNSUPPORTED_BRIDGE_ENV;
|
|
112
121
|
},
|
|
113
|
-
callHandler(
|
|
122
|
+
callHandler(n, o, r) {
|
|
114
123
|
throw f.UNSUPPORTED_BRIDGE_ENV;
|
|
115
124
|
}
|
|
116
|
-
})(window?.navigator?.userAgent),
|
|
125
|
+
})(window?.navigator?.userAgent), H = (e) => new Promise((n, o) => {
|
|
117
126
|
try {
|
|
118
|
-
P.registerHandler(e.name, e.handler), e.success?.(),
|
|
119
|
-
} catch (
|
|
120
|
-
e.fail?.(
|
|
127
|
+
P.registerHandler(e.name, e.handler), e.success?.(), n();
|
|
128
|
+
} catch (r) {
|
|
129
|
+
e.fail?.(r), o(r);
|
|
121
130
|
} finally {
|
|
122
131
|
e.complete?.();
|
|
123
132
|
}
|
|
124
133
|
});
|
|
125
134
|
function d(e) {
|
|
126
|
-
const
|
|
127
|
-
let
|
|
128
|
-
const t = (
|
|
129
|
-
(!
|
|
130
|
-
},
|
|
131
|
-
(!
|
|
135
|
+
const n = (o) => {
|
|
136
|
+
let r;
|
|
137
|
+
const t = (i) => {
|
|
138
|
+
(!r || r === "success") && (r = "success", o.success?.(i));
|
|
139
|
+
}, s = (i) => {
|
|
140
|
+
(!r || r === "error") && (r = "error", o.fail?.(i));
|
|
132
141
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
},
|
|
142
|
+
o.timeout && setTimeout(() => {
|
|
143
|
+
s(f.TIMEOUT);
|
|
144
|
+
}, o.timeout);
|
|
136
145
|
try {
|
|
137
|
-
P.callHandler(
|
|
146
|
+
P.callHandler(o.name, o.params, (i) => {
|
|
138
147
|
let a;
|
|
139
148
|
try {
|
|
140
|
-
a = typeof
|
|
149
|
+
a = typeof i == "string" ? JSON.parse(i.replace(/\n/g, "\\n").replace(/\r/g, "\\r")) : i;
|
|
141
150
|
} catch {
|
|
142
151
|
a = null;
|
|
143
152
|
}
|
|
144
153
|
t(a);
|
|
145
154
|
});
|
|
146
|
-
} catch (
|
|
147
|
-
|
|
155
|
+
} catch (i) {
|
|
156
|
+
s(i);
|
|
148
157
|
}
|
|
149
158
|
};
|
|
150
|
-
return new Promise((
|
|
151
|
-
|
|
159
|
+
return new Promise((o, r) => {
|
|
160
|
+
n({
|
|
152
161
|
name: e.name,
|
|
153
|
-
params: e.params,
|
|
162
|
+
params: R(e.params),
|
|
154
163
|
timeout: e.timeout,
|
|
155
164
|
success: (t) => {
|
|
156
|
-
e.success?.(t), e.complete?.(),
|
|
165
|
+
e.success?.(t), e.complete?.(), o(t);
|
|
157
166
|
},
|
|
158
167
|
fail: (t) => {
|
|
159
|
-
e.fail?.(t), e.complete?.(),
|
|
168
|
+
e.fail?.(t), e.complete?.(), r(t);
|
|
160
169
|
}
|
|
161
170
|
});
|
|
162
171
|
});
|
|
163
172
|
}
|
|
164
173
|
const q = /(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent);
|
|
165
|
-
function
|
|
166
|
-
return new Promise(async (
|
|
174
|
+
function u(e, n) {
|
|
175
|
+
return new Promise(async (o, r) => {
|
|
167
176
|
try {
|
|
168
|
-
const t = await
|
|
169
|
-
e.success?.(t),
|
|
177
|
+
const t = await n();
|
|
178
|
+
e.success?.(t), o(t);
|
|
170
179
|
} catch (t) {
|
|
171
|
-
const
|
|
172
|
-
e.fail?.(
|
|
180
|
+
const s = t?.errorCode ? t : new f({ errorCode: f.UNKNOWN.errorCode, errorMsg: String(t) });
|
|
181
|
+
e.fail?.(s), r(s);
|
|
173
182
|
} finally {
|
|
174
183
|
e.complete?.();
|
|
175
184
|
}
|
|
176
185
|
});
|
|
177
186
|
}
|
|
178
187
|
function V(e) {
|
|
179
|
-
let
|
|
180
|
-
return function(...
|
|
181
|
-
return
|
|
182
|
-
|
|
183
|
-
}),
|
|
188
|
+
let n;
|
|
189
|
+
return function(...o) {
|
|
190
|
+
return n || (n = e(...o), Promise.resolve(n).catch(() => {
|
|
191
|
+
n = void 0;
|
|
192
|
+
}), n);
|
|
184
193
|
};
|
|
185
194
|
}
|
|
186
|
-
const
|
|
195
|
+
const M = V(() => d({
|
|
187
196
|
name: "OpenActRequest",
|
|
188
197
|
params: {
|
|
189
198
|
// 这个函数只能使用35, 而不能使用新提供的60001, 这是因为写这个sdk的时候, 60001 也没有提供!!!
|
|
@@ -191,20 +200,20 @@ const H = V(() => d({
|
|
|
191
200
|
data: {}
|
|
192
201
|
}
|
|
193
202
|
}));
|
|
194
|
-
function
|
|
195
|
-
return
|
|
203
|
+
function U(e) {
|
|
204
|
+
return u(e, async () => (await M()).vcode >= e.minVersion);
|
|
196
205
|
}
|
|
197
|
-
function p(e,
|
|
198
|
-
return (...
|
|
206
|
+
function p(e, n) {
|
|
207
|
+
return (...o) => U({
|
|
199
208
|
minVersion: e.minVersion
|
|
200
|
-
}).then((
|
|
209
|
+
}).then((r) => r ? n(...o) : Promise.reject(new f({
|
|
201
210
|
errorCode: f.UNSUPPORTED_VERSION.errorCode,
|
|
202
211
|
errorMsg: `最低版本要求${e.minVersion}`
|
|
203
212
|
})));
|
|
204
213
|
}
|
|
205
214
|
class D {
|
|
206
215
|
}
|
|
207
|
-
const C = V((e) =>
|
|
216
|
+
const C = V((e) => u(
|
|
208
217
|
e || {},
|
|
209
218
|
p({ minVersion: 80805 }, () => d({
|
|
210
219
|
name: "OpenActRequest",
|
|
@@ -214,36 +223,27 @@ const C = V((e) => c(
|
|
|
214
223
|
}
|
|
215
224
|
}))
|
|
216
225
|
));
|
|
217
|
-
function
|
|
218
|
-
|
|
219
|
-
return {};
|
|
220
|
-
const r = {};
|
|
221
|
-
return Object.keys(e).forEach((i) => {
|
|
222
|
-
const s = e[i];
|
|
223
|
-
s !== void 0 && (r[i] = s);
|
|
224
|
-
}), r;
|
|
225
|
-
}
|
|
226
|
-
function J(e) {
|
|
227
|
-
return c(
|
|
226
|
+
function j(e) {
|
|
227
|
+
return u(
|
|
228
228
|
e,
|
|
229
229
|
p({ minVersion: 80805 }, async () => d({
|
|
230
230
|
name: "OpenActRequest",
|
|
231
231
|
params: {
|
|
232
232
|
type: 60400,
|
|
233
|
-
data:
|
|
233
|
+
data: {
|
|
234
234
|
/** 事件名 */
|
|
235
235
|
eventId: e.eventName,
|
|
236
236
|
/** 上报值 */
|
|
237
237
|
trackParams: e.eventParams,
|
|
238
238
|
/** 开始结束类型传递 */
|
|
239
239
|
ExtEventType: e.eventType
|
|
240
|
-
}
|
|
240
|
+
}
|
|
241
241
|
}
|
|
242
242
|
}))
|
|
243
243
|
);
|
|
244
244
|
}
|
|
245
|
-
function
|
|
246
|
-
return
|
|
245
|
+
function J(e) {
|
|
246
|
+
return u(
|
|
247
247
|
{ ...e },
|
|
248
248
|
p({ minVersion: 80805 }, async () => d({
|
|
249
249
|
name: "OpenActRequest",
|
|
@@ -254,7 +254,7 @@ function B(e) {
|
|
|
254
254
|
}))
|
|
255
255
|
);
|
|
256
256
|
}
|
|
257
|
-
const
|
|
257
|
+
const B = (e) => u(
|
|
258
258
|
e,
|
|
259
259
|
p({ minVersion: 80805 }, async () => d({
|
|
260
260
|
name: "OpenActRequest",
|
|
@@ -264,18 +264,18 @@ const x = (e) => c(
|
|
|
264
264
|
}
|
|
265
265
|
}))
|
|
266
266
|
), h = "SHARE_EVENT_NAME";
|
|
267
|
-
class
|
|
267
|
+
class x {
|
|
268
268
|
}
|
|
269
|
-
function
|
|
270
|
-
return
|
|
269
|
+
function G(e) {
|
|
270
|
+
return u(e, async () => H({
|
|
271
271
|
name: "CommonShare",
|
|
272
|
-
handler(
|
|
273
|
-
window.dispatchEvent(new Event(h)), "onShareApp" in e && e.onShareApp ?
|
|
272
|
+
handler(n, o) {
|
|
273
|
+
window.dispatchEvent(new Event(h)), "onShareApp" in e && e.onShareApp ? o({ type: 12, data: e.onShareApp() }) : o({ type: 12, data: e });
|
|
274
274
|
}
|
|
275
275
|
}));
|
|
276
276
|
}
|
|
277
|
-
function
|
|
278
|
-
return
|
|
277
|
+
function K(e) {
|
|
278
|
+
return u(
|
|
279
279
|
e,
|
|
280
280
|
p({ minVersion: 80805 }, async () => (window.dispatchEvent(new Event(h)), d({
|
|
281
281
|
name: "OpenActRequest",
|
|
@@ -286,15 +286,15 @@ function W(e) {
|
|
|
286
286
|
})))
|
|
287
287
|
);
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function W(e) {
|
|
290
290
|
return window.addEventListener(h, e), () => {
|
|
291
291
|
window.removeEventListener(h, e);
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
|
-
class
|
|
294
|
+
class $ {
|
|
295
295
|
}
|
|
296
296
|
async function F(e) {
|
|
297
|
-
return
|
|
297
|
+
return u(
|
|
298
298
|
e || {},
|
|
299
299
|
p({ minVersion: 80805 }, async () => (await d({
|
|
300
300
|
name: "OpenActRequest",
|
|
@@ -303,7 +303,7 @@ async function F(e) {
|
|
|
303
303
|
);
|
|
304
304
|
}
|
|
305
305
|
function L(e) {
|
|
306
|
-
return
|
|
306
|
+
return u(
|
|
307
307
|
e || {},
|
|
308
308
|
p({ minVersion: 80805 }, async () => (await d({
|
|
309
309
|
name: "OpenActRequest",
|
|
@@ -312,41 +312,44 @@ function L(e) {
|
|
|
312
312
|
);
|
|
313
313
|
}
|
|
314
314
|
async function z(e) {
|
|
315
|
-
return
|
|
315
|
+
return u(
|
|
316
316
|
e || {},
|
|
317
317
|
p({ minVersion: 80805 }, async () => (await d({
|
|
318
318
|
name: "OpenActRequest",
|
|
319
|
-
params: { type: 60201 }
|
|
319
|
+
params: { type: 60201, data: e }
|
|
320
320
|
})).data)
|
|
321
321
|
);
|
|
322
322
|
}
|
|
323
323
|
function Q(e) {
|
|
324
|
-
return
|
|
324
|
+
return u(
|
|
325
325
|
e || {},
|
|
326
326
|
p({ minVersion: 80805 }, async () => (await d({
|
|
327
327
|
name: "OpenActRequest",
|
|
328
|
-
params: {
|
|
328
|
+
params: {
|
|
329
|
+
type: 60210,
|
|
330
|
+
data: e
|
|
331
|
+
}
|
|
329
332
|
})).data)
|
|
330
333
|
);
|
|
331
334
|
}
|
|
332
335
|
export {
|
|
333
336
|
D as AppBaseInfo,
|
|
334
|
-
|
|
335
|
-
|
|
337
|
+
x as AppShareModel,
|
|
338
|
+
$ as AuthResult,
|
|
336
339
|
f as BridgeCode,
|
|
337
340
|
q as IS_KB_APP_ENV,
|
|
338
|
-
|
|
341
|
+
G as defineAppShareModel,
|
|
339
342
|
C as getAppBaseInfo,
|
|
340
343
|
F as getAuthToken,
|
|
341
344
|
L as getAuthTokenWithSilent,
|
|
342
345
|
d as invokeNativeApi,
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
346
|
+
U as isAppVersionSupport,
|
|
347
|
+
W as onAppSharePanelShow,
|
|
348
|
+
K as openAppSharePanel,
|
|
349
|
+
H as registerNativeApiHandler,
|
|
350
|
+
j as reportDAEvent,
|
|
348
351
|
z as requestPayment,
|
|
349
352
|
Q as requestRefund,
|
|
350
|
-
|
|
351
|
-
|
|
353
|
+
J as runAction,
|
|
354
|
+
B as shareImage
|
|
352
355
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,
|
|
1
|
+
(function(s,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(s=typeof globalThis<"u"?globalThis:s||self,v(s.kbMarket={}))})(this,(function(s){"use strict";function v(e){if(Object.prototype.toString.call(e)!=="[object Object]")return e;const n={};return Object.keys(e).forEach(o=>{const r=e[o];r!=null&&(n[o]=Object.prototype.toString.call(r)==="[object Object]"?v(r):r)}),n}const p=class p{constructor(n){this.errorCode=n.errorCode,this.errorMsg=n.errorMsg}};p.UNKNOWN=new p({errorCode:1e3,errorMsg:"未知错误"}),p.UNSUPPORTED_VERSION=new p({errorCode:1001,errorMsg:"当前开吧版本不支持"}),p.TIMEOUT=new p({errorCode:1002,errorMsg:"执行超时"}),p.UNSUPPORTED_BRIDGE_ENV=new p({errorCode:1003,errorMsg:"请在开吧app内执行"});let f=p;const M=()=>{const e=(t,a,i)=>{var u="";typeof a=="function"&&(i=a,a={});var c={data:a===void 0?null:a};if(typeof i=="function"){var A="dscb"+window.dscb++;window[A]=i,c._dscbstub=A}if(c=JSON.stringify(c),window.flutter_inappwebview?window.flutter_inappwebview.callHandler&&(u=window.flutter_inappwebview.callHandler(""+t,c)):(window._dswk||navigator.userAgent.indexOf("_dsbridge")!=-1)&&(u=prompt("_flutterDsbridge="+t,c)),u instanceof Promise)return u;try{return JSON.parse(u||"{}").data}catch{console.error("callHandle异常,JSON.parse错误")}},n=()=>window.navigator.userAgent.includes("Android")?window.flutter_inappwebview&&window.flutter_inappwebview._platformReady:!0,o=(()=>{const t=[],a=setInterval(()=>{n()&&(clearInterval(a),t.forEach(i=>{e.apply(window,i)}),t.length=0)},500);return(...i)=>{t.push(i)}})();var r={default:void 0,callHandler:function(t,a,i){return n()?e(t,a,i):o(t,a,i)},register:function(t,a,i){var u=i?window._dsaf:window._dsf;window._dsInit||(window._dsInit=!0,setTimeout(function(){r.callHandler("_dsb.dsinit")},0)),typeof a=="object"?u._obs[t]=a:u[t]=a},registerHandler:function(t,a){this.register(t,a,!0)}};return(function(){if(!window._dsf){var t={_dsf:{_obs:{}},_dsaf:{_obs:{}},dscb:0,jsBridge:r,_handleMessageFromNative:function(i){var u=JSON.parse(i.data),c={id:i.callbackId,complete:!0},A=this._dsf[i.method],g=this._dsaf[i.method],V=function(E,b){c.data=E.apply(b,u),r.callHandler("_dsb.returnValue",c)},I=function(E,b){u.push(function(X,Y){c.data=X,c.complete=Y!==!1,r.callHandler("_dsb.returnValue",c)}),E.apply(b,u)};if(A)V(A,this._dsf);else if(g)I(g,this._dsaf);else{var S=i.method.split(".");if(S.length<2)return;var T=S.pop(),k=S.join("."),m=this._dsf._obs,y=m[k]||{},h=y[T];if(h&&typeof h=="function"){V(h,y);return}if(m=this._dsaf._obs,y=m[k]||{},h=y[T],h&&typeof h=="function"){I(h,y);return}}}};for(var a in t)window[a]=t[a]}})(),r},N=(e=>/(kb)/i.test(e)?M():{registerHandler(n,o){throw f.UNSUPPORTED_BRIDGE_ENV},callHandler(n,o,r){throw f.UNSUPPORTED_BRIDGE_ENV}})(window?.navigator?.userAgent),O=e=>new Promise((n,o)=>{try{N.registerHandler(e.name,e.handler),e.success?.(),n()}catch(r){e.fail?.(r),o(r)}finally{e.complete?.()}});function l(e){const n=o=>{let r;const t=i=>{(!r||r==="success")&&(r="success",o.success?.(i))},a=i=>{(!r||r==="error")&&(r="error",o.fail?.(i))};o.timeout&&setTimeout(()=>{a(f.TIMEOUT)},o.timeout);try{N.callHandler(o.name,o.params,i=>{let u;try{u=typeof i=="string"?JSON.parse(i.replace(/\n/g,"\\n").replace(/\r/g,"\\r")):i}catch{u=null}t(u)})}catch(i){a(i)}};return new Promise((o,r)=>{n({name:e.name,params:v(e.params),timeout:e.timeout,success:t=>{e.success?.(t),e.complete?.(),o(t)},fail:t=>{e.fail?.(t),e.complete?.(),r(t)}})})}const H=/(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent);function d(e,n){return new Promise(async(o,r)=>{try{const t=await n();e.success?.(t),o(t)}catch(t){const a=t?.errorCode?t:new f({errorCode:f.UNKNOWN.errorCode,errorMsg:String(t)});e.fail?.(a),r(a)}finally{e.complete?.()}})}function P(e){let n;return function(...o){return n||(n=e(...o),Promise.resolve(n).catch(()=>{n=void 0}),n)}}const q=P(()=>l({name:"OpenActRequest",params:{type:35,data:{}}}));function R(e){return d(e,async()=>(await q()).vcode>=e.minVersion)}function w(e,n){return(...o)=>R({minVersion:e.minVersion}).then(r=>r?n(...o):Promise.reject(new f({errorCode:f.UNSUPPORTED_VERSION.errorCode,errorMsg:`最低版本要求${e.minVersion}`})))}class U{}const D=P(e=>d(e||{},w({minVersion:80805},()=>l({name:"OpenActRequest",params:{type:60001,data:{}}}))));function C(e){return d(e,w({minVersion:80805},async()=>l({name:"OpenActRequest",params:{type:60400,data:{eventId:e.eventName,trackParams:e.eventParams,ExtEventType:e.eventType}}})))}function j(e){return d({...e},w({minVersion:80805},async()=>l({name:"OpenActRequest",params:{type:60300,data:e}})))}const B=e=>d(e,w({minVersion:80805},async()=>l({name:"OpenActRequest",params:{type:60500,data:e}}))),_="SHARE_EVENT_NAME";class J{}function K(e){return d(e,async()=>O({name:"CommonShare",handler(n,o){window.dispatchEvent(new Event(_)),"onShareApp"in e&&e.onShareApp?o({type:12,data:e.onShareApp()}):o({type:12,data:e})}}))}function W(e){return d(e,w({minVersion:80805},async()=>(window.dispatchEvent(new Event(_)),l({name:"OpenActRequest",params:{type:60500,data:e}}))))}function G(e){return window.addEventListener(_,e),()=>{window.removeEventListener(_,e)}}class ${}async function F(e){return d(e||{},w({minVersion:80805},async()=>(await l({name:"OpenActRequest",params:{type:60101}})).data||null))}function L(e){return d(e||{},w({minVersion:80805},async()=>(await l({name:"OpenActRequest",params:{type:60100}})).data||null))}async function z(e){return d(e||{},w({minVersion:80805},async()=>(await l({name:"OpenActRequest",params:{type:60201,data:e}})).data))}function Q(e){return d(e||{},w({minVersion:80805},async()=>(await l({name:"OpenActRequest",params:{type:60210,data:e}})).data))}s.AppBaseInfo=U,s.AppShareModel=J,s.AuthResult=$,s.BridgeCode=f,s.IS_KB_APP_ENV=H,s.defineAppShareModel=K,s.getAppBaseInfo=D,s.getAuthToken=F,s.getAuthTokenWithSilent=L,s.invokeNativeApi=l,s.isAppVersionSupport=R,s.onAppSharePanelShow=G,s.openAppSharePanel=W,s.registerNativeApiHandler=O,s.reportDAEvent=C,s.requestPayment=z,s.requestRefund=Q,s.runAction=j,s.shareImage=B,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 递归过滤对象中所有层级的 undefined 和 null 属性
|
|
3
3
|
* @param obj 待过滤的对象(仅支持纯对象,不支持数组/非对象类型)
|
|
4
|
-
* @returns
|
|
4
|
+
* @returns 过滤后的新对象(自动剔除所有层级的 undefined 和 null 值)
|
|
5
5
|
*/
|
|
6
|
-
export declare function
|
|
7
|
-
[K in keyof T]: T[K] extends undefined ? never : K;
|
|
8
|
-
}[keyof T]>;
|
|
6
|
+
export declare function filterUndefinedAndNullProperties<T extends Record<string, any>>(obj: T): T;
|
package/examples/index.html
CHANGED