@cloudcare/cocos-sdk 0.1.1-alpha.2 → 0.1.1-alpha.3
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/dist/creator2/core/auto-tracking.d.ts +3 -1
- package/dist/creator2/core/auto-tracking.d.ts.map +1 -1
- package/dist/creator2/core/auto-tracking.js +60 -7
- package/dist/creator2/core/auto-tracking.js.map +1 -1
- package/dist/creator2/core/client.d.ts.map +1 -1
- package/dist/creator2/core/client.js +1 -3
- package/dist/creator2/core/client.js.map +1 -1
- package/dist/creator2/core/modules.d.ts.map +1 -1
- package/dist/creator2/core/modules.js +2 -2
- package/dist/creator2/core/modules.js.map +1 -1
- package/dist/creator2/core/observation.d.ts +25 -0
- package/dist/creator2/core/observation.d.ts.map +1 -0
- package/dist/creator2/core/observation.js +93 -0
- package/dist/creator2/core/observation.js.map +1 -0
- package/dist/creator2/core/platform-runtime.d.ts +2 -1
- package/dist/creator2/core/platform-runtime.d.ts.map +1 -1
- package/dist/creator2/core/platform-runtime.js.map +1 -1
- package/dist/creator2/core/types.d.ts +9 -0
- package/dist/creator2/core/types.d.ts.map +1 -1
- package/dist/creator2/core/types.js.map +1 -1
- package/dist/creator2/core/validation.d.ts +1 -0
- package/dist/creator2/core/validation.d.ts.map +1 -1
- package/dist/creator2/core/validation.js +13 -0
- package/dist/creator2/core/validation.js.map +1 -1
- package/dist/creator2/core/version.d.ts +1 -3
- package/dist/creator2/core/version.d.ts.map +1 -1
- package/dist/creator2/core/version.js +2 -4
- package/dist/creator2/core/version.js.map +1 -1
- package/dist/creator2/native/bootstrap.js +3 -2
- package/dist/creator2/native/bootstrap.js.map +1 -1
- package/dist/creator2/native/error-bootstrap.d.ts +2 -0
- package/dist/creator2/native/error-bootstrap.d.ts.map +1 -0
- package/dist/creator2/native/error-bootstrap.js +7 -0
- package/dist/creator2/native/error-bootstrap.js.map +1 -0
- package/dist/creator2/native/jsb-errors.d.ts +21 -0
- package/dist/creator2/native/jsb-errors.d.ts.map +1 -0
- package/dist/creator2/native/jsb-errors.js +91 -0
- package/dist/creator2/native/jsb-errors.js.map +1 -0
- package/dist/creator2/web/runtime.d.ts.map +1 -1
- package/dist/creator2/web/runtime.js +0 -1
- package/dist/creator2/web/runtime.js.map +1 -1
- package/dist/creator3/core/auto-tracking.d.ts +3 -1
- package/dist/creator3/core/auto-tracking.d.ts.map +1 -1
- package/dist/creator3/core/auto-tracking.js +60 -7
- package/dist/creator3/core/auto-tracking.js.map +1 -1
- package/dist/creator3/core/client.d.ts.map +1 -1
- package/dist/creator3/core/client.js +1 -3
- package/dist/creator3/core/client.js.map +1 -1
- package/dist/creator3/core/modules.d.ts.map +1 -1
- package/dist/creator3/core/modules.js +4 -9
- package/dist/creator3/core/modules.js.map +1 -1
- package/dist/creator3/core/observation.d.ts +25 -0
- package/dist/creator3/core/observation.d.ts.map +1 -0
- package/dist/creator3/core/observation.js +84 -0
- package/dist/creator3/core/observation.js.map +1 -0
- package/dist/creator3/core/platform-runtime.d.ts +2 -1
- package/dist/creator3/core/platform-runtime.d.ts.map +1 -1
- package/dist/creator3/core/platform-runtime.js.map +1 -1
- package/dist/creator3/core/types.d.ts +9 -0
- package/dist/creator3/core/types.d.ts.map +1 -1
- package/dist/creator3/core/validation.d.ts +1 -0
- package/dist/creator3/core/validation.d.ts.map +1 -1
- package/dist/creator3/core/validation.js +11 -0
- package/dist/creator3/core/validation.js.map +1 -1
- package/dist/creator3/core/version.d.ts +1 -3
- package/dist/creator3/core/version.d.ts.map +1 -1
- package/dist/creator3/core/version.js +1 -3
- package/dist/creator3/core/version.js.map +1 -1
- package/dist/creator3/creator3/index.js +2 -2
- package/dist/creator3/creator3/index.js.map +1 -1
- package/dist/creator3/native/bootstrap.js +2 -2
- package/dist/creator3/native/bootstrap.js.map +1 -1
- package/dist/creator3/native/error-bootstrap.d.ts +2 -0
- package/dist/creator3/native/error-bootstrap.d.ts.map +1 -0
- package/dist/creator3/native/error-bootstrap.js +5 -0
- package/dist/creator3/native/error-bootstrap.js.map +1 -0
- package/dist/creator3/native/jsb-errors.d.ts +21 -0
- package/dist/creator3/native/jsb-errors.d.ts.map +1 -0
- package/dist/creator3/native/jsb-errors.js +82 -0
- package/dist/creator3/native/jsb-errors.js.map +1 -0
- package/dist/creator3/web/runtime.d.ts.map +1 -1
- package/dist/creator3/web/runtime.js +1 -2
- package/dist/creator3/web/runtime.js.map +1 -1
- package/extensions/creator2/install-native.cjs +19 -1
- package/extensions/creator3/install-native.cjs +19 -1
- package/native/android/src/main/java/com/ft/sdk/cocos/FTCocosBridge.java +7 -10
- package/native/ios/FTCocosBridge.m +6 -4
- package/native/ios/FTCocosBridge.podspec +1 -1
- package/native/jsb-errors.js +266 -0
- package/package.json +1 -1
- package/runtime/native.js +181 -21
- package/web/bootstrap.js +17 -6
- package/web/bootstrap.js.map +2 -2
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(function() {
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __commonJS = function(cb, mod) {
|
|
5
|
+
return function __require() {
|
|
6
|
+
try {
|
|
7
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8
|
+
} catch (e) {
|
|
9
|
+
throw mod = 0, e;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// packages/cocos/dist/creator2/core/version.js
|
|
15
|
+
var require_version = __commonJS({
|
|
16
|
+
"packages/cocos/dist/creator2/core/version.js": function(exports) {
|
|
17
|
+
"use strict";
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.FT_COCOS_SDK_BRIDGE_INFO = exports.FT_COCOS_SDK_BRIDGE_INFO_KEY = exports.FT_COCOS_SDK_VERSION = void 0;
|
|
20
|
+
exports.FT_COCOS_SDK_VERSION = "0.1.1-alpha.3";
|
|
21
|
+
exports.FT_COCOS_SDK_BRIDGE_INFO_KEY = "sdk_bridge_info";
|
|
22
|
+
exports.FT_COCOS_SDK_BRIDGE_INFO = JSON.stringify({
|
|
23
|
+
cocos: exports.FT_COCOS_SDK_VERSION
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// packages/cocos/dist/creator2/core/platform-runtime.js
|
|
29
|
+
var require_platform_runtime = __commonJS({
|
|
30
|
+
"packages/cocos/dist/creator2/core/platform-runtime.js": function(exports) {
|
|
31
|
+
"use strict";
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.platformGlobal = platformGlobal;
|
|
34
|
+
exports.existingPlatformImplementation = existingPlatformImplementation;
|
|
35
|
+
exports.platformImplementation = platformImplementation;
|
|
36
|
+
var version_js_1 = require_version();
|
|
37
|
+
function platformGlobal() {
|
|
38
|
+
return typeof window !== "undefined" ? window : globalThis;
|
|
39
|
+
}
|
|
40
|
+
function existingPlatformImplementation(context, target) {
|
|
41
|
+
var _a;
|
|
42
|
+
if (target === void 0) {
|
|
43
|
+
target = platformGlobal();
|
|
44
|
+
}
|
|
45
|
+
var previous = (_a = target.__FT_COCOS_INSTANCES__) === null || _a === void 0 ? void 0 : _a[context.engine + ":" + context.platform];
|
|
46
|
+
if (previous && previous.version !== version_js_1.FT_COCOS_SDK_VERSION)
|
|
47
|
+
throw new Error("Cocos SDK versions must match on the same page");
|
|
48
|
+
return previous === null || previous === void 0 ? void 0 : previous.sdk;
|
|
49
|
+
}
|
|
50
|
+
function platformImplementation(context, target, create) {
|
|
51
|
+
if (target === void 0) {
|
|
52
|
+
target = platformGlobal();
|
|
53
|
+
}
|
|
54
|
+
var key = context.engine + ":" + context.platform;
|
|
55
|
+
var instances = target.__FT_COCOS_INSTANCES__ || (target.__FT_COCOS_INSTANCES__ = {});
|
|
56
|
+
var previous = existingPlatformImplementation(context, target);
|
|
57
|
+
if (previous)
|
|
58
|
+
return previous;
|
|
59
|
+
var factory = context.platform === "web" ? target.__FT_COCOS_WEB_FACTORY__ : target.__FT_COCOS_NATIVE_FACTORY__;
|
|
60
|
+
if (!create && (!factory || factory.protocol !== 1 || factory.version !== version_js_1.FT_COCOS_SDK_VERSION)) {
|
|
61
|
+
throw new Error(context.platform === "web" ? "Cocos Web runtime is missing or incompatible. Run the installer with --web and rebuild, or load /web/bootstrap before game scripts." : "Cocos native runtime is missing or incompatible. Rerun the SDK installer and rebuild the project.");
|
|
62
|
+
}
|
|
63
|
+
var sdk = create ? create() : factory.create(context, target);
|
|
64
|
+
instances[key] = { version: version_js_1.FT_COCOS_SDK_VERSION, sdk: sdk };
|
|
65
|
+
return sdk;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// packages/cocos/dist/creator2/core/observation.js
|
|
71
|
+
var require_observation = __commonJS({
|
|
72
|
+
"packages/cocos/dist/creator2/core/observation.js": function(exports) {
|
|
73
|
+
"use strict";
|
|
74
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
75
|
+
exports.FTObservationQueue = void 0;
|
|
76
|
+
exports.observationState = observationState;
|
|
77
|
+
function observationState(target) {
|
|
78
|
+
return target.__FT_COCOS_OBSERVATION_STATE__ || (target.__FT_COCOS_OBSERVATION_STATE__ = { reporting: 0 });
|
|
79
|
+
}
|
|
80
|
+
var FTObservationQueue = (
|
|
81
|
+
/** @class */
|
|
82
|
+
(function() {
|
|
83
|
+
function FTObservationQueue2(target) {
|
|
84
|
+
this.target = target;
|
|
85
|
+
this.pending = [];
|
|
86
|
+
this.size = 0;
|
|
87
|
+
this.generation = 0;
|
|
88
|
+
this.dropped = 0;
|
|
89
|
+
this.state = observationState(target);
|
|
90
|
+
}
|
|
91
|
+
FTObservationQueue2.prototype.enqueue = function(run, size) {
|
|
92
|
+
var _this = this;
|
|
93
|
+
if (size === void 0) {
|
|
94
|
+
size = 0;
|
|
95
|
+
}
|
|
96
|
+
if (this.state.reporting)
|
|
97
|
+
return false;
|
|
98
|
+
if (this.pending.length >= 128 || this.size + size > 1024 * 1024) {
|
|
99
|
+
this.dropped++;
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
this.pending.push({ run: run, size: size });
|
|
103
|
+
this.size += size;
|
|
104
|
+
if (this.timer !== void 0)
|
|
105
|
+
return true;
|
|
106
|
+
var generation = this.generation;
|
|
107
|
+
try {
|
|
108
|
+
var schedule = this.target.setTimeout || (typeof setTimeout === "function" ? setTimeout : void 0);
|
|
109
|
+
var cancel = this.target.clearTimeout || (typeof clearTimeout === "function" ? clearTimeout : void 0);
|
|
110
|
+
if (!schedule) {
|
|
111
|
+
this.dropped += this.pending.length;
|
|
112
|
+
this.pending = [];
|
|
113
|
+
this.size = 0;
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
this.cancel = cancel === null || cancel === void 0 ? void 0 : cancel.bind(this.target);
|
|
117
|
+
this.timer = schedule.call(this.target, function() {
|
|
118
|
+
_this.timer = void 0;
|
|
119
|
+
if (generation !== _this.generation)
|
|
120
|
+
return;
|
|
121
|
+
var batch = _this.pending;
|
|
122
|
+
_this.pending = [];
|
|
123
|
+
_this.size = 0;
|
|
124
|
+
_this.state.reporting++;
|
|
125
|
+
try {
|
|
126
|
+
for (var _i = 0, batch_1 = batch; _i < batch_1.length; _i++) {
|
|
127
|
+
var task = batch_1[_i];
|
|
128
|
+
if (generation !== _this.generation)
|
|
129
|
+
break;
|
|
130
|
+
try {
|
|
131
|
+
task.run();
|
|
132
|
+
} catch (_a) {
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} finally {
|
|
136
|
+
_this.state.reporting--;
|
|
137
|
+
}
|
|
138
|
+
}, 0);
|
|
139
|
+
return true;
|
|
140
|
+
} catch (_a) {
|
|
141
|
+
this.dropped += this.pending.length;
|
|
142
|
+
this.pending = [];
|
|
143
|
+
this.size = 0;
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
FTObservationQueue2.prototype.stop = function() {
|
|
148
|
+
var _a;
|
|
149
|
+
this.generation++;
|
|
150
|
+
this.pending = [];
|
|
151
|
+
this.size = 0;
|
|
152
|
+
if (this.timer !== void 0) {
|
|
153
|
+
try {
|
|
154
|
+
(_a = this.cancel) === null || _a === void 0 ? void 0 : _a.call(this, this.timer);
|
|
155
|
+
} catch (_b) {
|
|
156
|
+
}
|
|
157
|
+
this.timer = void 0;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
return FTObservationQueue2;
|
|
161
|
+
})()
|
|
162
|
+
);
|
|
163
|
+
exports.FTObservationQueue = FTObservationQueue;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// packages/cocos/dist/creator2/native/jsb-errors.js
|
|
168
|
+
var require_jsb_errors = __commonJS({
|
|
169
|
+
"packages/cocos/dist/creator2/native/jsb-errors.js": function(exports) {
|
|
170
|
+
"use strict";
|
|
171
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
172
|
+
exports.installJsbErrorSource = installJsbErrorSource;
|
|
173
|
+
var observation_js_1 = require_observation();
|
|
174
|
+
function installJsbErrorSource(target) {
|
|
175
|
+
var jsb = target.jsb;
|
|
176
|
+
if (!(jsb === null || jsb === void 0 ? void 0 : jsb.onError) || target.__FT_COCOS_JSB_ERRORS__)
|
|
177
|
+
return;
|
|
178
|
+
var register = jsb.onError;
|
|
179
|
+
var handler;
|
|
180
|
+
var state = (0, observation_js_1.observationState)(target);
|
|
181
|
+
var observing = 0;
|
|
182
|
+
var subscribers = [];
|
|
183
|
+
var dispatch = function(location, message, stack) {
|
|
184
|
+
var _a;
|
|
185
|
+
var observations = [];
|
|
186
|
+
try {
|
|
187
|
+
if (!state.reporting && !observing) {
|
|
188
|
+
observing++;
|
|
189
|
+
try {
|
|
190
|
+
var timestampMs = Date.now();
|
|
191
|
+
for (var _i = 0, _b = subscribers.slice(); _i < _b.length; _i++) {
|
|
192
|
+
var subscriber = _b[_i];
|
|
193
|
+
try {
|
|
194
|
+
observations.push({ subscriber: subscriber, observation: { timestampMs: timestampMs, context: (_a = subscriber.captureContext) === null || _a === void 0 ? void 0 : _a.call(subscriber) } });
|
|
195
|
+
} catch (_c) {
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
} finally {
|
|
199
|
+
observing--;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
} catch (_d) {
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
return handler === null || handler === void 0 ? void 0 : handler.call(this, location, message, stack);
|
|
206
|
+
} finally {
|
|
207
|
+
for (var _e = 0, observations_1 = observations; _e < observations_1.length; _e++) {
|
|
208
|
+
var _f = observations_1[_e], subscriber = _f.subscriber, observation = _f.observation;
|
|
209
|
+
if (!subscriber.active)
|
|
210
|
+
continue;
|
|
211
|
+
observing++;
|
|
212
|
+
try {
|
|
213
|
+
subscriber.callback(location, message, stack, observation);
|
|
214
|
+
} catch (_g) {
|
|
215
|
+
} finally {
|
|
216
|
+
observing--;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
jsb.onError = function() {
|
|
222
|
+
var args = [];
|
|
223
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
224
|
+
args[_i] = arguments[_i];
|
|
225
|
+
}
|
|
226
|
+
if (args.length !== 1 || typeof args[0] !== "function")
|
|
227
|
+
return register.apply(this, args);
|
|
228
|
+
var callback = args[0];
|
|
229
|
+
var result = register.call(this, subscribers.length ? dispatch : callback);
|
|
230
|
+
handler = callback;
|
|
231
|
+
return result;
|
|
232
|
+
};
|
|
233
|
+
target.__FT_COCOS_JSB_ERRORS__ = {
|
|
234
|
+
protocol: 2,
|
|
235
|
+
subscribe: function(callback, captureContext) {
|
|
236
|
+
if (subscribers.length === 0)
|
|
237
|
+
register.call(jsb, dispatch);
|
|
238
|
+
var subscriber = { callback: callback, captureContext: captureContext, active: true };
|
|
239
|
+
subscribers.push(subscriber);
|
|
240
|
+
return function() {
|
|
241
|
+
if (!subscriber.active)
|
|
242
|
+
return;
|
|
243
|
+
subscriber.active = false;
|
|
244
|
+
var index = subscribers.indexOf(subscriber);
|
|
245
|
+
if (index >= 0)
|
|
246
|
+
subscribers.splice(index, 1);
|
|
247
|
+
if (subscribers.length === 0 && handler)
|
|
248
|
+
register.call(jsb, handler);
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// packages/cocos/dist/creator2/native/error-bootstrap.js
|
|
257
|
+
var require_error_bootstrap = __commonJS({
|
|
258
|
+
"packages/cocos/dist/creator2/native/error-bootstrap.js": function(exports) {
|
|
259
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
260
|
+
var platform_runtime_js_1 = require_platform_runtime();
|
|
261
|
+
var jsb_errors_js_1 = require_jsb_errors();
|
|
262
|
+
(0, jsb_errors_js_1.installJsbErrorSource)((0, platform_runtime_js_1.platformGlobal)());
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
require_error_bootstrap();
|
|
266
|
+
})();
|
package/package.json
CHANGED
package/runtime/native.js
CHANGED
|
@@ -11,6 +11,103 @@
|
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
// packages/cocos/dist/creator2/core/observation.js
|
|
15
|
+
var require_observation = __commonJS({
|
|
16
|
+
"packages/cocos/dist/creator2/core/observation.js": function(exports) {
|
|
17
|
+
"use strict";
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.FTObservationQueue = void 0;
|
|
20
|
+
exports.observationState = observationState;
|
|
21
|
+
function observationState(target) {
|
|
22
|
+
return target.__FT_COCOS_OBSERVATION_STATE__ || (target.__FT_COCOS_OBSERVATION_STATE__ = { reporting: 0 });
|
|
23
|
+
}
|
|
24
|
+
var FTObservationQueue = (
|
|
25
|
+
/** @class */
|
|
26
|
+
(function() {
|
|
27
|
+
function FTObservationQueue2(target) {
|
|
28
|
+
this.target = target;
|
|
29
|
+
this.pending = [];
|
|
30
|
+
this.size = 0;
|
|
31
|
+
this.generation = 0;
|
|
32
|
+
this.dropped = 0;
|
|
33
|
+
this.state = observationState(target);
|
|
34
|
+
}
|
|
35
|
+
FTObservationQueue2.prototype.enqueue = function(run, size) {
|
|
36
|
+
var _this = this;
|
|
37
|
+
if (size === void 0) {
|
|
38
|
+
size = 0;
|
|
39
|
+
}
|
|
40
|
+
if (this.state.reporting)
|
|
41
|
+
return false;
|
|
42
|
+
if (this.pending.length >= 128 || this.size + size > 1024 * 1024) {
|
|
43
|
+
this.dropped++;
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
this.pending.push({ run: run, size: size });
|
|
47
|
+
this.size += size;
|
|
48
|
+
if (this.timer !== void 0)
|
|
49
|
+
return true;
|
|
50
|
+
var generation = this.generation;
|
|
51
|
+
try {
|
|
52
|
+
var schedule = this.target.setTimeout || (typeof setTimeout === "function" ? setTimeout : void 0);
|
|
53
|
+
var cancel = this.target.clearTimeout || (typeof clearTimeout === "function" ? clearTimeout : void 0);
|
|
54
|
+
if (!schedule) {
|
|
55
|
+
this.dropped += this.pending.length;
|
|
56
|
+
this.pending = [];
|
|
57
|
+
this.size = 0;
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
this.cancel = cancel === null || cancel === void 0 ? void 0 : cancel.bind(this.target);
|
|
61
|
+
this.timer = schedule.call(this.target, function() {
|
|
62
|
+
_this.timer = void 0;
|
|
63
|
+
if (generation !== _this.generation)
|
|
64
|
+
return;
|
|
65
|
+
var batch = _this.pending;
|
|
66
|
+
_this.pending = [];
|
|
67
|
+
_this.size = 0;
|
|
68
|
+
_this.state.reporting++;
|
|
69
|
+
try {
|
|
70
|
+
for (var _i = 0, batch_1 = batch; _i < batch_1.length; _i++) {
|
|
71
|
+
var task = batch_1[_i];
|
|
72
|
+
if (generation !== _this.generation)
|
|
73
|
+
break;
|
|
74
|
+
try {
|
|
75
|
+
task.run();
|
|
76
|
+
} catch (_a) {
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
} finally {
|
|
80
|
+
_this.state.reporting--;
|
|
81
|
+
}
|
|
82
|
+
}, 0);
|
|
83
|
+
return true;
|
|
84
|
+
} catch (_a) {
|
|
85
|
+
this.dropped += this.pending.length;
|
|
86
|
+
this.pending = [];
|
|
87
|
+
this.size = 0;
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
FTObservationQueue2.prototype.stop = function() {
|
|
92
|
+
var _a;
|
|
93
|
+
this.generation++;
|
|
94
|
+
this.pending = [];
|
|
95
|
+
this.size = 0;
|
|
96
|
+
if (this.timer !== void 0) {
|
|
97
|
+
try {
|
|
98
|
+
(_a = this.cancel) === null || _a === void 0 ? void 0 : _a.call(this, this.timer);
|
|
99
|
+
} catch (_b) {
|
|
100
|
+
}
|
|
101
|
+
this.timer = void 0;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return FTObservationQueue2;
|
|
105
|
+
})()
|
|
106
|
+
);
|
|
107
|
+
exports.FTObservationQueue = FTObservationQueue;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
14
111
|
// packages/cocos/dist/creator2/core/auto-tracking.js
|
|
15
112
|
var require_auto_tracking = __commonJS({
|
|
16
113
|
"packages/cocos/dist/creator2/core/auto-tracking.js": function(exports) {
|
|
@@ -133,6 +230,7 @@
|
|
|
133
230
|
};
|
|
134
231
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
135
232
|
exports.FTDefaultAutoTracking = void 0;
|
|
233
|
+
var observation_js_1 = require_observation();
|
|
136
234
|
var FTDefaultAutoTracking = (
|
|
137
235
|
/** @class */
|
|
138
236
|
(function() {
|
|
@@ -147,6 +245,7 @@
|
|
|
147
245
|
this.target = target;
|
|
148
246
|
this.stops = [];
|
|
149
247
|
this.networkStops = [];
|
|
248
|
+
this.observations = new observation_js_1.FTObservationQueue(target);
|
|
150
249
|
}
|
|
151
250
|
FTDefaultAutoTracking2.prototype.start = function(config, viewName, scope) {
|
|
152
251
|
if (scope === void 0) {
|
|
@@ -195,6 +294,7 @@
|
|
|
195
294
|
if (scope !== "page")
|
|
196
295
|
this.networkStops.splice(0).reverse().forEach(cleanup);
|
|
197
296
|
if (scope !== "network") {
|
|
297
|
+
this.observations.stop();
|
|
198
298
|
this.stops.splice(0).reverse().forEach(cleanup);
|
|
199
299
|
if (this.activeView) {
|
|
200
300
|
cleanup(function() {
|
|
@@ -226,12 +326,33 @@
|
|
|
226
326
|
};
|
|
227
327
|
FTDefaultAutoTracking2.prototype.installErrorTracking = function() {
|
|
228
328
|
var _this = this;
|
|
329
|
+
var _a;
|
|
330
|
+
var nativeErrors = this.target.__FT_COCOS_JSB_ERRORS__;
|
|
331
|
+
if ((nativeErrors === null || nativeErrors === void 0 ? void 0 : nativeErrors.protocol) === 2) {
|
|
332
|
+
this.stops.push(nativeErrors.subscribe(function(location, message, stack) {
|
|
333
|
+
var _a2;
|
|
334
|
+
if (message === "handlerAddedAfterPromiseRejected" || message === "rejectAfterPromiseResolved" || message === "resolveAfterPromiseResolved")
|
|
335
|
+
return;
|
|
336
|
+
var rejection = message === "unhandledRejectedPromise";
|
|
337
|
+
var reason = rejection ? (_a2 = stack.split(/\r?\n/, 1)[0]) === null || _a2 === void 0 ? void 0 : _a2.replace(/^Error:\s*/, "") : message;
|
|
338
|
+
var errorMessage = reason || message || "Uncaught JavaScript error";
|
|
339
|
+
var errorStack = stack || location || "";
|
|
340
|
+
var type = rejection ? "unhandled_promise_rejection" : "cocos_error";
|
|
341
|
+
_this.observations.enqueue(function() {
|
|
342
|
+
_this.rum.addError(errorMessage, errorStack, type);
|
|
343
|
+
}, 2 * (location.length + message.length + stack.length));
|
|
344
|
+
}));
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (nativeErrors || typeof ((_a = this.target.jsb) === null || _a === void 0 ? void 0 : _a.onError) === "function") {
|
|
348
|
+
throw new Error("Cocos native error bootstrap is missing. Rerun the SDK installer and rebuild the native project.");
|
|
349
|
+
}
|
|
229
350
|
if (!this.target.addEventListener || !this.target.removeEventListener)
|
|
230
351
|
return;
|
|
231
352
|
var errorListener = function(event) {
|
|
232
|
-
var
|
|
353
|
+
var _a2;
|
|
233
354
|
var errorEvent = event;
|
|
234
|
-
_this.rum.addError(errorEvent.message || "Uncaught JavaScript error", ((
|
|
355
|
+
_this.rum.addError(errorEvent.message || "Uncaught JavaScript error", ((_a2 = errorEvent.error) === null || _a2 === void 0 ? void 0 : _a2.stack) || "".concat(errorEvent.filename || "", ":").concat(errorEvent.lineno || 0));
|
|
235
356
|
};
|
|
236
357
|
var rejectionListener = function(event) {
|
|
237
358
|
var reason = event.reason;
|
|
@@ -240,8 +361,8 @@
|
|
|
240
361
|
this.target.addEventListener("error", errorListener);
|
|
241
362
|
this.target.addEventListener("unhandledrejection", rejectionListener);
|
|
242
363
|
this.stops.push(function() {
|
|
243
|
-
var
|
|
244
|
-
(_b = (
|
|
364
|
+
var _a2, _b, _c, _d;
|
|
365
|
+
(_b = (_a2 = _this.target).removeEventListener) === null || _b === void 0 ? void 0 : _b.call(_a2, "error", errorListener);
|
|
245
366
|
(_d = (_c = _this.target).removeEventListener) === null || _d === void 0 ? void 0 : _d.call(_c, "unhandledrejection", rejectionListener);
|
|
246
367
|
});
|
|
247
368
|
};
|
|
@@ -256,24 +377,50 @@
|
|
|
256
377
|
"warn",
|
|
257
378
|
"error"
|
|
258
379
|
];
|
|
380
|
+
var observations = this.observations;
|
|
381
|
+
var state = (0, observation_js_1.observationState)(this.target);
|
|
259
382
|
var originals = /* @__PURE__ */ new Map();
|
|
383
|
+
var wrappers = /* @__PURE__ */ new Map();
|
|
384
|
+
var active = true;
|
|
260
385
|
methods.forEach(function(method) {
|
|
261
|
-
var original = consoleObject[method]
|
|
386
|
+
var original = consoleObject[method];
|
|
262
387
|
originals.set(method, original);
|
|
263
|
-
|
|
388
|
+
var logger = _this.logger;
|
|
389
|
+
consoleObject[method] = function() {
|
|
264
390
|
var args = [];
|
|
265
391
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
266
392
|
args[_i] = arguments[_i];
|
|
267
393
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
394
|
+
var snapshot;
|
|
395
|
+
try {
|
|
396
|
+
if (active && !state.reporting)
|
|
397
|
+
snapshot = { timestampMs: Date.now(), values: args.slice(0, 16) };
|
|
398
|
+
} catch (_a) {
|
|
399
|
+
}
|
|
400
|
+
try {
|
|
401
|
+
return original.apply(this, args);
|
|
402
|
+
} finally {
|
|
403
|
+
try {
|
|
404
|
+
if (active && snapshot) {
|
|
405
|
+
var timestampMs_1 = snapshot.timestampMs, values_1 = snapshot.values;
|
|
406
|
+
observations.enqueue(function() {
|
|
407
|
+
var level = method === "warn" ? "warning" : method === "error" ? "error" : "info";
|
|
408
|
+
logger.log(values_1.map(stringifyLogValue).join(" "), level, { cocos_observed_at_ms: timestampMs_1 });
|
|
409
|
+
}, values_1.reduce(function(size, value) {
|
|
410
|
+
return size + (typeof value === "string" ? value.length * 2 : 64);
|
|
411
|
+
}, 0));
|
|
412
|
+
}
|
|
413
|
+
} catch (_b) {
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
wrappers.set(method, consoleObject[method]);
|
|
272
418
|
});
|
|
273
419
|
this.stops.push(function() {
|
|
420
|
+
active = false;
|
|
274
421
|
methods.forEach(function(method) {
|
|
275
422
|
var original = originals.get(method);
|
|
276
|
-
if (original)
|
|
423
|
+
if (original && consoleObject[method] === wrappers.get(method))
|
|
277
424
|
consoleObject[method] = original;
|
|
278
425
|
});
|
|
279
426
|
});
|
|
@@ -512,6 +659,7 @@
|
|
|
512
659
|
exports.samplingPercentage = samplingPercentage;
|
|
513
660
|
exports.validatedSamplingConfig = validatedSamplingConfig;
|
|
514
661
|
exports.requireText = requireText;
|
|
662
|
+
exports.validateWebViewHosts = validateWebViewHosts;
|
|
515
663
|
function samplingRate(value, name) {
|
|
516
664
|
if (value === void 0)
|
|
517
665
|
return void 0;
|
|
@@ -547,6 +695,18 @@
|
|
|
547
695
|
throw new TypeError("".concat(name, " must not be empty"));
|
|
548
696
|
return value;
|
|
549
697
|
}
|
|
698
|
+
function validateWebViewHosts(value) {
|
|
699
|
+
if (value === void 0 || value === null)
|
|
700
|
+
return;
|
|
701
|
+
var message = "sdk.allowWebViewHost must be an array of strings or null";
|
|
702
|
+
if (!Array.isArray(value))
|
|
703
|
+
throw new TypeError(message);
|
|
704
|
+
for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
|
|
705
|
+
var host = value_1[_i];
|
|
706
|
+
if (typeof host !== "string")
|
|
707
|
+
throw new TypeError(message);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
550
710
|
}
|
|
551
711
|
});
|
|
552
712
|
|
|
@@ -555,9 +715,8 @@
|
|
|
555
715
|
"packages/cocos/dist/creator2/core/version.js": function(exports) {
|
|
556
716
|
"use strict";
|
|
557
717
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
558
|
-
exports.FT_COCOS_SDK_BRIDGE_INFO = exports.FT_COCOS_SDK_BRIDGE_INFO_KEY = exports.
|
|
559
|
-
exports.FT_COCOS_SDK_VERSION = "0.1.1-alpha.
|
|
560
|
-
exports.FT_COCOS_SDK_VERSION_KEY = "sdk_package_cocos";
|
|
718
|
+
exports.FT_COCOS_SDK_BRIDGE_INFO = exports.FT_COCOS_SDK_BRIDGE_INFO_KEY = exports.FT_COCOS_SDK_VERSION = void 0;
|
|
719
|
+
exports.FT_COCOS_SDK_VERSION = "0.1.1-alpha.3";
|
|
561
720
|
exports.FT_COCOS_SDK_BRIDGE_INFO_KEY = "sdk_bridge_info";
|
|
562
721
|
exports.FT_COCOS_SDK_BRIDGE_INFO = JSON.stringify({
|
|
563
722
|
cocos: exports.FT_COCOS_SDK_VERSION
|
|
@@ -643,12 +802,12 @@
|
|
|
643
802
|
this.ownership = ownership;
|
|
644
803
|
}
|
|
645
804
|
FTMobileAgent2.prototype.start = function(config) {
|
|
646
|
-
var _a;
|
|
647
805
|
if (!config.datakitUrl && !(config.datawayUrl && config.clientToken)) {
|
|
648
806
|
throw new TypeError("Configure datakitUrl or datawayUrl with clientToken");
|
|
649
807
|
}
|
|
808
|
+
(0, validation_js_1.validateWebViewHosts)(config.allowWebViewHost);
|
|
650
809
|
this.ownership.claimStandalone();
|
|
651
|
-
this.transport.invoke("sdk.configure", compact(
|
|
810
|
+
this.transport.invoke("sdk.configure", compact(config));
|
|
652
811
|
};
|
|
653
812
|
FTMobileAgent2.prototype.bindUser = function(user) {
|
|
654
813
|
this.transport.invoke("sdk.bindUser", typeof user === "string" ? { userId: (0, validation_js_1.requireText)(user, "userId") } : user);
|
|
@@ -920,9 +1079,7 @@
|
|
|
920
1079
|
this.ownership.claimNativeHost();
|
|
921
1080
|
try {
|
|
922
1081
|
(_c = (_a = this.extension) === null || _a === void 0 ? void 0 : (_b = _a.lifecycle).beforeAttach) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
923
|
-
this.transport.invoke("hybrid.attach"
|
|
924
|
-
sdkVersion: version_js_1.FT_COCOS_SDK_VERSION
|
|
925
|
-
});
|
|
1082
|
+
this.transport.invoke("hybrid.attach");
|
|
926
1083
|
if ((_d = config.autoTrack) === null || _d === void 0 ? void 0 : _d.network) {
|
|
927
1084
|
(_e = this.autoTracking) === null || _e === void 0 ? void 0 : _e.start({ network: true }, void 0, "network");
|
|
928
1085
|
}
|
|
@@ -1166,7 +1323,10 @@
|
|
|
1166
1323
|
(0, platform_runtime_js_1.platformGlobal)().__FT_COCOS_NATIVE_FACTORY__ = {
|
|
1167
1324
|
protocol: 1,
|
|
1168
1325
|
version: version_js_1.FT_COCOS_SDK_VERSION,
|
|
1169
|
-
create: function(context) {
|
|
1326
|
+
create: function(context, target) {
|
|
1327
|
+
if (target === void 0) {
|
|
1328
|
+
target = (0, platform_runtime_js_1.platformGlobal)();
|
|
1329
|
+
}
|
|
1170
1330
|
if (context.platform === "web")
|
|
1171
1331
|
throw new Error("Native runtime cannot serve a Web application");
|
|
1172
1332
|
var transport = {
|
|
@@ -1181,7 +1341,7 @@
|
|
|
1181
1341
|
return (0, transport_js_1.parseTransportResponse)(raw);
|
|
1182
1342
|
}
|
|
1183
1343
|
};
|
|
1184
|
-
var tracking = new auto_tracking_js_1.FTDefaultAutoTracking(new modules_js_1.FTRUM(transport), new modules_js_1.FTLogger(transport), new modules_js_1.FTTrace(transport), context.hooks);
|
|
1344
|
+
var tracking = new auto_tracking_js_1.FTDefaultAutoTracking(new modules_js_1.FTRUM(transport), new modules_js_1.FTLogger(transport), new modules_js_1.FTTrace(transport), context.hooks, target);
|
|
1185
1345
|
return new client_js_1.FTCocosSDK(transport, tracking, context.engine);
|
|
1186
1346
|
}
|
|
1187
1347
|
};
|
package/web/bootstrap.js
CHANGED
|
@@ -31,6 +31,7 @@ var CocosWebSDK = (function() {
|
|
|
31
31
|
exports.samplingPercentage = samplingPercentage;
|
|
32
32
|
exports.validatedSamplingConfig = validatedSamplingConfig;
|
|
33
33
|
exports.requireText = requireText;
|
|
34
|
+
exports.validateWebViewHosts = validateWebViewHosts;
|
|
34
35
|
function samplingRate(value, name) {
|
|
35
36
|
if (value === void 0)
|
|
36
37
|
return void 0;
|
|
@@ -66,6 +67,18 @@ var CocosWebSDK = (function() {
|
|
|
66
67
|
throw new TypeError("".concat(name, " must not be empty"));
|
|
67
68
|
return value;
|
|
68
69
|
}
|
|
70
|
+
function validateWebViewHosts(value) {
|
|
71
|
+
if (value === void 0 || value === null)
|
|
72
|
+
return;
|
|
73
|
+
var message = "sdk.allowWebViewHost must be an array of strings or null";
|
|
74
|
+
if (!Array.isArray(value))
|
|
75
|
+
throw new TypeError(message);
|
|
76
|
+
for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
|
|
77
|
+
var host = value_1[_i];
|
|
78
|
+
if (typeof host !== "string")
|
|
79
|
+
throw new TypeError(message);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
69
82
|
}
|
|
70
83
|
});
|
|
71
84
|
|
|
@@ -74,9 +87,8 @@ var CocosWebSDK = (function() {
|
|
|
74
87
|
"packages/cocos/dist/creator2/core/version.js": function(exports) {
|
|
75
88
|
"use strict";
|
|
76
89
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
|
-
exports.FT_COCOS_SDK_BRIDGE_INFO = exports.FT_COCOS_SDK_BRIDGE_INFO_KEY = exports.
|
|
78
|
-
exports.FT_COCOS_SDK_VERSION = "0.1.1-alpha.
|
|
79
|
-
exports.FT_COCOS_SDK_VERSION_KEY = "sdk_package_cocos";
|
|
90
|
+
exports.FT_COCOS_SDK_BRIDGE_INFO = exports.FT_COCOS_SDK_BRIDGE_INFO_KEY = exports.FT_COCOS_SDK_VERSION = void 0;
|
|
91
|
+
exports.FT_COCOS_SDK_VERSION = "0.1.1-alpha.3";
|
|
80
92
|
exports.FT_COCOS_SDK_BRIDGE_INFO_KEY = "sdk_bridge_info";
|
|
81
93
|
exports.FT_COCOS_SDK_BRIDGE_INFO = JSON.stringify({
|
|
82
94
|
cocos: exports.FT_COCOS_SDK_VERSION
|
|
@@ -162,12 +174,12 @@ var CocosWebSDK = (function() {
|
|
|
162
174
|
this.ownership = ownership;
|
|
163
175
|
}
|
|
164
176
|
FTMobileAgent2.prototype.start = function(config) {
|
|
165
|
-
var _a;
|
|
166
177
|
if (!config.datakitUrl && !(config.datawayUrl && config.clientToken)) {
|
|
167
178
|
throw new TypeError("Configure datakitUrl or datawayUrl with clientToken");
|
|
168
179
|
}
|
|
180
|
+
(0, validation_js_1.validateWebViewHosts)(config.allowWebViewHost);
|
|
169
181
|
this.ownership.claimStandalone();
|
|
170
|
-
this.transport.invoke("sdk.configure", compact(
|
|
182
|
+
this.transport.invoke("sdk.configure", compact(config));
|
|
171
183
|
};
|
|
172
184
|
FTMobileAgent2.prototype.bindUser = function(user) {
|
|
173
185
|
this.transport.invoke("sdk.bindUser", typeof user === "string" ? { userId: (0, validation_js_1.requireText)(user, "userId") } : user);
|
|
@@ -600,7 +612,6 @@ var CocosWebSDK = (function() {
|
|
|
600
612
|
Object.keys(context).forEach(function(key) {
|
|
601
613
|
return api.setGlobalContextProperty(key, context[key]);
|
|
602
614
|
});
|
|
603
|
-
api.setGlobalContextProperty(version_js_1.FT_COCOS_SDK_VERSION_KEY, version_js_1.FT_COCOS_SDK_VERSION);
|
|
604
615
|
};
|
|
605
616
|
return FTWebRuntime2;
|
|
606
617
|
})()
|