@ccos/ccsdk-lite 1.0.3 → 1.0.5
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 → lib}/app/index.d.ts +0 -2
- package/{dist → lib}/bundle.js +367 -345
- package/{dist → lib}/index.d.ts +0 -1
- package/package.json +7 -11
- /package/{dist → lib}/androidView/index.d.ts +0 -0
- /package/{dist → lib}/audio/index.d.ts +0 -0
- /package/{dist → lib}/core/bus.d.ts +0 -0
- /package/{dist → lib}/core/index.d.ts +0 -0
- /package/{dist → lib}/file/index.d.ts +0 -0
- /package/{dist → lib}/network/index.d.ts +0 -0
- /package/{dist → lib}/storage/index.d.ts +0 -0
- /package/{dist → lib}/system/index.d.ts +0 -0
|
@@ -17,7 +17,6 @@ export declare function startBackEndAction(action: object): Promise<any>;
|
|
|
17
17
|
export declare function exitPage(): void;
|
|
18
18
|
export declare function moveTaskToBack(): Promise<any>;
|
|
19
19
|
export declare function getUserInfo(): Promise<any>;
|
|
20
|
-
export declare function setUserLogout(): Promise<any>;
|
|
21
20
|
export declare function getAppList(): Promise<any>;
|
|
22
21
|
export declare function getAppInfo(params: GetAppInfoParam): Promise<any>;
|
|
23
22
|
export declare function addLocalBroadcastHook(action: string, callback: Function): Promise<any>;
|
|
@@ -36,7 +35,6 @@ declare const _default: {
|
|
|
36
35
|
exitPage: typeof exitPage;
|
|
37
36
|
moveTaskToBack: typeof moveTaskToBack;
|
|
38
37
|
getUserInfo: typeof getUserInfo;
|
|
39
|
-
setUserLogout: typeof setUserLogout;
|
|
40
38
|
getAppList: typeof getAppList;
|
|
41
39
|
getAppInfo: typeof getAppInfo;
|
|
42
40
|
addLocalBroadcastHook: typeof addLocalBroadcastHook;
|
package/{dist → lib}/bundle.js
RENAMED
|
@@ -4,70 +4,76 @@
|
|
|
4
4
|
* 未传入name时默认会有自增id作为name
|
|
5
5
|
* 主要为 定时器 bridge 等服务
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
var Bus = /** @class */ (function () {
|
|
8
|
+
function Bus() {
|
|
9
9
|
this._busId = 0;
|
|
10
10
|
this._pool = {};
|
|
11
11
|
}
|
|
12
|
-
register(callback, name) {
|
|
13
|
-
|
|
12
|
+
Bus.prototype.register = function (callback, name) {
|
|
13
|
+
var busName = name ? name.toString() : (++this._busId).toString();
|
|
14
14
|
if (!this._pool[busName])
|
|
15
15
|
this._pool[busName] = [];
|
|
16
16
|
this._pool[busName].push(callback);
|
|
17
17
|
return busName;
|
|
18
|
-
}
|
|
19
|
-
fire(name
|
|
18
|
+
};
|
|
19
|
+
Bus.prototype.fire = function (name) {
|
|
20
|
+
var args = [];
|
|
21
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
22
|
+
args[_i - 1] = arguments[_i];
|
|
23
|
+
}
|
|
20
24
|
if (!name)
|
|
21
25
|
return;
|
|
22
|
-
|
|
26
|
+
var callbacks = this._pool[name];
|
|
23
27
|
if (!callbacks || !callbacks.length)
|
|
24
28
|
return;
|
|
25
|
-
return callbacks.map((callback)
|
|
26
|
-
}
|
|
27
|
-
has(name, callback) {
|
|
29
|
+
return callbacks.map(function (callback) { return callback.apply(void 0, args); });
|
|
30
|
+
};
|
|
31
|
+
Bus.prototype.has = function (name, callback) {
|
|
28
32
|
if (!name || !this._pool[name])
|
|
29
33
|
return false;
|
|
30
34
|
if (!callback)
|
|
31
35
|
return true;
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
var callbacks = this._pool[name];
|
|
37
|
+
var index = callbacks.indexOf(callback);
|
|
34
38
|
return index > -1;
|
|
35
|
-
}
|
|
36
|
-
remove(name, callback) {
|
|
39
|
+
};
|
|
40
|
+
Bus.prototype.remove = function (name, callback) {
|
|
37
41
|
if (!name || !this._pool[name])
|
|
38
42
|
return;
|
|
39
43
|
if (!callback) {
|
|
40
44
|
delete this._pool[name];
|
|
41
45
|
return;
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
var callbacks = this._pool[name];
|
|
48
|
+
var index = callbacks.indexOf(callback);
|
|
45
49
|
if (index > -1)
|
|
46
50
|
callbacks.splice(index, 1);
|
|
47
|
-
}
|
|
48
|
-
clear() {
|
|
51
|
+
};
|
|
52
|
+
Bus.prototype.clear = function () {
|
|
49
53
|
this._busId = 0;
|
|
50
54
|
this._pool = {};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
};
|
|
56
|
+
return Bus;
|
|
57
|
+
}());
|
|
58
|
+
var bus = new Bus();
|
|
54
59
|
|
|
55
|
-
|
|
60
|
+
var actionList = []; // 这里保存, 未注册命令处理函数之前,APP发过来的命令
|
|
56
61
|
function defaultAppCmd(cmd, payload) {
|
|
57
62
|
console.log('default appCmd ' + cmd);
|
|
58
|
-
actionList.push({ cmd, payload }); // 有可能APP发过来的命令比较早,而页面的一些初始化还没有做完,这时把命令先存起来,放到 actionList 中
|
|
63
|
+
actionList.push({ cmd: cmd, payload: payload }); // 有可能APP发过来的命令比较早,而页面的一些初始化还没有做完,这时把命令先存起来,放到 actionList 中
|
|
59
64
|
}
|
|
60
|
-
|
|
65
|
+
var appCmdProcessor = defaultAppCmd; // APP 发过来的命令,JS的执行函数
|
|
61
66
|
function onCommandFromApp(cmd, payload) {
|
|
62
67
|
appCmdProcessor(cmd, payload);
|
|
63
68
|
}
|
|
64
69
|
function setAppCommandCallback(cb) {
|
|
65
70
|
appCmdProcessor = cb;
|
|
66
71
|
//
|
|
67
|
-
|
|
72
|
+
var workList = actionList;
|
|
68
73
|
actionList = [];
|
|
69
74
|
// 如果 actionList 中有初始化之前来的命令,则执行这些命令
|
|
70
|
-
for (
|
|
75
|
+
for (var _i = 0, workList_1 = workList; _i < workList_1.length; _i++) {
|
|
76
|
+
var action = workList_1[_i];
|
|
71
77
|
console.log('ahead cmd = ' + action.cmd);
|
|
72
78
|
cb(action.cmd, action.payload);
|
|
73
79
|
}
|
|
@@ -78,7 +84,7 @@ function unsetAppCommandCallback() {
|
|
|
78
84
|
}
|
|
79
85
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
80
86
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
81
|
-
|
|
87
|
+
var persistentCallbackId = []; // 持久化 callback-id 列表
|
|
82
88
|
function nativeCall(funcName, callbackId, params) {
|
|
83
89
|
if (window['_liteNativeApi']) {
|
|
84
90
|
// 运行于 android 浏览器webview
|
|
@@ -92,22 +98,22 @@ function nativeCall(funcName, callbackId, params) {
|
|
|
92
98
|
}
|
|
93
99
|
function nativeRequest(funcName, params, persistent, persistentIdName, persistentCallback) {
|
|
94
100
|
if (!persistent) {
|
|
95
|
-
return new Promise((resolve)
|
|
96
|
-
|
|
101
|
+
return new Promise(function (resolve) {
|
|
102
|
+
var callbackId = bus.register(function (res) {
|
|
97
103
|
resolve(res);
|
|
98
104
|
});
|
|
99
105
|
nativeCall(funcName, callbackId, params);
|
|
100
106
|
});
|
|
101
107
|
}
|
|
102
108
|
// 以下是持久化调用处理
|
|
103
|
-
|
|
109
|
+
var index = persistentCallbackId.indexOf(persistentIdName);
|
|
104
110
|
if (index < 0) {
|
|
105
111
|
persistentCallbackId.push(persistentIdName);
|
|
106
112
|
}
|
|
107
113
|
bus.remove(persistentIdName);
|
|
108
114
|
bus.register(persistentCallback, persistentIdName); // 这里注册一个持久化的回调,通常应用于 native 会持续回调的情况
|
|
109
|
-
return new Promise((resolve)
|
|
110
|
-
|
|
115
|
+
return new Promise(function (resolve) {
|
|
116
|
+
var callbackId = bus.register(function (res) {
|
|
111
117
|
resolve(res);
|
|
112
118
|
});
|
|
113
119
|
nativeCall(funcName, callbackId, params);
|
|
@@ -124,14 +130,14 @@ function callWithPersistentCallBack(funcName, params, persistentIdName, callback
|
|
|
124
130
|
// 注销一个持久的回调函数
|
|
125
131
|
function deletePersistentCallBack(persistentIdName) {
|
|
126
132
|
bus.remove(persistentIdName);
|
|
127
|
-
|
|
133
|
+
var index = persistentCallbackId.indexOf(persistentIdName);
|
|
128
134
|
if (index < 0) {
|
|
129
135
|
return;
|
|
130
136
|
}
|
|
131
137
|
persistentCallbackId.splice(index, 1); // 从persistentCallbackId中删除name
|
|
132
138
|
}
|
|
133
139
|
function callbackFromNative(callbackId, data) {
|
|
134
|
-
|
|
140
|
+
var payload = '';
|
|
135
141
|
if (typeof data == 'string') {
|
|
136
142
|
try {
|
|
137
143
|
payload = JSON.parse(data);
|
|
@@ -145,13 +151,13 @@ function callbackFromNative(callbackId, data) {
|
|
|
145
151
|
}
|
|
146
152
|
bus.fire(callbackId, payload);
|
|
147
153
|
// 判断,如果不是持久的回调函数,则调用完毕之后删除该回调
|
|
148
|
-
|
|
154
|
+
var index = persistentCallbackId.indexOf(callbackId);
|
|
149
155
|
if (index < 0) {
|
|
150
156
|
bus.remove(callbackId);
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
159
|
|
|
154
|
-
|
|
160
|
+
var moduleName$6 = 'network';
|
|
155
161
|
function getFuncName$6(name) {
|
|
156
162
|
return moduleName$6 + '_' + name;
|
|
157
163
|
}
|
|
@@ -159,12 +165,13 @@ function paramToUrl(params) {
|
|
|
159
165
|
if (!params)
|
|
160
166
|
return '';
|
|
161
167
|
if (typeof params == 'object') {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
168
|
+
var strArr = [];
|
|
169
|
+
var counter = 0;
|
|
170
|
+
var keys = Object.keys(params);
|
|
165
171
|
keys.sort();
|
|
166
|
-
for (
|
|
167
|
-
|
|
172
|
+
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
173
|
+
var key = keys_1[_i];
|
|
174
|
+
var value = params[key];
|
|
168
175
|
if (counter != 0) {
|
|
169
176
|
strArr.push('&');
|
|
170
177
|
}
|
|
@@ -187,8 +194,8 @@ function simpleHttpRequest(params) {
|
|
|
187
194
|
return callNative(getFuncName$6('simpleHttpRequest'), params);
|
|
188
195
|
}
|
|
189
196
|
function httpGet(url, urlParam, header, base64) {
|
|
190
|
-
|
|
191
|
-
|
|
197
|
+
var paramString = paramToUrl(urlParam);
|
|
198
|
+
var newUrl;
|
|
192
199
|
if (paramString) {
|
|
193
200
|
if (url.indexOf('?') >= 0) {
|
|
194
201
|
newUrl = url + '&' + paramString;
|
|
@@ -201,7 +208,7 @@ function httpGet(url, urlParam, header, base64) {
|
|
|
201
208
|
newUrl = url;
|
|
202
209
|
}
|
|
203
210
|
//
|
|
204
|
-
|
|
211
|
+
var obj = {
|
|
205
212
|
url: newUrl,
|
|
206
213
|
method: 'GET'
|
|
207
214
|
};
|
|
@@ -214,7 +221,7 @@ function httpGet(url, urlParam, header, base64) {
|
|
|
214
221
|
return simpleHttpRequest(obj);
|
|
215
222
|
}
|
|
216
223
|
function httpPost(url, body, header, postJson, base64, postType) {
|
|
217
|
-
|
|
224
|
+
var obj = {
|
|
218
225
|
url: url,
|
|
219
226
|
method: 'POST'
|
|
220
227
|
};
|
|
@@ -255,8 +262,8 @@ function httpPost(url, body, header, postJson, base64, postType) {
|
|
|
255
262
|
return simpleHttpRequest(obj);
|
|
256
263
|
}
|
|
257
264
|
function httpSseGet(url, urlParam, header, base64) {
|
|
258
|
-
|
|
259
|
-
|
|
265
|
+
var paramString = paramToUrl(urlParam);
|
|
266
|
+
var newUrl;
|
|
260
267
|
if (paramString) {
|
|
261
268
|
if (url.indexOf('?') >= 0) {
|
|
262
269
|
newUrl = url + '&' + paramString;
|
|
@@ -269,7 +276,7 @@ function httpSseGet(url, urlParam, header, base64) {
|
|
|
269
276
|
newUrl = url;
|
|
270
277
|
}
|
|
271
278
|
//
|
|
272
|
-
|
|
279
|
+
var obj = {
|
|
273
280
|
url: newUrl,
|
|
274
281
|
method: 'GET'
|
|
275
282
|
};
|
|
@@ -287,7 +294,7 @@ function getNetworkInfo() {
|
|
|
287
294
|
}
|
|
288
295
|
// 获取合规化后的域名
|
|
289
296
|
function getDomainName(domain) {
|
|
290
|
-
return callNative(getFuncName$6('getDomainName'), { domain });
|
|
297
|
+
return callNative(getFuncName$6('getDomainName'), { domain: domain });
|
|
291
298
|
}
|
|
292
299
|
// 获取基本 Header 信息
|
|
293
300
|
function getCommonHeader() {
|
|
@@ -306,32 +313,37 @@ function readSse(params) {
|
|
|
306
313
|
// body: 如果为 POST 请求,这里放入 POST 的内容
|
|
307
314
|
// 返回:
|
|
308
315
|
// 返回下载到的文件名路径
|
|
309
|
-
function downloadToFile(url, tempFlag
|
|
316
|
+
function downloadToFile(url, tempFlag, method, header, postType, body) {
|
|
317
|
+
if (tempFlag === void 0) { tempFlag = true; }
|
|
318
|
+
if (method === void 0) { method = 'GET'; }
|
|
319
|
+
if (header === void 0) { header = ''; }
|
|
320
|
+
if (postType === void 0) { postType = ''; }
|
|
321
|
+
if (body === void 0) { body = ''; }
|
|
310
322
|
return callNative(getFuncName$6('downloadToFile'), {
|
|
311
|
-
url,
|
|
312
|
-
tempFlag,
|
|
313
|
-
method,
|
|
314
|
-
header,
|
|
315
|
-
postType,
|
|
316
|
-
body
|
|
323
|
+
url: url,
|
|
324
|
+
tempFlag: tempFlag,
|
|
325
|
+
method: method,
|
|
326
|
+
header: header,
|
|
327
|
+
postType: postType,
|
|
328
|
+
body: body
|
|
317
329
|
});
|
|
318
330
|
}
|
|
319
331
|
var network = {
|
|
320
|
-
simpleHttpRequest,
|
|
321
|
-
httpGet,
|
|
322
|
-
httpPost,
|
|
323
|
-
httpSseGet,
|
|
324
|
-
getNetworkInfo,
|
|
325
|
-
getDomainName,
|
|
326
|
-
getCommonHeader,
|
|
327
|
-
downloadToFile
|
|
332
|
+
simpleHttpRequest: simpleHttpRequest,
|
|
333
|
+
httpGet: httpGet,
|
|
334
|
+
httpPost: httpPost,
|
|
335
|
+
httpSseGet: httpSseGet,
|
|
336
|
+
getNetworkInfo: getNetworkInfo,
|
|
337
|
+
getDomainName: getDomainName,
|
|
338
|
+
getCommonHeader: getCommonHeader,
|
|
339
|
+
downloadToFile: downloadToFile
|
|
328
340
|
};
|
|
329
341
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
342
|
+
var moduleName$5 = 'app';
|
|
343
|
+
var localBroadcastHookCallbackId = 'localBroadcastHookCallbackId';
|
|
344
|
+
var globalBroadcastHookCallbackId = 'globalBroadcastHookCallbackId';
|
|
345
|
+
var localBroadcastActionMap = new Map();
|
|
346
|
+
var globalBroadcastActionMap = new Map();
|
|
335
347
|
function getFuncName$5(name) {
|
|
336
348
|
return moduleName$5 + '_' + name;
|
|
337
349
|
}
|
|
@@ -359,9 +371,6 @@ function moveTaskToBack() {
|
|
|
359
371
|
function getUserInfo() {
|
|
360
372
|
return callNative(getFuncName$5('getUserInfo'), null);
|
|
361
373
|
}
|
|
362
|
-
function setUserLogout() {
|
|
363
|
-
return callNative(getFuncName$5('setUserLogout'), null);
|
|
364
|
-
}
|
|
365
374
|
function getAppList() {
|
|
366
375
|
return callNative(getFuncName$5('getAppList'), null);
|
|
367
376
|
}
|
|
@@ -370,9 +379,9 @@ function getAppInfo(params) {
|
|
|
370
379
|
}
|
|
371
380
|
function processLocalBroadcast(payload) {
|
|
372
381
|
if (payload.hasOwnProperty('action')) {
|
|
373
|
-
|
|
382
|
+
var action = payload['action'];
|
|
374
383
|
if (localBroadcastActionMap.has(action)) {
|
|
375
|
-
|
|
384
|
+
var func = localBroadcastActionMap.get(action);
|
|
376
385
|
if (func) {
|
|
377
386
|
func(payload);
|
|
378
387
|
}
|
|
@@ -381,9 +390,9 @@ function processLocalBroadcast(payload) {
|
|
|
381
390
|
}
|
|
382
391
|
function processGlobalBroadcast(payload) {
|
|
383
392
|
if (payload.hasOwnProperty('action')) {
|
|
384
|
-
|
|
393
|
+
var action = payload['action'];
|
|
385
394
|
if (globalBroadcastActionMap.has(action)) {
|
|
386
|
-
|
|
395
|
+
var func = globalBroadcastActionMap.get(action);
|
|
387
396
|
if (func) {
|
|
388
397
|
func(payload);
|
|
389
398
|
}
|
|
@@ -393,29 +402,31 @@ function processGlobalBroadcast(payload) {
|
|
|
393
402
|
function addLocalBroadcastHook(action, callback) {
|
|
394
403
|
localBroadcastActionMap.set(action, callback); // action 如存在会更新
|
|
395
404
|
//
|
|
396
|
-
return callWithPersistentCallBack(getFuncName$5('addLocalBroadcastHook'), { callbackId: localBroadcastHookCallbackId, action }, localBroadcastHookCallbackId, processLocalBroadcast);
|
|
405
|
+
return callWithPersistentCallBack(getFuncName$5('addLocalBroadcastHook'), { callbackId: localBroadcastHookCallbackId, action: action }, localBroadcastHookCallbackId, processLocalBroadcast);
|
|
397
406
|
}
|
|
398
407
|
function deleteLocalBroadcastHook(action) {
|
|
399
408
|
localBroadcastActionMap.delete(action);
|
|
400
|
-
return callNative(getFuncName$5('deleteLocalBroadcastHook'), { action });
|
|
409
|
+
return callNative(getFuncName$5('deleteLocalBroadcastHook'), { action: action });
|
|
401
410
|
}
|
|
402
411
|
function addBroadcastHook(action, callback) {
|
|
403
412
|
globalBroadcastActionMap.set(action, callback); // action 如存在会更新
|
|
404
413
|
//
|
|
405
|
-
return callWithPersistentCallBack(getFuncName$5('addBroadcastHook'), { callbackId: globalBroadcastHookCallbackId, action }, globalBroadcastHookCallbackId, processGlobalBroadcast);
|
|
414
|
+
return callWithPersistentCallBack(getFuncName$5('addBroadcastHook'), { callbackId: globalBroadcastHookCallbackId, action: action }, globalBroadcastHookCallbackId, processGlobalBroadcast);
|
|
406
415
|
}
|
|
407
416
|
function deleteBroadcastHook(action) {
|
|
408
417
|
globalBroadcastActionMap.delete(action);
|
|
409
|
-
return callNative(getFuncName$5('deleteBroadcastHook'), { action });
|
|
418
|
+
return callNative(getFuncName$5('deleteBroadcastHook'), { action: action });
|
|
410
419
|
}
|
|
411
|
-
function playAudio(source, loop
|
|
412
|
-
|
|
420
|
+
function playAudio(source, loop, fromAssets) {
|
|
421
|
+
if (loop === void 0) { loop = false; }
|
|
422
|
+
if (fromAssets === void 0) { fromAssets = false; }
|
|
423
|
+
return callNative(getFuncName$5('playAudio'), { source: source, loop: loop, fromAssets: fromAssets });
|
|
413
424
|
}
|
|
414
425
|
function stopAudio() {
|
|
415
426
|
return callNative(getFuncName$5('stopAudio'), null);
|
|
416
427
|
}
|
|
417
428
|
function appPrivateMethod(method, params) {
|
|
418
|
-
|
|
429
|
+
var str = '';
|
|
419
430
|
if (params) {
|
|
420
431
|
if (typeof params == 'object') {
|
|
421
432
|
str = JSON.stringify(params);
|
|
@@ -424,31 +435,30 @@ function appPrivateMethod(method, params) {
|
|
|
424
435
|
str = String(params);
|
|
425
436
|
}
|
|
426
437
|
}
|
|
427
|
-
return callNative(getFuncName$5('appPrivateMethod'), { method, params: str });
|
|
438
|
+
return callNative(getFuncName$5('appPrivateMethod'), { method: method, params: str });
|
|
428
439
|
}
|
|
429
440
|
var app = {
|
|
430
|
-
startActivity,
|
|
431
|
-
startService,
|
|
432
|
-
sendBroadcast,
|
|
433
|
-
sendLocalBroadcast,
|
|
434
|
-
startBackEndAction,
|
|
435
|
-
exitPage,
|
|
436
|
-
moveTaskToBack,
|
|
437
|
-
getUserInfo,
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
appPrivateMethod
|
|
441
|
+
startActivity: startActivity,
|
|
442
|
+
startService: startService,
|
|
443
|
+
sendBroadcast: sendBroadcast,
|
|
444
|
+
sendLocalBroadcast: sendLocalBroadcast,
|
|
445
|
+
startBackEndAction: startBackEndAction,
|
|
446
|
+
exitPage: exitPage,
|
|
447
|
+
moveTaskToBack: moveTaskToBack,
|
|
448
|
+
getUserInfo: getUserInfo,
|
|
449
|
+
getAppList: getAppList,
|
|
450
|
+
getAppInfo: getAppInfo,
|
|
451
|
+
addLocalBroadcastHook: addLocalBroadcastHook,
|
|
452
|
+
deleteLocalBroadcastHook: deleteLocalBroadcastHook,
|
|
453
|
+
addBroadcastHook: addBroadcastHook,
|
|
454
|
+
deleteBroadcastHook: deleteBroadcastHook,
|
|
455
|
+
playAudio: playAudio,
|
|
456
|
+
stopAudio: stopAudio,
|
|
457
|
+
appPrivateMethod: appPrivateMethod
|
|
448
458
|
};
|
|
449
459
|
|
|
450
|
-
|
|
451
|
-
|
|
460
|
+
var moduleName$4 = 'system';
|
|
461
|
+
var lifeCycleHookCallbackId = 'lifeCycleHookCallback';
|
|
452
462
|
function getFuncName$4(name) {
|
|
453
463
|
return moduleName$4 + '_' + name;
|
|
454
464
|
}
|
|
@@ -475,7 +485,7 @@ function getDeviceInfo() {
|
|
|
475
485
|
}
|
|
476
486
|
// 获取 android property 的值
|
|
477
487
|
function getProperty(key) {
|
|
478
|
-
return callNative(getFuncName$4('getProperty'), { key });
|
|
488
|
+
return callNative(getFuncName$4('getProperty'), { key: key });
|
|
479
489
|
}
|
|
480
490
|
// 获取当前设备所处的位置信息
|
|
481
491
|
function getLocation() {
|
|
@@ -483,165 +493,257 @@ function getLocation() {
|
|
|
483
493
|
}
|
|
484
494
|
// 检查 JS-API 是否已经实现
|
|
485
495
|
function checkApi(apiName) {
|
|
486
|
-
return callNative(getFuncName$4('checkApi'), { apiName });
|
|
496
|
+
return callNative(getFuncName$4('checkApi'), { apiName: apiName });
|
|
487
497
|
}
|
|
488
498
|
// 获取显示屏幕信息
|
|
489
499
|
function getDisplayInfo() {
|
|
490
500
|
return callNative(getFuncName$4('getDisplayInfo'), null);
|
|
491
501
|
}
|
|
492
502
|
var system = {
|
|
493
|
-
getSdkVersion,
|
|
494
|
-
addLifeCycleHook,
|
|
495
|
-
deleteLifeCycleHook,
|
|
496
|
-
enableSystemKey,
|
|
497
|
-
getDeviceInfo,
|
|
498
|
-
getProperty,
|
|
499
|
-
getLocation,
|
|
500
|
-
checkApi,
|
|
501
|
-
getDisplayInfo,
|
|
503
|
+
getSdkVersion: getSdkVersion,
|
|
504
|
+
addLifeCycleHook: addLifeCycleHook,
|
|
505
|
+
deleteLifeCycleHook: deleteLifeCycleHook,
|
|
506
|
+
enableSystemKey: enableSystemKey,
|
|
507
|
+
getDeviceInfo: getDeviceInfo,
|
|
508
|
+
getProperty: getProperty,
|
|
509
|
+
getLocation: getLocation,
|
|
510
|
+
checkApi: checkApi,
|
|
511
|
+
getDisplayInfo: getDisplayInfo,
|
|
502
512
|
};
|
|
503
513
|
|
|
504
|
-
|
|
514
|
+
var moduleName$3 = 'storage';
|
|
505
515
|
function getFuncName$3(name) {
|
|
506
516
|
return moduleName$3 + '_' + name;
|
|
507
517
|
}
|
|
508
518
|
function setKey(key, value) {
|
|
509
|
-
return callNative(getFuncName$3('setKey'), { key, value });
|
|
519
|
+
return callNative(getFuncName$3('setKey'), { key: key, value: value });
|
|
510
520
|
}
|
|
511
521
|
function getKey(key) {
|
|
512
|
-
return callNative(getFuncName$3('getKey'), { key });
|
|
522
|
+
return callNative(getFuncName$3('getKey'), { key: key });
|
|
513
523
|
}
|
|
514
524
|
function deleteKey(key) {
|
|
515
|
-
return callNative(getFuncName$3('deleteKey'), { key });
|
|
525
|
+
return callNative(getFuncName$3('deleteKey'), { key: key });
|
|
516
526
|
}
|
|
517
527
|
function clearAllKeys() {
|
|
518
528
|
return callNative(getFuncName$3('clearAllKeys'), null);
|
|
519
529
|
}
|
|
520
530
|
var storage = {
|
|
521
|
-
setKey,
|
|
522
|
-
getKey,
|
|
523
|
-
deleteKey,
|
|
524
|
-
clearAllKeys
|
|
531
|
+
setKey: setKey,
|
|
532
|
+
getKey: getKey,
|
|
533
|
+
deleteKey: deleteKey,
|
|
534
|
+
clearAllKeys: clearAllKeys
|
|
525
535
|
};
|
|
526
536
|
|
|
527
|
-
|
|
537
|
+
var moduleName$2 = 'audio';
|
|
528
538
|
function getFuncName$2(name) {
|
|
529
539
|
return moduleName$2 + '_' + name;
|
|
530
540
|
}
|
|
531
|
-
|
|
541
|
+
var audioPlayerListenerCallbackId = 'audioPlayerListenerCallbackId';
|
|
542
|
+
// 播放器,播放新的URL或者本地文件系统的路径
|
|
543
|
+
function playNew(path) {
|
|
544
|
+
return callNative(getFuncName$2('playNew'), { path: path });
|
|
545
|
+
}
|
|
546
|
+
// 播放器,停止播放
|
|
547
|
+
function stop() {
|
|
548
|
+
return callNative(getFuncName$2('stop'), null);
|
|
549
|
+
}
|
|
550
|
+
// 播放器,是否正在播放中
|
|
551
|
+
function isPlaying() {
|
|
552
|
+
return callNative(getFuncName$2('isPlaying'), null);
|
|
553
|
+
}
|
|
554
|
+
// 播放器,是否准备好
|
|
555
|
+
function hasPrepared() {
|
|
556
|
+
return callNative(getFuncName$2('hasPrepared'), null);
|
|
557
|
+
}
|
|
558
|
+
// 播放器,获取总时长
|
|
559
|
+
function getDuration() {
|
|
560
|
+
return callNative(getFuncName$2('getDuration'), null);
|
|
561
|
+
}
|
|
562
|
+
// 播放器,获取当前进度值
|
|
563
|
+
function getCurrentPosition() {
|
|
564
|
+
return callNative(getFuncName$2('getCurrentPosition'), null);
|
|
565
|
+
}
|
|
566
|
+
// 播放器,获取播放状态,返回的value为字符串来标识播放状态
|
|
567
|
+
// 例如:Idle, Initialized, Preparing, Prepared, Started, Paused, Stopped, Completed, Error, End
|
|
568
|
+
function getPlayerState() {
|
|
569
|
+
return callNative(getFuncName$2('getPlayerState'), null);
|
|
570
|
+
}
|
|
571
|
+
// 播放器,暂停播放
|
|
572
|
+
function pause() {
|
|
573
|
+
return callNative(getFuncName$2('pause'), null);
|
|
574
|
+
}
|
|
575
|
+
// 播放器,启动播放或者从暂停恢复播放
|
|
576
|
+
function start() {
|
|
577
|
+
return callNative(getFuncName$2('start'), null);
|
|
578
|
+
}
|
|
579
|
+
// 播放器,重新播放
|
|
580
|
+
function rePlay() {
|
|
581
|
+
return callNative(getFuncName$2('rePlay'), null);
|
|
582
|
+
}
|
|
583
|
+
// 播放器,seek
|
|
584
|
+
function seekTo(position) {
|
|
585
|
+
return callNative(getFuncName$2('seekTo'), { position: Math.floor(position) });
|
|
586
|
+
}
|
|
587
|
+
// 播放器,设置单片循环模式
|
|
588
|
+
// isLooping: 是否循环播放
|
|
589
|
+
// silentLoop - 静默循环,默认关闭, 开启之后,部分依靠onCompletion重新播放来实现循环播放的方案下:
|
|
590
|
+
// 会无感知重播,即重播时,不会调idle/ preparing/ prepared等开始播放之前的状态)
|
|
591
|
+
function setLooping(isLooping, silentLoop) {
|
|
592
|
+
if (silentLoop === void 0) { silentLoop = false; }
|
|
593
|
+
return callNative(getFuncName$2('setLooping'), { isLooping: isLooping, silentLoop: silentLoop });
|
|
594
|
+
}
|
|
595
|
+
// 设置音量
|
|
596
|
+
function setVolume(volume) {
|
|
597
|
+
return callNative(getFuncName$2('setVolume'), { volume: volume });
|
|
598
|
+
}
|
|
599
|
+
// 设置视频播放器的事件回调
|
|
600
|
+
// 注意: 使用此回调的话,不用时记得使用 deleteListener 注销事件回调
|
|
601
|
+
function setListener(callback) {
|
|
602
|
+
return callWithPersistentCallBack(getFuncName$2('setListener'), { callbackId: audioPlayerListenerCallbackId }, audioPlayerListenerCallbackId, callback);
|
|
603
|
+
}
|
|
604
|
+
// 注销视频播放器的事件回调
|
|
605
|
+
function deleteListener() {
|
|
606
|
+
deletePersistentCallBack(audioPlayerListenerCallbackId);
|
|
607
|
+
return callNative(getFuncName$2('deleteListener'), null);
|
|
608
|
+
}
|
|
609
|
+
var audio = {
|
|
610
|
+
playNew: playNew,
|
|
611
|
+
stop: stop,
|
|
612
|
+
isPlaying: isPlaying,
|
|
613
|
+
hasPrepared: hasPrepared,
|
|
614
|
+
getDuration: getDuration,
|
|
615
|
+
getCurrentPosition: getCurrentPosition,
|
|
616
|
+
getPlayerState: getPlayerState,
|
|
617
|
+
pause: pause,
|
|
618
|
+
start: start,
|
|
619
|
+
rePlay: rePlay,
|
|
620
|
+
seekTo: seekTo,
|
|
621
|
+
setLooping: setLooping,
|
|
622
|
+
setVolume: setVolume,
|
|
623
|
+
setListener: setListener,
|
|
624
|
+
deleteListener: deleteListener
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
var moduleName$1 = 'androidView';
|
|
628
|
+
function getFuncName$1(name) {
|
|
629
|
+
return moduleName$1 + '_' + name;
|
|
630
|
+
}
|
|
631
|
+
var playerListenerCallbackId = 'playerListenerCallbackId';
|
|
532
632
|
// 播放PAG动画
|
|
533
633
|
// repeat: 循环次数 -1 表示无限
|
|
534
634
|
//
|
|
535
635
|
function startPagAni(params) {
|
|
536
|
-
return callNative(getFuncName$
|
|
636
|
+
return callNative(getFuncName$1('startPagAni'), params);
|
|
537
637
|
}
|
|
538
638
|
// 停止PAG动画,并消失
|
|
539
639
|
function stopPagAni() {
|
|
540
|
-
return callNative(getFuncName$
|
|
640
|
+
return callNative(getFuncName$1('stopPagAni'), null);
|
|
541
641
|
}
|
|
542
642
|
// 播报 TTS 文本语音
|
|
543
643
|
function sendTts(text, ttsId) {
|
|
544
|
-
return callNative(getFuncName$
|
|
644
|
+
return callNative(getFuncName$1('sendTts'), { text: text, id: ttsId });
|
|
545
645
|
}
|
|
546
646
|
// 停止播报 TTS
|
|
547
647
|
function stopTts() {
|
|
548
|
-
return callNative(getFuncName$
|
|
648
|
+
return callNative(getFuncName$1('stopTts'), null);
|
|
549
649
|
}
|
|
550
650
|
// 流式播报 TTS
|
|
551
651
|
function sendStreamTts(text, ttsId, isFirst, isEnd) {
|
|
552
|
-
return callNative(getFuncName$
|
|
652
|
+
return callNative(getFuncName$1('sendStreamTts'), { text: text, id: ttsId, isFirst: isFirst, isEnd: isEnd });
|
|
553
653
|
}
|
|
554
654
|
// 播放器,播放新的URL
|
|
555
655
|
function playerPlayNewUrl(url) {
|
|
556
|
-
return callNative(getFuncName$
|
|
656
|
+
return callNative(getFuncName$1('playerPlayNewUrl'), { url: url });
|
|
557
657
|
}
|
|
558
658
|
// 播放器,停止播放
|
|
559
659
|
function playerStop() {
|
|
560
|
-
return callNative(getFuncName$
|
|
660
|
+
return callNative(getFuncName$1('playerStop'), null);
|
|
561
661
|
}
|
|
562
662
|
// 播放器,暂停播放
|
|
563
663
|
function playerPause() {
|
|
564
|
-
return callNative(getFuncName$
|
|
664
|
+
return callNative(getFuncName$1('playerPause'), null);
|
|
565
665
|
}
|
|
566
666
|
// 播放器,启动播放或者从暂停恢复播放
|
|
567
667
|
function playerStart() {
|
|
568
|
-
return callNative(getFuncName$
|
|
668
|
+
return callNative(getFuncName$1('playerStart'), null);
|
|
569
669
|
}
|
|
570
670
|
// 播放器,seek
|
|
571
671
|
function playerSeekTo(position) {
|
|
572
|
-
return callNative(getFuncName$
|
|
672
|
+
return callNative(getFuncName$1('playerSeekTo'), { position: Math.floor(position) });
|
|
573
673
|
}
|
|
574
674
|
// 播放器,是否准备好
|
|
575
675
|
function playerHasPrepared() {
|
|
576
|
-
return callNative(getFuncName$
|
|
676
|
+
return callNative(getFuncName$1('playerHasPrepared'), null);
|
|
577
677
|
}
|
|
578
678
|
// 播放器,是否正在播放中
|
|
579
679
|
function playerIsPlaying() {
|
|
580
|
-
return callNative(getFuncName$
|
|
680
|
+
return callNative(getFuncName$1('playerIsPlaying'), null);
|
|
581
681
|
}
|
|
582
682
|
// 播放器,获取总时长
|
|
583
683
|
function playerGetDuration() {
|
|
584
|
-
return callNative(getFuncName$
|
|
684
|
+
return callNative(getFuncName$1('playerGetDuration'), null);
|
|
585
685
|
}
|
|
586
686
|
// 播放器,获取当前进度值
|
|
587
687
|
function playerGetCurrentPosition() {
|
|
588
|
-
return callNative(getFuncName$
|
|
688
|
+
return callNative(getFuncName$1('playerGetCurrentPosition'), null);
|
|
589
689
|
}
|
|
590
690
|
// 播放器,获取播放状态,返回的value为字符串来标识播放状态
|
|
591
691
|
// 例如:Idle, Initialized, Preparing, Prepared, Started, Paused, Stopped, Completed, Error, End
|
|
592
692
|
function playerGetPlayerState() {
|
|
593
|
-
return callNative(getFuncName$
|
|
693
|
+
return callNative(getFuncName$1('playerGetPlayerState'), null);
|
|
594
694
|
}
|
|
595
695
|
// 播放器,播放新的本地文件路径
|
|
596
696
|
function playerPlayNewFile(path) {
|
|
597
|
-
return callNative(getFuncName$
|
|
697
|
+
return callNative(getFuncName$1('playerPlayNewFile'), { path: path });
|
|
598
698
|
}
|
|
599
699
|
// 播放器,设置单片循环模式
|
|
600
700
|
// isLooping: 是否循环播放
|
|
601
701
|
// silentLoop - 静默循环,默认关闭, 开启之后,部分依靠onCompletion重新播放来实现循环播放的方案下:
|
|
602
702
|
// 会无感知重播,即重播时,不会调idle/ preparing/ prepared等开始播放之前的状态)
|
|
603
|
-
function playerSetLooping(isLooping, silentLoop
|
|
604
|
-
|
|
703
|
+
function playerSetLooping(isLooping, silentLoop) {
|
|
704
|
+
if (silentLoop === void 0) { silentLoop = false; }
|
|
705
|
+
return callNative(getFuncName$1('playerSetLooping'), { isLooping: isLooping, silentLoop: silentLoop });
|
|
605
706
|
}
|
|
606
707
|
// 播放器,设置自动屏保锁,即:开始或恢复播放->锁屏保,停止或暂停播放->释放屏保锁 默认关闭
|
|
607
708
|
function playerSetAutoWakeLock(autoWakeLock) {
|
|
608
|
-
return callNative(getFuncName$
|
|
709
|
+
return callNative(getFuncName$1('playerSetAutoWakeLock'), { autoWakeLock: autoWakeLock });
|
|
609
710
|
}
|
|
610
711
|
// 播放器,重新播放
|
|
611
712
|
function playerRePlay() {
|
|
612
|
-
return callNative(getFuncName$
|
|
713
|
+
return callNative(getFuncName$1('playerRePlay'), null);
|
|
613
714
|
}
|
|
614
715
|
// 播放器,设置是否自动播放,即 play ready 后音视频自动播放 默认开启
|
|
615
|
-
function playerSetPlayWhenReady(playWhenReady
|
|
616
|
-
|
|
716
|
+
function playerSetPlayWhenReady(playWhenReady) {
|
|
717
|
+
if (playWhenReady === void 0) { playWhenReady = true; }
|
|
718
|
+
return callNative(getFuncName$1('playerSetPlayWhenReady'), { playWhenReady: playWhenReady });
|
|
617
719
|
}
|
|
618
720
|
// 获取当前设置的播放内核, 有可能会返回 DefaultPlayer
|
|
619
721
|
// 值: DefaultPlayer, MediaPlayer, SocPlayer, ExoPlayer
|
|
620
722
|
function playerGetPlayerCore() {
|
|
621
|
-
return callNative(getFuncName$
|
|
723
|
+
return callNative(getFuncName$1('playerGetPlayerCore'), null);
|
|
622
724
|
}
|
|
623
725
|
// 获取实际的播放内核, 部分内核如:最佳内核,实际上是在各个内核中进行选择,不会返回 DefaultPlayer
|
|
624
726
|
// 值: MediaPlayer, SocPlayer, ExoPlayer
|
|
625
727
|
function playerGetRealPlayerCore() {
|
|
626
|
-
return callNative(getFuncName$
|
|
728
|
+
return callNative(getFuncName$1('playerGetRealPlayerCore'), null);
|
|
627
729
|
}
|
|
628
730
|
// 设置视频播放器的事件回调
|
|
629
731
|
// 注意: 使用此回调的话,不用时记得使用 playerDeleteListener 注销事件回调
|
|
630
732
|
function playerSetListener(callback) {
|
|
631
|
-
return callWithPersistentCallBack(getFuncName$
|
|
733
|
+
return callWithPersistentCallBack(getFuncName$1('playerSetListener'), { callbackId: playerListenerCallbackId }, playerListenerCallbackId, callback);
|
|
632
734
|
}
|
|
633
735
|
// 注销视频播放器的事件回调
|
|
634
736
|
function playerDeleteListener() {
|
|
635
737
|
deletePersistentCallBack(playerListenerCallbackId);
|
|
636
|
-
return callNative(getFuncName$
|
|
738
|
+
return callNative(getFuncName$1('playerDeleteListener'), null);
|
|
637
739
|
}
|
|
638
740
|
// 设置视频播放窗口的位置与宽高
|
|
639
741
|
function setVideoLayout(width, height, x, y) {
|
|
640
|
-
return callNative(getFuncName$
|
|
742
|
+
return callNative(getFuncName$1('setVideoLayout'), { x: Number(x), y: Number(y), w: Number(width), h: Number(height) });
|
|
641
743
|
}
|
|
642
744
|
// 设置视频窗口是否显示
|
|
643
745
|
function setVideoVisible(show) {
|
|
644
|
-
return callNative(getFuncName$
|
|
746
|
+
return callNative(getFuncName$1('setVideoVisible'), { visible: show });
|
|
645
747
|
}
|
|
646
748
|
// 设置背景
|
|
647
749
|
// needUpdateColor : 是否更新颜色
|
|
@@ -649,143 +751,55 @@ function setVideoVisible(show) {
|
|
|
649
751
|
// needUpdateImage : 是否更新背景图
|
|
650
752
|
// imageUrl: 背景图的URL
|
|
651
753
|
function setBackground(needUpdateColor, color, needUpdateImage, imageUrl) {
|
|
652
|
-
return callNative(getFuncName$
|
|
754
|
+
return callNative(getFuncName$1('setBackground'), { updateColorFlag: needUpdateColor, updateImageFlag: needUpdateImage, color: Math.floor(color), imageUrl: imageUrl });
|
|
653
755
|
}
|
|
654
756
|
// 清除背景
|
|
655
757
|
function clearBackground() {
|
|
656
|
-
return callNative(getFuncName$
|
|
758
|
+
return callNative(getFuncName$1('clearBackground'), null);
|
|
657
759
|
}
|
|
658
760
|
// 显示语音文本提示条, tips文本中如果带 # 字符,会把 # 字符显示成麦克风图标
|
|
659
|
-
function showVoiceTipsBar(tips
|
|
660
|
-
|
|
761
|
+
function showVoiceTipsBar(tips) {
|
|
762
|
+
if (tips === void 0) { tips = ''; }
|
|
763
|
+
return callNative(getFuncName$1('showVoiceTipsBar'), { tips: tips });
|
|
661
764
|
}
|
|
662
765
|
// 隐藏语音文本提示条
|
|
663
766
|
function hideVoiceTipsBar() {
|
|
664
|
-
return callNative(getFuncName$
|
|
767
|
+
return callNative(getFuncName$1('hideVoiceTipsBar'), null);
|
|
665
768
|
}
|
|
666
769
|
var androidView = {
|
|
667
|
-
startPagAni,
|
|
668
|
-
stopPagAni,
|
|
669
|
-
sendTts,
|
|
670
|
-
stopTts,
|
|
671
|
-
sendStreamTts,
|
|
672
|
-
playerPlayNewUrl,
|
|
673
|
-
playerStop,
|
|
674
|
-
playerPause,
|
|
675
|
-
playerStart,
|
|
676
|
-
playerSeekTo,
|
|
677
|
-
playerHasPrepared,
|
|
678
|
-
playerIsPlaying,
|
|
679
|
-
playerGetDuration,
|
|
680
|
-
playerGetCurrentPosition,
|
|
681
|
-
playerGetPlayerState,
|
|
682
|
-
playerPlayNewFile,
|
|
683
|
-
playerSetLooping,
|
|
684
|
-
playerSetAutoWakeLock,
|
|
685
|
-
playerRePlay,
|
|
686
|
-
playerSetPlayWhenReady,
|
|
687
|
-
playerGetPlayerCore,
|
|
688
|
-
playerGetRealPlayerCore,
|
|
689
|
-
playerSetListener,
|
|
690
|
-
playerDeleteListener,
|
|
691
|
-
setVideoLayout,
|
|
692
|
-
setVideoVisible,
|
|
693
|
-
setBackground,
|
|
694
|
-
clearBackground,
|
|
695
|
-
showVoiceTipsBar,
|
|
696
|
-
hideVoiceTipsBar,
|
|
697
|
-
};
|
|
698
|
-
|
|
699
|
-
const moduleName$1 = 'audio';
|
|
700
|
-
function getFuncName$1(name) {
|
|
701
|
-
return moduleName$1 + '_' + name;
|
|
702
|
-
}
|
|
703
|
-
const audioPlayerListenerCallbackId = 'audioPlayerListenerCallbackId';
|
|
704
|
-
// 播放器,播放新的URL或者本地文件系统的路径
|
|
705
|
-
function playNew(path) {
|
|
706
|
-
return callNative(getFuncName$1('playNew'), { path });
|
|
707
|
-
}
|
|
708
|
-
// 播放器,停止播放
|
|
709
|
-
function stop() {
|
|
710
|
-
return callNative(getFuncName$1('stop'), null);
|
|
711
|
-
}
|
|
712
|
-
// 播放器,是否正在播放中
|
|
713
|
-
function isPlaying() {
|
|
714
|
-
return callNative(getFuncName$1('isPlaying'), null);
|
|
715
|
-
}
|
|
716
|
-
// 播放器,是否准备好
|
|
717
|
-
function hasPrepared() {
|
|
718
|
-
return callNative(getFuncName$1('hasPrepared'), null);
|
|
719
|
-
}
|
|
720
|
-
// 播放器,获取总时长
|
|
721
|
-
function getDuration() {
|
|
722
|
-
return callNative(getFuncName$1('getDuration'), null);
|
|
723
|
-
}
|
|
724
|
-
// 播放器,获取当前进度值
|
|
725
|
-
function getCurrentPosition() {
|
|
726
|
-
return callNative(getFuncName$1('getCurrentPosition'), null);
|
|
727
|
-
}
|
|
728
|
-
// 播放器,获取播放状态,返回的value为字符串来标识播放状态
|
|
729
|
-
// 例如:Idle, Initialized, Preparing, Prepared, Started, Paused, Stopped, Completed, Error, End
|
|
730
|
-
function getPlayerState() {
|
|
731
|
-
return callNative(getFuncName$1('getPlayerState'), null);
|
|
732
|
-
}
|
|
733
|
-
// 播放器,暂停播放
|
|
734
|
-
function pause() {
|
|
735
|
-
return callNative(getFuncName$1('pause'), null);
|
|
736
|
-
}
|
|
737
|
-
// 播放器,启动播放或者从暂停恢复播放
|
|
738
|
-
function start() {
|
|
739
|
-
return callNative(getFuncName$1('start'), null);
|
|
740
|
-
}
|
|
741
|
-
// 播放器,重新播放
|
|
742
|
-
function rePlay() {
|
|
743
|
-
return callNative(getFuncName$1('rePlay'), null);
|
|
744
|
-
}
|
|
745
|
-
// 播放器,seek
|
|
746
|
-
function seekTo(position) {
|
|
747
|
-
return callNative(getFuncName$1('seekTo'), { position: Math.floor(position) });
|
|
748
|
-
}
|
|
749
|
-
// 播放器,设置单片循环模式
|
|
750
|
-
// isLooping: 是否循环播放
|
|
751
|
-
// silentLoop - 静默循环,默认关闭, 开启之后,部分依靠onCompletion重新播放来实现循环播放的方案下:
|
|
752
|
-
// 会无感知重播,即重播时,不会调idle/ preparing/ prepared等开始播放之前的状态)
|
|
753
|
-
function setLooping(isLooping, silentLoop = false) {
|
|
754
|
-
return callNative(getFuncName$1('setLooping'), { isLooping, silentLoop });
|
|
755
|
-
}
|
|
756
|
-
// 设置音量
|
|
757
|
-
function setVolume(volume) {
|
|
758
|
-
return callNative(getFuncName$1('setVolume'), { volume });
|
|
759
|
-
}
|
|
760
|
-
// 设置视频播放器的事件回调
|
|
761
|
-
// 注意: 使用此回调的话,不用时记得使用 deleteListener 注销事件回调
|
|
762
|
-
function setListener(callback) {
|
|
763
|
-
return callWithPersistentCallBack(getFuncName$1('setListener'), { callbackId: audioPlayerListenerCallbackId }, audioPlayerListenerCallbackId, callback);
|
|
764
|
-
}
|
|
765
|
-
// 注销视频播放器的事件回调
|
|
766
|
-
function deleteListener() {
|
|
767
|
-
deletePersistentCallBack(audioPlayerListenerCallbackId);
|
|
768
|
-
return callNative(getFuncName$1('deleteListener'), null);
|
|
769
|
-
}
|
|
770
|
-
var audio = {
|
|
771
|
-
playNew,
|
|
772
|
-
stop,
|
|
773
|
-
isPlaying,
|
|
774
|
-
hasPrepared,
|
|
775
|
-
getDuration,
|
|
776
|
-
getCurrentPosition,
|
|
777
|
-
getPlayerState,
|
|
778
|
-
pause,
|
|
779
|
-
start,
|
|
780
|
-
rePlay,
|
|
781
|
-
seekTo,
|
|
782
|
-
setLooping,
|
|
783
|
-
setVolume,
|
|
784
|
-
setListener,
|
|
785
|
-
deleteListener
|
|
770
|
+
startPagAni: startPagAni,
|
|
771
|
+
stopPagAni: stopPagAni,
|
|
772
|
+
sendTts: sendTts,
|
|
773
|
+
stopTts: stopTts,
|
|
774
|
+
sendStreamTts: sendStreamTts,
|
|
775
|
+
playerPlayNewUrl: playerPlayNewUrl,
|
|
776
|
+
playerStop: playerStop,
|
|
777
|
+
playerPause: playerPause,
|
|
778
|
+
playerStart: playerStart,
|
|
779
|
+
playerSeekTo: playerSeekTo,
|
|
780
|
+
playerHasPrepared: playerHasPrepared,
|
|
781
|
+
playerIsPlaying: playerIsPlaying,
|
|
782
|
+
playerGetDuration: playerGetDuration,
|
|
783
|
+
playerGetCurrentPosition: playerGetCurrentPosition,
|
|
784
|
+
playerGetPlayerState: playerGetPlayerState,
|
|
785
|
+
playerPlayNewFile: playerPlayNewFile,
|
|
786
|
+
playerSetLooping: playerSetLooping,
|
|
787
|
+
playerSetAutoWakeLock: playerSetAutoWakeLock,
|
|
788
|
+
playerRePlay: playerRePlay,
|
|
789
|
+
playerSetPlayWhenReady: playerSetPlayWhenReady,
|
|
790
|
+
playerGetPlayerCore: playerGetPlayerCore,
|
|
791
|
+
playerGetRealPlayerCore: playerGetRealPlayerCore,
|
|
792
|
+
playerSetListener: playerSetListener,
|
|
793
|
+
playerDeleteListener: playerDeleteListener,
|
|
794
|
+
setVideoLayout: setVideoLayout,
|
|
795
|
+
setVideoVisible: setVideoVisible,
|
|
796
|
+
setBackground: setBackground,
|
|
797
|
+
clearBackground: clearBackground,
|
|
798
|
+
showVoiceTipsBar: showVoiceTipsBar,
|
|
799
|
+
hideVoiceTipsBar: hideVoiceTipsBar,
|
|
786
800
|
};
|
|
787
801
|
|
|
788
|
-
|
|
802
|
+
var moduleName = 'file';
|
|
789
803
|
function getFuncName(name) {
|
|
790
804
|
return moduleName + '_' + name;
|
|
791
805
|
}
|
|
@@ -793,16 +807,18 @@ function getFuncName(name) {
|
|
|
793
807
|
// 参数:
|
|
794
808
|
// path: 读取文件的路径
|
|
795
809
|
// base64Flag: 是否以base64编码方式返回, 如果读取文件文件,则应该设置 base64Flag = false,如果读取二进制文件,则应该设置 base64Flag = true
|
|
796
|
-
function readAllContent(path, base64Flag
|
|
797
|
-
|
|
810
|
+
function readAllContent(path, base64Flag) {
|
|
811
|
+
if (base64Flag === void 0) { base64Flag = false; }
|
|
812
|
+
return callNative(getFuncName('readAllContent'), { path: path, base64Flag: base64Flag });
|
|
798
813
|
}
|
|
799
814
|
// 将内容全部写入文件
|
|
800
815
|
// 参数:
|
|
801
816
|
// path: 写入文件的路径
|
|
802
817
|
// content: 写入的内容,字符串,如果要写入二进制,应该先编码成 base64 字符串再传入
|
|
803
818
|
// base64Flag: 是否以base64编码方式传输content, 如果写文件文件,则应该设置 base64Flag = false,如果写入二进制文件,则应该设置 base64Flag = true
|
|
804
|
-
function writeAllContent(path, content, base64Flag
|
|
805
|
-
|
|
819
|
+
function writeAllContent(path, content, base64Flag) {
|
|
820
|
+
if (base64Flag === void 0) { base64Flag = false; }
|
|
821
|
+
return callNative(getFuncName('writeAllContent'), { path: path, content: content, base64Flag: base64Flag });
|
|
806
822
|
}
|
|
807
823
|
// 获取应用基本目录的全路径名
|
|
808
824
|
function getBaseDir() {
|
|
@@ -815,169 +831,175 @@ function getCacheDir() {
|
|
|
815
831
|
// 构建一个临时文件名,返回该文件的绝对路径的全文件路径名
|
|
816
832
|
// 参数:
|
|
817
833
|
// fileName: 指定临时文件的基本名,如果不指定,会默认随机生成一个文件名
|
|
818
|
-
function makeCacheFile(fileName
|
|
819
|
-
|
|
834
|
+
function makeCacheFile(fileName) {
|
|
835
|
+
if (fileName === void 0) { fileName = ''; }
|
|
836
|
+
return callNative(getFuncName('makeCacheFile'), { fileName: fileName });
|
|
820
837
|
}
|
|
821
838
|
// 构建一个正常文件名,返回该文件的绝对路径的全文件路径名
|
|
822
839
|
// 参数:
|
|
823
840
|
// fileName: 指定文件的基本名,如果不指定,会默认随机生成一个文件名
|
|
824
|
-
function makeNormalFile(fileName
|
|
825
|
-
|
|
841
|
+
function makeNormalFile(fileName) {
|
|
842
|
+
if (fileName === void 0) { fileName = ''; }
|
|
843
|
+
return callNative(getFuncName('makeNormalFile'), { fileName: fileName });
|
|
826
844
|
}
|
|
827
845
|
// 检测一个文件或者目录是否存在
|
|
828
846
|
// 参数:
|
|
829
847
|
// path: 指定路径
|
|
830
848
|
function exists(path) {
|
|
831
|
-
return callNative(getFuncName('exists'), { path });
|
|
849
|
+
return callNative(getFuncName('exists'), { path: path });
|
|
832
850
|
}
|
|
833
851
|
// 检测一个路径是否为一个普通文件
|
|
834
852
|
// 参数:
|
|
835
853
|
// path: 指定路径
|
|
836
854
|
function isFile(path) {
|
|
837
|
-
return callNative(getFuncName('isFile'), { path });
|
|
855
|
+
return callNative(getFuncName('isFile'), { path: path });
|
|
838
856
|
}
|
|
839
857
|
// 检测一个路径是否为一个目录
|
|
840
858
|
// 参数:
|
|
841
859
|
// path: 指定路径
|
|
842
860
|
function isDirectory(path) {
|
|
843
|
-
return callNative(getFuncName('isDirectory'), { path });
|
|
861
|
+
return callNative(getFuncName('isDirectory'), { path: path });
|
|
844
862
|
}
|
|
845
863
|
// 检测一个路径表示的文件或目录 是否是隐藏的
|
|
846
864
|
// 参数:
|
|
847
865
|
// path: 指定路径
|
|
848
866
|
function isHidden(path) {
|
|
849
|
-
return callNative(getFuncName('isHidden'), { path });
|
|
867
|
+
return callNative(getFuncName('isHidden'), { path: path });
|
|
850
868
|
}
|
|
851
869
|
// 检测一个路径表示的文件或目录 是否可读
|
|
852
870
|
// 参数:
|
|
853
871
|
// path: 指定路径
|
|
854
872
|
function canRead(path) {
|
|
855
|
-
return callNative(getFuncName('canRead'), { path });
|
|
873
|
+
return callNative(getFuncName('canRead'), { path: path });
|
|
856
874
|
}
|
|
857
875
|
// 检测一个路径表示的文件或目录 是否可写
|
|
858
876
|
// 参数:
|
|
859
877
|
// path: 指定路径
|
|
860
878
|
function canWrite(path) {
|
|
861
|
-
return callNative(getFuncName('canWrite'), { path });
|
|
879
|
+
return callNative(getFuncName('canWrite'), { path: path });
|
|
862
880
|
}
|
|
863
881
|
// 检测一个路径表示的文件或目录 是否可执行
|
|
864
882
|
// 参数:
|
|
865
883
|
// path: 指定路径
|
|
866
884
|
function canExecute(path) {
|
|
867
|
-
return callNative(getFuncName('canExecute'), { path });
|
|
885
|
+
return callNative(getFuncName('canExecute'), { path: path });
|
|
868
886
|
}
|
|
869
887
|
// 检测一个路径表示的文件或目录 的最后修改的时间,返回时间戳(1970年开始的秒数)
|
|
870
888
|
// 参数:
|
|
871
889
|
// path: 指定路径
|
|
872
890
|
function lastModified(path) {
|
|
873
|
-
return callNative(getFuncName('lastModified'), { path });
|
|
891
|
+
return callNative(getFuncName('lastModified'), { path: path });
|
|
874
892
|
}
|
|
875
893
|
// 删除文件
|
|
876
894
|
// 参数:
|
|
877
895
|
// path: 指定路径
|
|
878
896
|
function deleteIt(path) {
|
|
879
|
-
return callNative(getFuncName('delete'), { path });
|
|
897
|
+
return callNative(getFuncName('delete'), { path: path });
|
|
880
898
|
}
|
|
881
899
|
// 新建目录
|
|
882
900
|
// 参数:
|
|
883
901
|
// path: 指定路径
|
|
884
902
|
function mkdir(path) {
|
|
885
|
-
return callNative(getFuncName('mkdir'), { path });
|
|
903
|
+
return callNative(getFuncName('mkdir'), { path: path });
|
|
886
904
|
}
|
|
887
905
|
// 新建目录 (如果父目录补存在则一并新建所有尚未存在的父目录)
|
|
888
906
|
// 参数:
|
|
889
907
|
// path: 指定路径
|
|
890
908
|
function mkdirs(path) {
|
|
891
|
-
return callNative(getFuncName('mkdirs'), { path });
|
|
909
|
+
return callNative(getFuncName('mkdirs'), { path: path });
|
|
892
910
|
}
|
|
893
911
|
// 改名
|
|
894
912
|
// 参数:
|
|
895
913
|
// from: 指定源路径
|
|
896
914
|
// to: 指定目标路径
|
|
897
915
|
function rename(from, to) {
|
|
898
|
-
return callNative(getFuncName('rename'), { from, to });
|
|
916
|
+
return callNative(getFuncName('rename'), { from: from, to: to });
|
|
899
917
|
}
|
|
900
918
|
// 将相对路径的转换为全路径
|
|
901
919
|
// 参数:
|
|
902
920
|
// path: 指定路径
|
|
903
921
|
function getAbsolutePath(path) {
|
|
904
|
-
return callNative(getFuncName('getAbsolutePath'), { path });
|
|
922
|
+
return callNative(getFuncName('getAbsolutePath'), { path: path });
|
|
905
923
|
}
|
|
906
924
|
// 指定路径创建新文件
|
|
907
925
|
// 参数:
|
|
908
926
|
// path: 指定路径
|
|
909
927
|
function createNewFile(path) {
|
|
910
|
-
return callNative(getFuncName('createNewFile'), { path });
|
|
928
|
+
return callNative(getFuncName('createNewFile'), { path: path });
|
|
911
929
|
}
|
|
912
930
|
// 设置可读属性
|
|
913
931
|
// 参数:
|
|
914
932
|
// path: 指定路径
|
|
915
933
|
// value: 是否可读
|
|
916
|
-
function setReadable(path, value
|
|
917
|
-
|
|
934
|
+
function setReadable(path, value) {
|
|
935
|
+
if (value === void 0) { value = true; }
|
|
936
|
+
return callNative(getFuncName('setReadable'), { path: path, value: value });
|
|
918
937
|
}
|
|
919
938
|
// 设置可写属性
|
|
920
939
|
// 参数:
|
|
921
940
|
// path: 指定路径
|
|
922
941
|
// value: 是否可写
|
|
923
|
-
function setWritable(path, value
|
|
924
|
-
|
|
942
|
+
function setWritable(path, value) {
|
|
943
|
+
if (value === void 0) { value = true; }
|
|
944
|
+
return callNative(getFuncName('setWritable'), { path: path, value: value });
|
|
925
945
|
}
|
|
926
946
|
// 设置可执行属性
|
|
927
947
|
// 参数:
|
|
928
948
|
// path: 指定路径
|
|
929
949
|
// value: 是否可执行
|
|
930
|
-
function setExecutable(path, value
|
|
931
|
-
|
|
950
|
+
function setExecutable(path, value) {
|
|
951
|
+
if (value === void 0) { value = true; }
|
|
952
|
+
return callNative(getFuncName('setExecutable'), { path: path, value: value });
|
|
932
953
|
}
|
|
933
954
|
// 设置文件最后修改的时间
|
|
934
955
|
// 参数:
|
|
935
956
|
// path: 指定路径
|
|
936
957
|
// value: 时间戳
|
|
937
|
-
function setLastModified(path, value
|
|
938
|
-
|
|
958
|
+
function setLastModified(path, value) {
|
|
959
|
+
if (value === void 0) { value = 0; }
|
|
960
|
+
return callNative(getFuncName('setLastModified'), { path: path, value: value });
|
|
939
961
|
}
|
|
940
962
|
// 读取目录,返回该目录下的文件列表
|
|
941
963
|
// 参数:
|
|
942
964
|
// path: 指定路径
|
|
943
965
|
function list(path) {
|
|
944
|
-
return callNative(getFuncName('list'), { path });
|
|
966
|
+
return callNative(getFuncName('list'), { path: path });
|
|
945
967
|
}
|
|
946
968
|
var file = {
|
|
947
|
-
readAllContent,
|
|
948
|
-
writeAllContent,
|
|
949
|
-
getBaseDir,
|
|
950
|
-
getCacheDir,
|
|
951
|
-
makeCacheFile,
|
|
952
|
-
makeNormalFile,
|
|
953
|
-
exists,
|
|
954
|
-
isFile,
|
|
955
|
-
isDirectory,
|
|
956
|
-
isHidden,
|
|
957
|
-
canRead,
|
|
958
|
-
canWrite,
|
|
959
|
-
canExecute,
|
|
960
|
-
lastModified,
|
|
961
|
-
deleteIt,
|
|
962
|
-
mkdir,
|
|
963
|
-
mkdirs,
|
|
964
|
-
rename,
|
|
965
|
-
getAbsolutePath,
|
|
966
|
-
createNewFile,
|
|
967
|
-
setReadable,
|
|
968
|
-
setWritable,
|
|
969
|
-
setExecutable,
|
|
970
|
-
setLastModified,
|
|
971
|
-
list
|
|
969
|
+
readAllContent: readAllContent,
|
|
970
|
+
writeAllContent: writeAllContent,
|
|
971
|
+
getBaseDir: getBaseDir,
|
|
972
|
+
getCacheDir: getCacheDir,
|
|
973
|
+
makeCacheFile: makeCacheFile,
|
|
974
|
+
makeNormalFile: makeNormalFile,
|
|
975
|
+
exists: exists,
|
|
976
|
+
isFile: isFile,
|
|
977
|
+
isDirectory: isDirectory,
|
|
978
|
+
isHidden: isHidden,
|
|
979
|
+
canRead: canRead,
|
|
980
|
+
canWrite: canWrite,
|
|
981
|
+
canExecute: canExecute,
|
|
982
|
+
lastModified: lastModified,
|
|
983
|
+
deleteIt: deleteIt,
|
|
984
|
+
mkdir: mkdir,
|
|
985
|
+
mkdirs: mkdirs,
|
|
986
|
+
rename: rename,
|
|
987
|
+
getAbsolutePath: getAbsolutePath,
|
|
988
|
+
createNewFile: createNewFile,
|
|
989
|
+
setReadable: setReadable,
|
|
990
|
+
setWritable: setWritable,
|
|
991
|
+
setExecutable: setExecutable,
|
|
992
|
+
setLastModified: setLastModified,
|
|
993
|
+
list: list
|
|
972
994
|
};
|
|
973
995
|
|
|
974
996
|
window['appNativeCall'] = function apkNativeCall(str) {
|
|
975
|
-
|
|
997
|
+
var res = null;
|
|
976
998
|
//console.log('str1=' + str);
|
|
977
999
|
try {
|
|
978
|
-
|
|
1000
|
+
var dec1 = atob(str);
|
|
979
1001
|
//console.log('dec1=' + dec1);
|
|
980
|
-
|
|
1002
|
+
var dec2 = decodeURIComponent(dec1);
|
|
981
1003
|
//console.log('dec2=' + dec2);
|
|
982
1004
|
res = JSON.parse(dec2);
|
|
983
1005
|
//console.log('data type = ' + typeof(res.data));
|
|
@@ -1004,14 +1026,14 @@ function isRunInAppBrowser() {
|
|
|
1004
1026
|
return window['_liteNativeApi'] ? true : false;
|
|
1005
1027
|
}
|
|
1006
1028
|
var index = {
|
|
1007
|
-
network,
|
|
1008
|
-
app,
|
|
1009
|
-
system,
|
|
1010
|
-
storage,
|
|
1011
|
-
androidView,
|
|
1012
|
-
audio,
|
|
1013
|
-
file,
|
|
1014
|
-
isRunInAppBrowser
|
|
1029
|
+
network: network,
|
|
1030
|
+
app: app,
|
|
1031
|
+
system: system,
|
|
1032
|
+
storage: storage,
|
|
1033
|
+
androidView: androidView,
|
|
1034
|
+
audio: audio,
|
|
1035
|
+
file: file,
|
|
1036
|
+
isRunInAppBrowser: isRunInAppBrowser
|
|
1015
1037
|
};
|
|
1016
1038
|
|
|
1017
1039
|
export { index as default, isRunInAppBrowser, setAppCommandCallback, unsetAppCommandCallback };
|
package/{dist → lib}/index.d.ts
RENAMED
|
@@ -20,7 +20,6 @@ declare const _default: {
|
|
|
20
20
|
exitPage: typeof import("./app").exitPage;
|
|
21
21
|
moveTaskToBack: typeof import("./app").moveTaskToBack;
|
|
22
22
|
getUserInfo: typeof import("./app").getUserInfo;
|
|
23
|
-
setUserLogout: typeof import("./app").setUserLogout;
|
|
24
23
|
getAppList: typeof import("./app").getAppList;
|
|
25
24
|
getAppInfo: typeof import("./app").getAppInfo;
|
|
26
25
|
addLocalBroadcastHook: typeof import("./app").addLocalBroadcastHook;
|
package/package.json
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ccos/ccsdk-lite",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "a jssdk for coocaa tv-system",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/bundle.js",
|
|
7
|
+
"module": "lib/bundle.js",
|
|
8
|
+
"types": "lib/index.d.ts",
|
|
8
9
|
"files": [
|
|
9
|
-
"
|
|
10
|
+
"lib",
|
|
10
11
|
"README.md"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
|
-
"build": "rollup -c"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "http://gitlab.skysri.com/systemWebpage/ccsdk-lite"
|
|
18
18
|
},
|
|
19
19
|
"author": "coocaa",
|
|
20
|
-
"license": "
|
|
20
|
+
"license": "MIT",
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@rollup/plugin-typescript": "^12.1.4",
|
|
23
|
-
"rollup": "^4.45.1",
|
|
24
|
-
"tslib": "^2.8.1",
|
|
25
|
-
"typescript": "^5.8.3"
|
|
26
22
|
}
|
|
27
23
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|