@ccos/ccsdk-lite 1.0.13 → 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 +14 -0
- package/package.json +1 -1
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;
|
|
@@ -1127,6 +1140,7 @@ function init() {
|
|
|
1127
1140
|
}
|
|
1128
1141
|
initSDK();
|
|
1129
1142
|
}
|
|
1143
|
+
init();
|
|
1130
1144
|
var index = {
|
|
1131
1145
|
init: init,
|
|
1132
1146
|
network: network,
|