@ccos/ccsdk-lite 1.0.26 → 1.0.28
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 +31 -1
- package/lib/core/index.d.ts +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/voice/index.d.ts +2 -0
- package/package.json +1 -1
package/lib/bundle.js
CHANGED
|
@@ -60,6 +60,8 @@ var bus = new Bus();
|
|
|
60
60
|
var hasInitialized = false;
|
|
61
61
|
var actionList = []; // 这里保存, 未注册命令处理函数之前,APP发过来的命令
|
|
62
62
|
var apiCode = '';
|
|
63
|
+
var nativeObject = null;
|
|
64
|
+
var nativeType = '';
|
|
63
65
|
function defaultAppCmd(cmd, payload) {
|
|
64
66
|
console.log('default appCmd ' + cmd);
|
|
65
67
|
actionList.push({ cmd: cmd, payload: payload }); // 有可能APP发过来的命令比较早,而页面的一些初始化还没有做完,这时把命令先存起来,放到 actionList 中
|
|
@@ -84,6 +86,10 @@ function unsetAppCommandCallback() {
|
|
|
84
86
|
appCmdProcessor = defaultAppCmd;
|
|
85
87
|
actionList = [];
|
|
86
88
|
}
|
|
89
|
+
function setNativeObject(obj, _type) {
|
|
90
|
+
nativeObject = obj;
|
|
91
|
+
nativeType = _type;
|
|
92
|
+
}
|
|
87
93
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
88
94
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
89
95
|
var persistentCallbackMap = new Map(); // 持久化 callback-id 与回调函数对应的列表 (回调函数可以多个,组成一个Set)
|
|
@@ -128,6 +134,18 @@ function nativeCall(funcName, callbackId, params) {
|
|
|
128
134
|
apkNativeCallJs(resData);
|
|
129
135
|
});
|
|
130
136
|
}
|
|
137
|
+
else if (nativeObject) {
|
|
138
|
+
if (nativeType == 'cocos') {
|
|
139
|
+
// 运行于 android 的 cocos 平台
|
|
140
|
+
var object2 = {
|
|
141
|
+
func: funcName,
|
|
142
|
+
id: callbackId,
|
|
143
|
+
params: params || {},
|
|
144
|
+
apiCode: apiCode,
|
|
145
|
+
};
|
|
146
|
+
nativeObject.reflection.callStaticMethod('com/coocaa/cocos_game/UniNativeAPI', 'callToHostApp', "(Ljava/lang/String;)V", JSON.stringify(object2));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
131
149
|
}
|
|
132
150
|
function nativeRequest(funcName, params, persistent, persistentIdName, persistentCallback) {
|
|
133
151
|
if (!persistent) {
|
|
@@ -1171,6 +1189,10 @@ function sendStreamTts$1(text, ttsId, isFirst, isEnd) {
|
|
|
1171
1189
|
function setTtsSpeaker(speaker) {
|
|
1172
1190
|
return callNative(getFuncName$2('setTtsSpeaker'), { speaker: speaker });
|
|
1173
1191
|
}
|
|
1192
|
+
// 设置播放TTS的音速
|
|
1193
|
+
function setTtsSpeed(speed) {
|
|
1194
|
+
return callNative(getFuncName$2('setTtsSpeed'), { speed: speed });
|
|
1195
|
+
}
|
|
1174
1196
|
// 发送纯文本
|
|
1175
1197
|
function sendVoiceTextToAI(text) {
|
|
1176
1198
|
return callNative(getFuncName$2('sendVoiceTextToAI'), { text: text });
|
|
@@ -1191,6 +1213,7 @@ var voice = {
|
|
|
1191
1213
|
sendTts: sendTts$1,
|
|
1192
1214
|
sendStreamTts: sendStreamTts$1,
|
|
1193
1215
|
setTtsSpeaker: setTtsSpeaker,
|
|
1216
|
+
setTtsSpeed: setTtsSpeed,
|
|
1194
1217
|
sendVoiceTextToAI: sendVoiceTextToAI,
|
|
1195
1218
|
setA2UI: setA2UI,
|
|
1196
1219
|
};
|
|
@@ -1294,10 +1317,17 @@ function apkNativeCallJs(str) {
|
|
|
1294
1317
|
function isRunInAppBrowser() {
|
|
1295
1318
|
return window['_liteNativeApi'] ? true : false;
|
|
1296
1319
|
}
|
|
1297
|
-
function init() {
|
|
1320
|
+
function init(nativeObject, nativeType) {
|
|
1321
|
+
if (nativeObject === void 0) { nativeObject = null; }
|
|
1322
|
+
if (nativeType === void 0) { nativeType = ''; }
|
|
1298
1323
|
if (window['_liteNativeApi']) {
|
|
1299
1324
|
window['appNativeCall'] = apkNativeCallJs;
|
|
1300
1325
|
}
|
|
1326
|
+
else if (window['CoocaaJsApiBridge']) ;
|
|
1327
|
+
else if (nativeObject) {
|
|
1328
|
+
setNativeObject(nativeObject, nativeType);
|
|
1329
|
+
window['appNativeCall'] = apkNativeCallJs;
|
|
1330
|
+
}
|
|
1301
1331
|
initSDK();
|
|
1302
1332
|
}
|
|
1303
1333
|
init();
|
package/lib/core/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare function onCommandFromApp(cmd: string, payload: string): void;
|
|
2
2
|
export declare function setAppCommandCallback(cb: Function): void;
|
|
3
3
|
export declare function unsetAppCommandCallback(): void;
|
|
4
|
+
export declare function setNativeObject(obj: any, _type: string): void;
|
|
4
5
|
export declare function callNative(funcName: string, params: any): Promise<any>;
|
|
5
6
|
export declare function callWithPersistentCallBack(funcName: string, params: any, persistentIdName: string, callback: Function): Promise<any>;
|
|
6
7
|
export declare function deletePersistentCallBack(persistentIdName: string, callback: Function): boolean;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { setAppCommandCallback, unsetAppCommandCallback } from './core';
|
|
2
2
|
export declare function apkNativeCallJs(str: string | object): void;
|
|
3
3
|
export declare function isRunInAppBrowser(): boolean;
|
|
4
|
-
export declare function init(): void;
|
|
4
|
+
export declare function init(nativeObject?: any, nativeType?: string): void;
|
|
5
5
|
declare const _default: {
|
|
6
6
|
init: typeof init;
|
|
7
7
|
network: {
|
|
@@ -109,6 +109,7 @@ declare const _default: {
|
|
|
109
109
|
sendTts: typeof import("./voice").sendTts;
|
|
110
110
|
sendStreamTts: typeof import("./voice").sendStreamTts;
|
|
111
111
|
setTtsSpeaker: typeof import("./voice").setTtsSpeaker;
|
|
112
|
+
setTtsSpeed: typeof import("./voice").setTtsSpeed;
|
|
112
113
|
sendVoiceTextToAI: typeof import("./voice").sendVoiceTextToAI;
|
|
113
114
|
setA2UI: typeof import("./voice").setA2UI;
|
|
114
115
|
};
|
package/lib/voice/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare function stopTts(): Promise<any>;
|
|
|
8
8
|
export declare function sendTts(text: string, ttsId: string): Promise<any>;
|
|
9
9
|
export declare function sendStreamTts(text: string, ttsId: string, isFirst: boolean, isEnd: boolean): Promise<any>;
|
|
10
10
|
export declare function setTtsSpeaker(speaker: string): Promise<any>;
|
|
11
|
+
export declare function setTtsSpeed(speed: number): Promise<any>;
|
|
11
12
|
export declare function sendVoiceTextToAI(text: string): Promise<any>;
|
|
12
13
|
export declare function setA2UI(enable?: boolean): Promise<any>;
|
|
13
14
|
declare const _default: {
|
|
@@ -21,6 +22,7 @@ declare const _default: {
|
|
|
21
22
|
sendTts: typeof sendTts;
|
|
22
23
|
sendStreamTts: typeof sendStreamTts;
|
|
23
24
|
setTtsSpeaker: typeof setTtsSpeaker;
|
|
25
|
+
setTtsSpeed: typeof setTtsSpeed;
|
|
24
26
|
sendVoiceTextToAI: typeof sendVoiceTextToAI;
|
|
25
27
|
setA2UI: typeof setA2UI;
|
|
26
28
|
};
|