@cloudcare/cocos-sdk 0.1.0 → 0.1.1-alpha.2

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.
Files changed (139) hide show
  1. package/README.md +35 -6
  2. package/bin/cli.cjs +42 -5
  3. package/bin/project-configuration.cjs +135 -0
  4. package/bin/web-assets.cjs +32 -0
  5. package/dist/creator2/core/auto-tracking.js.map +1 -1
  6. package/dist/creator2/core/client.d.ts +1 -0
  7. package/dist/creator2/core/client.d.ts.map +1 -1
  8. package/dist/creator2/core/client.js +13 -0
  9. package/dist/creator2/core/client.js.map +1 -1
  10. package/dist/creator2/core/index.js.map +1 -1
  11. package/dist/creator2/core/modules.js.map +1 -1
  12. package/dist/creator2/core/platform-client.d.ts +46 -0
  13. package/dist/creator2/core/platform-client.d.ts.map +1 -0
  14. package/dist/creator2/core/platform-client.js +195 -0
  15. package/dist/creator2/core/platform-client.js.map +1 -0
  16. package/dist/creator2/core/platform-options.d.ts +30 -0
  17. package/dist/creator2/core/platform-options.d.ts.map +1 -0
  18. package/dist/creator2/core/platform-options.js +3 -0
  19. package/dist/creator2/core/platform-options.js.map +1 -0
  20. package/dist/creator2/core/platform-runtime.d.ts +59 -0
  21. package/dist/creator2/core/platform-runtime.d.ts.map +1 -0
  22. package/dist/creator2/core/platform-runtime.js +36 -0
  23. package/dist/creator2/core/platform-runtime.js.map +1 -0
  24. package/dist/creator2/core/plugin-api.d.ts +1 -1
  25. package/dist/creator2/core/plugin-api.d.ts.map +1 -1
  26. package/dist/creator2/core/plugin-api.js.map +1 -1
  27. package/dist/creator2/core/transport.d.ts +1 -1
  28. package/dist/creator2/core/transport.d.ts.map +1 -1
  29. package/dist/creator2/core/transport.js.map +1 -1
  30. package/dist/creator2/core/types.js.map +1 -1
  31. package/dist/creator2/core/validation.js.map +1 -1
  32. package/dist/creator2/core/version.d.ts +1 -1
  33. package/dist/creator2/core/version.d.ts.map +1 -1
  34. package/dist/creator2/core/version.js +1 -1
  35. package/dist/creator2/core/version.js.map +1 -1
  36. package/dist/creator2/creator2/auto.js.map +1 -1
  37. package/dist/creator2/creator2/index.d.ts +6 -3
  38. package/dist/creator2/creator2/index.d.ts.map +1 -1
  39. package/dist/creator2/creator2/index.js +12 -8
  40. package/dist/creator2/creator2/index.js.map +1 -1
  41. package/dist/creator2/creator2/transport.js.map +1 -1
  42. package/dist/creator2/native/bootstrap.d.ts +2 -0
  43. package/dist/creator2/native/bootstrap.d.ts.map +1 -0
  44. package/dist/creator2/native/bootstrap.js +34 -0
  45. package/dist/creator2/native/bootstrap.js.map +1 -0
  46. package/dist/creator2/web/bootstrap.d.ts +3 -0
  47. package/dist/creator2/web/bootstrap.d.ts.map +1 -0
  48. package/dist/creator2/web/bootstrap.js +15 -0
  49. package/dist/creator2/web/bootstrap.js.map +1 -0
  50. package/dist/creator2/web/client.d.ts +60 -0
  51. package/dist/creator2/web/client.d.ts.map +1 -0
  52. package/dist/creator2/web/client.js +293 -0
  53. package/dist/creator2/web/client.js.map +1 -0
  54. package/dist/creator2/web/creator2.d.ts +5 -0
  55. package/dist/creator2/web/creator2.d.ts.map +1 -0
  56. package/dist/creator2/web/creator2.js +27 -0
  57. package/dist/creator2/web/creator2.js.map +1 -0
  58. package/dist/creator2/web/privacy.d.ts +3 -0
  59. package/dist/creator2/web/privacy.d.ts.map +1 -0
  60. package/dist/creator2/web/privacy.js +39 -0
  61. package/dist/creator2/web/privacy.js.map +1 -0
  62. package/dist/creator2/web/runtime.d.ts +23 -0
  63. package/dist/creator2/web/runtime.d.ts.map +1 -0
  64. package/dist/creator2/web/runtime.js +265 -0
  65. package/dist/creator2/web/runtime.js.map +1 -0
  66. package/dist/creator2/web/types.d.ts +91 -0
  67. package/dist/creator2/web/types.d.ts.map +1 -0
  68. package/dist/creator2/web/types.js +3 -0
  69. package/dist/creator2/web/types.js.map +1 -0
  70. package/dist/creator3/core/client.d.ts +1 -0
  71. package/dist/creator3/core/client.d.ts.map +1 -1
  72. package/dist/creator3/core/client.js +5 -0
  73. package/dist/creator3/core/client.js.map +1 -1
  74. package/dist/creator3/core/platform-client.d.ts +46 -0
  75. package/dist/creator3/core/platform-client.d.ts.map +1 -0
  76. package/dist/creator3/core/platform-client.js +135 -0
  77. package/dist/creator3/core/platform-client.js.map +1 -0
  78. package/dist/creator3/core/platform-options.d.ts +30 -0
  79. package/dist/creator3/core/platform-options.d.ts.map +1 -0
  80. package/dist/creator3/core/platform-options.js +2 -0
  81. package/dist/creator3/core/platform-options.js.map +1 -0
  82. package/dist/creator3/core/platform-runtime.d.ts +59 -0
  83. package/dist/creator3/core/platform-runtime.d.ts.map +1 -0
  84. package/dist/creator3/core/platform-runtime.js +29 -0
  85. package/dist/creator3/core/platform-runtime.js.map +1 -0
  86. package/dist/creator3/core/plugin-api.d.ts +1 -1
  87. package/dist/creator3/core/plugin-api.d.ts.map +1 -1
  88. package/dist/creator3/core/transport.d.ts +1 -1
  89. package/dist/creator3/core/transport.d.ts.map +1 -1
  90. package/dist/creator3/core/version.d.ts +1 -1
  91. package/dist/creator3/core/version.d.ts.map +1 -1
  92. package/dist/creator3/core/version.js +1 -1
  93. package/dist/creator3/core/version.js.map +1 -1
  94. package/dist/creator3/creator3/index.d.ts +6 -3
  95. package/dist/creator3/creator3/index.d.ts.map +1 -1
  96. package/dist/creator3/creator3/index.js +13 -8
  97. package/dist/creator3/creator3/index.js.map +1 -1
  98. package/dist/creator3/native/bootstrap.d.ts +2 -0
  99. package/dist/creator3/native/bootstrap.d.ts.map +1 -0
  100. package/dist/creator3/native/bootstrap.js +32 -0
  101. package/dist/creator3/native/bootstrap.js.map +1 -0
  102. package/dist/creator3/web/bootstrap.d.ts +3 -0
  103. package/dist/creator3/web/bootstrap.d.ts.map +1 -0
  104. package/dist/creator3/web/bootstrap.js +11 -0
  105. package/dist/creator3/web/bootstrap.js.map +1 -0
  106. package/dist/creator3/web/client.d.ts +60 -0
  107. package/dist/creator3/web/client.d.ts.map +1 -0
  108. package/dist/creator3/web/client.js +255 -0
  109. package/dist/creator3/web/client.js.map +1 -0
  110. package/dist/creator3/web/creator3.d.ts +5 -0
  111. package/dist/creator3/web/creator3.d.ts.map +1 -0
  112. package/dist/creator3/web/creator3.js +11 -0
  113. package/dist/creator3/web/creator3.js.map +1 -0
  114. package/dist/creator3/web/privacy.d.ts +3 -0
  115. package/dist/creator3/web/privacy.d.ts.map +1 -0
  116. package/dist/creator3/web/privacy.js +26 -0
  117. package/dist/creator3/web/privacy.js.map +1 -0
  118. package/dist/creator3/web/runtime.d.ts +23 -0
  119. package/dist/creator3/web/runtime.d.ts.map +1 -0
  120. package/dist/creator3/web/runtime.js +267 -0
  121. package/dist/creator3/web/runtime.js.map +1 -0
  122. package/dist/creator3/web/types.d.ts +91 -0
  123. package/dist/creator3/web/types.d.ts.map +1 -0
  124. package/dist/creator3/web/types.js +2 -0
  125. package/dist/creator3/web/types.js.map +1 -0
  126. package/extensions/creator2/install-web.cjs +69 -0
  127. package/extensions/creator2/main.js +19 -2
  128. package/extensions/creator2/project-configuration.cjs +135 -0
  129. package/extensions/creator3/dist/hooks.js +13 -0
  130. package/extensions/creator3/install-web.cjs +69 -0
  131. package/extensions/creator3/project-configuration.cjs +135 -0
  132. package/native/ios/FTCocosBridge.podspec +1 -1
  133. package/package.json +19 -3
  134. package/runtime/native.js +1191 -0
  135. package/web/bootstrap/package.json +4 -0
  136. package/web/bootstrap.js +1042 -0
  137. package/web/bootstrap.js.map +7 -0
  138. package/web/creator2/package.json +4 -0
  139. package/web/creator3/package.json +4 -0
@@ -0,0 +1,255 @@
1
+ import { FTLogger, FTMobileAgent, FTRUM, FTTrace } from '../core/modules.js';
2
+ import { FTWebRuntime } from './runtime.js';
3
+ /** Web facade. Browser owns page-wide collectors; detach only removes Cocos instrumentation. */
4
+ export class FTCocosWebSDK {
5
+ get lifecycleMode() {
6
+ return this.state === 'idle' ? 'idle' : this.state === 'standalone' ? 'standalone' : 'hybrid';
7
+ }
8
+ get isCocosEntered() { return this.state === 'standalone' || this.state === 'entered'; }
9
+ constructor(hooks, canvasIsPublic, target = window, consoleObject = console) {
10
+ this.hooks = hooks;
11
+ this.canvasIsPublic = canvasIsPublic;
12
+ this.target = target;
13
+ this.consoleObject = consoleObject;
14
+ this.platform = 'web';
15
+ this.capabilities = {
16
+ timedActions: false, manualResourceTiming: false, manualLongTasks: false,
17
+ manualTraceHeaders: false, shutdown: false, nodeReplayMasks: false,
18
+ };
19
+ this.tracking = {};
20
+ this.state = 'idle';
21
+ this.stops = [];
22
+ this.activeView = false;
23
+ this.privateNodes = new Map();
24
+ this.replay = {
25
+ /** Recording settings belong to the pre-engine Web bootstrap. */
26
+ start: () => { this.requireRuntime().startReplay(); },
27
+ stop: () => { this.requireRuntime().stopReplay(); },
28
+ isRecording: () => { var _a; return ((_a = this.runtime) === null || _a === void 0 ? void 0 : _a.isRecording()) || false; },
29
+ /** Any protected node blocks the entire Cocos canvas; Browser Replay cannot render node masks. */
30
+ setPrivacy: (node, mode) => {
31
+ if (!node)
32
+ throw new Error('A Cocos node is required');
33
+ if (mode === 'unmask')
34
+ this.privateNodes.delete(node);
35
+ else if (mode === 'mask' || mode === 'hide')
36
+ this.privateNodes.set(node, mode);
37
+ else
38
+ throw new Error('Unknown Replay privacy mode');
39
+ },
40
+ };
41
+ const transport = {
42
+ platform: 'web',
43
+ invoke: (method, payload) => this.requireRuntime().invoke(method, payload),
44
+ };
45
+ this.mobile = new FTMobileAgent(transport);
46
+ this.rum = new FTRUM(transport);
47
+ this.logger = new FTLogger(transport);
48
+ this.trace = new FTTrace(transport);
49
+ }
50
+ /** Starts standalone Cocos tracking, reusing pre-engine configuration when installed. */
51
+ start(config) {
52
+ if (this.state !== 'idle')
53
+ throw new Error('Web SDK already started or attached');
54
+ if (config && 'replay' in config)
55
+ throw new Error('Configure Web Replay at web.replay before engine boot');
56
+ let runtime = this.target.__FT_COCOS_WEB__;
57
+ if (runtime) {
58
+ if (config)
59
+ assertBootstrapConfiguration(config, runtime.config);
60
+ this.attach({ autoTrack: config === null || config === void 0 ? void 0 : config.autoTrack });
61
+ }
62
+ else {
63
+ if (!config || !('web' in config))
64
+ throw new Error('Configure web explicitly or install the pre-engine Web bootstrap');
65
+ runtime = new FTWebRuntime(config, this.target);
66
+ this.target.__FT_COCOS_WEB__ = runtime;
67
+ this.bind(runtime, config.autoTrack || {});
68
+ }
69
+ this.state = 'standalone';
70
+ try {
71
+ this.startPage();
72
+ }
73
+ catch (error) {
74
+ try {
75
+ this.detach();
76
+ }
77
+ catch ( /* Preserve the startup error. */_a) { /* Preserve the startup error. */ }
78
+ throw error;
79
+ }
80
+ }
81
+ /** Attaches to bootstrapWeb(), without initializing Browser collectors a second time. */
82
+ attach(config = {}) {
83
+ var _a;
84
+ if (this.state === 'standalone')
85
+ throw new Error('start() and attach() are mutually exclusive');
86
+ if (this.state !== 'idle')
87
+ return;
88
+ if ('replay' in config)
89
+ throw new Error('Configure Web Replay at web.replay in the page bootstrap');
90
+ const runtime = this.target.__FT_COCOS_WEB__;
91
+ if (!runtime || runtime.protocol !== 1)
92
+ throw new Error('Run the Cocos Web bootstrap before attach()');
93
+ if (config.applicationId && config.applicationId !== runtime.config.web.applicationId)
94
+ throw new Error('Web applicationId does not match page bootstrap');
95
+ const tracking = { ...runtime.config.autoTrack, ...config.autoTrack };
96
+ for (const key of ['network', 'errors']) {
97
+ if (!!tracking[key] !== !!((_a = runtime.config.autoTrack) === null || _a === void 0 ? void 0 : _a[key]))
98
+ throw new Error(`Configure autoTrack.${key} at page bootstrap`);
99
+ }
100
+ this.bind(runtime, tracking);
101
+ this.state = 'attached';
102
+ }
103
+ enterCocos(options = {}) {
104
+ var _a;
105
+ if (this.state === 'idle')
106
+ throw new Error('Call attach() before enterCocos()');
107
+ if (this.state === 'standalone')
108
+ throw new Error('enterCocos() requires attach()');
109
+ if (this.state === 'entered')
110
+ return;
111
+ if (!this.tracking.scenes && !((_a = options.viewName) === null || _a === void 0 ? void 0 : _a.trim()))
112
+ throw new Error('enterCocos.viewName is required when scene tracking is disabled');
113
+ try {
114
+ this.startPage(options.viewName);
115
+ this.state = 'entered';
116
+ }
117
+ catch (error) {
118
+ try {
119
+ this.stopPage();
120
+ }
121
+ catch ( /* Preserve the entry error. */_b) { /* Preserve the entry error. */ }
122
+ throw error;
123
+ }
124
+ }
125
+ /** Transitions to web.outsideViewName (CocosInactive by default). Browser session/network collection continues. */
126
+ leaveCocos() {
127
+ if (this.state === 'standalone')
128
+ throw new Error('Use detach() to stop standalone Cocos instrumentation on Web');
129
+ if (this.state !== 'entered')
130
+ return;
131
+ try {
132
+ this.stopPage();
133
+ }
134
+ finally {
135
+ this.state = 'attached';
136
+ }
137
+ }
138
+ /** Releases Cocos hooks and Replay. Browser page collectors remain initialized until navigation/unload. */
139
+ detach() {
140
+ if (this.state === 'idle')
141
+ return;
142
+ try {
143
+ this.stopPage();
144
+ }
145
+ finally {
146
+ this.runtime.release(this);
147
+ this.runtime = undefined;
148
+ this.state = 'idle';
149
+ this.privateNodes.clear();
150
+ }
151
+ }
152
+ /** Stops this Cocos instance while retaining the page runtime. */
153
+ stop() { this.detach(); }
154
+ shutdown() {
155
+ throw new Error('Browser SDK has no public shutdown API. Use detach() to release Cocos hooks; page collectors continue until unload.');
156
+ }
157
+ setReplayCamera(_camera) {
158
+ throw new Error('Browser Replay captures the configured canvas, not a Cocos camera');
159
+ }
160
+ bind(runtime, tracking) {
161
+ if ((tracking.scenes || tracking.actions || tracking.errors || tracking.network) && !runtime.config.rum)
162
+ throw new Error('Cocos RUM tracking requires rum configuration');
163
+ if (tracking.console && !runtime.config.logger)
164
+ throw new Error('Console tracking requires logger');
165
+ runtime.claim(this);
166
+ this.runtime = runtime;
167
+ this.tracking = tracking;
168
+ runtime.setPrivacyCheck(this, () => this.privateNodes.size === 0 && this.canvasIsPublic());
169
+ }
170
+ startPage(viewName) {
171
+ const view = (name) => { this.rum.startView(name); this.activeView = true; };
172
+ if (viewName)
173
+ view(viewName);
174
+ if (this.tracking.scenes)
175
+ this.stops.push(this.hooks.onSceneChanged(view, !viewName));
176
+ if (this.tracking.actions)
177
+ this.stops.push(this.hooks.onAction((name, attributes) => this.rum.addAction(name, 'click', attributes)));
178
+ if (this.tracking.console)
179
+ this.trackConsole();
180
+ if (this.runtime.config.web.replay)
181
+ this.runtime.startReplay();
182
+ }
183
+ stopPage() {
184
+ let failure;
185
+ const clean = (fn) => { try {
186
+ fn();
187
+ }
188
+ catch (error) {
189
+ if (!failure)
190
+ failure = error;
191
+ } };
192
+ clean(() => { var _a; return (_a = this.runtime) === null || _a === void 0 ? void 0 : _a.stopReplay(); });
193
+ this.stops.splice(0).reverse().forEach(clean);
194
+ if (this.activeView) {
195
+ clean(() => this.rum.stopView());
196
+ this.activeView = false;
197
+ }
198
+ if (failure)
199
+ throw failure;
200
+ }
201
+ requireRuntime() {
202
+ if (!this.runtime)
203
+ throw new Error('Start or attach the Cocos Web SDK first');
204
+ return this.runtime;
205
+ }
206
+ trackConsole() {
207
+ ['log', 'info', 'warn', 'error'].forEach(method => {
208
+ const original = this.consoleObject[method];
209
+ const wrapped = (...values) => {
210
+ original.apply(this.consoleObject, values);
211
+ this.logger.log(values.map(value => {
212
+ if (typeof value === 'string')
213
+ return value;
214
+ try {
215
+ return JSON.stringify(value);
216
+ }
217
+ catch (_a) {
218
+ return String(value);
219
+ }
220
+ }).join(' '), method === 'warn' ? 'warning' : method === 'error' ? 'error' : 'info');
221
+ };
222
+ this.consoleObject[method] = wrapped;
223
+ this.stops.push(() => { if (this.consoleObject[method] === wrapped)
224
+ this.consoleObject[method] = original; });
225
+ });
226
+ }
227
+ }
228
+ /** Native-only options may coexist, but settings used by Browser cannot change after bootstrap. */
229
+ function assertBootstrapConfiguration(config, installed) {
230
+ const shared = {
231
+ sdk: ['serviceName', 'env', 'globalContext'],
232
+ rum: ['sessionSamplingRate', 'sampleRate', 'sessionOnErrorSamplingRate', 'sessionOnErrorSampleRate', 'globalContext'],
233
+ logger: ['logSamplingRate', 'sampleRate', 'enableCustomLog', 'logLevelFilters', 'globalContext'],
234
+ trace: ['traceType', 'traceSamplingRate', 'sampleRate'],
235
+ web: Object.keys(('web' in config && config.web) || {}),
236
+ };
237
+ Object.keys(shared).forEach(group => {
238
+ const requested = config[group];
239
+ if (requested === undefined)
240
+ return;
241
+ const actual = installed[group];
242
+ if (actual === undefined)
243
+ throw new Error(`Configure ${group} in the pre-engine Web bootstrap`);
244
+ shared[group].forEach(key => {
245
+ if (requested[key] !== undefined && stableValue(requested[key]) !== stableValue(actual[key])) {
246
+ throw new Error(`Configure ${group}.${key} in the pre-engine Web bootstrap; collectors are already initialized`);
247
+ }
248
+ });
249
+ });
250
+ }
251
+ function stableValue(value) {
252
+ return JSON.stringify(value, (_key, item) => item && typeof item === 'object' && !Array.isArray(item)
253
+ ? Object.keys(item).sort().reduce((result, key) => { result[key] = item[key]; return result; }, {}) : item);
254
+ }
255
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../src/web/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,gGAAgG;AAChG,MAAM,OAAO,aAAa;IAgBxB,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC;IAChG,CAAC;IACD,IAAI,cAAc,KAAc,OAAO,IAAI,CAAC,KAAK,KAAK,YAAY,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;IAejG,YACmB,KAA4B,EAC5B,cAA6B,EAC7B,SAAsB,MAAqB,EAC3C,gBAAyB,OAAO;QAHhC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CocosWebSDK } from './client.js';
2
+ export declare const guanceSdk: FTCocosWebSDK;
3
+ export type * from './types.js';
4
+ export * from '../core/index.js';
5
+ //# sourceMappingURL=creator3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creator3.d.ts","sourceRoot":"","sources":["../../../../../src/web/creator3.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO5C,eAAO,MAAM,SAAS,EAC+B,aAAa,CAAC;AACnE,mBAAmB,YAAY,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { director } from 'cc';
2
+ import { FTCreator3TrackingHooks } from '../creator3/auto.js';
3
+ import { FTCocosWebSDK } from './client.js';
4
+ import { platformImplementation } from '../core/platform-runtime.js';
5
+ import { isScenePublic } from './privacy.js';
6
+ /** Web-only entry; no native bridge or native Replay dependencies. */
7
+ const hooks = new FTCreator3TrackingHooks();
8
+ const canvasIsPublic = () => isScenePublic(director.getScene());
9
+ export const guanceSdk = platformImplementation({ engine: 'creator3', platform: 'web', hooks, canvasIsPublic }, undefined, () => new FTCocosWebSDK(hooks, canvasIsPublic));
10
+ export * from '../core/index.js';
11
+ //# sourceMappingURL=creator3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creator3.js","sourceRoot":"","sources":["../../../../../src/web/creator3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,sEAAsE;AACtE,MAAM,KAAK,GAAG,IAAI,uBAAuB,EAAE,CAAC;AAC5C,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,SAAS,GAAG,sBAAsB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,SAAS,EACvH,GAAG,EAAE,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC,CAAkB,CAAC;AAEnE,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Conservative Web policy: a protected component or editable field blocks the whole canvas. */
2
+ export declare function isScenePublic(scene: any, sceneHasComponents?: boolean): boolean;
3
+ //# sourceMappingURL=privacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy.d.ts","sourceRoot":"","sources":["../../../../../src/web/privacy.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,kBAAkB,UAAO,GAAG,OAAO,CAgB5E"}
@@ -0,0 +1,26 @@
1
+ /** Conservative Web policy: a protected component or editable field blocks the whole canvas. */
2
+ export function isScenePublic(scene, sceneHasComponents = true) {
3
+ var _a, _b, _c, _d;
4
+ if (!scene)
5
+ return false;
6
+ const nodes = sceneHasComponents ? [scene] : [...(scene.children || [])];
7
+ while (nodes.length) {
8
+ const node = nodes.pop();
9
+ if (node.activeInHierarchy === false)
10
+ continue;
11
+ const privacy = (_a = node.getComponent) === null || _a === void 0 ? void 0 : _a.call(node, 'ReplayPrivacy');
12
+ if (privacy && privacy.enabledInHierarchy !== false)
13
+ return false;
14
+ // The installed editor component exposes this marker; subclasses need not share its registered class name.
15
+ const components = ((_b = node.getComponents) === null || _b === void 0 ? void 0 : _b.call(node, 'cc.Component')) || node._components || [];
16
+ if (components.some((component) => component.enabledInHierarchy !== false && component.enabled !== false
17
+ && (component.replayPrivacyMode === 'mask' || component.replayPrivacyMode === 'hide')))
18
+ return false;
19
+ if (((_c = node.getComponent) === null || _c === void 0 ? void 0 : _c.call(node, 'cc.EditBox')) || ((_d = node.getComponent) === null || _d === void 0 ? void 0 : _d.call(node, 'EditBox')))
20
+ return false;
21
+ if (node.children)
22
+ nodes.push(...node.children);
23
+ }
24
+ return true;
25
+ }
26
+ //# sourceMappingURL=privacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy.js","sourceRoot":"","sources":["../../../../../src/web/privacy.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,MAAM,UAAU,aAAa,CAAC,KAAU,EAAE,kBAAkB,GAAG,IAAI;;IACjE,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,KAAK,GAAU,kBAAkB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC;IAChF,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,iBAAiB,KAAK,KAAK;YAAE,SAAS;QAC/C,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,YAAY,qDAAG,eAAe,CAAC,CAAC;QACrD,IAAI,OAAO,IAAI,OAAO,CAAC,kBAAkB,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC;QAClE,2GAA2G;QAC3G,MAAM,UAAU,GAAG,CAAA,MAAA,IAAI,CAAC,aAAa,qDAAG,cAAc,CAAC,KAAI,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;QAClF,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,SAAc,EAAE,EAAE,CAAC,SAAS,CAAC,kBAAkB,KAAK,KAAK,IAAI,SAAS,CAAC,OAAO,KAAK,KAAK;eACxG,CAAC,SAAS,CAAC,iBAAiB,KAAK,MAAM,IAAI,SAAS,CAAC,iBAAiB,KAAK,MAAM,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QACvG,IAAI,CAAA,MAAA,IAAI,CAAC,YAAY,qDAAG,YAAY,CAAC,MAAI,MAAA,IAAI,CAAC,YAAY,qDAAG,SAAS,CAAC,CAAA;YAAE,OAAO,KAAK,CAAC;QACtF,IAAI,IAAI,CAAC,QAAQ;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { FTCocosWebConfig, FTWebPageRuntime, FTWebWindow } from './types.js';
2
+ /** Owns page initialization once. Browser collectors live until the page is unloaded. */
3
+ export declare class FTWebRuntime implements FTWebPageRuntime {
4
+ readonly config: FTCocosWebConfig;
5
+ readonly protocol: 1;
6
+ private owner;
7
+ private privacyCheck;
8
+ private replayStarted;
9
+ private readonly rum;
10
+ private readonly logs;
11
+ constructor(config: FTCocosWebConfig, target: FTWebWindow, beforeEngine?: boolean);
12
+ claim(owner: object): void;
13
+ release(owner: object): void;
14
+ setPrivacyCheck(owner: object, check: (() => boolean) | undefined): void;
15
+ startReplay(): void;
16
+ stopReplay(): void;
17
+ isRecording(): boolean;
18
+ invoke<T>(method: string, input?: unknown): T | undefined;
19
+ private requireRum;
20
+ private setContext;
21
+ }
22
+ export declare function bootstrapWeb(config: FTCocosWebConfig, target?: FTWebWindow): FTWebPageRuntime;
23
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../../src/web/runtime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA+B,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAO/G,yFAAyF;AACzF,qBAAa,YAAa,YAAW,gBAAgB;IAQvC,QAAQ,CAAC,MAAM,EAAE,gBAAgB;IAP7C,QAAQ,CAAC,QAAQ,EAAG,CAAC,CAAU;IAC/B,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA2B;IAC/C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;gBAE5B,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,UAAQ;IA2GxF,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI1B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM5B,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI;IAIxE,WAAW,IAAI,IAAI;IAKnB,UAAU,IAAI,IAAI;IAKlB,WAAW,IAAI,OAAO;IAEtB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,CAAC,GAAG,SAAS;IA8BzD,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,UAAU;CAInB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAE,WAAmC,GAAG,gBAAgB,CAKpH"}
@@ -0,0 +1,267 @@
1
+ import { samplingPercentage, samplingRate } from '../core/validation.js';
2
+ import { FT_COCOS_SDK_BRIDGE_INFO_KEY, FT_COCOS_SDK_VERSION, FT_COCOS_SDK_VERSION_KEY } from '../core/version.js';
3
+ const TRACE_TYPES = {
4
+ ddTrace: 'ddtrace', zipkinMultiHeader: 'zipkin', zipkinSingleHeader: 'zipkin_single_header',
5
+ traceparent: 'w3c_traceparent', skywalking: 'skywalking_v3', jaeger: 'jaeger',
6
+ };
7
+ /** Owns page initialization once. Browser collectors live until the page is unloaded. */
8
+ export class FTWebRuntime {
9
+ constructor(config, target, beforeEngine = false) {
10
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
11
+ this.config = config;
12
+ this.protocol = 1;
13
+ this.replayStarted = false;
14
+ // Keep later caller mutations from changing filtering or privacy after init.
15
+ config = JSON.parse(JSON.stringify(config));
16
+ this.config = config;
17
+ const web = config.web;
18
+ if (!web)
19
+ throw new Error('Configure web explicitly before starting the Web SDK');
20
+ const connection = reportingConnection(web);
21
+ const replay = web.replay;
22
+ if (replay) {
23
+ const keys = ['enabled', 'sessionReplaySamplingRate', 'sessionReplayOnErrorSamplingRate', 'canvasPrivacy', 'canvasId', 'captureFps', 'maxImageDimension', 'quality', 'maxFrameBytes'];
24
+ for (const key of Object.keys(replay))
25
+ if (!keys.includes(key))
26
+ throw new Error(`Unsupported web.replay.${key}`);
27
+ }
28
+ if (!config.rum && !config.logger)
29
+ throw new Error('Enable rum or logger for Web collection');
30
+ if (!config.rum && (((_a = config.autoTrack) === null || _a === void 0 ? void 0 : _a.scenes) || ((_b = config.autoTrack) === null || _b === void 0 ? void 0 : _b.actions) || ((_c = config.autoTrack) === null || _c === void 0 ? void 0 : _c.errors) || ((_d = config.autoTrack) === null || _d === void 0 ? void 0 : _d.network)))
31
+ throw new Error('Cocos RUM tracking requires rum configuration');
32
+ if (config.trace && !config.rum)
33
+ throw new Error('Web tracing requires RUM');
34
+ if (((_e = config.autoTrack) === null || _e === void 0 ? void 0 : _e.console) && !config.logger)
35
+ throw new Error('Console tracking requires logger');
36
+ if (replay && (!beforeEngine || !config.rum))
37
+ throw new Error('Web Replay must be configured before engine boot with RUM enabled');
38
+ if (replay && replay.enabled !== true)
39
+ throw new Error('Web Replay requires enabled: true');
40
+ if ((replay === null || replay === void 0 ? void 0 : replay.canvasPrivacy) !== undefined && !['block', 'allow'].includes(replay.canvasPrivacy)) {
41
+ throw new Error('web.replay.canvasPrivacy must be block or allow');
42
+ }
43
+ const fps = integer(replay === null || replay === void 0 ? void 0 : replay.captureFps, 1, 5, 1, 'captureFps');
44
+ const dimension = integer(replay === null || replay === void 0 ? void 0 : replay.maxImageDimension, 1, 2048, 720, 'maxImageDimension');
45
+ if (web.outsideViewName !== undefined && !web.outsideViewName.trim())
46
+ throw new Error('outsideViewName must not be empty');
47
+ if ((_f = web.allowedTracingUrls) === null || _f === void 0 ? void 0 : _f.some(url => typeof url !== 'string' || !/^https?:\/\//.test(url))) {
48
+ throw new Error('allowedTracingUrls must contain absolute HTTP(S) URL prefixes');
49
+ }
50
+ if ((replay === null || replay === void 0 ? void 0 : replay.quality) !== undefined && !(typeof replay.quality === 'number'
51
+ ? Number.isFinite(replay.quality) && replay.quality >= 0 && replay.quality <= 1
52
+ : ['low', 'medium', 'high'].includes(replay.quality)))
53
+ throw new Error('web.replay.quality must be low, medium, high, or a number between 0 and 1');
54
+ const quality = (replay === null || replay === void 0 ? void 0 : replay.quality) === 'low' ? 0.25 : (replay === null || replay === void 0 ? void 0 : replay.quality) === 'medium' ? 0.4 : (replay === null || replay === void 0 ? void 0 : replay.quality) === 'high' ? 0.5 : (_g = replay === null || replay === void 0 ? void 0 : replay.quality) !== null && _g !== void 0 ? _g : 0.4;
55
+ const maxBytes = integer(replay === null || replay === void 0 ? void 0 : replay.maxFrameBytes, 1024, 1048576, 40000, 'web.replay.maxFrameBytes');
56
+ const common = { ...connection, service: (_h = config.sdk) === null || _h === void 0 ? void 0 : _h.serviceName, env: (_j = config.sdk) === null || _j === void 0 ? void 0 : _j.env, telemetrySampleRate: 0 };
57
+ const rumConfig = config.rum ? {
58
+ ...common,
59
+ applicationId: required(web.applicationId, 'web.applicationId'),
60
+ sessionSampleRate: percentage(config.rum.sessionSamplingRate, config.rum.sampleRate, 100, 'sessionSamplingRate'),
61
+ sessionOnErrorSampleRate: percentage(config.rum.sessionOnErrorSamplingRate, config.rum.sessionOnErrorSampleRate, 0, 'sessionOnErrorSamplingRate'),
62
+ trackViewsManually: true,
63
+ trackUserInteractions: false,
64
+ sessionReplaySampleRate: percentage(replay === null || replay === void 0 ? void 0 : replay.sessionReplaySamplingRate, undefined, replay ? 100 : 0, 'sessionReplaySamplingRate'),
65
+ sessionReplayOnErrorSampleRate: percentage(replay === null || replay === void 0 ? void 0 : replay.sessionReplayOnErrorSamplingRate, undefined, 0, 'sessionReplayOnErrorSamplingRate'),
66
+ allowedTracingUrls: config.trace ? web.allowedTracingUrls || [] : [],
67
+ tracingSampleRate: percentage((_k = config.trace) === null || _k === void 0 ? void 0 : _k.traceSamplingRate, (_l = config.trace) === null || _l === void 0 ? void 0 : _l.sampleRate, 100, 'traceSamplingRate'),
68
+ traceType: TRACE_TYPES[((_m = config.trace) === null || _m === void 0 ? void 0 : _m.traceType) || 'ddTrace'],
69
+ replayCanvasEnabled: !!replay,
70
+ replayCanvasMode: 'auto',
71
+ replayCanvasSampling: fps,
72
+ replayCanvasAutoInterval: 1000 / fps,
73
+ // The WebGL plugin otherwise retains a 1000ms cooldown, overriding higher target FPS.
74
+ // One in-flight encode and the capture interval bound load; 1ms is the minimum accepted cooldown.
75
+ replayCanvasAutoCooldown: 1,
76
+ replayCanvasQuality: quality,
77
+ replayCanvasMaxEncodedBytes: maxBytes,
78
+ replayCanvasMaxCanvasSize: dimension,
79
+ replayCanvasMaxConcurrentEncodes: 1,
80
+ replayCanvasAutoMaxPerRun: 1,
81
+ defaultPrivacyLevel: 'mask',
82
+ shouldRecordCanvas: (canvas) => {
83
+ var _a;
84
+ if (!this.replayStarted || (replay === null || replay === void 0 ? void 0 : replay.canvasPrivacy) !== 'allow' || canvas.id !== (replay.canvasId || 'GameCanvas'))
85
+ return false;
86
+ // Fail closed until the engine has registered a fresh scene privacy check.
87
+ try {
88
+ return ((_a = this.privacyCheck) === null || _a === void 0 ? void 0 : _a.call(this)) === true;
89
+ }
90
+ catch (_b) {
91
+ return false;
92
+ }
93
+ },
94
+ beforeSend: (event) => {
95
+ var _a, _b, _c;
96
+ const manual = !!((_a = event.context) === null || _a === void 0 ? void 0 : _a[FT_COCOS_SDK_BRIDGE_INFO_KEY]);
97
+ if (event.type === 'resource')
98
+ return ((_b = config.autoTrack) === null || _b === void 0 ? void 0 : _b.network) === true;
99
+ if (event.type === 'error')
100
+ return manual || ((_c = config.autoTrack) === null || _c === void 0 ? void 0 : _c.errors) === true;
101
+ if (event.type === 'long_task')
102
+ return web.trackLongTasks === true;
103
+ return true;
104
+ },
105
+ } : undefined;
106
+ const logsConfig = config.logger ? {
107
+ ...common,
108
+ sessionSampleRate: percentage(config.logger.logSamplingRate, config.logger.sampleRate, 100, 'logSamplingRate'),
109
+ forwardErrorsToLogs: false,
110
+ forwardConsoleLogs: [],
111
+ forwardReports: [],
112
+ } : undefined;
113
+ this.rum = rumConfig ? target.DATAFLUX_RUM : undefined;
114
+ this.logs = logsConfig ? target.DATAFLUX_LOGS : undefined;
115
+ // Preflight every dependency before the first irreversible Browser init.
116
+ if (rumConfig && (!this.rum || typeof this.rum.getInitConfiguration !== 'function'))
117
+ throw new Error('Load the Browser RUM bundle before Cocos');
118
+ if (logsConfig && (!this.logs || typeof this.logs.getInitConfiguration !== 'function'))
119
+ throw new Error('Load the Browser Logs bundle before Cocos');
120
+ if (((_o = this.rum) === null || _o === void 0 ? void 0 : _o.getInitConfiguration()) || ((_p = this.logs) === null || _p === void 0 ? void 0 : _p.getInitConfiguration()))
121
+ throw new Error('Browser SDK already initialized; use the page bootstrap and attach()');
122
+ if (replay && !((_q = target.DATAFLUX_RUM_WEBGL) === null || _q === void 0 ? void 0 : _q.webglReplayPlugin))
123
+ throw new Error('Load the Browser WebGL bundle before Cocos');
124
+ if (rumConfig && this.rum) {
125
+ let accepted = false;
126
+ const ownershipPlugin = { name: 'cocos-adapter', onInit: () => { accepted = true; } };
127
+ this.rum.init({
128
+ ...rumConfig,
129
+ plugins: [ownershipPlugin, ...(replay ? [target.DATAFLUX_RUM_WEBGL.webglReplayPlugin()] : [])],
130
+ });
131
+ // A host awaiting its first manual view can still return undefined from getInitConfiguration().
132
+ if (!accepted)
133
+ throw new Error('Browser RUM is already initialized or did not accept Cocos initialization');
134
+ this.setContext(this.rum, { ...(_r = config.sdk) === null || _r === void 0 ? void 0 : _r.globalContext, ...(_s = config.rum) === null || _s === void 0 ? void 0 : _s.globalContext });
135
+ // Browser 3.3 exposes its public init configuration only after the first manual view.
136
+ this.rum.startView({ name: web.outsideViewName || 'CocosInactive' });
137
+ if (!this.rum.getInitConfiguration())
138
+ throw new Error('Browser RUM rejected its configuration');
139
+ this.rum.stopSessionReplayRecording();
140
+ }
141
+ if (logsConfig && this.logs) {
142
+ this.logs.init(logsConfig);
143
+ if (!this.logs.getInitConfiguration())
144
+ throw new Error('Browser Logs rejected its configuration');
145
+ this.setContext(this.logs, { ...(_t = config.sdk) === null || _t === void 0 ? void 0 : _t.globalContext, ...(_u = config.logger) === null || _u === void 0 ? void 0 : _u.globalContext });
146
+ }
147
+ }
148
+ claim(owner) {
149
+ if (this.owner && this.owner !== owner)
150
+ throw new Error('Another Cocos facade already owns this page attachment');
151
+ this.owner = owner;
152
+ }
153
+ release(owner) {
154
+ if (this.owner !== owner)
155
+ return;
156
+ this.stopReplay();
157
+ this.privacyCheck = undefined;
158
+ this.owner = undefined;
159
+ }
160
+ setPrivacyCheck(owner, check) {
161
+ if (this.owner !== owner)
162
+ throw new Error('Attach the Web SDK before configuring privacy');
163
+ this.privacyCheck = check;
164
+ }
165
+ startReplay() {
166
+ if (!this.config.web.replay)
167
+ throw new Error('Configure Web Replay in the pre-engine bootstrap');
168
+ this.replayStarted = true;
169
+ this.rum.startSessionReplayRecording();
170
+ }
171
+ stopReplay() {
172
+ var _a;
173
+ if (!this.replayStarted)
174
+ return;
175
+ this.replayStarted = false;
176
+ (_a = this.rum) === null || _a === void 0 ? void 0 : _a.stopSessionReplayRecording();
177
+ }
178
+ isRecording() { var _a; return this.replayStarted && !!((_a = this.rum) === null || _a === void 0 ? void 0 : _a.isRecording()); }
179
+ invoke(method, input) {
180
+ var _a, _b, _c, _d;
181
+ const data = (input || {});
182
+ switch (method) {
183
+ case 'sdk.bindUser': {
184
+ const user = data;
185
+ const identity = { ...user.extra, id: required(user.userId, 'userId'), name: user.userName, email: user.userEmail };
186
+ (_a = this.rum) === null || _a === void 0 ? void 0 : _a.setUser(identity);
187
+ (_b = this.logs) === null || _b === void 0 ? void 0 : _b.setUser(identity);
188
+ break;
189
+ }
190
+ case 'sdk.unbindUser':
191
+ (_c = this.rum) === null || _c === void 0 ? void 0 : _c.clearUser();
192
+ (_d = this.logs) === null || _d === void 0 ? void 0 : _d.clearUser();
193
+ break;
194
+ case 'rum.startView':
195
+ this.requireRum().startView({ name: data.name, context: data.attributes });
196
+ break;
197
+ case 'rum.stopView':
198
+ this.requireRum().startView({ name: this.config.web.outsideViewName || 'CocosInactive', context: data.attributes });
199
+ break;
200
+ case 'rum.addAction':
201
+ this.requireRum().addTypeAction(data.name, data.type, data.attributes);
202
+ break;
203
+ case 'rum.addError': {
204
+ const error = new Error(data.message);
205
+ error.name = data.type;
206
+ error.stack = data.stack;
207
+ this.requireRum().addError(error, { ...data.attributes, cocos_error_state: data.state });
208
+ break;
209
+ }
210
+ case 'logger.log': {
211
+ if (!this.logs)
212
+ throw new Error('Web logging was not enabled');
213
+ const config = this.config.logger;
214
+ if (config.enableCustomLog === false || (config.logLevelFilters && config.logLevelFilters.indexOf(data.level) < 0))
215
+ break;
216
+ const status = data.level === 'warning' ? 'warn' : data.level;
217
+ if (['ok', 'debug', 'info', 'notice', 'warn', 'error', 'critical', 'alert', 'emerg'].indexOf(status) < 0) {
218
+ throw new Error(`Unsupported Browser log level: ${data.level}`);
219
+ }
220
+ this.logs.logger.log(data.content, data.attributes, status);
221
+ break;
222
+ }
223
+ default: throw new Error(`${method} is not supported on Web. Configure collectors at page bootstrap; use Browser automatic network/trace collection and detach() for Cocos cleanup.`);
224
+ }
225
+ return undefined;
226
+ }
227
+ requireRum() {
228
+ if (!this.rum)
229
+ throw new Error('Web RUM was not enabled');
230
+ return this.rum;
231
+ }
232
+ setContext(api, context) {
233
+ Object.keys(context).forEach(key => api.setGlobalContextProperty(key, context[key]));
234
+ api.setGlobalContextProperty(FT_COCOS_SDK_VERSION_KEY, FT_COCOS_SDK_VERSION);
235
+ }
236
+ }
237
+ export function bootstrapWeb(config, target = window) {
238
+ if (target.__FT_COCOS_WEB__)
239
+ throw new Error('Cocos Web bootstrap already initialized');
240
+ const runtime = new FTWebRuntime(config, target, true);
241
+ target.__FT_COCOS_WEB__ = runtime;
242
+ return runtime;
243
+ }
244
+ function required(value, name) {
245
+ if (typeof value !== 'string' || !value.trim())
246
+ throw new Error(`${name} is required`);
247
+ return value;
248
+ }
249
+ function reportingConnection(web) {
250
+ if (web.datakitOrigin && (web.site || web.clientToken))
251
+ throw new Error('Choose datakitOrigin or site with clientToken');
252
+ const origin = required(web.datakitOrigin || web.site, 'web.datakitOrigin or web.site');
253
+ if (!/^https?:\/\/[^/?#@]+\/?$/.test(origin))
254
+ throw new Error('Browser reporting endpoint must be an HTTP(S) origin without a path, credentials, query or fragment');
255
+ return web.datakitOrigin ? { datakitOrigin: origin } : { site: origin, clientToken: required(web.clientToken, 'web.clientToken') };
256
+ }
257
+ function percentage(value, legacy, fallback, name) {
258
+ return value !== undefined ? samplingPercentage(value, name) : legacy !== undefined ? samplingRate(legacy, name) * 100 : fallback;
259
+ }
260
+ function integer(value, min, max, fallback, name) {
261
+ if (value === undefined)
262
+ return fallback;
263
+ if (!Number.isInteger(value) || value < min || value > max)
264
+ throw new RangeError(`${name} must be an integer between ${min} and ${max}`);
265
+ return value;
266
+ }
267
+ //# sourceMappingURL=runtime.js.map