@ccos/ccsdk-lite 1.0.8 → 1.0.10

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.
@@ -9,36 +9,26 @@ export interface GetAppInfoParam {
9
9
  package: string;
10
10
  needIcon?: boolean;
11
11
  }
12
+ export declare function getUserInfo(): Promise<any>;
13
+ export declare function getHostAppInfo(): Promise<any>;
14
+ export declare function startPage(params: IntentParam): Promise<any>;
12
15
  export declare function startActivity(params: IntentParam): Promise<any>;
13
- export declare function startService(params: IntentParam): Promise<any>;
14
- export declare function sendBroadcast(params: IntentParam): Promise<any>;
15
- export declare function sendLocalBroadcast(params: IntentParam): Promise<any>;
16
- export declare function startBackEndAction(action: object): Promise<any>;
17
16
  export declare function exitPage(): void;
18
- export declare function moveTaskToBack(): Promise<any>;
19
- export declare function getUserInfo(): Promise<any>;
20
- export declare function getAppList(): Promise<any>;
21
- export declare function getAppInfo(params: GetAppInfoParam): Promise<any>;
22
- export declare function setLocalBroadcastHook(action: string, callback: Function): Promise<any>;
23
- export declare function deleteLocalBroadcastHook(action: string): Promise<any>;
24
- export declare function setBroadcastHook(action: string, callback: Function): Promise<any>;
25
- export declare function deleteBroadcastHook(action: string): Promise<any>;
26
- export declare function appPrivateMethod(method: string, params: any): Promise<any>;
17
+ export declare function movePageToBack(): Promise<any>;
18
+ export declare function startService(params: IntentParam): Promise<any>;
19
+ export declare function getInstalledAppInfo(params: GetAppInfoParam): Promise<any>;
20
+ export declare function getInstalledAppsList(): void;
21
+ export declare function execActionString(action: object): Promise<any>;
27
22
  declare const _default: {
23
+ getUserInfo: typeof getUserInfo;
24
+ getHostAppInfo: typeof getHostAppInfo;
25
+ startPage: typeof startPage;
28
26
  startActivity: typeof startActivity;
29
- startService: typeof startService;
30
- sendBroadcast: typeof sendBroadcast;
31
- sendLocalBroadcast: typeof sendLocalBroadcast;
32
- startBackEndAction: typeof startBackEndAction;
33
27
  exitPage: typeof exitPage;
34
- moveTaskToBack: typeof moveTaskToBack;
35
- getUserInfo: typeof getUserInfo;
36
- getAppList: typeof getAppList;
37
- getAppInfo: typeof getAppInfo;
38
- setLocalBroadcastHook: typeof setLocalBroadcastHook;
39
- deleteLocalBroadcastHook: typeof deleteLocalBroadcastHook;
40
- setBroadcastHook: typeof setBroadcastHook;
41
- deleteBroadcastHook: typeof deleteBroadcastHook;
42
- appPrivateMethod: typeof appPrivateMethod;
28
+ movePageToBack: typeof movePageToBack;
29
+ startService: typeof startService;
30
+ getInstalledAppInfo: typeof getInstalledAppInfo;
31
+ getInstalledAppsList: typeof getInstalledAppsList;
32
+ execActionString: typeof execActionString;
43
33
  };
44
34
  export default _default;
@@ -12,9 +12,6 @@ export declare function seekTo(position: number): Promise<any>;
12
12
  export declare function setLooping(isLooping: boolean, silentLoop?: boolean): Promise<any>;
13
13
  export declare function setVolume(volume: number): Promise<any>;
14
14
  export declare function setPlayerCore(core: 'DefaultPlayer' | 'MediaPlayer' | 'SocPlayer' | 'ExoPlayer'): Promise<any>;
15
- export declare function setRenderType(playerRender: 'SurfaceView' | 'TextureView'): Promise<any>;
16
- export declare function setListener(callback: Function): Promise<any>;
17
- export declare function deleteListener(): Promise<any>;
18
15
  declare const _default: {
19
16
  playNew: typeof playNew;
20
17
  stop: typeof stop;
@@ -30,8 +27,5 @@ declare const _default: {
30
27
  setLooping: typeof setLooping;
31
28
  setVolume: typeof setVolume;
32
29
  setPlayerCore: typeof setPlayerCore;
33
- setRenderType: typeof setRenderType;
34
- setListener: typeof setListener;
35
- deleteListener: typeof deleteListener;
36
30
  };
37
31
  export default _default;
package/lib/bundle.js CHANGED
@@ -85,7 +85,7 @@ function unsetAppCommandCallback() {
85
85
  }
86
86
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
87
87
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
88
- var persistentCallbackId = []; // 持久化 callback-id 列表
88
+ var persistentCallbackMap = new Map(); // 持久化 callback-id 与回调函数对应的列表 (回调函数可以多个,组成一个Set)
89
89
  function nativeCall(funcName, callbackId, params) {
90
90
  if (window['_liteNativeApi']) {
91
91
  // 运行于 android 浏览器webview
@@ -97,6 +97,16 @@ function nativeCall(funcName, callbackId, params) {
97
97
  };
98
98
  window['_liteNativeApi'].exec(JSON.stringify(object1));
99
99
  }
100
+ else if (window['CoocaaJsApiBridge']) { // 视九
101
+ // 运行于 android 浏览器webview
102
+ var object1 = {
103
+ func: funcName,
104
+ id: callbackId,
105
+ params: params || {},
106
+ apiCode: apiCode,
107
+ };
108
+ window['CoocaaJsApiBridge'].invoke(JSON.stringify(object1));
109
+ }
100
110
  }
101
111
  function nativeRequest(funcName, params, persistent, persistentIdName, persistentCallback) {
102
112
  if (!persistent) {
@@ -108,12 +118,27 @@ function nativeRequest(funcName, params, persistent, persistentIdName, persisten
108
118
  });
109
119
  }
110
120
  // 以下是持久化调用处理
111
- var index = persistentCallbackId.indexOf(persistentIdName);
112
- if (index < 0) {
113
- persistentCallbackId.push(persistentIdName);
121
+ var id = persistentIdName;
122
+ if (!persistentCallbackMap.has(id)) {
123
+ persistentCallbackMap.set(id, new Set());
124
+ }
125
+ if (!persistentCallbackMap.get(id).has(persistentCallback)) {
126
+ persistentCallbackMap.get(id).add(persistentCallback);
114
127
  }
115
- bus.remove(persistentIdName);
116
- bus.register(persistentCallback, persistentIdName); // 这里注册一个持久化的回调,通常应用于 native 会持续回调的情况
128
+ // 构建一个回调函数
129
+ var myCallBack = function (payload) {
130
+ // 将 Set 转换为数组
131
+ var funcArray = Array.from(persistentCallbackMap.get(id));
132
+ // 使用 for 循环遍历数组
133
+ for (var i = 0; i < funcArray.length; i++) {
134
+ if (funcArray[i]) {
135
+ funcArray[i](payload);
136
+ }
137
+ }
138
+ };
139
+ //
140
+ bus.remove(id);
141
+ bus.register(myCallBack, id); // 这里注册一个持久化的回调,通常应用于 native 会持续回调的情况
117
142
  return new Promise(function (resolve) {
118
143
  var callbackId = bus.register(function (res) {
119
144
  resolve(res);
@@ -129,14 +154,23 @@ function callNative(funcName, params) {
129
154
  function callWithPersistentCallBack(funcName, params, persistentIdName, callback) {
130
155
  return nativeRequest(funcName, params, true, persistentIdName, callback);
131
156
  }
132
- // 注销一个持久的回调函数
133
- function deletePersistentCallBack(persistentIdName) {
134
- bus.remove(persistentIdName);
135
- var index = persistentCallbackId.indexOf(persistentIdName);
136
- if (index < 0) {
137
- return;
157
+ // 注销一个持久的回调函数 (对应id的所有回调函数都已经清空的话, 返回true, 如果该id如果还有其它回调函数, 返回false)
158
+ function deletePersistentCallBack(persistentIdName, callback) {
159
+ var id = persistentIdName;
160
+ if (!persistentCallbackMap.has(id)) {
161
+ bus.remove(id);
162
+ return true;
163
+ }
164
+ var ret = false;
165
+ if (persistentCallbackMap.get(id).has(callback)) {
166
+ persistentCallbackMap.get(id).delete(callback);
138
167
  }
139
- persistentCallbackId.splice(index, 1); // 从persistentCallbackId中删除name
168
+ if (persistentCallbackMap.get(id).size == 0) {
169
+ ret = true;
170
+ persistentCallbackMap.delete(id);
171
+ bus.remove(id);
172
+ }
173
+ return ret;
140
174
  }
141
175
  function callbackFromNative(callbackId, data) {
142
176
  var payload = '';
@@ -153,8 +187,7 @@ function callbackFromNative(callbackId, data) {
153
187
  }
154
188
  bus.fire(callbackId, payload);
155
189
  // 判断,如果不是持久的回调函数,则调用完毕之后删除该回调
156
- var index = persistentCallbackId.indexOf(callbackId);
157
- if (index < 0) {
190
+ if (!persistentCallbackMap.has(callbackId)) {
158
191
  bus.remove(callbackId);
159
192
  }
160
193
  }
@@ -344,28 +377,6 @@ function downloadToFile(url, tempFlag, method, header, postType, body) {
344
377
  body: body
345
378
  });
346
379
  }
347
- var downloadListenerCallbackId = 'downloadListenerCallbackId';
348
- // 设置下载的事件回调
349
- // 注意: 使用此回调的话,不用时记得使用 deleteDownloadListener 注销事件回调
350
- function setDownloadListener(callback) {
351
- return callWithPersistentCallBack(getFuncName$7('setDownloadListener'), { callbackId: downloadListenerCallbackId }, downloadListenerCallbackId, callback);
352
- }
353
- // 注销下载的事件回调
354
- function deleteDownloadListener() {
355
- deletePersistentCallBack(downloadListenerCallbackId);
356
- return callNative(getFuncName$7('deleteDownloadListener'), null);
357
- }
358
- var streamResponseListenerCallbackId = 'streamResponseListenerCallbackId';
359
- // 设置SSE请求的事件回调
360
- // 注意: 使用此回调的话,不用时记得使用 deleteStreamResponseListener 注销事件回调
361
- function setStreamResponseListener(callback) {
362
- return callWithPersistentCallBack(getFuncName$7('setStreamResponseListener'), { callbackId: streamResponseListenerCallbackId }, streamResponseListenerCallbackId, callback);
363
- }
364
- // 注销SSE请求的事件回调
365
- function deleteStreamResponseListener() {
366
- deletePersistentCallBack(streamResponseListenerCallbackId);
367
- return callNative(getFuncName$7('deleteStreamResponseListener'), null);
368
- }
369
380
  var network = {
370
381
  simpleHttpRequest: simpleHttpRequest,
371
382
  httpGet: httpGet,
@@ -375,189 +386,148 @@ var network = {
375
386
  getDomainName: getDomainName,
376
387
  getCommonHeader: getCommonHeader,
377
388
  downloadToFile: downloadToFile,
378
- setDownloadListener: setDownloadListener,
379
- deleteDownloadListener: deleteDownloadListener,
380
- setStreamResponseListener: setStreamResponseListener,
381
- deleteStreamResponseListener: deleteStreamResponseListener,
382
389
  };
383
390
 
384
391
  var moduleName$6 = 'app';
385
- var localBroadcastHookCallbackId = 'localBroadcastHookCallbackId';
386
- var globalBroadcastHookCallbackId = 'globalBroadcastHookCallbackId';
387
- var localBroadcastActionMap = new Map();
388
- var globalBroadcastActionMap = new Map();
389
392
  function getFuncName$6(name) {
390
393
  return moduleName$6 + '_' + name;
391
394
  }
392
- function startActivity(params) {
393
- return callNative(getFuncName$6('startActivity'), params);
394
- }
395
- function startService(params) {
396
- return callNative(getFuncName$6('startService'), params);
397
- }
398
- function sendBroadcast(params) {
399
- return callNative(getFuncName$6('sendBroadcast'), params);
400
- }
401
- function sendLocalBroadcast(params) {
402
- return callNative(getFuncName$6('sendLocalBroadcast'), params);
403
- }
404
- function startBackEndAction(action) {
405
- return callNative(getFuncName$6('startBackEndAction'), action);
406
- }
407
- function exitPage() {
408
- callNative(getFuncName$6('exitPage'), null);
409
- }
410
- function moveTaskToBack() {
411
- return callNative(getFuncName$6('moveTaskToBack'), null);
412
- }
413
395
  function getUserInfo() {
414
396
  return callNative(getFuncName$6('getUserInfo'), null);
415
397
  }
416
- function getAppList() {
417
- return callNative(getFuncName$6('getAppList'), null);
398
+ function getHostAppInfo() {
399
+ return callNative(getFuncName$6('getHostAppInfo'), null);
418
400
  }
419
- function getAppInfo(params) {
420
- return callNative(getFuncName$6('getAppInfo'), params);
401
+ function startPage(params) {
402
+ return callNative(getFuncName$6('startPage'), params);
421
403
  }
422
- function processLocalBroadcast(payload) {
423
- if (payload.hasOwnProperty('action')) {
424
- var action = payload['action'];
425
- if (localBroadcastActionMap.has(action)) {
426
- var func = localBroadcastActionMap.get(action);
427
- if (func) {
428
- func(payload);
429
- }
430
- }
431
- }
404
+ function startActivity(params) {
405
+ return callNative(getFuncName$6('startPage'), params);
432
406
  }
433
- function processGlobalBroadcast(payload) {
434
- if (payload.hasOwnProperty('action')) {
435
- var action = payload['action'];
436
- if (globalBroadcastActionMap.has(action)) {
437
- var func = globalBroadcastActionMap.get(action);
438
- if (func) {
439
- func(payload);
440
- }
441
- }
442
- }
407
+ function exitPage() {
408
+ callNative(getFuncName$6('exitPage'), null);
443
409
  }
444
- function setLocalBroadcastHook(action, callback) {
445
- localBroadcastActionMap.set(action, callback); // action 如存在会更新
446
- //
447
- return callWithPersistentCallBack(getFuncName$6('setLocalBroadcastHook'), { callbackId: localBroadcastHookCallbackId, action: action }, localBroadcastHookCallbackId, processLocalBroadcast);
410
+ function movePageToBack() {
411
+ return callNative(getFuncName$6('movePageToBack'), null);
448
412
  }
449
- function deleteLocalBroadcastHook(action) {
450
- localBroadcastActionMap.delete(action);
451
- return callNative(getFuncName$6('deleteLocalBroadcastHook'), { action: action });
413
+ function startService(params) {
414
+ return callNative(getFuncName$6('startService'), params);
452
415
  }
453
- function setBroadcastHook(action, callback) {
454
- globalBroadcastActionMap.set(action, callback); // action 如存在会更新
455
- //
456
- return callWithPersistentCallBack(getFuncName$6('setBroadcastHook'), { callbackId: globalBroadcastHookCallbackId, action: action }, globalBroadcastHookCallbackId, processGlobalBroadcast);
416
+ function getInstalledAppInfo(params) {
417
+ return callNative(getFuncName$6('getInstalledAppInfo'), params);
457
418
  }
458
- function deleteBroadcastHook(action) {
459
- globalBroadcastActionMap.delete(action);
460
- return callNative(getFuncName$6('deleteBroadcastHook'), { action: action });
419
+ function getInstalledAppsList() {
420
+ callNative(getFuncName$6('getInstalledAppsList'), null);
461
421
  }
462
- function appPrivateMethod(method, params) {
463
- var str = '';
464
- if (params) {
465
- if (typeof params == 'object') {
466
- str = JSON.stringify(params);
467
- }
468
- else {
469
- str = String(params);
470
- }
471
- }
472
- return callNative(getFuncName$6('appPrivateMethod'), { method: method, params: str });
422
+ function execActionString(action) {
423
+ return callNative(getFuncName$6('execActionString'), action);
473
424
  }
474
425
  var app = {
426
+ getUserInfo: getUserInfo,
427
+ getHostAppInfo: getHostAppInfo,
428
+ startPage: startPage,
475
429
  startActivity: startActivity,
476
- startService: startService,
477
- sendBroadcast: sendBroadcast,
478
- sendLocalBroadcast: sendLocalBroadcast,
479
- startBackEndAction: startBackEndAction,
480
430
  exitPage: exitPage,
481
- moveTaskToBack: moveTaskToBack,
482
- getUserInfo: getUserInfo,
483
- getAppList: getAppList,
484
- getAppInfo: getAppInfo,
485
- setLocalBroadcastHook: setLocalBroadcastHook,
486
- deleteLocalBroadcastHook: deleteLocalBroadcastHook,
487
- setBroadcastHook: setBroadcastHook,
488
- deleteBroadcastHook: deleteBroadcastHook,
489
- appPrivateMethod: appPrivateMethod
431
+ movePageToBack: movePageToBack,
432
+ startService: startService,
433
+ getInstalledAppInfo: getInstalledAppInfo,
434
+ getInstalledAppsList: getInstalledAppsList,
435
+ execActionString: execActionString,
490
436
  };
491
437
 
492
438
  var moduleName$5 = 'system';
493
- var lifeCycleHookCallbackId = 'lifeCycleHookCallback';
494
439
  function getFuncName$5(name) {
495
440
  return moduleName$5 + '_' + name;
496
441
  }
497
- // 获取SDK的版本信息
498
- function getSdkVersion() {
499
- return callNative(getFuncName$5('getSdkVersion'), null);
500
- }
501
- // 添加 Activity 的生命周期的回调钩子
502
- function setLifeCycleHook(callback) {
503
- return callWithPersistentCallBack(getFuncName$5('setLifeCycleHook'), { callbackId: lifeCycleHookCallbackId }, lifeCycleHookCallbackId, callback);
442
+ // 告知宿主,小程序或者网页已经准备好
443
+ function ready() {
444
+ return callNative(getFuncName$5('ready'), null);
504
445
  }
505
- // 删除生命周期的回调钩子
506
- function deleteLifeCycleHook() {
507
- deletePersistentCallBack(lifeCycleHookCallbackId);
508
- return callNative(getFuncName$5('deleteLifeCycleHook'), null);
509
- }
510
- // 声明本页面接收并处理系统级的按键(如:返回、HOME、MENU 键)
511
- function enableSystemKey(params) {
512
- return callNative(getFuncName$5('enableSystemKey'), params);
446
+ // 获取启动参数
447
+ function getStartupParams() {
448
+ return callNative(getFuncName$5('getStartupParams'), null);
513
449
  }
514
450
  // 获取设备信息
515
451
  function getDeviceInfo() {
516
452
  return callNative(getFuncName$5('getDeviceInfo'), null);
517
453
  }
454
+ // 获取显示屏幕信息
455
+ function getDisplayInfo() {
456
+ return callNative(getFuncName$5('getDisplayInfo'), null);
457
+ }
518
458
  // 获取 android property 的值
519
459
  function getProperty(key) {
520
- return callNative(getFuncName$5('getProperty'), { key: key });
521
- }
522
- // 获取当前设备所处的位置信息
523
- function getLocation() {
524
- return callNative(getFuncName$5('getLocation'), null);
460
+ return callNative(getFuncName$5('getProperty'), { propName: key });
525
461
  }
526
462
  // 检查 JS-API 是否已经实现
527
463
  function checkApi(apiName) {
528
464
  return callNative(getFuncName$5('checkApi'), { apiName: apiName });
529
465
  }
530
- // 获取显示屏幕信息
531
- function getDisplayInfo() {
532
- return callNative(getFuncName$5('getDisplayInfo'), null);
466
+ // 获取本地字体的路径
467
+ function getFontPath(fontFileName) {
468
+ return callNative(getFuncName$5('getFontPath'), { fontFileName: fontFileName });
469
+ }
470
+ // 设置屏幕是否常亮
471
+ function setKeepScreenOn(enable) {
472
+ return callNative(getFuncName$5('setKeepScreenOn'), { enable: enable });
473
+ }
474
+ // 添加事件监听
475
+ function addEventListener(eventName, callback, options) {
476
+ if (options === void 0) { options = {}; }
477
+ return callWithPersistentCallBack(getFuncName$5('addEventListener'), { callbackId: eventName, options: options }, eventName, callback);
478
+ }
479
+ // 删除事件监听
480
+ function removeEventListener(eventName, callback, options) {
481
+ if (options === void 0) { options = {}; }
482
+ var ret = deletePersistentCallBack(eventName, callback);
483
+ if (ret) {
484
+ return callNative(getFuncName$5('removeEventListener'), { callbackId: eventName, options: options });
485
+ }
486
+ return new Promise(function (resolve) { resolve(); });
487
+ }
488
+ function sendBroadcast(params) {
489
+ return callNative(getFuncName$5('sendBroadcast'), params);
490
+ }
491
+ // 声明本页面接收并处理系统级的按键(如:返回、HOME、MENU 键)
492
+ function enableSystemKey(params) {
493
+ return callNative(getFuncName$5('enableSystemKey'), params);
533
494
  }
534
495
  var system = {
535
- getSdkVersion: getSdkVersion,
536
- setLifeCycleHook: setLifeCycleHook,
537
- deleteLifeCycleHook: deleteLifeCycleHook,
538
- enableSystemKey: enableSystemKey,
496
+ ready: ready,
497
+ getStartupParams: getStartupParams,
539
498
  getDeviceInfo: getDeviceInfo,
499
+ getDisplayInfo: getDisplayInfo,
540
500
  getProperty: getProperty,
541
- getLocation: getLocation,
542
501
  checkApi: checkApi,
543
- getDisplayInfo: getDisplayInfo,
502
+ getFontPath: getFontPath,
503
+ setKeepScreenOn: setKeepScreenOn,
504
+ addEventListener: addEventListener,
505
+ removeEventListener: removeEventListener,
506
+ sendBroadcast: sendBroadcast,
507
+ //registerKeysOrUnregisterKeys
508
+ //sendEvent
509
+ enableSystemKey: enableSystemKey,
544
510
  };
545
511
 
546
512
  var moduleName$4 = 'storage';
547
513
  function getFuncName$4(name) {
548
514
  return moduleName$4 + '_' + name;
549
515
  }
550
- function setKey(key, value) {
551
- return callNative(getFuncName$4('setKey'), { key: key, value: value });
516
+ function setKey(key, value, namespace) {
517
+ if (namespace === void 0) { namespace = ''; }
518
+ return callNative(getFuncName$4('setKey'), { key: key, value: value, namespace: namespace });
552
519
  }
553
- function getKey(key) {
554
- return callNative(getFuncName$4('getKey'), { key: key });
520
+ function getKey(key, namespace) {
521
+ if (namespace === void 0) { namespace = ''; }
522
+ return callNative(getFuncName$4('getKey'), { key: key, namespace: namespace });
555
523
  }
556
- function deleteKey(key) {
557
- return callNative(getFuncName$4('deleteKey'), { key: key });
524
+ function deleteKey(key, namespace) {
525
+ if (namespace === void 0) { namespace = ''; }
526
+ return callNative(getFuncName$4('deleteKey'), { key: key, namespace: namespace });
558
527
  }
559
- function clearAllKeys() {
560
- return callNative(getFuncName$4('clearAllKeys'), null);
528
+ function clearAllKeys(namespace) {
529
+ if (namespace === void 0) { namespace = ''; }
530
+ return callNative(getFuncName$4('clearAllKeys'), { namespace: namespace });
561
531
  }
562
532
  var storage = {
563
533
  setKey: setKey,
@@ -570,7 +540,6 @@ var moduleName$3 = 'audio';
570
540
  function getFuncName$3(name) {
571
541
  return moduleName$3 + '_' + name;
572
542
  }
573
- var audioPlayerListenerCallbackId = 'audioPlayerListenerCallbackId';
574
543
  // 播放器,播放新的URL或者本地文件系统的路径
575
544
  function playNew(path) {
576
545
  return callNative(getFuncName$3('playNew'), { path: path });
@@ -633,21 +602,6 @@ function setVolume(volume) {
633
602
  function setPlayerCore$1(core) {
634
603
  return callNative(getFuncName$3('setPlayerCore'), { core: core });
635
604
  }
636
- // 设置渲染模式
637
- // 值: SurfaceView, TextureView
638
- function setRenderType(playerRender) {
639
- return callNative(getFuncName$3('setRenderType'), { playerRender: playerRender });
640
- }
641
- // 设置视频播放器的事件回调
642
- // 注意: 使用此回调的话,不用时记得使用 deleteListener 注销事件回调
643
- function setListener$1(callback) {
644
- return callWithPersistentCallBack(getFuncName$3('setListener'), { callbackId: audioPlayerListenerCallbackId }, audioPlayerListenerCallbackId, callback);
645
- }
646
- // 注销视频播放器的事件回调
647
- function deleteListener$1() {
648
- deletePersistentCallBack(audioPlayerListenerCallbackId);
649
- return callNative(getFuncName$3('deleteListener'), null);
650
- }
651
605
  var audio = {
652
606
  playNew: playNew,
653
607
  stop: stop$1,
@@ -663,16 +617,12 @@ var audio = {
663
617
  setLooping: setLooping$1,
664
618
  setVolume: setVolume,
665
619
  setPlayerCore: setPlayerCore$1,
666
- setRenderType: setRenderType,
667
- setListener: setListener$1,
668
- deleteListener: deleteListener$1
669
620
  };
670
621
 
671
622
  var moduleName$2 = 'video';
672
623
  function getFuncName$2(name) {
673
624
  return moduleName$2 + '_' + name;
674
625
  }
675
- var videoPlayerListenerCallbackId = 'videoPlayerListenerCallbackId';
676
626
  // 设置视频播放窗口的位置与宽高
677
627
  function setVideoLayout(width, height, x, y) {
678
628
  return callNative(getFuncName$2('setVideoLayout'), { x: Number(x), y: Number(y), w: Number(width), h: Number(height) });
@@ -762,15 +712,10 @@ function getRealPlayerCore() {
762
712
  function setPlayerCore(core) {
763
713
  return callNative(getFuncName$2('setPlayerCore'), { core: core });
764
714
  }
765
- // 设置视频播放器的事件回调
766
- // 注意: 使用此回调的话,不用时记得使用 deleteListener 注销事件回调
767
- function setListener(callback) {
768
- return callWithPersistentCallBack(getFuncName$2('setListener'), { callbackId: videoPlayerListenerCallbackId }, videoPlayerListenerCallbackId, callback);
769
- }
770
- // 注销视频播放器的事件回调
771
- function deleteListener() {
772
- deletePersistentCallBack(videoPlayerListenerCallbackId);
773
- return callNative(getFuncName$2('deleteListener'), null);
715
+ // 设置渲染模式
716
+ // 值: SurfaceView, TextureView
717
+ function setRenderType(playerRender) {
718
+ return callNative(getFuncName$2('setRenderType'), { playerRender: playerRender });
774
719
  }
775
720
  var video = {
776
721
  setVideoLayout: setVideoLayout,
@@ -793,8 +738,7 @@ var video = {
793
738
  getPlayerCore: getPlayerCore,
794
739
  getRealPlayerCore: getRealPlayerCore,
795
740
  setPlayerCore: setPlayerCore,
796
- setListener: setListener,
797
- deleteListener: deleteListener,
741
+ setRenderType: setRenderType,
798
742
  };
799
743
 
800
744
  var moduleName$1 = 'fs';
@@ -991,7 +935,7 @@ var fs = {
991
935
  list: list
992
936
  };
993
937
 
994
- var moduleName = 'nativeView';
938
+ var moduleName = 'pag';
995
939
  function getFuncName(name) {
996
940
  return moduleName + '_' + name;
997
941
  }
@@ -1054,7 +998,7 @@ function setPagXY(x, y) {
1054
998
  // export function clearBackground() : Promise<any> {
1055
999
  // return callNative(getFuncName('clearBackground'), null);
1056
1000
  // }
1057
- var nativeView = {
1001
+ var pag = {
1058
1002
  startNewPagAni: startNewPagAni,
1059
1003
  stopPagAni: stopPagAni,
1060
1004
  setPagVisibility: setPagVisibility,
@@ -1099,7 +1043,9 @@ function isRunInAppBrowser() {
1099
1043
  return window['_liteNativeApi'] ? true : false;
1100
1044
  }
1101
1045
  function init() {
1102
- window['appNativeCall'] = apkNativeCallJs;
1046
+ if (window['_liteNativeApi']) {
1047
+ window['appNativeCall'] = apkNativeCallJs;
1048
+ }
1103
1049
  initSDK();
1104
1050
  }
1105
1051
  var index = {
@@ -1110,7 +1056,7 @@ var index = {
1110
1056
  storage: storage,
1111
1057
  audio: audio,
1112
1058
  video: video,
1113
- nativeView: nativeView,
1059
+ pag: pag,
1114
1060
  fs: fs,
1115
1061
  isRunInAppBrowser: isRunInAppBrowser
1116
1062
  };
@@ -3,6 +3,6 @@ export declare function setAppCommandCallback(cb: Function): void;
3
3
  export declare function unsetAppCommandCallback(): void;
4
4
  export declare function callNative(funcName: string, params: any): Promise<any>;
5
5
  export declare function callWithPersistentCallBack(funcName: string, params: any, persistentIdName: string, callback: Function): Promise<any>;
6
- export declare function deletePersistentCallBack(persistentIdName: string): void;
6
+ export declare function deletePersistentCallBack(persistentIdName: string, callback: Function): boolean;
7
7
  export declare function callbackFromNative(callbackId: string, data: string | object): void;
8
8
  export declare function initSDK(): Promise<any>;
package/lib/index.d.ts CHANGED
@@ -12,38 +12,32 @@ declare const _default: {
12
12
  getDomainName: typeof import("./network").getDomainName;
13
13
  getCommonHeader: typeof import("./network").getCommonHeader;
14
14
  downloadToFile: typeof import("./network").downloadToFile;
15
- setDownloadListener: typeof import("./network").setDownloadListener;
16
- deleteDownloadListener: typeof import("./network").deleteDownloadListener;
17
- setStreamResponseListener: typeof import("./network").setStreamResponseListener;
18
- deleteStreamResponseListener: typeof import("./network").deleteStreamResponseListener;
19
15
  };
20
16
  app: {
17
+ getUserInfo: typeof import("./app").getUserInfo;
18
+ getHostAppInfo: typeof import("./app").getHostAppInfo;
19
+ startPage: typeof import("./app").startPage;
21
20
  startActivity: typeof import("./app").startActivity;
22
- startService: typeof import("./app").startService;
23
- sendBroadcast: typeof import("./app").sendBroadcast;
24
- sendLocalBroadcast: typeof import("./app").sendLocalBroadcast;
25
- startBackEndAction: typeof import("./app").startBackEndAction;
26
21
  exitPage: typeof import("./app").exitPage;
27
- moveTaskToBack: typeof import("./app").moveTaskToBack;
28
- getUserInfo: typeof import("./app").getUserInfo;
29
- getAppList: typeof import("./app").getAppList;
30
- getAppInfo: typeof import("./app").getAppInfo;
31
- setLocalBroadcastHook: typeof import("./app").setLocalBroadcastHook;
32
- deleteLocalBroadcastHook: typeof import("./app").deleteLocalBroadcastHook;
33
- setBroadcastHook: typeof import("./app").setBroadcastHook;
34
- deleteBroadcastHook: typeof import("./app").deleteBroadcastHook;
35
- appPrivateMethod: typeof import("./app").appPrivateMethod;
22
+ movePageToBack: typeof import("./app").movePageToBack;
23
+ startService: typeof import("./app").startService;
24
+ getInstalledAppInfo: typeof import("./app").getInstalledAppInfo;
25
+ getInstalledAppsList: typeof import("./app").getInstalledAppsList;
26
+ execActionString: typeof import("./app").execActionString;
36
27
  };
37
28
  system: {
38
- getSdkVersion: typeof import("./system").getSdkVersion;
39
- setLifeCycleHook: typeof import("./system").setLifeCycleHook;
40
- deleteLifeCycleHook: typeof import("./system").deleteLifeCycleHook;
41
- enableSystemKey: typeof import("./system").enableSystemKey;
29
+ ready: typeof import("./system").ready;
30
+ getStartupParams: typeof import("./system").getStartupParams;
42
31
  getDeviceInfo: typeof import("./system").getDeviceInfo;
32
+ getDisplayInfo: typeof import("./system").getDisplayInfo;
43
33
  getProperty: typeof import("./system").getProperty;
44
- getLocation: typeof import("./system").getLocation;
45
34
  checkApi: typeof import("./system").checkApi;
46
- getDisplayInfo: typeof import("./system").getDisplayInfo;
35
+ getFontPath: typeof import("./system").getFontPath;
36
+ setKeepScreenOn: typeof import("./system").setKeepScreenOn;
37
+ addEventListener: typeof import("./system").addEventListener;
38
+ removeEventListener: typeof import("./system").removeEventListener;
39
+ sendBroadcast: typeof import("./system").sendBroadcast;
40
+ enableSystemKey: typeof import("./system").enableSystemKey;
47
41
  };
48
42
  storage: {
49
43
  setKey: typeof import("./storage").setKey;
@@ -66,9 +60,6 @@ declare const _default: {
66
60
  setLooping: typeof import("./audio").setLooping;
67
61
  setVolume: typeof import("./audio").setVolume;
68
62
  setPlayerCore: typeof import("./audio").setPlayerCore;
69
- setRenderType: typeof import("./audio").setRenderType;
70
- setListener: typeof import("./audio").setListener;
71
- deleteListener: typeof import("./audio").deleteListener;
72
63
  };
73
64
  video: {
74
65
  setVideoLayout: typeof import("./video").setVideoLayout;
@@ -91,14 +82,13 @@ declare const _default: {
91
82
  getPlayerCore: typeof import("./video").getPlayerCore;
92
83
  getRealPlayerCore: typeof import("./video").getRealPlayerCore;
93
84
  setPlayerCore: typeof import("./video").setPlayerCore;
94
- setListener: typeof import("./video").setListener;
95
- deleteListener: typeof import("./video").deleteListener;
85
+ setRenderType: typeof import("./video").setRenderType;
96
86
  };
97
- nativeView: {
98
- startNewPagAni: typeof import("./nativeView").startNewPagAni;
99
- stopPagAni: typeof import("./nativeView").stopPagAni;
100
- setPagVisibility: typeof import("./nativeView").setPagVisibility;
101
- setPagXY: typeof import("./nativeView").setPagXY;
87
+ pag: {
88
+ startNewPagAni: typeof import("./pag").startNewPagAni;
89
+ stopPagAni: typeof import("./pag").stopPagAni;
90
+ setPagVisibility: typeof import("./pag").setPagVisibility;
91
+ setPagXY: typeof import("./pag").setPagXY;
102
92
  };
103
93
  fs: {
104
94
  readAllContent: typeof import("./file").readAllContent;
@@ -24,10 +24,6 @@ export declare function getDomainName(domain: string): Promise<any>;
24
24
  export declare function getCommonHeader(): Promise<any>;
25
25
  export declare function readSse(params: SSERequestParam): Promise<any>;
26
26
  export declare function downloadToFile(url: string, tempFlag?: boolean, method?: string, header?: string, postType?: string, body?: string): Promise<any>;
27
- export declare function setDownloadListener(callback: Function): Promise<any>;
28
- export declare function deleteDownloadListener(): Promise<any>;
29
- export declare function setStreamResponseListener(callback: Function): Promise<any>;
30
- export declare function deleteStreamResponseListener(): Promise<any>;
31
27
  declare const _default: {
32
28
  simpleHttpRequest: typeof simpleHttpRequest;
33
29
  httpGet: typeof httpGet;
@@ -37,9 +33,5 @@ declare const _default: {
37
33
  getDomainName: typeof getDomainName;
38
34
  getCommonHeader: typeof getCommonHeader;
39
35
  downloadToFile: typeof downloadToFile;
40
- setDownloadListener: typeof setDownloadListener;
41
- deleteDownloadListener: typeof deleteDownloadListener;
42
- setStreamResponseListener: typeof setStreamResponseListener;
43
- deleteStreamResponseListener: typeof deleteStreamResponseListener;
44
36
  };
45
37
  export default _default;
@@ -0,0 +1,19 @@
1
+ export interface StartPAGParam {
2
+ path: string;
3
+ repeat: number;
4
+ x: number;
5
+ y: number;
6
+ width: number;
7
+ height: number;
8
+ }
9
+ export declare function startNewPagAni(params: StartPAGParam): Promise<any>;
10
+ export declare function stopPagAni(): Promise<any>;
11
+ export declare function setPagVisibility(visible?: boolean): Promise<any>;
12
+ export declare function setPagXY(x: number, y: number): Promise<any>;
13
+ declare const _default: {
14
+ startNewPagAni: typeof startNewPagAni;
15
+ stopPagAni: typeof stopPagAni;
16
+ setPagVisibility: typeof setPagVisibility;
17
+ setPagXY: typeof setPagXY;
18
+ };
19
+ export default _default;
@@ -1,7 +1,7 @@
1
- export declare function setKey(key: string, value: string): Promise<any>;
2
- export declare function getKey(key: string): Promise<any>;
3
- export declare function deleteKey(key: string): Promise<any>;
4
- export declare function clearAllKeys(): Promise<any>;
1
+ export declare function setKey(key: string, value: string, namespace?: string): Promise<any>;
2
+ export declare function getKey(key: string, namespace?: string): Promise<any>;
3
+ export declare function deleteKey(key: string, namespace?: string): Promise<any>;
4
+ export declare function clearAllKeys(namespace?: string): Promise<any>;
5
5
  declare const _default: {
6
6
  setKey: typeof setKey;
7
7
  getKey: typeof getKey;
@@ -1,24 +1,37 @@
1
1
  export interface SystemKeyParam {
2
2
  keys: number[];
3
3
  }
4
- export declare function getSdkVersion(): Promise<any>;
5
- export declare function setLifeCycleHook(callback: Function): Promise<any>;
6
- export declare function deleteLifeCycleHook(): Promise<any>;
7
- export declare function enableSystemKey(params: SystemKeyParam | null): Promise<any>;
4
+ export interface IntentParam {
5
+ action?: string;
6
+ package?: string;
7
+ class?: string;
8
+ uri?: string;
9
+ extras?: any;
10
+ }
11
+ export declare function ready(): Promise<any>;
12
+ export declare function getStartupParams(): Promise<any>;
8
13
  export declare function getDeviceInfo(): Promise<any>;
14
+ export declare function getDisplayInfo(): Promise<any>;
9
15
  export declare function getProperty(key: string): Promise<any>;
10
- export declare function getLocation(): Promise<any>;
11
16
  export declare function checkApi(apiName: string): Promise<any>;
12
- export declare function getDisplayInfo(): Promise<any>;
17
+ export declare function getFontPath(fontFileName: string): Promise<any>;
18
+ export declare function setKeepScreenOn(enable: boolean): Promise<any>;
19
+ export declare function addEventListener(eventName: string, callback: Function, options?: object): Promise<any>;
20
+ export declare function removeEventListener(eventName: string, callback: Function, options?: object): Promise<any>;
21
+ export declare function sendBroadcast(params: IntentParam): Promise<any>;
22
+ export declare function enableSystemKey(params: SystemKeyParam | null): Promise<any>;
13
23
  declare const _default: {
14
- getSdkVersion: typeof getSdkVersion;
15
- setLifeCycleHook: typeof setLifeCycleHook;
16
- deleteLifeCycleHook: typeof deleteLifeCycleHook;
17
- enableSystemKey: typeof enableSystemKey;
24
+ ready: typeof ready;
25
+ getStartupParams: typeof getStartupParams;
18
26
  getDeviceInfo: typeof getDeviceInfo;
27
+ getDisplayInfo: typeof getDisplayInfo;
19
28
  getProperty: typeof getProperty;
20
- getLocation: typeof getLocation;
21
29
  checkApi: typeof checkApi;
22
- getDisplayInfo: typeof getDisplayInfo;
30
+ getFontPath: typeof getFontPath;
31
+ setKeepScreenOn: typeof setKeepScreenOn;
32
+ addEventListener: typeof addEventListener;
33
+ removeEventListener: typeof removeEventListener;
34
+ sendBroadcast: typeof sendBroadcast;
35
+ enableSystemKey: typeof enableSystemKey;
23
36
  };
24
37
  export default _default;
@@ -18,8 +18,7 @@ export declare function setPlayWhenReady(playWhenReady?: boolean): Promise<any>;
18
18
  export declare function getPlayerCore(): Promise<any>;
19
19
  export declare function getRealPlayerCore(): Promise<any>;
20
20
  export declare function setPlayerCore(core: 'DefaultPlayer' | 'MediaPlayer' | 'SocPlayer' | 'ExoPlayer'): Promise<any>;
21
- export declare function setListener(callback: Function): Promise<any>;
22
- export declare function deleteListener(): Promise<any>;
21
+ export declare function setRenderType(playerRender: 'SurfaceView' | 'TextureView'): Promise<any>;
23
22
  declare const _default: {
24
23
  setVideoLayout: typeof setVideoLayout;
25
24
  setVideoVisible: typeof setVideoVisible;
@@ -41,7 +40,6 @@ declare const _default: {
41
40
  getPlayerCore: typeof getPlayerCore;
42
41
  getRealPlayerCore: typeof getRealPlayerCore;
43
42
  setPlayerCore: typeof setPlayerCore;
44
- setListener: typeof setListener;
45
- deleteListener: typeof deleteListener;
43
+ setRenderType: typeof setRenderType;
46
44
  };
47
45
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccos/ccsdk-lite",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "a jssdk for coocaa tv-system",
5
5
  "type": "module",
6
6
  "main": "lib/bundle.js",