@ccos/ccsdk-lite 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/bundle.js CHANGED
@@ -57,6 +57,7 @@ var Bus = /** @class */ (function () {
57
57
  }());
58
58
  var bus = new Bus();
59
59
 
60
+ var hasInitialized = false;
60
61
  var actionList = []; // 这里保存, 未注册命令处理函数之前,APP发过来的命令
61
62
  var apiCode = '';
62
63
  function defaultAppCmd(cmd, payload) {
@@ -148,6 +149,17 @@ function nativeRequest(funcName, params, persistent, persistentIdName, persisten
148
149
  }
149
150
  //
150
151
  function callNative(funcName, params) {
152
+ if (!hasInitialized) {
153
+ hasInitialized = true;
154
+ return new Promise(function (resolve) {
155
+ initSDK();
156
+ setTimeout(function () {
157
+ nativeRequest(funcName, params, false).then(function (res) {
158
+ resolve(res);
159
+ });
160
+ }, 1);
161
+ });
162
+ }
151
163
  return nativeRequest(funcName, params, false);
152
164
  }
153
165
  // 带有持久性回调的调用
@@ -194,6 +206,7 @@ function callbackFromNative(callbackId, data) {
194
206
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
195
207
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
196
208
  function initSDK() {
209
+ hasInitialized = true;
197
210
  var num1 = Math.floor(Math.random() * 65536);
198
211
  var num2 = Math.floor(Math.random() * 16384);
199
212
  var num3 = num2 * 65536 + num1;
@@ -206,9 +219,9 @@ function initSDK() {
206
219
  return callNative('tiny' + num4.toString(), null);
207
220
  }
208
221
 
209
- var moduleName$8 = 'network';
210
- function getFuncName$8(name) {
211
- return moduleName$8 + '_' + name;
222
+ var moduleName$9 = 'network';
223
+ function getFuncName$9(name) {
224
+ return moduleName$9 + '_' + name;
212
225
  }
213
226
  function paramToUrl(params) {
214
227
  if (!params)
@@ -240,7 +253,7 @@ function paramToUrl(params) {
240
253
  }
241
254
  // 简单的 HTTP 请求
242
255
  function simpleHttpRequest(params) {
243
- return callNative(getFuncName$8('simpleHttpRequest'), params);
256
+ return callNative(getFuncName$9('simpleHttpRequest'), params);
244
257
  }
245
258
  function httpGet(url, urlParam, header, base64) {
246
259
  var paramString = paramToUrl(urlParam);
@@ -339,19 +352,19 @@ function httpSseGet(url, urlParam, header, base64) {
339
352
  }
340
353
  // 获取网络的基本信息
341
354
  function getNetworkInfo() {
342
- return callNative(getFuncName$8('getNetworkInfo'), null);
355
+ return callNative(getFuncName$9('getNetworkInfo'), null);
343
356
  }
344
357
  // 获取合规化后的域名
345
358
  function getDomainName(domain) {
346
- return callNative(getFuncName$8('getDomainName'), { domain: domain });
359
+ return callNative(getFuncName$9('getDomainName'), { domain: domain });
347
360
  }
348
361
  // 获取基本 Header 信息
349
362
  function getCommonHeader() {
350
- return callNative(getFuncName$8('getCommonHeader'), null);
363
+ return callNative(getFuncName$9('getCommonHeader'), null);
351
364
  }
352
365
  // 读取SSE流
353
366
  function readSse(params) {
354
- return callNative(getFuncName$8('readSse'), params);
367
+ return callNative(getFuncName$9('readSse'), params);
355
368
  }
356
369
  // 下载一个文件到设备本地
357
370
  // url : 需要下载的链接
@@ -368,7 +381,7 @@ function downloadToFile(url, tempFlag, method, header, postType, body) {
368
381
  if (header === void 0) { header = ''; }
369
382
  if (postType === void 0) { postType = ''; }
370
383
  if (body === void 0) { body = ''; }
371
- return callNative(getFuncName$8('downloadToFile'), {
384
+ return callNative(getFuncName$9('downloadToFile'), {
372
385
  url: url,
373
386
  tempFlag: tempFlag,
374
387
  method: method,
@@ -388,39 +401,39 @@ var network = {
388
401
  downloadToFile: downloadToFile,
389
402
  };
390
403
 
391
- var moduleName$7 = 'app';
392
- function getFuncName$7(name) {
393
- return moduleName$7 + '_' + name;
404
+ var moduleName$8 = 'app';
405
+ function getFuncName$8(name) {
406
+ return moduleName$8 + '_' + name;
394
407
  }
395
408
  function getUserInfo() {
396
- return callNative(getFuncName$7('getUserInfo'), null);
409
+ return callNative(getFuncName$8('getUserInfo'), null);
397
410
  }
398
411
  function getHostAppInfo() {
399
- return callNative(getFuncName$7('getHostAppInfo'), null);
412
+ return callNative(getFuncName$8('getHostAppInfo'), null);
400
413
  }
401
414
  function startPage(params) {
402
- return callNative(getFuncName$7('startPage'), params);
415
+ return callNative(getFuncName$8('startPage'), params);
403
416
  }
404
417
  function startActivity(params) {
405
- return callNative(getFuncName$7('startPage'), params);
418
+ return callNative(getFuncName$8('startPage'), params);
406
419
  }
407
420
  function exitPage() {
408
- callNative(getFuncName$7('exitPage'), null);
421
+ callNative(getFuncName$8('exitPage'), null);
409
422
  }
410
423
  function movePageToBack() {
411
- return callNative(getFuncName$7('movePageToBack'), null);
424
+ return callNative(getFuncName$8('movePageToBack'), null);
412
425
  }
413
426
  function startService(params) {
414
- return callNative(getFuncName$7('startService'), params);
427
+ return callNative(getFuncName$8('startService'), params);
415
428
  }
416
429
  function getInstalledAppInfo(params) {
417
- return callNative(getFuncName$7('getInstalledAppInfo'), params);
430
+ return callNative(getFuncName$8('getInstalledAppInfo'), params);
418
431
  }
419
432
  function getInstalledAppsList() {
420
- callNative(getFuncName$7('getInstalledAppsList'), null);
433
+ callNative(getFuncName$8('getInstalledAppsList'), null);
421
434
  }
422
435
  function execActionString(action) {
423
- return callNative(getFuncName$7('execActionString'), action);
436
+ return callNative(getFuncName$8('execActionString'), action);
424
437
  }
425
438
  var app = {
426
439
  getUserInfo: getUserInfo,
@@ -435,66 +448,66 @@ var app = {
435
448
  execActionString: execActionString,
436
449
  };
437
450
 
438
- var moduleName$6 = 'system';
439
- function getFuncName$6(name) {
440
- return moduleName$6 + '_' + name;
451
+ var moduleName$7 = 'system';
452
+ function getFuncName$7(name) {
453
+ return moduleName$7 + '_' + name;
441
454
  }
442
455
  // 告知宿主,小程序或者网页已经准备好
443
456
  function ready() {
444
- return callNative(getFuncName$6('ready'), null);
457
+ return callNative(getFuncName$7('ready'), null);
445
458
  }
446
459
  // 获取启动参数
447
460
  function getStartupParams() {
448
- return callNative(getFuncName$6('getStartupParams'), null);
461
+ return callNative(getFuncName$7('getStartupParams'), null);
449
462
  }
450
463
  // 获取设备信息
451
464
  function getDeviceInfo() {
452
- return callNative(getFuncName$6('getDeviceInfo'), null);
465
+ return callNative(getFuncName$7('getDeviceInfo'), null);
453
466
  }
454
467
  // 获取显示屏幕信息
455
468
  function getDisplayInfo() {
456
- return callNative(getFuncName$6('getDisplayInfo'), null);
469
+ return callNative(getFuncName$7('getDisplayInfo'), null);
457
470
  }
458
471
  // 获取 android property 的值
459
472
  function getProperty(key) {
460
- return callNative(getFuncName$6('getProperty'), { propName: key });
473
+ return callNative(getFuncName$7('getProperty'), { propName: key });
461
474
  }
462
475
  // 检查 JS-API 是否已经实现
463
476
  function checkApi(apiName) {
464
- return callNative(getFuncName$6('checkApi'), { apiName: apiName });
477
+ return callNative(getFuncName$7('checkApi'), { apiName: apiName });
465
478
  }
466
479
  // 获取本地字体的路径
467
480
  function getFontPath(fontFileName) {
468
- return callNative(getFuncName$6('getFontPath'), { fontFileName: fontFileName });
481
+ return callNative(getFuncName$7('getFontPath'), { fontFileName: fontFileName });
469
482
  }
470
483
  // 设置屏幕是否常亮
471
484
  function setKeepScreenOn(enable) {
472
- return callNative(getFuncName$6('setKeepScreenOn'), { enable: enable });
485
+ return callNative(getFuncName$7('setKeepScreenOn'), { enable: enable });
473
486
  }
474
487
  // 添加事件监听
475
- function addEventListener(eventName, callback, options) {
488
+ function addEventListener$1(eventName, callback, options) {
476
489
  if (options === void 0) { options = {}; }
477
- return callWithPersistentCallBack(getFuncName$6('addEventListener'), { callbackId: eventName, options: options }, eventName, callback);
490
+ return callWithPersistentCallBack(getFuncName$7('addEventListener'), { callbackId: eventName, options: options }, eventName, callback);
478
491
  }
479
492
  // 删除事件监听
480
- function removeEventListener(eventName, callback, options) {
493
+ function removeEventListener$1(eventName, callback, options) {
481
494
  if (options === void 0) { options = {}; }
482
495
  var ret = deletePersistentCallBack(eventName, callback);
483
496
  if (ret) {
484
- return callNative(getFuncName$6('removeEventListener'), { callbackId: eventName, options: options });
497
+ return callNative(getFuncName$7('removeEventListener'), { callbackId: eventName, options: options });
485
498
  }
486
499
  return new Promise(function (resolve) { resolve(); });
487
500
  }
488
501
  function sendBroadcast(params) {
489
- return callNative(getFuncName$6('sendBroadcast'), params);
502
+ return callNative(getFuncName$7('sendBroadcast'), params);
490
503
  }
491
504
  // 声明本页面接收并处理系统级的按键(如:返回、HOME、MENU 键)
492
505
  function registerKeys(params) {
493
- return callNative(getFuncName$6('registerKeys'), params || { keys: [] });
506
+ return callNative(getFuncName$7('registerKeys'), params || { keys: [] });
494
507
  }
495
508
  // 声明本页面接收并处理系统级的按键(如:返回、HOME、MENU 键)
496
509
  function unregisterKeys(params) {
497
- return callNative(getFuncName$6('unregisterKeys'), params || { keys: [] });
510
+ return callNative(getFuncName$7('unregisterKeys'), params || { keys: [] });
498
511
  }
499
512
  var system = {
500
513
  ready: ready,
@@ -505,34 +518,33 @@ var system = {
505
518
  checkApi: checkApi,
506
519
  getFontPath: getFontPath,
507
520
  setKeepScreenOn: setKeepScreenOn,
508
- addEventListener: addEventListener,
509
- removeEventListener: removeEventListener,
521
+ addEventListener: addEventListener$1,
522
+ removeEventListener: removeEventListener$1,
510
523
  sendBroadcast: sendBroadcast,
511
524
  registerKeys: registerKeys,
512
525
  unregisterKeys: unregisterKeys,
513
- //registerKeysOrUnregisterKeys
514
- //sendEvent
526
+ //sendEvent
515
527
  };
516
528
 
517
- var moduleName$5 = 'storage';
518
- function getFuncName$5(name) {
519
- return moduleName$5 + '_' + name;
529
+ var moduleName$6 = 'storage';
530
+ function getFuncName$6(name) {
531
+ return moduleName$6 + '_' + name;
520
532
  }
521
533
  function setKey(key, value, namespace) {
522
534
  if (namespace === void 0) { namespace = ''; }
523
- return callNative(getFuncName$5('setKey'), { key: key, value: value, namespace: namespace });
535
+ return callNative(getFuncName$6('setKey'), { key: key, value: value, namespace: namespace });
524
536
  }
525
537
  function getKey(key, namespace) {
526
538
  if (namespace === void 0) { namespace = ''; }
527
- return callNative(getFuncName$5('getKey'), { key: key, namespace: namespace });
539
+ return callNative(getFuncName$6('getKey'), { key: key, namespace: namespace });
528
540
  }
529
541
  function deleteKey(key, namespace) {
530
542
  if (namespace === void 0) { namespace = ''; }
531
- return callNative(getFuncName$5('deleteKey'), { key: key, namespace: namespace });
543
+ return callNative(getFuncName$6('deleteKey'), { key: key, namespace: namespace });
532
544
  }
533
545
  function clearAllKeys(namespace) {
534
546
  if (namespace === void 0) { namespace = ''; }
535
- return callNative(getFuncName$5('clearAllKeys'), { namespace: namespace });
547
+ return callNative(getFuncName$6('clearAllKeys'), { namespace: namespace });
536
548
  }
537
549
  var storage = {
538
550
  setKey: setKey,
@@ -541,54 +553,54 @@ var storage = {
541
553
  clearAllKeys: clearAllKeys
542
554
  };
543
555
 
544
- var moduleName$4 = 'audio';
545
- function getFuncName$4(name) {
546
- return moduleName$4 + '_' + name;
556
+ var moduleName$5 = 'audio';
557
+ function getFuncName$5(name) {
558
+ return moduleName$5 + '_' + name;
547
559
  }
548
560
  // 播放器,播放新的URL或者本地文件系统的路径
549
561
  function playNew(path) {
550
- return callNative(getFuncName$4('playNew'), { path: path });
562
+ return callNative(getFuncName$5('playNew'), { path: path });
551
563
  }
552
564
  // 播放器,停止播放
553
565
  function stop$1() {
554
- return callNative(getFuncName$4('stop'), null);
566
+ return callNative(getFuncName$5('stop'), null);
555
567
  }
556
568
  // 播放器,是否正在播放中
557
569
  function isPlaying$1() {
558
- return callNative(getFuncName$4('isPlaying'), null);
570
+ return callNative(getFuncName$5('isPlaying'), null);
559
571
  }
560
572
  // 播放器,是否准备好
561
573
  function hasPrepared$1() {
562
- return callNative(getFuncName$4('hasPrepared'), null);
574
+ return callNative(getFuncName$5('hasPrepared'), null);
563
575
  }
564
576
  // 播放器,获取总时长
565
577
  function getDuration$1() {
566
- return callNative(getFuncName$4('getDuration'), null);
578
+ return callNative(getFuncName$5('getDuration'), null);
567
579
  }
568
580
  // 播放器,获取当前进度值
569
581
  function getCurrentPosition$1() {
570
- return callNative(getFuncName$4('getCurrentPosition'), null);
582
+ return callNative(getFuncName$5('getCurrentPosition'), null);
571
583
  }
572
584
  // 播放器,获取播放状态,返回的value为字符串来标识播放状态
573
585
  // 例如:Idle, Initialized, Preparing, Prepared, Started, Paused, Stopped, Completed, Error, End
574
586
  function getPlayerState$1() {
575
- return callNative(getFuncName$4('getPlayerState'), null);
587
+ return callNative(getFuncName$5('getPlayerState'), null);
576
588
  }
577
589
  // 播放器,暂停播放
578
590
  function pause$1() {
579
- return callNative(getFuncName$4('pause'), null);
591
+ return callNative(getFuncName$5('pause'), null);
580
592
  }
581
593
  // 播放器,启动播放或者从暂停恢复播放
582
594
  function start$1() {
583
- return callNative(getFuncName$4('start'), null);
595
+ return callNative(getFuncName$5('start'), null);
584
596
  }
585
597
  // 播放器,重新播放
586
598
  function rePlay$1() {
587
- return callNative(getFuncName$4('rePlay'), null);
599
+ return callNative(getFuncName$5('rePlay'), null);
588
600
  }
589
601
  // 播放器,seek
590
602
  function seekTo$1(position) {
591
- return callNative(getFuncName$4('seekTo'), { position: Math.floor(position) });
603
+ return callNative(getFuncName$5('seekTo'), { position: Math.floor(position) });
592
604
  }
593
605
  // 播放器,设置单片循环模式
594
606
  // isLooping: 是否循环播放
@@ -596,16 +608,16 @@ function seekTo$1(position) {
596
608
  // 会无感知重播,即重播时,不会调idle/ preparing/ prepared等开始播放之前的状态)
597
609
  function setLooping$1(isLooping, silentLoop) {
598
610
  if (silentLoop === void 0) { silentLoop = false; }
599
- return callNative(getFuncName$4('setLooping'), { isLooping: isLooping, silentLoop: silentLoop });
611
+ return callNative(getFuncName$5('setLooping'), { isLooping: isLooping, silentLoop: silentLoop });
600
612
  }
601
613
  // 设置音量
602
614
  function setVolume(volume) {
603
- return callNative(getFuncName$4('setVolume'), { volume: volume });
615
+ return callNative(getFuncName$5('setVolume'), { volume: volume });
604
616
  }
605
617
  // 设置播放内核
606
618
  // 值: DefaultPlayer, MediaPlayer, SocPlayer, ExoPlayer
607
619
  function setPlayerCore$1(core) {
608
- return callNative(getFuncName$4('setPlayerCore'), { core: core });
620
+ return callNative(getFuncName$5('setPlayerCore'), { core: core });
609
621
  }
610
622
  var audio = {
611
623
  playNew: playNew,
@@ -624,62 +636,62 @@ var audio = {
624
636
  setPlayerCore: setPlayerCore$1,
625
637
  };
626
638
 
627
- var moduleName$3 = 'video';
628
- function getFuncName$3(name) {
629
- return moduleName$3 + '_' + name;
639
+ var moduleName$4 = 'video';
640
+ function getFuncName$4(name) {
641
+ return moduleName$4 + '_' + name;
630
642
  }
631
643
  // 设置视频播放窗口的位置与宽高
632
644
  function setVideoLayout(width, height, x, y) {
633
- return callNative(getFuncName$3('setVideoLayout'), { x: Number(x), y: Number(y), w: Number(width), h: Number(height) });
645
+ return callNative(getFuncName$4('setVideoLayout'), { x: Number(x), y: Number(y), w: Number(width), h: Number(height) });
634
646
  }
635
647
  // 设置视频窗口是否显示
636
648
  function setVideoVisible(show) {
637
- return callNative(getFuncName$3('setVideoVisible'), { visible: show });
649
+ return callNative(getFuncName$4('setVideoVisible'), { visible: show });
638
650
  }
639
651
  // 播放器,播放新的URL
640
652
  function playNewUrl(url) {
641
- return callNative(getFuncName$3('playNewUrl'), { url: url });
653
+ return callNative(getFuncName$4('playNewUrl'), { url: url });
642
654
  }
643
655
  // 播放器,播放新的本地文件路径
644
656
  function playNewFile(path) {
645
- return callNative(getFuncName$3('playNewFile'), { path: path });
657
+ return callNative(getFuncName$4('playNewFile'), { path: path });
646
658
  }
647
659
  // 播放器,停止播放
648
660
  function stop() {
649
- return callNative(getFuncName$3('stop'), null);
661
+ return callNative(getFuncName$4('stop'), null);
650
662
  }
651
663
  // 播放器,暂停播放
652
664
  function pause() {
653
- return callNative(getFuncName$3('pause'), null);
665
+ return callNative(getFuncName$4('pause'), null);
654
666
  }
655
667
  // 播放器,启动播放或者从暂停恢复播放
656
668
  function start() {
657
- return callNative(getFuncName$3('start'), null);
669
+ return callNative(getFuncName$4('start'), null);
658
670
  }
659
671
  // 播放器,seek
660
672
  function seekTo(position) {
661
- return callNative(getFuncName$3('seekTo'), { position: Math.floor(position) });
673
+ return callNative(getFuncName$4('seekTo'), { position: Math.floor(position) });
662
674
  }
663
675
  // 播放器,是否准备好
664
676
  function hasPrepared() {
665
- return callNative(getFuncName$3('hasPrepared'), null);
677
+ return callNative(getFuncName$4('hasPrepared'), null);
666
678
  }
667
679
  // 播放器,是否正在播放中
668
680
  function isPlaying() {
669
- return callNative(getFuncName$3('isPlaying'), null);
681
+ return callNative(getFuncName$4('isPlaying'), null);
670
682
  }
671
683
  // 播放器,获取总时长
672
684
  function getDuration() {
673
- return callNative(getFuncName$3('getDuration'), null);
685
+ return callNative(getFuncName$4('getDuration'), null);
674
686
  }
675
687
  // 播放器,获取当前进度值
676
688
  function getCurrentPosition() {
677
- return callNative(getFuncName$3('getCurrentPosition'), null);
689
+ return callNative(getFuncName$4('getCurrentPosition'), null);
678
690
  }
679
691
  // 播放器,获取播放状态,返回的value为字符串来标识播放状态
680
692
  // 例如:Idle, Initialized, Preparing, Prepared, Started, Paused, Stopped, Completed, Error, End
681
693
  function getPlayerState() {
682
- return callNative(getFuncName$3('getPlayerState'), null);
694
+ return callNative(getFuncName$4('getPlayerState'), null);
683
695
  }
684
696
  // 播放器,设置单片循环模式
685
697
  // isLooping: 是否循环播放
@@ -687,40 +699,40 @@ function getPlayerState() {
687
699
  // 会无感知重播,即重播时,不会调idle/ preparing/ prepared等开始播放之前的状态)
688
700
  function setLooping(isLooping, silentLoop) {
689
701
  if (silentLoop === void 0) { silentLoop = false; }
690
- return callNative(getFuncName$3('setLooping'), { isLooping: isLooping, silentLoop: silentLoop });
702
+ return callNative(getFuncName$4('setLooping'), { isLooping: isLooping, silentLoop: silentLoop });
691
703
  }
692
704
  // 播放器,设置自动屏保锁,即:开始或恢复播放->锁屏保,停止或暂停播放->释放屏保锁 默认关闭
693
705
  function setAutoWakeLock(autoWakeLock) {
694
- return callNative(getFuncName$3('setAutoWakeLock'), { autoWakeLock: autoWakeLock });
706
+ return callNative(getFuncName$4('setAutoWakeLock'), { autoWakeLock: autoWakeLock });
695
707
  }
696
708
  // 播放器,重新播放
697
709
  function rePlay() {
698
- return callNative(getFuncName$3('rePlay'), null);
710
+ return callNative(getFuncName$4('rePlay'), null);
699
711
  }
700
712
  // 播放器,设置是否自动播放,即 play ready 后音视频自动播放 默认开启
701
713
  function setPlayWhenReady(playWhenReady) {
702
714
  if (playWhenReady === void 0) { playWhenReady = true; }
703
- return callNative(getFuncName$3('setPlayWhenReady'), { playWhenReady: playWhenReady });
715
+ return callNative(getFuncName$4('setPlayWhenReady'), { playWhenReady: playWhenReady });
704
716
  }
705
717
  // 获取当前设置的播放内核, 有可能会返回 DefaultPlayer
706
718
  // 值: DefaultPlayer, MediaPlayer, SocPlayer, ExoPlayer
707
719
  function getPlayerCore() {
708
- return callNative(getFuncName$3('getPlayerCore'), null);
720
+ return callNative(getFuncName$4('getPlayerCore'), null);
709
721
  }
710
722
  // 获取实际的播放内核, 部分内核如:最佳内核,实际上是在各个内核中进行选择,不会返回 DefaultPlayer
711
723
  // 值: MediaPlayer, SocPlayer, ExoPlayer
712
724
  function getRealPlayerCore() {
713
- return callNative(getFuncName$3('getRealPlayerCore'), null);
725
+ return callNative(getFuncName$4('getRealPlayerCore'), null);
714
726
  }
715
727
  // 设置播放内核
716
728
  // 值: DefaultPlayer, MediaPlayer, SocPlayer, ExoPlayer
717
729
  function setPlayerCore(core) {
718
- return callNative(getFuncName$3('setPlayerCore'), { core: core });
730
+ return callNative(getFuncName$4('setPlayerCore'), { core: core });
719
731
  }
720
732
  // 设置渲染模式
721
733
  // 值: SurfaceView, TextureView
722
734
  function setRenderType(playerRender) {
723
- return callNative(getFuncName$3('setRenderType'), { playerRender: playerRender });
735
+ return callNative(getFuncName$4('setRenderType'), { playerRender: playerRender });
724
736
  }
725
737
  var video = {
726
738
  setVideoLayout: setVideoLayout,
@@ -746,9 +758,9 @@ var video = {
746
758
  setRenderType: setRenderType,
747
759
  };
748
760
 
749
- var moduleName$2 = 'fs';
750
- function getFuncName$2(name) {
751
- return moduleName$2 + '_' + name;
761
+ var moduleName$3 = 'fs';
762
+ function getFuncName$3(name) {
763
+ return moduleName$3 + '_' + name;
752
764
  }
753
765
  // 读取文件并返回文件的所有内容
754
766
  // 参数:
@@ -756,7 +768,7 @@ function getFuncName$2(name) {
756
768
  // base64Flag: 是否以base64编码方式返回, 如果读取文本文件,则应该设置 base64Flag = false,如果读取二进制文件,则应该设置 base64Flag = true
757
769
  function readAllContent(path, base64Flag) {
758
770
  if (base64Flag === void 0) { base64Flag = false; }
759
- return callNative(getFuncName$2('readAllContent'), { path: path, base64Flag: base64Flag });
771
+ return callNative(getFuncName$3('readAllContent'), { path: path, base64Flag: base64Flag });
760
772
  }
761
773
  // 将内容全部写入文件
762
774
  // 参数:
@@ -765,114 +777,114 @@ function readAllContent(path, base64Flag) {
765
777
  // base64Flag: 是否以base64编码方式传输content, 如果写文本文件,则应该设置 base64Flag = false,如果写入二进制文件,则应该设置 base64Flag = true
766
778
  function writeAllContent(path, content, base64Flag) {
767
779
  if (base64Flag === void 0) { base64Flag = false; }
768
- return callNative(getFuncName$2('writeAllContent'), { path: path, content: content, base64Flag: base64Flag });
780
+ return callNative(getFuncName$3('writeAllContent'), { path: path, content: content, base64Flag: base64Flag });
769
781
  }
770
782
  // 获取应用基本目录的全路径名
771
783
  function getAppBaseDir() {
772
- return callNative(getFuncName$2('getAppBaseDir'), null);
784
+ return callNative(getFuncName$3('getAppBaseDir'), null);
773
785
  }
774
786
  // 获取 Cache 目录的全路径名
775
787
  function getAppCacheDir() {
776
- return callNative(getFuncName$2('getAppCacheDir'), null);
788
+ return callNative(getFuncName$3('getAppCacheDir'), null);
777
789
  }
778
790
  // 构建一个临时文件名,返回该文件的绝对路径的全文件路径名
779
791
  // 参数:
780
792
  // fileName: 指定临时文件的基本名,如果不指定,会默认随机生成一个文件名
781
793
  function makeCacheFile(fileName) {
782
794
  if (fileName === void 0) { fileName = ''; }
783
- return callNative(getFuncName$2('makeCacheFile'), { fileName: fileName });
795
+ return callNative(getFuncName$3('makeCacheFile'), { fileName: fileName });
784
796
  }
785
797
  // 构建一个正常文件名,返回该文件的绝对路径的全文件路径名
786
798
  // 参数:
787
799
  // fileName: 指定文件的基本名,如果不指定,会默认随机生成一个文件名
788
800
  function makeNormalFile(fileName) {
789
801
  if (fileName === void 0) { fileName = ''; }
790
- return callNative(getFuncName$2('makeNormalFile'), { fileName: fileName });
802
+ return callNative(getFuncName$3('makeNormalFile'), { fileName: fileName });
791
803
  }
792
804
  // 检测一个文件或者目录是否存在
793
805
  // 参数:
794
806
  // path: 指定路径
795
807
  function exists(path) {
796
- return callNative(getFuncName$2('exists'), { path: path });
808
+ return callNative(getFuncName$3('exists'), { path: path });
797
809
  }
798
810
  // 检测一个路径是否为一个普通文件
799
811
  // 参数:
800
812
  // path: 指定路径
801
813
  function isFile(path) {
802
- return callNative(getFuncName$2('isFile'), { path: path });
814
+ return callNative(getFuncName$3('isFile'), { path: path });
803
815
  }
804
816
  // 检测一个路径是否为一个目录
805
817
  // 参数:
806
818
  // path: 指定路径
807
819
  function isDirectory(path) {
808
- return callNative(getFuncName$2('isDirectory'), { path: path });
820
+ return callNative(getFuncName$3('isDirectory'), { path: path });
809
821
  }
810
822
  // 检测一个路径表示的文件或目录 是否是隐藏的
811
823
  // 参数:
812
824
  // path: 指定路径
813
825
  function isHidden(path) {
814
- return callNative(getFuncName$2('isHidden'), { path: path });
826
+ return callNative(getFuncName$3('isHidden'), { path: path });
815
827
  }
816
828
  // 检测一个路径表示的文件或目录 是否可读
817
829
  // 参数:
818
830
  // path: 指定路径
819
831
  function canRead(path) {
820
- return callNative(getFuncName$2('canRead'), { path: path });
832
+ return callNative(getFuncName$3('canRead'), { path: path });
821
833
  }
822
834
  // 检测一个路径表示的文件或目录 是否可写
823
835
  // 参数:
824
836
  // path: 指定路径
825
837
  function canWrite(path) {
826
- return callNative(getFuncName$2('canWrite'), { path: path });
838
+ return callNative(getFuncName$3('canWrite'), { path: path });
827
839
  }
828
840
  // 检测一个路径表示的文件或目录 是否可执行
829
841
  // 参数:
830
842
  // path: 指定路径
831
843
  function canExecute(path) {
832
- return callNative(getFuncName$2('canExecute'), { path: path });
844
+ return callNative(getFuncName$3('canExecute'), { path: path });
833
845
  }
834
846
  // 检测一个路径表示的文件或目录 的最后修改的时间,返回时间戳(1970年开始的秒数)
835
847
  // 参数:
836
848
  // path: 指定路径
837
849
  function lastModified(path) {
838
- return callNative(getFuncName$2('lastModified'), { path: path });
850
+ return callNative(getFuncName$3('lastModified'), { path: path });
839
851
  }
840
852
  // 删除文件
841
853
  // 参数:
842
854
  // path: 指定路径
843
855
  function deleteIt(path) {
844
- return callNative(getFuncName$2('delete'), { path: path });
856
+ return callNative(getFuncName$3('delete'), { path: path });
845
857
  }
846
858
  // 新建目录
847
859
  // 参数:
848
860
  // path: 指定路径
849
861
  function mkdir(path) {
850
- return callNative(getFuncName$2('mkdir'), { path: path });
862
+ return callNative(getFuncName$3('mkdir'), { path: path });
851
863
  }
852
864
  // 新建目录 (如果父目录补存在则一并新建所有尚未存在的父目录)
853
865
  // 参数:
854
866
  // path: 指定路径
855
867
  function mkdirs(path) {
856
- return callNative(getFuncName$2('mkdirs'), { path: path });
868
+ return callNative(getFuncName$3('mkdirs'), { path: path });
857
869
  }
858
870
  // 改名
859
871
  // 参数:
860
872
  // from: 指定源路径
861
873
  // to: 指定目标路径
862
874
  function rename(from, to) {
863
- return callNative(getFuncName$2('rename'), { from: from, to: to });
875
+ return callNative(getFuncName$3('rename'), { from: from, to: to });
864
876
  }
865
877
  // 将相对路径的转换为全路径
866
878
  // 参数:
867
879
  // path: 指定路径
868
880
  function getAbsolutePath(path) {
869
- return callNative(getFuncName$2('getAbsolutePath'), { path: path });
881
+ return callNative(getFuncName$3('getAbsolutePath'), { path: path });
870
882
  }
871
883
  // 指定路径创建新文件
872
884
  // 参数:
873
885
  // path: 指定路径
874
886
  function createNewFile(path) {
875
- return callNative(getFuncName$2('createNewFile'), { path: path });
887
+ return callNative(getFuncName$3('createNewFile'), { path: path });
876
888
  }
877
889
  // 设置可读属性
878
890
  // 参数:
@@ -880,7 +892,7 @@ function createNewFile(path) {
880
892
  // value: 是否可读
881
893
  function setReadable(path, value) {
882
894
  if (value === void 0) { value = true; }
883
- return callNative(getFuncName$2('setReadable'), { path: path, value: value });
895
+ return callNative(getFuncName$3('setReadable'), { path: path, value: value });
884
896
  }
885
897
  // 设置可写属性
886
898
  // 参数:
@@ -888,7 +900,7 @@ function setReadable(path, value) {
888
900
  // value: 是否可写
889
901
  function setWritable(path, value) {
890
902
  if (value === void 0) { value = true; }
891
- return callNative(getFuncName$2('setWritable'), { path: path, value: value });
903
+ return callNative(getFuncName$3('setWritable'), { path: path, value: value });
892
904
  }
893
905
  // 设置可执行属性
894
906
  // 参数:
@@ -896,7 +908,7 @@ function setWritable(path, value) {
896
908
  // value: 是否可执行
897
909
  function setExecutable(path, value) {
898
910
  if (value === void 0) { value = true; }
899
- return callNative(getFuncName$2('setExecutable'), { path: path, value: value });
911
+ return callNative(getFuncName$3('setExecutable'), { path: path, value: value });
900
912
  }
901
913
  // 设置文件最后修改的时间
902
914
  // 参数:
@@ -904,13 +916,13 @@ function setExecutable(path, value) {
904
916
  // value: 时间戳
905
917
  function setLastModified(path, value) {
906
918
  if (value === void 0) { value = 0; }
907
- return callNative(getFuncName$2('setLastModified'), { path: path, value: value });
919
+ return callNative(getFuncName$3('setLastModified'), { path: path, value: value });
908
920
  }
909
921
  // 读取目录,返回该目录下的文件列表
910
922
  // 参数:
911
923
  // path: 指定路径
912
924
  function list(path) {
913
- return callNative(getFuncName$2('list'), { path: path });
925
+ return callNative(getFuncName$3('list'), { path: path });
914
926
  }
915
927
  var fs = {
916
928
  readAllContent: readAllContent,
@@ -940,19 +952,19 @@ var fs = {
940
952
  list: list
941
953
  };
942
954
 
943
- var moduleName$1 = 'pag';
944
- function getFuncName$1(name) {
945
- return moduleName$1 + '_' + name;
955
+ var moduleName$2 = 'pag';
956
+ function getFuncName$2(name) {
957
+ return moduleName$2 + '_' + name;
946
958
  }
947
959
  // 播放PAG动画
948
960
  // repeat: 循环次数 -1 表示无限
949
961
  //
950
962
  function startNewPagAni(params) {
951
- return callNative(getFuncName$1('startNewPagAni'), params);
963
+ return callNative(getFuncName$2('startNewPagAni'), params);
952
964
  }
953
965
  // 停止PAG动画,并消失
954
966
  function stopPagAni() {
955
- return callNative(getFuncName$1('stopPagAni'), null);
967
+ return callNative(getFuncName$2('stopPagAni'), null);
956
968
  }
957
969
  function setPagVisibility(visible) {
958
970
  if (visible === void 0) { visible = true; }
@@ -969,10 +981,10 @@ function setPagVisibility(visible) {
969
981
  else {
970
982
  value = visible;
971
983
  }
972
- return callNative(getFuncName$1('setPagVisibility'), { visible: value });
984
+ return callNative(getFuncName$2('setPagVisibility'), { visible: value });
973
985
  }
974
986
  function setPagXY(x, y) {
975
- return callNative(getFuncName$1('setPagXY'), { x: x, y: y });
987
+ return callNative(getFuncName$2('setPagXY'), { x: x, y: y });
976
988
  }
977
989
  // // 播报 TTS 文本语音
978
990
  // export function sendTts(text: string, ttsId: string): Promise<any> {
@@ -1015,6 +1027,58 @@ var pag = {
1015
1027
  // clearBackground,
1016
1028
  };
1017
1029
 
1030
+ var moduleName$1 = 'voice';
1031
+ function getFuncName$1(name) {
1032
+ return moduleName$1 + '_' + name;
1033
+ }
1034
+ // 开启语音输入
1035
+ function enableVoiceInput() {
1036
+ return callNative(getFuncName$1('enableVoiceInput'), {});
1037
+ }
1038
+ // 停止TTS播报
1039
+ //
1040
+ function stopTts$1() {
1041
+ return callNative(getFuncName$1('stopTts'), {});
1042
+ }
1043
+ // 开始 TTS 播报
1044
+ function sendTts$1(text, ttsId) {
1045
+ return callNative(getFuncName$1('sendTts'), { text: text, ttsId: ttsId });
1046
+ }
1047
+ // 流式播报 TTS
1048
+ function sendStreamTts$1(text, ttsId, isFirst, isEnd) {
1049
+ return callNative(getFuncName$1('sendStreamTts'), { text: text, ttsId: ttsId, isFirst: isFirst, isEnd: isEnd });
1050
+ }
1051
+ // 设置播放TTS的人声
1052
+ function setTtsSpeaker(speaker) {
1053
+ return callNative(getFuncName$1('setTtsSpeaker'), { speaker: speaker });
1054
+ }
1055
+ var voice = {
1056
+ enableVoiceInput: enableVoiceInput,
1057
+ stopTts: stopTts$1,
1058
+ sendTts: sendTts$1,
1059
+ sendStreamTts: sendStreamTts$1,
1060
+ setTtsSpeaker: setTtsSpeaker,
1061
+ };
1062
+
1063
+ // 添加事件监听
1064
+ function addEventListener(eventName, callback, options) {
1065
+ if (options === void 0) { options = {}; }
1066
+ return callWithPersistentCallBack('system_' + 'addEventListener', { callbackId: eventName, options: options }, eventName, callback);
1067
+ }
1068
+ // 删除事件监听
1069
+ function removeEventListener(eventName, callback, options) {
1070
+ if (options === void 0) { options = {}; }
1071
+ var ret = deletePersistentCallBack(eventName, callback);
1072
+ if (ret) {
1073
+ return callNative('system_' + 'removeEventListener', { callbackId: eventName, options: options });
1074
+ }
1075
+ return new Promise(function (resolve) { resolve(); });
1076
+ }
1077
+ var event = {
1078
+ addEventListener: addEventListener,
1079
+ removeEventListener: removeEventListener,
1080
+ };
1081
+
1018
1082
  var moduleName = 'tts';
1019
1083
  function getFuncName(name) {
1020
1084
  return moduleName + '_' + name;
@@ -1076,6 +1140,7 @@ function init() {
1076
1140
  }
1077
1141
  initSDK();
1078
1142
  }
1143
+ init();
1079
1144
  var index = {
1080
1145
  init: init,
1081
1146
  network: network,
@@ -1085,8 +1150,10 @@ var index = {
1085
1150
  audio: audio,
1086
1151
  video: video,
1087
1152
  pag: pag,
1088
- tts: tts,
1153
+ voice: voice,
1154
+ event: event,
1089
1155
  fs: fs,
1156
+ tts: tts,
1090
1157
  isRunInAppBrowser: isRunInAppBrowser
1091
1158
  };
1092
1159
 
@@ -0,0 +1,7 @@
1
+ export declare function addEventListener(eventName: string, callback: Function, options?: object): Promise<any>;
2
+ export declare function removeEventListener(eventName: string, callback: Function, options?: object): Promise<any>;
3
+ declare const _default: {
4
+ addEventListener: typeof addEventListener;
5
+ removeEventListener: typeof removeEventListener;
6
+ };
7
+ export default _default;
package/lib/index.d.ts CHANGED
@@ -91,10 +91,16 @@ declare const _default: {
91
91
  setPagVisibility: typeof import("./pag").setPagVisibility;
92
92
  setPagXY: typeof import("./pag").setPagXY;
93
93
  };
94
- tts: {
95
- stopTts: typeof import("./tts").stopTts;
96
- sendTts: typeof import("./tts").sendTts;
97
- sendStreamTts: typeof import("./tts").sendStreamTts;
94
+ voice: {
95
+ enableVoiceInput: typeof import("./voice").enableVoiceInput;
96
+ stopTts: typeof import("./voice").stopTts;
97
+ sendTts: typeof import("./voice").sendTts;
98
+ sendStreamTts: typeof import("./voice").sendStreamTts;
99
+ setTtsSpeaker: typeof import("./voice").setTtsSpeaker;
100
+ };
101
+ event: {
102
+ addEventListener: typeof import("./event").addEventListener;
103
+ removeEventListener: typeof import("./event").removeEventListener;
98
104
  };
99
105
  fs: {
100
106
  readAllContent: typeof import("./file").readAllContent;
@@ -123,6 +129,11 @@ declare const _default: {
123
129
  setLastModified: typeof import("./file").setLastModified;
124
130
  list: typeof import("./file").list;
125
131
  };
132
+ tts: {
133
+ stopTts: typeof import("./tts").stopTts;
134
+ sendTts: typeof import("./tts").sendTts;
135
+ sendStreamTts: typeof import("./tts").sendStreamTts;
136
+ };
126
137
  isRunInAppBrowser: typeof isRunInAppBrowser;
127
138
  };
128
139
  export default _default;
@@ -1,11 +1,3 @@
1
- export interface StartPAGParam {
2
- path: string;
3
- repeat: number;
4
- x: number;
5
- y: number;
6
- width: number;
7
- height: number;
8
- }
9
1
  export declare function stopTts(): Promise<any>;
10
2
  export declare function sendTts(text: string, ttsId: string): Promise<any>;
11
3
  export declare function sendStreamTts(text: string, ttsId: string, isFirst: boolean, isEnd: boolean): Promise<any>;
@@ -0,0 +1,13 @@
1
+ export declare function enableVoiceInput(): Promise<any>;
2
+ export declare function stopTts(): Promise<any>;
3
+ export declare function sendTts(text: string, ttsId: string): Promise<any>;
4
+ export declare function sendStreamTts(text: string, ttsId: string, isFirst: boolean, isEnd: boolean): Promise<any>;
5
+ export declare function setTtsSpeaker(speaker: string): Promise<any>;
6
+ declare const _default: {
7
+ enableVoiceInput: typeof enableVoiceInput;
8
+ stopTts: typeof stopTts;
9
+ sendTts: typeof sendTts;
10
+ sendStreamTts: typeof sendStreamTts;
11
+ setTtsSpeaker: typeof setTtsSpeaker;
12
+ };
13
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccos/ccsdk-lite",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "a jssdk for coocaa tv-system",
5
5
  "type": "module",
6
6
  "main": "lib/bundle.js",