@ccos/ccsdk-lite 1.0.20 → 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 +44 -13
- package/lib/index.d.ts +3 -0
- package/lib/system/index.d.ts +7 -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) {
|
|
@@ -509,6 +529,9 @@ function registerKeys(params) {
|
|
|
509
529
|
function unregisterKeys(params) {
|
|
510
530
|
return callNative(getFuncName$7('unregisterKeys'), params || { keys: [] });
|
|
511
531
|
}
|
|
532
|
+
function providerCall(params) {
|
|
533
|
+
return callNative(getFuncName$7('providerCall'), params);
|
|
534
|
+
}
|
|
512
535
|
var system = {
|
|
513
536
|
ready: ready,
|
|
514
537
|
getStartupParams: getStartupParams,
|
|
@@ -523,6 +546,7 @@ var system = {
|
|
|
523
546
|
sendBroadcast: sendBroadcast,
|
|
524
547
|
registerKeys: registerKeys,
|
|
525
548
|
unregisterKeys: unregisterKeys,
|
|
549
|
+
providerCall: providerCall,
|
|
526
550
|
//sendEvent
|
|
527
551
|
};
|
|
528
552
|
|
|
@@ -1189,18 +1213,24 @@ var tts = {
|
|
|
1189
1213
|
function apkNativeCallJs(str) {
|
|
1190
1214
|
var res = null;
|
|
1191
1215
|
//console.log('str1=' + str);
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
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
|
+
}
|
|
1199
1229
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
return;
|
|
1230
|
+
else {
|
|
1231
|
+
res = str;
|
|
1203
1232
|
}
|
|
1233
|
+
//
|
|
1204
1234
|
if (!res) {
|
|
1205
1235
|
console.error('apkNativeCall: res is empty');
|
|
1206
1236
|
return;
|
|
@@ -1238,7 +1268,8 @@ var index = {
|
|
|
1238
1268
|
event: event,
|
|
1239
1269
|
fs: fs,
|
|
1240
1270
|
tts: tts,
|
|
1271
|
+
apkNativeCallJs: apkNativeCallJs,
|
|
1241
1272
|
isRunInAppBrowser: isRunInAppBrowser
|
|
1242
1273
|
};
|
|
1243
1274
|
|
|
1244
|
-
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: {
|
|
@@ -39,6 +40,7 @@ declare const _default: {
|
|
|
39
40
|
sendBroadcast: typeof import("./system").sendBroadcast;
|
|
40
41
|
registerKeys: typeof import("./system").registerKeys;
|
|
41
42
|
unregisterKeys: typeof import("./system").unregisterKeys;
|
|
43
|
+
providerCall: typeof import("./system").providerCall;
|
|
42
44
|
};
|
|
43
45
|
storage: {
|
|
44
46
|
setKey: typeof import("./storage").setKey;
|
|
@@ -146,6 +148,7 @@ declare const _default: {
|
|
|
146
148
|
sendTts: typeof import("./tts").sendTts;
|
|
147
149
|
sendStreamTts: typeof import("./tts").sendStreamTts;
|
|
148
150
|
};
|
|
151
|
+
apkNativeCallJs: typeof apkNativeCallJs;
|
|
149
152
|
isRunInAppBrowser: typeof isRunInAppBrowser;
|
|
150
153
|
};
|
|
151
154
|
export default _default;
|
package/lib/system/index.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ export interface IntentParam {
|
|
|
8
8
|
uri?: string;
|
|
9
9
|
extras?: any;
|
|
10
10
|
}
|
|
11
|
+
export interface ProviderCallParam {
|
|
12
|
+
uri: string;
|
|
13
|
+
method?: string;
|
|
14
|
+
arg?: string;
|
|
15
|
+
}
|
|
11
16
|
export declare function ready(): Promise<any>;
|
|
12
17
|
export declare function getStartupParams(): Promise<any>;
|
|
13
18
|
export declare function getDeviceInfo(): Promise<any>;
|
|
@@ -21,6 +26,7 @@ export declare function removeEventListener(eventName: string, callback: Functio
|
|
|
21
26
|
export declare function sendBroadcast(params: IntentParam): Promise<any>;
|
|
22
27
|
export declare function registerKeys(params: SystemKeyParam | null): Promise<any>;
|
|
23
28
|
export declare function unregisterKeys(params: SystemKeyParam | null): Promise<any>;
|
|
29
|
+
export declare function providerCall(params: ProviderCallParam): Promise<any>;
|
|
24
30
|
declare const _default: {
|
|
25
31
|
ready: typeof ready;
|
|
26
32
|
getStartupParams: typeof getStartupParams;
|
|
@@ -35,5 +41,6 @@ declare const _default: {
|
|
|
35
41
|
sendBroadcast: typeof sendBroadcast;
|
|
36
42
|
registerKeys: typeof registerKeys;
|
|
37
43
|
unregisterKeys: typeof unregisterKeys;
|
|
44
|
+
providerCall: typeof providerCall;
|
|
38
45
|
};
|
|
39
46
|
export default _default;
|