@ccos/ccsdk-lite 1.0.2 → 1.0.4

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.
@@ -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/bundle.js CHANGED
@@ -4,70 +4,76 @@
4
4
  * 未传入name时默认会有自增id作为name
5
5
  * 主要为 定时器 bridge 等服务
6
6
  */
7
- class Bus {
8
- constructor() {
7
+ var Bus = /** @class */ (function () {
8
+ function Bus() {
9
9
  this._busId = 0;
10
10
  this._pool = {};
11
11
  }
12
- register(callback, name) {
13
- let busName = name ? name.toString() : (++this._busId).toString();
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, ...args) {
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
- const callbacks = this._pool[name];
26
+ var callbacks = this._pool[name];
23
27
  if (!callbacks || !callbacks.length)
24
28
  return;
25
- return callbacks.map((callback) => callback(...args));
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
- const callbacks = this._pool[name];
33
- const index = callbacks.indexOf(callback);
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
- const callbacks = this._pool[name];
44
- const index = callbacks.indexOf(callback);
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
- const bus = new Bus();
55
+ };
56
+ return Bus;
57
+ }());
58
+ var bus = new Bus();
54
59
 
55
- let actionList = []; // 这里保存, 未注册命令处理函数之前,APP发过来的命令
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
- let appCmdProcessor = defaultAppCmd; // APP 发过来的命令,JS的执行函数
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
- const workList = actionList;
72
+ var workList = actionList;
68
73
  actionList = [];
69
74
  // 如果 actionList 中有初始化之前来的命令,则执行这些命令
70
- for (const action of workList) {
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
- let persistentCallbackId = []; // 持久化 callback-id 列表
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
- let callbackId = bus.register((res) => {
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
- let index = persistentCallbackId.indexOf(persistentIdName);
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
- let callbackId = bus.register((res) => {
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
- let index = persistentCallbackId.indexOf(persistentIdName);
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
- let payload = '';
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
- let index = persistentCallbackId.indexOf(callbackId);
154
+ var index = persistentCallbackId.indexOf(callbackId);
149
155
  if (index < 0) {
150
156
  bus.remove(callbackId);
151
157
  }
152
158
  }
153
159
 
154
- const moduleName$6 = 'network';
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
- let strArr = [];
163
- let counter = 0;
164
- let keys = Object.keys(params);
168
+ var strArr = [];
169
+ var counter = 0;
170
+ var keys = Object.keys(params);
165
171
  keys.sort();
166
- for (const key of keys) {
167
- const value = params[key];
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
- const paramString = paramToUrl(urlParam);
191
- let newUrl;
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
- let obj = {
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
- let obj = {
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
- const paramString = paramToUrl(urlParam);
259
- let newUrl;
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
- let obj = {
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 = true, method = 'GET', header = '', postType = '', body = '') {
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
- const moduleName$5 = 'app';
331
- const localBroadcastHookCallbackId = 'localBroadcastHookCallbackId';
332
- const globalBroadcastHookCallbackId = 'globalBroadcastHookCallbackId';
333
- const localBroadcastActionMap = new Map();
334
- const globalBroadcastActionMap = new Map();
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
- const action = payload['action'];
382
+ var action = payload['action'];
374
383
  if (localBroadcastActionMap.has(action)) {
375
- const func = localBroadcastActionMap.get(action);
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
- const action = payload['action'];
393
+ var action = payload['action'];
385
394
  if (globalBroadcastActionMap.has(action)) {
386
- const func = globalBroadcastActionMap.get(action);
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 = false, fromAssets = false) {
412
- return callNative(getFuncName$5('playAudio'), { source, loop, fromAssets });
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
- let str = '';
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
- setUserLogout,
439
- getAppList,
440
- getAppInfo,
441
- addLocalBroadcastHook,
442
- deleteLocalBroadcastHook,
443
- addBroadcastHook,
444
- deleteBroadcastHook,
445
- playAudio,
446
- stopAudio,
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
- const moduleName$4 = 'system';
451
- const lifeCycleHookCallbackId = 'lifeCycleHookCallback';
460
+ var moduleName$4 = 'system';
461
+ var lifeCycleHookCallbackId = 'lifeCycleHookCallback';
452
462
  function getFuncName$4(name) {
453
463
  return moduleName$4 + '_' + name;
454
464
  }
@@ -475,163 +485,265 @@ 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() {
482
492
  return callNative(getFuncName$4('getLocation'), null);
483
493
  }
494
+ // 检查 JS-API 是否已经实现
495
+ function checkApi(apiName) {
496
+ return callNative(getFuncName$4('checkApi'), { apiName: apiName });
497
+ }
498
+ // 获取显示屏幕信息
499
+ function getDisplayInfo() {
500
+ return callNative(getFuncName$4('getDisplayInfo'), null);
501
+ }
484
502
  var system = {
485
- getSdkVersion,
486
- addLifeCycleHook,
487
- deleteLifeCycleHook,
488
- enableSystemKey,
489
- getDeviceInfo,
490
- getProperty,
491
- getLocation
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,
492
512
  };
493
513
 
494
- const moduleName$3 = 'storage';
514
+ var moduleName$3 = 'storage';
495
515
  function getFuncName$3(name) {
496
516
  return moduleName$3 + '_' + name;
497
517
  }
498
518
  function setKey(key, value) {
499
- return callNative(getFuncName$3('setKey'), { key, value });
519
+ return callNative(getFuncName$3('setKey'), { key: key, value: value });
500
520
  }
501
521
  function getKey(key) {
502
- return callNative(getFuncName$3('getKey'), { key });
522
+ return callNative(getFuncName$3('getKey'), { key: key });
503
523
  }
504
524
  function deleteKey(key) {
505
- return callNative(getFuncName$3('deleteKey'), { key });
525
+ return callNative(getFuncName$3('deleteKey'), { key: key });
506
526
  }
507
527
  function clearAllKeys() {
508
528
  return callNative(getFuncName$3('clearAllKeys'), null);
509
529
  }
510
530
  var storage = {
511
- setKey,
512
- getKey,
513
- deleteKey,
514
- clearAllKeys
531
+ setKey: setKey,
532
+ getKey: getKey,
533
+ deleteKey: deleteKey,
534
+ clearAllKeys: clearAllKeys
515
535
  };
516
536
 
517
- const moduleName$2 = 'androidView';
537
+ var moduleName$2 = 'audio';
518
538
  function getFuncName$2(name) {
519
539
  return moduleName$2 + '_' + name;
520
540
  }
521
- const playerListenerCallbackId = 'playerListenerCallbackId';
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';
522
632
  // 播放PAG动画
523
633
  // repeat: 循环次数 -1 表示无限
524
634
  //
525
635
  function startPagAni(params) {
526
- return callNative(getFuncName$2('startPagAni'), params);
636
+ return callNative(getFuncName$1('startPagAni'), params);
527
637
  }
528
638
  // 停止PAG动画,并消失
529
639
  function stopPagAni() {
530
- return callNative(getFuncName$2('stopPagAni'), null);
640
+ return callNative(getFuncName$1('stopPagAni'), null);
531
641
  }
532
642
  // 播报 TTS 文本语音
533
643
  function sendTts(text, ttsId) {
534
- return callNative(getFuncName$2('sendTts'), { text, id: ttsId });
644
+ return callNative(getFuncName$1('sendTts'), { text: text, id: ttsId });
535
645
  }
536
646
  // 停止播报 TTS
537
647
  function stopTts() {
538
- return callNative(getFuncName$2('stopTts'), null);
648
+ return callNative(getFuncName$1('stopTts'), null);
539
649
  }
540
650
  // 流式播报 TTS
541
651
  function sendStreamTts(text, ttsId, isFirst, isEnd) {
542
- return callNative(getFuncName$2('sendStreamTts'), { text, id: ttsId, isFirst, isEnd });
652
+ return callNative(getFuncName$1('sendStreamTts'), { text: text, id: ttsId, isFirst: isFirst, isEnd: isEnd });
543
653
  }
544
654
  // 播放器,播放新的URL
545
655
  function playerPlayNewUrl(url) {
546
- return callNative(getFuncName$2('playerPlayNewUrl'), { url });
656
+ return callNative(getFuncName$1('playerPlayNewUrl'), { url: url });
547
657
  }
548
658
  // 播放器,停止播放
549
659
  function playerStop() {
550
- return callNative(getFuncName$2('playerStop'), null);
660
+ return callNative(getFuncName$1('playerStop'), null);
551
661
  }
552
662
  // 播放器,暂停播放
553
663
  function playerPause() {
554
- return callNative(getFuncName$2('playerPause'), null);
664
+ return callNative(getFuncName$1('playerPause'), null);
555
665
  }
556
666
  // 播放器,启动播放或者从暂停恢复播放
557
667
  function playerStart() {
558
- return callNative(getFuncName$2('playerStart'), null);
668
+ return callNative(getFuncName$1('playerStart'), null);
559
669
  }
560
670
  // 播放器,seek
561
671
  function playerSeekTo(position) {
562
- return callNative(getFuncName$2('playerSeekTo'), { position: Math.floor(position) });
672
+ return callNative(getFuncName$1('playerSeekTo'), { position: Math.floor(position) });
563
673
  }
564
674
  // 播放器,是否准备好
565
675
  function playerHasPrepared() {
566
- return callNative(getFuncName$2('playerHasPrepared'), null);
676
+ return callNative(getFuncName$1('playerHasPrepared'), null);
567
677
  }
568
678
  // 播放器,是否正在播放中
569
679
  function playerIsPlaying() {
570
- return callNative(getFuncName$2('playerIsPlaying'), null);
680
+ return callNative(getFuncName$1('playerIsPlaying'), null);
571
681
  }
572
682
  // 播放器,获取总时长
573
683
  function playerGetDuration() {
574
- return callNative(getFuncName$2('playerGetDuration'), null);
684
+ return callNative(getFuncName$1('playerGetDuration'), null);
575
685
  }
576
686
  // 播放器,获取当前进度值
577
687
  function playerGetCurrentPosition() {
578
- return callNative(getFuncName$2('playerGetCurrentPosition'), null);
688
+ return callNative(getFuncName$1('playerGetCurrentPosition'), null);
579
689
  }
580
690
  // 播放器,获取播放状态,返回的value为字符串来标识播放状态
581
691
  // 例如:Idle, Initialized, Preparing, Prepared, Started, Paused, Stopped, Completed, Error, End
582
692
  function playerGetPlayerState() {
583
- return callNative(getFuncName$2('playerGetPlayerState'), null);
693
+ return callNative(getFuncName$1('playerGetPlayerState'), null);
584
694
  }
585
695
  // 播放器,播放新的本地文件路径
586
696
  function playerPlayNewFile(path) {
587
- return callNative(getFuncName$2('playerPlayNewFile'), { path });
697
+ return callNative(getFuncName$1('playerPlayNewFile'), { path: path });
588
698
  }
589
699
  // 播放器,设置单片循环模式
590
700
  // isLooping: 是否循环播放
591
701
  // silentLoop - 静默循环,默认关闭, 开启之后,部分依靠onCompletion重新播放来实现循环播放的方案下:
592
702
  // 会无感知重播,即重播时,不会调idle/ preparing/ prepared等开始播放之前的状态)
593
- function playerSetLooping(isLooping, silentLoop = false) {
594
- return callNative(getFuncName$2('playerSetLooping'), { isLooping, silentLoop });
703
+ function playerSetLooping(isLooping, silentLoop) {
704
+ if (silentLoop === void 0) { silentLoop = false; }
705
+ return callNative(getFuncName$1('playerSetLooping'), { isLooping: isLooping, silentLoop: silentLoop });
595
706
  }
596
707
  // 播放器,设置自动屏保锁,即:开始或恢复播放->锁屏保,停止或暂停播放->释放屏保锁 默认关闭
597
708
  function playerSetAutoWakeLock(autoWakeLock) {
598
- return callNative(getFuncName$2('playerSetAutoWakeLock'), { autoWakeLock });
709
+ return callNative(getFuncName$1('playerSetAutoWakeLock'), { autoWakeLock: autoWakeLock });
599
710
  }
600
711
  // 播放器,重新播放
601
712
  function playerRePlay() {
602
- return callNative(getFuncName$2('playerRePlay'), null);
713
+ return callNative(getFuncName$1('playerRePlay'), null);
603
714
  }
604
715
  // 播放器,设置是否自动播放,即 play ready 后音视频自动播放 默认开启
605
- function playerSetPlayWhenReady(playWhenReady = true) {
606
- return callNative(getFuncName$2('playerSetPlayWhenReady'), { playWhenReady });
716
+ function playerSetPlayWhenReady(playWhenReady) {
717
+ if (playWhenReady === void 0) { playWhenReady = true; }
718
+ return callNative(getFuncName$1('playerSetPlayWhenReady'), { playWhenReady: playWhenReady });
607
719
  }
608
720
  // 获取当前设置的播放内核, 有可能会返回 DefaultPlayer
609
721
  // 值: DefaultPlayer, MediaPlayer, SocPlayer, ExoPlayer
610
722
  function playerGetPlayerCore() {
611
- return callNative(getFuncName$2('playerGetPlayerCore'), null);
723
+ return callNative(getFuncName$1('playerGetPlayerCore'), null);
612
724
  }
613
725
  // 获取实际的播放内核, 部分内核如:最佳内核,实际上是在各个内核中进行选择,不会返回 DefaultPlayer
614
726
  // 值: MediaPlayer, SocPlayer, ExoPlayer
615
727
  function playerGetRealPlayerCore() {
616
- return callNative(getFuncName$2('playerGetRealPlayerCore'), null);
728
+ return callNative(getFuncName$1('playerGetRealPlayerCore'), null);
617
729
  }
618
730
  // 设置视频播放器的事件回调
619
731
  // 注意: 使用此回调的话,不用时记得使用 playerDeleteListener 注销事件回调
620
732
  function playerSetListener(callback) {
621
- return callWithPersistentCallBack(getFuncName$2('playerSetListener'), { callbackId: playerListenerCallbackId }, playerListenerCallbackId, callback);
733
+ return callWithPersistentCallBack(getFuncName$1('playerSetListener'), { callbackId: playerListenerCallbackId }, playerListenerCallbackId, callback);
622
734
  }
623
735
  // 注销视频播放器的事件回调
624
736
  function playerDeleteListener() {
625
737
  deletePersistentCallBack(playerListenerCallbackId);
626
- return callNative(getFuncName$2('playerDeleteListener'), null);
738
+ return callNative(getFuncName$1('playerDeleteListener'), null);
627
739
  }
628
740
  // 设置视频播放窗口的位置与宽高
629
741
  function setVideoLayout(width, height, x, y) {
630
- return callNative(getFuncName$2('setVideoLayout'), { x: Number(x), y: Number(y), w: Number(width), h: Number(height) });
742
+ return callNative(getFuncName$1('setVideoLayout'), { x: Number(x), y: Number(y), w: Number(width), h: Number(height) });
631
743
  }
632
744
  // 设置视频窗口是否显示
633
745
  function setVideoVisible(show) {
634
- return callNative(getFuncName$2('setVideoVisible'), { visible: show });
746
+ return callNative(getFuncName$1('setVideoVisible'), { visible: show });
635
747
  }
636
748
  // 设置背景
637
749
  // needUpdateColor : 是否更新颜色
@@ -639,143 +751,55 @@ function setVideoVisible(show) {
639
751
  // needUpdateImage : 是否更新背景图
640
752
  // imageUrl: 背景图的URL
641
753
  function setBackground(needUpdateColor, color, needUpdateImage, imageUrl) {
642
- return callNative(getFuncName$2('setBackground'), { updateColorFlag: needUpdateColor, updateImageFlag: needUpdateImage, color: Math.floor(color), imageUrl });
754
+ return callNative(getFuncName$1('setBackground'), { updateColorFlag: needUpdateColor, updateImageFlag: needUpdateImage, color: Math.floor(color), imageUrl: imageUrl });
643
755
  }
644
756
  // 清除背景
645
757
  function clearBackground() {
646
- return callNative(getFuncName$2('clearBackground'), null);
758
+ return callNative(getFuncName$1('clearBackground'), null);
647
759
  }
648
760
  // 显示语音文本提示条, tips文本中如果带 # 字符,会把 # 字符显示成麦克风图标
649
- function showVoiceTipsBar(tips = '') {
650
- return callNative(getFuncName$2('showVoiceTipsBar'), { tips });
761
+ function showVoiceTipsBar(tips) {
762
+ if (tips === void 0) { tips = ''; }
763
+ return callNative(getFuncName$1('showVoiceTipsBar'), { tips: tips });
651
764
  }
652
765
  // 隐藏语音文本提示条
653
766
  function hideVoiceTipsBar() {
654
- return callNative(getFuncName$2('hideVoiceTipsBar'), null);
767
+ return callNative(getFuncName$1('hideVoiceTipsBar'), null);
655
768
  }
656
769
  var androidView = {
657
- startPagAni,
658
- stopPagAni,
659
- sendTts,
660
- stopTts,
661
- sendStreamTts,
662
- playerPlayNewUrl,
663
- playerStop,
664
- playerPause,
665
- playerStart,
666
- playerSeekTo,
667
- playerHasPrepared,
668
- playerIsPlaying,
669
- playerGetDuration,
670
- playerGetCurrentPosition,
671
- playerGetPlayerState,
672
- playerPlayNewFile,
673
- playerSetLooping,
674
- playerSetAutoWakeLock,
675
- playerRePlay,
676
- playerSetPlayWhenReady,
677
- playerGetPlayerCore,
678
- playerGetRealPlayerCore,
679
- playerSetListener,
680
- playerDeleteListener,
681
- setVideoLayout,
682
- setVideoVisible,
683
- setBackground,
684
- clearBackground,
685
- showVoiceTipsBar,
686
- hideVoiceTipsBar,
687
- };
688
-
689
- const moduleName$1 = 'audio';
690
- function getFuncName$1(name) {
691
- return moduleName$1 + '_' + name;
692
- }
693
- const audioPlayerListenerCallbackId = 'audioPlayerListenerCallbackId';
694
- // 播放器,播放新的URL或者本地文件系统的路径
695
- function playNew(path) {
696
- return callNative(getFuncName$1('playNew'), { path });
697
- }
698
- // 播放器,停止播放
699
- function stop() {
700
- return callNative(getFuncName$1('stop'), null);
701
- }
702
- // 播放器,是否正在播放中
703
- function isPlaying() {
704
- return callNative(getFuncName$1('isPlaying'), null);
705
- }
706
- // 播放器,是否准备好
707
- function hasPrepared() {
708
- return callNative(getFuncName$1('hasPrepared'), null);
709
- }
710
- // 播放器,获取总时长
711
- function getDuration() {
712
- return callNative(getFuncName$1('getDuration'), null);
713
- }
714
- // 播放器,获取当前进度值
715
- function getCurrentPosition() {
716
- return callNative(getFuncName$1('getCurrentPosition'), null);
717
- }
718
- // 播放器,获取播放状态,返回的value为字符串来标识播放状态
719
- // 例如:Idle, Initialized, Preparing, Prepared, Started, Paused, Stopped, Completed, Error, End
720
- function getPlayerState() {
721
- return callNative(getFuncName$1('getPlayerState'), null);
722
- }
723
- // 播放器,暂停播放
724
- function pause() {
725
- return callNative(getFuncName$1('pause'), null);
726
- }
727
- // 播放器,启动播放或者从暂停恢复播放
728
- function start() {
729
- return callNative(getFuncName$1('start'), null);
730
- }
731
- // 播放器,重新播放
732
- function rePlay() {
733
- return callNative(getFuncName$1('rePlay'), null);
734
- }
735
- // 播放器,seek
736
- function seekTo(position) {
737
- return callNative(getFuncName$1('seekTo'), { position: Math.floor(position) });
738
- }
739
- // 播放器,设置单片循环模式
740
- // isLooping: 是否循环播放
741
- // silentLoop - 静默循环,默认关闭, 开启之后,部分依靠onCompletion重新播放来实现循环播放的方案下:
742
- // 会无感知重播,即重播时,不会调idle/ preparing/ prepared等开始播放之前的状态)
743
- function setLooping(isLooping, silentLoop = false) {
744
- return callNative(getFuncName$1('setLooping'), { isLooping, silentLoop });
745
- }
746
- // 设置音量
747
- function setVolume(volume) {
748
- return callNative(getFuncName$1('setVolume'), { volume });
749
- }
750
- // 设置视频播放器的事件回调
751
- // 注意: 使用此回调的话,不用时记得使用 deleteListener 注销事件回调
752
- function setListener(callback) {
753
- return callWithPersistentCallBack(getFuncName$1('setListener'), { callbackId: audioPlayerListenerCallbackId }, audioPlayerListenerCallbackId, callback);
754
- }
755
- // 注销视频播放器的事件回调
756
- function deleteListener() {
757
- deletePersistentCallBack(audioPlayerListenerCallbackId);
758
- return callNative(getFuncName$1('deleteListener'), null);
759
- }
760
- var audio = {
761
- playNew,
762
- stop,
763
- isPlaying,
764
- hasPrepared,
765
- getDuration,
766
- getCurrentPosition,
767
- getPlayerState,
768
- pause,
769
- start,
770
- rePlay,
771
- seekTo,
772
- setLooping,
773
- setVolume,
774
- setListener,
775
- 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,
776
800
  };
777
801
 
778
- const moduleName = 'file';
802
+ var moduleName = 'file';
779
803
  function getFuncName(name) {
780
804
  return moduleName + '_' + name;
781
805
  }
@@ -783,16 +807,18 @@ function getFuncName(name) {
783
807
  // 参数:
784
808
  // path: 读取文件的路径
785
809
  // base64Flag: 是否以base64编码方式返回, 如果读取文件文件,则应该设置 base64Flag = false,如果读取二进制文件,则应该设置 base64Flag = true
786
- function readAllContent(path, base64Flag = false) {
787
- return callNative(getFuncName('readAllContent'), { path, base64Flag });
810
+ function readAllContent(path, base64Flag) {
811
+ if (base64Flag === void 0) { base64Flag = false; }
812
+ return callNative(getFuncName('readAllContent'), { path: path, base64Flag: base64Flag });
788
813
  }
789
814
  // 将内容全部写入文件
790
815
  // 参数:
791
816
  // path: 写入文件的路径
792
817
  // content: 写入的内容,字符串,如果要写入二进制,应该先编码成 base64 字符串再传入
793
818
  // base64Flag: 是否以base64编码方式传输content, 如果写文件文件,则应该设置 base64Flag = false,如果写入二进制文件,则应该设置 base64Flag = true
794
- function writeAllContent(path, content, base64Flag = false) {
795
- return callNative(getFuncName('writeAllContent'), { path, content, base64Flag });
819
+ function writeAllContent(path, content, base64Flag) {
820
+ if (base64Flag === void 0) { base64Flag = false; }
821
+ return callNative(getFuncName('writeAllContent'), { path: path, content: content, base64Flag: base64Flag });
796
822
  }
797
823
  // 获取应用基本目录的全路径名
798
824
  function getBaseDir() {
@@ -805,169 +831,175 @@ function getCacheDir() {
805
831
  // 构建一个临时文件名,返回该文件的绝对路径的全文件路径名
806
832
  // 参数:
807
833
  // fileName: 指定临时文件的基本名,如果不指定,会默认随机生成一个文件名
808
- function makeCacheFile(fileName = '') {
809
- return callNative(getFuncName('makeCacheFile'), { fileName });
834
+ function makeCacheFile(fileName) {
835
+ if (fileName === void 0) { fileName = ''; }
836
+ return callNative(getFuncName('makeCacheFile'), { fileName: fileName });
810
837
  }
811
838
  // 构建一个正常文件名,返回该文件的绝对路径的全文件路径名
812
839
  // 参数:
813
840
  // fileName: 指定文件的基本名,如果不指定,会默认随机生成一个文件名
814
- function makeNormalFile(fileName = '') {
815
- return callNative(getFuncName('makeNormalFile'), { fileName });
841
+ function makeNormalFile(fileName) {
842
+ if (fileName === void 0) { fileName = ''; }
843
+ return callNative(getFuncName('makeNormalFile'), { fileName: fileName });
816
844
  }
817
845
  // 检测一个文件或者目录是否存在
818
846
  // 参数:
819
847
  // path: 指定路径
820
848
  function exists(path) {
821
- return callNative(getFuncName('exists'), { path });
849
+ return callNative(getFuncName('exists'), { path: path });
822
850
  }
823
851
  // 检测一个路径是否为一个普通文件
824
852
  // 参数:
825
853
  // path: 指定路径
826
854
  function isFile(path) {
827
- return callNative(getFuncName('isFile'), { path });
855
+ return callNative(getFuncName('isFile'), { path: path });
828
856
  }
829
857
  // 检测一个路径是否为一个目录
830
858
  // 参数:
831
859
  // path: 指定路径
832
860
  function isDirectory(path) {
833
- return callNative(getFuncName('isDirectory'), { path });
861
+ return callNative(getFuncName('isDirectory'), { path: path });
834
862
  }
835
863
  // 检测一个路径表示的文件或目录 是否是隐藏的
836
864
  // 参数:
837
865
  // path: 指定路径
838
866
  function isHidden(path) {
839
- return callNative(getFuncName('isHidden'), { path });
867
+ return callNative(getFuncName('isHidden'), { path: path });
840
868
  }
841
869
  // 检测一个路径表示的文件或目录 是否可读
842
870
  // 参数:
843
871
  // path: 指定路径
844
872
  function canRead(path) {
845
- return callNative(getFuncName('canRead'), { path });
873
+ return callNative(getFuncName('canRead'), { path: path });
846
874
  }
847
875
  // 检测一个路径表示的文件或目录 是否可写
848
876
  // 参数:
849
877
  // path: 指定路径
850
878
  function canWrite(path) {
851
- return callNative(getFuncName('canWrite'), { path });
879
+ return callNative(getFuncName('canWrite'), { path: path });
852
880
  }
853
881
  // 检测一个路径表示的文件或目录 是否可执行
854
882
  // 参数:
855
883
  // path: 指定路径
856
884
  function canExecute(path) {
857
- return callNative(getFuncName('canExecute'), { path });
885
+ return callNative(getFuncName('canExecute'), { path: path });
858
886
  }
859
887
  // 检测一个路径表示的文件或目录 的最后修改的时间,返回时间戳(1970年开始的秒数)
860
888
  // 参数:
861
889
  // path: 指定路径
862
890
  function lastModified(path) {
863
- return callNative(getFuncName('lastModified'), { path });
891
+ return callNative(getFuncName('lastModified'), { path: path });
864
892
  }
865
893
  // 删除文件
866
894
  // 参数:
867
895
  // path: 指定路径
868
896
  function deleteIt(path) {
869
- return callNative(getFuncName('delete'), { path });
897
+ return callNative(getFuncName('delete'), { path: path });
870
898
  }
871
899
  // 新建目录
872
900
  // 参数:
873
901
  // path: 指定路径
874
902
  function mkdir(path) {
875
- return callNative(getFuncName('mkdir'), { path });
903
+ return callNative(getFuncName('mkdir'), { path: path });
876
904
  }
877
905
  // 新建目录 (如果父目录补存在则一并新建所有尚未存在的父目录)
878
906
  // 参数:
879
907
  // path: 指定路径
880
908
  function mkdirs(path) {
881
- return callNative(getFuncName('mkdirs'), { path });
909
+ return callNative(getFuncName('mkdirs'), { path: path });
882
910
  }
883
911
  // 改名
884
912
  // 参数:
885
913
  // from: 指定源路径
886
914
  // to: 指定目标路径
887
915
  function rename(from, to) {
888
- return callNative(getFuncName('rename'), { from, to });
916
+ return callNative(getFuncName('rename'), { from: from, to: to });
889
917
  }
890
918
  // 将相对路径的转换为全路径
891
919
  // 参数:
892
920
  // path: 指定路径
893
921
  function getAbsolutePath(path) {
894
- return callNative(getFuncName('getAbsolutePath'), { path });
922
+ return callNative(getFuncName('getAbsolutePath'), { path: path });
895
923
  }
896
924
  // 指定路径创建新文件
897
925
  // 参数:
898
926
  // path: 指定路径
899
927
  function createNewFile(path) {
900
- return callNative(getFuncName('createNewFile'), { path });
928
+ return callNative(getFuncName('createNewFile'), { path: path });
901
929
  }
902
930
  // 设置可读属性
903
931
  // 参数:
904
932
  // path: 指定路径
905
933
  // value: 是否可读
906
- function setReadable(path, value = true) {
907
- return callNative(getFuncName('setReadable'), { path, value });
934
+ function setReadable(path, value) {
935
+ if (value === void 0) { value = true; }
936
+ return callNative(getFuncName('setReadable'), { path: path, value: value });
908
937
  }
909
938
  // 设置可写属性
910
939
  // 参数:
911
940
  // path: 指定路径
912
941
  // value: 是否可写
913
- function setWritable(path, value = true) {
914
- return callNative(getFuncName('setWritable'), { path, value });
942
+ function setWritable(path, value) {
943
+ if (value === void 0) { value = true; }
944
+ return callNative(getFuncName('setWritable'), { path: path, value: value });
915
945
  }
916
946
  // 设置可执行属性
917
947
  // 参数:
918
948
  // path: 指定路径
919
949
  // value: 是否可执行
920
- function setExecutable(path, value = true) {
921
- return callNative(getFuncName('setExecutable'), { path, value });
950
+ function setExecutable(path, value) {
951
+ if (value === void 0) { value = true; }
952
+ return callNative(getFuncName('setExecutable'), { path: path, value: value });
922
953
  }
923
954
  // 设置文件最后修改的时间
924
955
  // 参数:
925
956
  // path: 指定路径
926
957
  // value: 时间戳
927
- function setLastModified(path, value = 0) {
928
- return callNative(getFuncName('setLastModified'), { path, value });
958
+ function setLastModified(path, value) {
959
+ if (value === void 0) { value = 0; }
960
+ return callNative(getFuncName('setLastModified'), { path: path, value: value });
929
961
  }
930
962
  // 读取目录,返回该目录下的文件列表
931
963
  // 参数:
932
964
  // path: 指定路径
933
965
  function list(path) {
934
- return callNative(getFuncName('list'), { path });
966
+ return callNative(getFuncName('list'), { path: path });
935
967
  }
936
968
  var file = {
937
- readAllContent,
938
- writeAllContent,
939
- getBaseDir,
940
- getCacheDir,
941
- makeCacheFile,
942
- makeNormalFile,
943
- exists,
944
- isFile,
945
- isDirectory,
946
- isHidden,
947
- canRead,
948
- canWrite,
949
- canExecute,
950
- lastModified,
951
- deleteIt,
952
- mkdir,
953
- mkdirs,
954
- rename,
955
- getAbsolutePath,
956
- createNewFile,
957
- setReadable,
958
- setWritable,
959
- setExecutable,
960
- setLastModified,
961
- 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
962
994
  };
963
995
 
964
- window['apkNativeCall'] = function apkNativeCall(str) {
965
- let res = null;
996
+ window['appNativeCall'] = function apkNativeCall(str) {
997
+ var res = null;
966
998
  //console.log('str1=' + str);
967
999
  try {
968
- const dec1 = atob(str);
1000
+ var dec1 = atob(str);
969
1001
  //console.log('dec1=' + dec1);
970
- const dec2 = decodeURIComponent(dec1);
1002
+ var dec2 = decodeURIComponent(dec1);
971
1003
  //console.log('dec2=' + dec2);
972
1004
  res = JSON.parse(dec2);
973
1005
  //console.log('data type = ' + typeof(res.data));
@@ -994,14 +1026,14 @@ function isRunInAppBrowser() {
994
1026
  return window['_liteNativeApi'] ? true : false;
995
1027
  }
996
1028
  var index = {
997
- network,
998
- app,
999
- system,
1000
- storage,
1001
- androidView,
1002
- audio,
1003
- file,
1004
- 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
1005
1037
  };
1006
1038
 
1007
1039
  export { index as default, isRunInAppBrowser, setAppCommandCallback, unsetAppCommandCallback };
package/dist/index.d.ts CHANGED
@@ -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;
@@ -39,6 +38,8 @@ declare const _default: {
39
38
  getDeviceInfo: typeof import("./system").getDeviceInfo;
40
39
  getProperty: typeof import("./system").getProperty;
41
40
  getLocation: typeof import("./system").getLocation;
41
+ checkApi: typeof import("./system").checkApi;
42
+ getDisplayInfo: typeof import("./system").getDisplayInfo;
42
43
  };
43
44
  storage: {
44
45
  setKey: typeof import("./storage").setKey;
@@ -8,6 +8,8 @@ export declare function enableSystemKey(params: SystemKeyParam | null): Promise<
8
8
  export declare function getDeviceInfo(): Promise<any>;
9
9
  export declare function getProperty(key: string): Promise<any>;
10
10
  export declare function getLocation(): Promise<any>;
11
+ export declare function checkApi(apiName: string): Promise<any>;
12
+ export declare function getDisplayInfo(): Promise<any>;
11
13
  declare const _default: {
12
14
  getSdkVersion: typeof getSdkVersion;
13
15
  addLifeCycleHook: typeof addLifeCycleHook;
@@ -16,5 +18,7 @@ declare const _default: {
16
18
  getDeviceInfo: typeof getDeviceInfo;
17
19
  getProperty: typeof getProperty;
18
20
  getLocation: typeof getLocation;
21
+ checkApi: typeof checkApi;
22
+ getDisplayInfo: typeof getDisplayInfo;
19
23
  };
20
24
  export default _default;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@ccos/ccsdk-lite",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "a jssdk for coocaa tv-system",
5
+ "type": "module",
5
6
  "main": "dist/bundle.js",
6
7
  "module": "dist/bundle.js",
7
8
  "types": "dist/index.d.ts",