@ccos/ccsdk-lite 1.0.21 → 1.0.22
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/lib/bundle.js +40 -13
- package/lib/index.d.ts +2 -0
- package/package.json +1 -1
package/lib/bundle.js
CHANGED
|
@@ -99,14 +99,34 @@ function nativeCall(funcName, callbackId, params) {
|
|
|
99
99
|
window['_liteNativeApi'].exec(JSON.stringify(object1));
|
|
100
100
|
}
|
|
101
101
|
else if (window['CoocaaJsApiBridge']) { // 视九
|
|
102
|
-
// 运行于 android 浏览器webview
|
|
103
102
|
var object1 = {
|
|
104
103
|
func: funcName,
|
|
105
104
|
id: callbackId,
|
|
106
105
|
params: params || {},
|
|
107
106
|
apiCode: apiCode,
|
|
108
107
|
};
|
|
109
|
-
window['CoocaaJsApiBridge'].invoke(JSON.stringify(object1));
|
|
108
|
+
var ret = window['CoocaaJsApiBridge'].invoke(JSON.stringify(object1));
|
|
109
|
+
ret.then(function (res) {
|
|
110
|
+
var resData;
|
|
111
|
+
if (typeof res == 'string') {
|
|
112
|
+
try {
|
|
113
|
+
resData = JSON.parse(res);
|
|
114
|
+
}
|
|
115
|
+
catch (ex) {
|
|
116
|
+
console.error('error: ' + ex.toString());
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
resData = res;
|
|
122
|
+
}
|
|
123
|
+
if (!resData) {
|
|
124
|
+
console.error('resData is empty');
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
//
|
|
128
|
+
apkNativeCallJs(resData);
|
|
129
|
+
});
|
|
110
130
|
}
|
|
111
131
|
}
|
|
112
132
|
function nativeRequest(funcName, params, persistent, persistentIdName, persistentCallback) {
|
|
@@ -1193,18 +1213,24 @@ var tts = {
|
|
|
1193
1213
|
function apkNativeCallJs(str) {
|
|
1194
1214
|
var res = null;
|
|
1195
1215
|
//console.log('str1=' + str);
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1216
|
+
if (typeof str == 'string') {
|
|
1217
|
+
try {
|
|
1218
|
+
var dec1 = atob(str);
|
|
1219
|
+
//console.log('dec1=' + dec1);
|
|
1220
|
+
var dec2 = decodeURIComponent(dec1);
|
|
1221
|
+
//console.log('dec2=' + dec2);
|
|
1222
|
+
res = JSON.parse(dec2);
|
|
1223
|
+
//console.log('data type = ' + typeof(res.data));
|
|
1224
|
+
}
|
|
1225
|
+
catch (ex) {
|
|
1226
|
+
console.error('error: ' + ex.toString());
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1203
1229
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
return;
|
|
1230
|
+
else {
|
|
1231
|
+
res = str;
|
|
1207
1232
|
}
|
|
1233
|
+
//
|
|
1208
1234
|
if (!res) {
|
|
1209
1235
|
console.error('apkNativeCall: res is empty');
|
|
1210
1236
|
return;
|
|
@@ -1242,7 +1268,8 @@ var index = {
|
|
|
1242
1268
|
event: event,
|
|
1243
1269
|
fs: fs,
|
|
1244
1270
|
tts: tts,
|
|
1271
|
+
apkNativeCallJs: apkNativeCallJs,
|
|
1245
1272
|
isRunInAppBrowser: isRunInAppBrowser
|
|
1246
1273
|
};
|
|
1247
1274
|
|
|
1248
|
-
export { index as default, init, isRunInAppBrowser, setAppCommandCallback, unsetAppCommandCallback };
|
|
1275
|
+
export { apkNativeCallJs, index as default, init, isRunInAppBrowser, setAppCommandCallback, unsetAppCommandCallback };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { setAppCommandCallback, unsetAppCommandCallback } from './core';
|
|
2
|
+
export declare function apkNativeCallJs(str: string | object): void;
|
|
2
3
|
export declare function isRunInAppBrowser(): boolean;
|
|
3
4
|
export declare function init(): void;
|
|
4
5
|
declare const _default: {
|
|
@@ -147,6 +148,7 @@ declare const _default: {
|
|
|
147
148
|
sendTts: typeof import("./tts").sendTts;
|
|
148
149
|
sendStreamTts: typeof import("./tts").sendStreamTts;
|
|
149
150
|
};
|
|
151
|
+
apkNativeCallJs: typeof apkNativeCallJs;
|
|
150
152
|
isRunInAppBrowser: typeof isRunInAppBrowser;
|
|
151
153
|
};
|
|
152
154
|
export default _default;
|