@truewatchtech/cocos-sdk 0.1.0-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.
Files changed (169) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +51 -0
  3. package/THIRD_PARTY_NOTICES +5 -0
  4. package/bin/cli.cjs +130 -0
  5. package/creator2/package.json +4 -0
  6. package/creator3/package.json +5 -0
  7. package/dist/creator2/core/auto-tracking.d.ts +35 -0
  8. package/dist/creator2/core/auto-tracking.d.ts.map +1 -0
  9. package/dist/creator2/core/auto-tracking.js +337 -0
  10. package/dist/creator2/core/auto-tracking.js.map +1 -0
  11. package/dist/creator2/core/client.d.ts +74 -0
  12. package/dist/creator2/core/client.d.ts.map +1 -0
  13. package/dist/creator2/core/client.js +176 -0
  14. package/dist/creator2/core/client.js.map +1 -0
  15. package/dist/creator2/core/index.d.ts +3 -0
  16. package/dist/creator2/core/index.d.ts.map +1 -0
  17. package/dist/creator2/core/index.js +6 -0
  18. package/dist/creator2/core/index.js.map +1 -0
  19. package/dist/creator2/core/modules.d.ts +159 -0
  20. package/dist/creator2/core/modules.d.ts.map +1 -0
  21. package/dist/creator2/core/modules.js +319 -0
  22. package/dist/creator2/core/modules.js.map +1 -0
  23. package/dist/creator2/core/replay-budget.d.ts +28 -0
  24. package/dist/creator2/core/replay-budget.d.ts.map +1 -0
  25. package/dist/creator2/core/replay-budget.js +113 -0
  26. package/dist/creator2/core/replay-budget.js.map +1 -0
  27. package/dist/creator2/core/replay-diagnostics.d.ts +36 -0
  28. package/dist/creator2/core/replay-diagnostics.d.ts.map +1 -0
  29. package/dist/creator2/core/replay-diagnostics.js +40 -0
  30. package/dist/creator2/core/replay-diagnostics.js.map +1 -0
  31. package/dist/creator2/core/replay-encoding.d.ts +31 -0
  32. package/dist/creator2/core/replay-encoding.d.ts.map +1 -0
  33. package/dist/creator2/core/replay-encoding.js +63 -0
  34. package/dist/creator2/core/replay-encoding.js.map +1 -0
  35. package/dist/creator2/core/replay-pixels.d.ts +3 -0
  36. package/dist/creator2/core/replay-pixels.d.ts.map +1 -0
  37. package/dist/creator2/core/replay-pixels.js +16 -0
  38. package/dist/creator2/core/replay-pixels.js.map +1 -0
  39. package/dist/creator2/core/replay-privacy.d.ts +15 -0
  40. package/dist/creator2/core/replay-privacy.d.ts.map +1 -0
  41. package/dist/creator2/core/replay-privacy.js +36 -0
  42. package/dist/creator2/core/replay-privacy.js.map +1 -0
  43. package/dist/creator2/core/replay.d.ts +97 -0
  44. package/dist/creator2/core/replay.d.ts.map +1 -0
  45. package/dist/creator2/core/replay.js +578 -0
  46. package/dist/creator2/core/replay.js.map +1 -0
  47. package/dist/creator2/core/transport.d.ts +16 -0
  48. package/dist/creator2/core/transport.d.ts.map +1 -0
  49. package/dist/creator2/core/transport.js +33 -0
  50. package/dist/creator2/core/transport.js.map +1 -0
  51. package/dist/creator2/core/types.d.ts +260 -0
  52. package/dist/creator2/core/types.d.ts.map +1 -0
  53. package/dist/creator2/core/types.js +3 -0
  54. package/dist/creator2/core/types.js.map +1 -0
  55. package/dist/creator2/core/validation.d.ts +14 -0
  56. package/dist/creator2/core/validation.d.ts.map +1 -0
  57. package/dist/creator2/core/validation.js +81 -0
  58. package/dist/creator2/core/validation.js.map +1 -0
  59. package/dist/creator2/core/version.d.ts +9 -0
  60. package/dist/creator2/core/version.d.ts.map +1 -0
  61. package/dist/creator2/core/version.js +14 -0
  62. package/dist/creator2/core/version.js.map +1 -0
  63. package/dist/creator2/creator2/auto.d.ts +9 -0
  64. package/dist/creator2/creator2/auto.d.ts.map +1 -0
  65. package/dist/creator2/creator2/auto.js +65 -0
  66. package/dist/creator2/creator2/auto.js.map +1 -0
  67. package/dist/creator2/creator2/capture.d.ts +17 -0
  68. package/dist/creator2/creator2/capture.d.ts.map +1 -0
  69. package/dist/creator2/creator2/capture.js +175 -0
  70. package/dist/creator2/creator2/capture.js.map +1 -0
  71. package/dist/creator2/creator2/index.d.ts +12 -0
  72. package/dist/creator2/creator2/index.d.ts.map +1 -0
  73. package/dist/creator2/creator2/index.js +41 -0
  74. package/dist/creator2/creator2/index.js.map +1 -0
  75. package/dist/creator2/creator2/transport.d.ts +7 -0
  76. package/dist/creator2/creator2/transport.d.ts.map +1 -0
  77. package/dist/creator2/creator2/transport.js +34 -0
  78. package/dist/creator2/creator2/transport.js.map +1 -0
  79. package/dist/creator3/core/auto-tracking.d.ts +35 -0
  80. package/dist/creator3/core/auto-tracking.d.ts.map +1 -0
  81. package/dist/creator3/core/auto-tracking.js +247 -0
  82. package/dist/creator3/core/auto-tracking.js.map +1 -0
  83. package/dist/creator3/core/client.d.ts +74 -0
  84. package/dist/creator3/core/client.d.ts.map +1 -0
  85. package/dist/creator3/core/client.js +158 -0
  86. package/dist/creator3/core/client.js.map +1 -0
  87. package/dist/creator3/core/index.d.ts +3 -0
  88. package/dist/creator3/core/index.d.ts.map +1 -0
  89. package/dist/creator3/core/index.js +2 -0
  90. package/dist/creator3/core/index.js.map +1 -0
  91. package/dist/creator3/core/modules.d.ts +159 -0
  92. package/dist/creator3/core/modules.d.ts.map +1 -0
  93. package/dist/creator3/core/modules.js +293 -0
  94. package/dist/creator3/core/modules.js.map +1 -0
  95. package/dist/creator3/core/replay-budget.d.ts +28 -0
  96. package/dist/creator3/core/replay-budget.d.ts.map +1 -0
  97. package/dist/creator3/core/replay-budget.js +105 -0
  98. package/dist/creator3/core/replay-budget.js.map +1 -0
  99. package/dist/creator3/core/replay-diagnostics.d.ts +36 -0
  100. package/dist/creator3/core/replay-diagnostics.d.ts.map +1 -0
  101. package/dist/creator3/core/replay-diagnostics.js +36 -0
  102. package/dist/creator3/core/replay-diagnostics.js.map +1 -0
  103. package/dist/creator3/core/replay-encoding.d.ts +31 -0
  104. package/dist/creator3/core/replay-encoding.d.ts.map +1 -0
  105. package/dist/creator3/core/replay-encoding.js +62 -0
  106. package/dist/creator3/core/replay-encoding.js.map +1 -0
  107. package/dist/creator3/core/replay-pixels.d.ts +3 -0
  108. package/dist/creator3/core/replay-pixels.d.ts.map +1 -0
  109. package/dist/creator3/core/replay-pixels.js +13 -0
  110. package/dist/creator3/core/replay-pixels.js.map +1 -0
  111. package/dist/creator3/core/replay-privacy.d.ts +15 -0
  112. package/dist/creator3/core/replay-privacy.d.ts.map +1 -0
  113. package/dist/creator3/core/replay-privacy.js +33 -0
  114. package/dist/creator3/core/replay-privacy.js.map +1 -0
  115. package/dist/creator3/core/replay.d.ts +97 -0
  116. package/dist/creator3/core/replay.d.ts.map +1 -0
  117. package/dist/creator3/core/replay.js +520 -0
  118. package/dist/creator3/core/replay.js.map +1 -0
  119. package/dist/creator3/core/transport.d.ts +16 -0
  120. package/dist/creator3/core/transport.d.ts.map +1 -0
  121. package/dist/creator3/core/transport.js +27 -0
  122. package/dist/creator3/core/transport.js.map +1 -0
  123. package/dist/creator3/core/types.d.ts +260 -0
  124. package/dist/creator3/core/types.d.ts.map +1 -0
  125. package/dist/creator3/core/types.js +2 -0
  126. package/dist/creator3/core/types.js.map +1 -0
  127. package/dist/creator3/core/validation.d.ts +14 -0
  128. package/dist/creator3/core/validation.d.ts.map +1 -0
  129. package/dist/creator3/core/validation.js +75 -0
  130. package/dist/creator3/core/validation.js.map +1 -0
  131. package/dist/creator3/core/version.d.ts +9 -0
  132. package/dist/creator3/core/version.d.ts.map +1 -0
  133. package/dist/creator3/core/version.js +11 -0
  134. package/dist/creator3/core/version.js.map +1 -0
  135. package/dist/creator3/creator3/auto.d.ts +9 -0
  136. package/dist/creator3/creator3/auto.d.ts.map +1 -0
  137. package/dist/creator3/creator3/auto.js +73 -0
  138. package/dist/creator3/creator3/auto.js.map +1 -0
  139. package/dist/creator3/creator3/capture.d.ts +17 -0
  140. package/dist/creator3/creator3/capture.d.ts.map +1 -0
  141. package/dist/creator3/creator3/capture.js +119 -0
  142. package/dist/creator3/creator3/capture.js.map +1 -0
  143. package/dist/creator3/creator3/index.d.ts +12 -0
  144. package/dist/creator3/creator3/index.d.ts.map +1 -0
  145. package/dist/creator3/creator3/index.js +23 -0
  146. package/dist/creator3/creator3/index.js.map +1 -0
  147. package/dist/creator3/creator3/replay-render-cycle.d.ts +9 -0
  148. package/dist/creator3/creator3/replay-render-cycle.d.ts.map +1 -0
  149. package/dist/creator3/creator3/replay-render-cycle.js +12 -0
  150. package/dist/creator3/creator3/replay-render-cycle.js.map +1 -0
  151. package/dist/creator3/creator3/transport.d.ts +8 -0
  152. package/dist/creator3/creator3/transport.d.ts.map +1 -0
  153. package/dist/creator3/creator3/transport.js +24 -0
  154. package/dist/creator3/creator3/transport.js.map +1 -0
  155. package/dist/creator3/package.json +1 -0
  156. package/extensions/creator2/install-native.cjs +333 -0
  157. package/extensions/creator2/main.js +23 -0
  158. package/extensions/creator2/package.json +6 -0
  159. package/extensions/creator3/dist/builder.js +9 -0
  160. package/extensions/creator3/dist/hooks.js +70 -0
  161. package/extensions/creator3/dist/main.js +4 -0
  162. package/extensions/creator3/install-native.cjs +333 -0
  163. package/extensions/creator3/package.json +10 -0
  164. package/native/android/src/main/java/com/ft/sdk/cocos/FTCocosBridge.java +532 -0
  165. package/native/android/src/main/java/com/ft/sdk/cocos/FTCocosBridgeProvider.java +70 -0
  166. package/native/ios/FTCocosBridge.h +10 -0
  167. package/native/ios/FTCocosBridge.m +470 -0
  168. package/native/ios/FTCocosBridge.podspec +18 -0
  169. package/package.json +60 -0
@@ -0,0 +1,520 @@
1
+ import { encodeReplayImageRecord, encodeReplayPointerRecords, } from './replay-encoding.js';
2
+ import { FTReplayBudget } from './replay-budget.js';
3
+ import { emitReplayDiagnostic, replayUtf8ByteLength } from './replay-diagnostics.js';
4
+ import { captureFps, replayImagePolicy, samplingRate, } from './validation.js';
5
+ const MAX_PENDING_POINTER_EVENTS = 512;
6
+ /** Cocos canvas Session Replay controls. */
7
+ export class FTSessionReplay {
8
+ constructor(transport, capture, pointerSource) {
9
+ this.transport = transport;
10
+ this.capture = capture;
11
+ this.pointerSource = pointerSource;
12
+ this.busy = false;
13
+ this.running = false;
14
+ this.mode = 'idle';
15
+ this.hybridReplayEnabled = false;
16
+ this.captureGeneration = 0;
17
+ this.config = { captureFps: 1 };
18
+ this.imagePolicy = replayImagePolicy({});
19
+ this.budget = new FTReplayBudget(this.imagePolicy);
20
+ this.imagePolicyEnabled = false;
21
+ this.recordCounts = new Map();
22
+ this.recordTouches = false;
23
+ this.pendingPointerEvents = [];
24
+ }
25
+ /**
26
+ * Enables native Session Replay and starts Cocos canvas capture for a
27
+ * standalone application.
28
+ *
29
+ * @param config - Replay sampling, capture, and touch-privacy settings.
30
+ */
31
+ start(config = {}) {
32
+ if (this.mode === 'hybrid') {
33
+ throw new Error('Hybrid Replay is managed by enterCocos() and leaveCocos()');
34
+ }
35
+ if (this.mode === 'standalone')
36
+ return;
37
+ samplingRate(config.sampleRate, 'replay.sampleRate');
38
+ samplingRate(config.sessionOnErrorSampleRate, 'replay.sessionOnErrorSampleRate');
39
+ this.configureCapture(config);
40
+ this.transport.invoke('replay.configure', config);
41
+ this.mode = 'standalone';
42
+ this.startCapture();
43
+ }
44
+ /** @internal */
45
+ attachHybrid(config) {
46
+ if (this.mode === 'standalone') {
47
+ throw new Error('Standalone Replay and Hybrid Replay are mutually exclusive');
48
+ }
49
+ if (this.mode === 'hybrid')
50
+ return;
51
+ this.configureCapture(config || {});
52
+ this.hybridReplayEnabled = config !== undefined;
53
+ this.mode = 'hybrid';
54
+ }
55
+ /** @internal */
56
+ detachHybrid() {
57
+ if (this.mode !== 'hybrid')
58
+ return;
59
+ this.stopCapture();
60
+ this.hybridReplayEnabled = false;
61
+ this.mode = 'idle';
62
+ }
63
+ /** @internal */
64
+ enterHybrid() {
65
+ if (this.mode !== 'hybrid') {
66
+ throw new Error('Call attach() before entering Hybrid Replay');
67
+ }
68
+ if (!this.hybridReplayEnabled || this.running)
69
+ return;
70
+ this.transport.invoke('hybrid.setExternalRecorderActive', { active: true });
71
+ this.startCapture();
72
+ }
73
+ /** @internal */
74
+ leaveHybrid() {
75
+ if (this.mode !== 'hybrid' || !this.hybridReplayEnabled)
76
+ return;
77
+ this.stopCapture();
78
+ this.transport.invoke('hybrid.setExternalRecorderActive', { active: false });
79
+ }
80
+ configureCapture(config) {
81
+ if (config.touchPrivacy !== undefined && config.touchPrivacy !== 'show' && config.touchPrivacy !== 'hide') {
82
+ throw new TypeError("touchPrivacy must be either 'show' or 'hide'");
83
+ }
84
+ this.config = { captureFps: captureFps(config.captureFps) };
85
+ this.imagePolicy = replayImagePolicy(config);
86
+ this.budget = new FTReplayBudget(this.imagePolicy);
87
+ // Lossy image MIME must be validated against the deployed player before
88
+ // becoming an implicit default. Supplying imagePolicy opts into V2 now.
89
+ this.imagePolicyEnabled = config.imagePolicy !== undefined;
90
+ this.recordTouches = config.touchPrivacy === 'show';
91
+ }
92
+ /** Stops standalone Cocos canvas capture and native Session Replay. */
93
+ stop() {
94
+ if (this.mode === 'hybrid') {
95
+ throw new Error('Hybrid Replay is managed by enterCocos() and leaveCocos()');
96
+ }
97
+ if (this.mode === 'idle')
98
+ return;
99
+ this.stopCapture();
100
+ this.transport.invoke('replay.stop');
101
+ this.mode = 'idle';
102
+ }
103
+ /**
104
+ * Changes the Session Replay privacy treatment for a Cocos node.
105
+ *
106
+ * `mask` obscures the node, `hide` removes the region from the replay, and
107
+ * `unmask` clears an earlier override. The node must belong to the active
108
+ * Cocos scene.
109
+ *
110
+ * @param node - Cocos node whose rendered bounds receive the privacy rule.
111
+ * @param mode - Privacy treatment to apply.
112
+ */
113
+ setPrivacy(node, mode) {
114
+ this.capture.setPrivacy(node, mode);
115
+ }
116
+ /** @internal */
117
+ async captureNow() {
118
+ var _a, _b;
119
+ if (this.busy) {
120
+ emitReplayDiagnostic({ type: 'capture_skipped', timestamp: Date.now(), reason: 'busy' });
121
+ return false;
122
+ }
123
+ const generation = this.captureGeneration;
124
+ this.busy = true;
125
+ let stored;
126
+ let context;
127
+ let pointerSize = this.lastImageSize;
128
+ try {
129
+ context = this.readContext();
130
+ if (!context)
131
+ return false;
132
+ const contextKey = `${context.applicationId}:${context.sessionId}:${context.viewId}`;
133
+ const contextChanged = contextKey !== this.lastContextKey;
134
+ const viewportSize = (_b = (_a = this.capture).getViewportSize) === null || _b === void 0 ? void 0 : _b.call(_a);
135
+ const viewportChanged = this.lastViewportSize !== undefined
136
+ && viewportSize !== undefined
137
+ && (viewportSize.width !== this.lastViewportSize.width
138
+ || viewportSize.height !== this.lastViewportSize.height);
139
+ const priorityKey = contextChanged
140
+ ? contextKey
141
+ : viewportChanged && viewportSize
142
+ ? `${contextKey}:${viewportSize.width}x${viewportSize.height}`
143
+ : undefined;
144
+ const now = Date.now();
145
+ const decision = this.budget.decide(now, priorityKey);
146
+ emitReplayDiagnostic({
147
+ type: 'capture_attempt',
148
+ timestamp: now,
149
+ usedBytes: decision.usedBytes,
150
+ maxBytesPerMinute: this.imagePolicy.maxBytesPerMinute,
151
+ });
152
+ if (!decision.allowed) {
153
+ emitReplayDiagnostic({
154
+ type: 'capture_skipped',
155
+ timestamp: now,
156
+ reason: decision.reason || 'budget',
157
+ });
158
+ return pointerSize ? this.writePendingPointers(context, pointerSize.width, pointerSize.height) : false;
159
+ }
160
+ const frame = await this.capture.capture(decision.maxImageDimension);
161
+ if (generation !== this.captureGeneration)
162
+ return false;
163
+ if (!frame)
164
+ return false;
165
+ pointerSize = { width: frame.width, height: frame.height };
166
+ applyPrivacyRegions(frame.rgba, frame.width, frame.height, frame.privacyRegions || []);
167
+ const fingerprint = frameFingerprint(frame.rgba);
168
+ const privacyKey = privacyRegionsKey(frame.privacyRegions || []);
169
+ const sample = sampleReplayFrame(frame.rgba, frame.width, frame.height);
170
+ const comparable = contextKey === this.lastContextKey
171
+ && !viewportChanged
172
+ && privacyKey === this.lastPrivacyKey;
173
+ const duplicate = comparable && fingerprint === this.lastFingerprint;
174
+ const approximatelyStatic = comparable
175
+ && !duplicate
176
+ && replayFramesLookSimilar(this.lastFrameSample, sample);
177
+ if (duplicate || approximatelyStatic) {
178
+ emitReplayDiagnostic({
179
+ type: 'capture_skipped',
180
+ timestamp: now,
181
+ reason: duplicate ? 'dedupe' : 'approx_static',
182
+ });
183
+ return this.writePendingPointers(context, frame.width, frame.height);
184
+ }
185
+ stored = await this.capture.persist(frame, fingerprint);
186
+ if (generation !== this.captureGeneration)
187
+ return false;
188
+ const saved = this.saveImage(stored, decision.compressionQuality, decision.maxFrameBytes);
189
+ if (!saved) {
190
+ emitReplayDiagnostic({ type: 'capture_skipped', timestamp: now, reason: 'budget' });
191
+ return this.writePendingPointers(context, frame.width, frame.height);
192
+ }
193
+ const pendingPointers = this.scaledPendingPointers(saved.width, saved.height);
194
+ const encoded = encodeReplayImageRecord({
195
+ context,
196
+ resourceId: saved.resourceId,
197
+ width: saved.width,
198
+ height: saved.height,
199
+ ...(saved.mimeType ? { mimeType: saved.mimeType } : {}),
200
+ timestamp: stored.timestamp,
201
+ contextChanged,
202
+ pointerEvents: pendingPointers,
203
+ });
204
+ this.transport.invoke('replay.writeSegment', {
205
+ viewId: context.viewId,
206
+ segment: encoded.segment,
207
+ });
208
+ emitReplayDiagnostic({
209
+ type: 'segment_encoded',
210
+ timestamp: now,
211
+ byteSize: replayUtf8ByteLength(encoded.segment),
212
+ recordCount: encoded.recordCount,
213
+ pointerRecordCount: pendingPointers.length,
214
+ hasImage: true,
215
+ });
216
+ this.updateRecordCount(context.viewId, encoded.recordCount);
217
+ this.pendingPointerEvents.splice(0, pendingPointers.length);
218
+ this.budget.record(now, saved.byteSize, priorityKey);
219
+ emitReplayDiagnostic({
220
+ type: 'image_saved',
221
+ timestamp: now,
222
+ byteSize: saved.byteSize,
223
+ width: saved.width,
224
+ height: saved.height,
225
+ ...(saved.mimeType ? { mimeType: saved.mimeType } : {}),
226
+ priority: decision.priority,
227
+ byteSizeSource: saved.byteSizeSource,
228
+ });
229
+ this.lastFingerprint = fingerprint;
230
+ this.lastContextKey = contextKey;
231
+ this.lastPrivacyKey = privacyKey;
232
+ this.lastFrameSample = sample;
233
+ this.lastImageSize = { width: saved.width, height: saved.height };
234
+ this.lastViewportSize = viewportSize;
235
+ return true;
236
+ }
237
+ catch (error) {
238
+ emitReplayDiagnostic({ type: 'capture_skipped', timestamp: Date.now(), reason: 'error' });
239
+ console.error('[cocos-sdk] Session Replay frame dropped:', error);
240
+ if (context && pointerSize) {
241
+ try {
242
+ return this.writePendingPointers(context, pointerSize.width, pointerSize.height);
243
+ }
244
+ catch (pointerError) {
245
+ console.error('[cocos-sdk] Session Replay pointer segment dropped:', pointerError);
246
+ }
247
+ }
248
+ return false;
249
+ }
250
+ finally {
251
+ if (stored)
252
+ this.capture.disposeStoredFrame(stored);
253
+ this.busy = false;
254
+ }
255
+ }
256
+ startCapture() {
257
+ this.captureGeneration += 1;
258
+ this.running = true;
259
+ this.lastFingerprint = undefined;
260
+ this.lastContextKey = undefined;
261
+ this.lastPrivacyKey = undefined;
262
+ this.lastFrameSample = undefined;
263
+ this.lastImageSize = undefined;
264
+ this.lastViewportSize = undefined;
265
+ this.budget.reset();
266
+ this.recordCounts.clear();
267
+ this.pendingPointerEvents = [];
268
+ if (this.recordTouches && this.pointerSource) {
269
+ this.stopPointerTracking = this.pointerSource.onReplayPointer((event) => {
270
+ emitReplayDiagnostic({
271
+ type: 'pointer_received',
272
+ timestamp: event.timestamp,
273
+ eventType: event.eventType,
274
+ });
275
+ this.pendingPointerEvents.push(event);
276
+ if (this.pendingPointerEvents.length > MAX_PENDING_POINTER_EVENTS) {
277
+ this.pendingPointerEvents.splice(0, this.pendingPointerEvents.length - MAX_PENDING_POINTER_EVENTS);
278
+ }
279
+ });
280
+ }
281
+ this.schedule(0, this.captureGeneration);
282
+ }
283
+ stopCapture() {
284
+ var _a;
285
+ const wasRunning = this.running;
286
+ this.captureGeneration += 1;
287
+ this.running = false;
288
+ (_a = this.stopPointerTracking) === null || _a === void 0 ? void 0 : _a.call(this);
289
+ this.stopPointerTracking = undefined;
290
+ this.pendingPointerEvents = [];
291
+ if (this.timer !== undefined)
292
+ clearTimeout(this.timer);
293
+ this.timer = undefined;
294
+ if (wasRunning)
295
+ emitReplayDiagnostic({ type: 'replay_stopped', timestamp: Date.now() });
296
+ }
297
+ schedule(delay, generation) {
298
+ if (!this.running)
299
+ return;
300
+ this.timer = setTimeout(async () => {
301
+ if (!this.running || generation !== this.captureGeneration)
302
+ return;
303
+ try {
304
+ await this.captureNow();
305
+ }
306
+ catch (error) {
307
+ console.error('[cocos-sdk] Session Replay frame dropped:', error);
308
+ }
309
+ finally {
310
+ if (this.running && generation === this.captureGeneration) {
311
+ this.schedule(1000 / this.config.captureFps, generation);
312
+ }
313
+ }
314
+ }, delay);
315
+ }
316
+ readContext() {
317
+ const value = this.transport.invoke('replay.getContext');
318
+ return normalizeRumContext(value);
319
+ }
320
+ saveImage(stored, compressionQuality, maxFrameBytes) {
321
+ if (this.imagePolicyEnabled && this.supportsSaveImageV2 !== false) {
322
+ try {
323
+ const value = this.transport.invoke('replay.saveImageV2', {
324
+ path: stored.path,
325
+ width: stored.width,
326
+ height: stored.height,
327
+ quality: compressionQuality,
328
+ maxFrameBytes,
329
+ });
330
+ if (value !== undefined) {
331
+ this.supportsSaveImageV2 = true;
332
+ if (isRejectedSaveImageV2(value))
333
+ return undefined;
334
+ return { ...normalizeSaveImageV2Result(value), byteSizeSource: 'native' };
335
+ }
336
+ this.supportsSaveImageV2 = false;
337
+ }
338
+ catch (error) {
339
+ if (!isUnknownBridgeMethod(error))
340
+ throw error;
341
+ this.supportsSaveImageV2 = false;
342
+ }
343
+ }
344
+ const resourceId = this.transport.invoke('replay.saveImage', {
345
+ path: stored.path,
346
+ width: stored.width,
347
+ height: stored.height,
348
+ });
349
+ if (!resourceId)
350
+ return undefined;
351
+ return {
352
+ resourceId,
353
+ // V1 cannot report encoded size. A conservative frame-limit estimate
354
+ // still prevents configured captureFps from multiplying traffic freely.
355
+ byteSize: maxFrameBytes,
356
+ width: stored.width,
357
+ height: stored.height,
358
+ byteSizeSource: 'frame_limit_estimate',
359
+ ...(this.transport.platform === 'ios' ? { mimeType: 'image/png' } : {}),
360
+ };
361
+ }
362
+ writePendingPointers(context, width, height) {
363
+ const pointerEvents = this.scaledPendingPointers(width, height);
364
+ if (pointerEvents.length === 0)
365
+ return false;
366
+ const encoded = encodeReplayPointerRecords({ context, pointerEvents });
367
+ this.transport.invoke('replay.writeSegment', {
368
+ viewId: context.viewId,
369
+ segment: encoded.segment,
370
+ });
371
+ emitReplayDiagnostic({
372
+ type: 'segment_encoded',
373
+ timestamp: Date.now(),
374
+ byteSize: replayUtf8ByteLength(encoded.segment),
375
+ recordCount: encoded.recordCount,
376
+ pointerRecordCount: pointerEvents.length,
377
+ hasImage: false,
378
+ });
379
+ this.updateRecordCount(context.viewId, encoded.recordCount);
380
+ this.pendingPointerEvents.splice(0, pointerEvents.length);
381
+ return true;
382
+ }
383
+ scaledPendingPointers(width, height) {
384
+ return this.pendingPointerEvents.map((event) => ({
385
+ eventType: event.eventType,
386
+ pointerId: event.pointerId,
387
+ x: Math.round(clamp(event.normalizedX, 0, 1) * width),
388
+ y: Math.round(clamp(event.normalizedY, 0, 1) * height),
389
+ timestamp: event.timestamp,
390
+ }));
391
+ }
392
+ updateRecordCount(viewId, added) {
393
+ const count = (this.recordCounts.get(viewId) || 0) + added;
394
+ this.recordCounts.set(viewId, count);
395
+ this.transport.invoke('replay.setRecordCount', { viewId, count });
396
+ }
397
+ }
398
+ function normalizeRumContext(value) {
399
+ if (!value || typeof value !== 'object')
400
+ return undefined;
401
+ const context = value;
402
+ const applicationId = stringValue(context.applicationId, context.application_id);
403
+ const sessionId = stringValue(context.sessionId, context.session_id);
404
+ const viewId = stringValue(context.viewId, context.view_id);
405
+ if (!applicationId || !sessionId || !viewId)
406
+ return undefined;
407
+ const globalContext = context.globalContext;
408
+ return {
409
+ applicationId,
410
+ sessionId,
411
+ viewId,
412
+ ...(globalContext && typeof globalContext === 'object'
413
+ ? { globalContext: globalContext }
414
+ : {}),
415
+ };
416
+ }
417
+ function stringValue(...values) {
418
+ return values.find((value) => typeof value === 'string' && value.length > 0);
419
+ }
420
+ export function normalizeSaveImageV2Result(value) {
421
+ if (!value || typeof value !== 'object')
422
+ throw new TypeError('Invalid replay.saveImageV2 result');
423
+ const result = value;
424
+ const resourceId = stringValue(result.resourceId, result.resource_id);
425
+ const byteSize = numberValue(result.byteSize, result.byte_size);
426
+ const width = numberValue(result.width);
427
+ const height = numberValue(result.height);
428
+ const mimeType = stringValue(result.mimeType, result.mime_type);
429
+ if (!resourceId || !isPositiveInteger(byteSize) || !isPositiveInteger(width) || !isPositiveInteger(height)) {
430
+ throw new TypeError('Invalid replay.saveImageV2 result');
431
+ }
432
+ if (mimeType && !mimeType.startsWith('image/')) {
433
+ throw new TypeError('Invalid replay.saveImageV2 mimeType');
434
+ }
435
+ return {
436
+ resourceId,
437
+ byteSize,
438
+ width,
439
+ height,
440
+ ...(mimeType ? { mimeType: mimeType } : {}),
441
+ };
442
+ }
443
+ function isRejectedSaveImageV2(value) {
444
+ return typeof value === 'object' && value !== null && value.accepted === false;
445
+ }
446
+ function isUnknownBridgeMethod(error) {
447
+ return error instanceof Error && /unknown bridge method|unrecognized selector/i.test(error.message);
448
+ }
449
+ function numberValue(...values) {
450
+ return values.find((value) => typeof value === 'number' && Number.isFinite(value));
451
+ }
452
+ function isPositiveInteger(value) {
453
+ return value !== undefined && Number.isInteger(value) && value > 0;
454
+ }
455
+ export function sampleReplayFrame(rgba, width, height, maximumSamples = 4096) {
456
+ const pixelCount = width * height;
457
+ if (width < 1 || height < 1 || rgba.length < pixelCount * 4) {
458
+ throw new RangeError('Replay frame RGBA data does not match its dimensions');
459
+ }
460
+ const sampleCount = Math.min(maximumSamples, pixelCount);
461
+ const luminance = new Uint8Array(sampleCount);
462
+ for (let index = 0; index < sampleCount; index += 1) {
463
+ const pixel = Math.min(pixelCount - 1, Math.floor(index * pixelCount / sampleCount));
464
+ const offset = pixel * 4;
465
+ luminance[index] = Math.round((rgba[offset] * 54 + rgba[offset + 1] * 183 + rgba[offset + 2] * 19) / 256);
466
+ }
467
+ return { width, height, luminance };
468
+ }
469
+ export function replayFramesLookSimilar(previous, current) {
470
+ if (!previous
471
+ || previous.width !== current.width
472
+ || previous.height !== current.height
473
+ || previous.luminance.length !== current.luminance.length)
474
+ return false;
475
+ let totalDifference = 0;
476
+ let changedSamples = 0;
477
+ for (let index = 0; index < current.luminance.length; index += 1) {
478
+ const difference = Math.abs(current.luminance[index] - previous.luminance[index]);
479
+ totalDifference += difference;
480
+ if (difference >= 12)
481
+ changedSamples += 1;
482
+ }
483
+ const averageDifference = totalDifference / current.luminance.length;
484
+ const changedRatio = changedSamples / current.luminance.length;
485
+ return averageDifference <= 2.5 && changedRatio <= 0.01;
486
+ }
487
+ function privacyRegionsKey(regions) {
488
+ return regions.map((region) => (`${region.mode}:${region.x}:${region.y}:${region.width}:${region.height}`)).join('|');
489
+ }
490
+ export function frameFingerprint(bytes) {
491
+ let hash = 2166136261;
492
+ const stride = Math.max(1, Math.floor(bytes.length / 8192));
493
+ for (let index = 0; index < bytes.length; index += stride) {
494
+ hash ^= bytes[index] || 0;
495
+ hash = Math.imul(hash, 16777619);
496
+ }
497
+ return `${bytes.length.toString(16)}-${(hash >>> 0).toString(16)}`;
498
+ }
499
+ export function applyPrivacyRegions(rgba, width, height, regions) {
500
+ regions.forEach((region) => {
501
+ const startX = clamp(Math.floor(region.x), 0, width);
502
+ const startY = clamp(Math.floor(region.y), 0, height);
503
+ const endX = clamp(Math.ceil(region.x + region.width), 0, width);
504
+ const endY = clamp(Math.ceil(region.y + region.height), 0, height);
505
+ const color = region.mode === 'hide' ? 0 : 128;
506
+ for (let y = startY; y < endY; y += 1) {
507
+ for (let x = startX; x < endX; x += 1) {
508
+ const offset = (y * width + x) * 4;
509
+ rgba[offset] = color;
510
+ rgba[offset + 1] = color;
511
+ rgba[offset + 2] = color;
512
+ rgba[offset + 3] = 255;
513
+ }
514
+ }
515
+ });
516
+ }
517
+ function clamp(value, minimum, maximum) {
518
+ return Math.min(maximum, Math.max(minimum, value));
519
+ }
520
+ //# sourceMappingURL=replay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.js","sourceRoot":"","sources":["../../../../../src/core/replay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,0BAA0B,GAE3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAUrF,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,YAAY,GAEb,MAAM,iBAAiB,CAAC;AAsBzB,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAoBvC,4CAA4C;AAC5C,MAAM,OAAO,eAAe;IAuB1B,YACmB,SAA4B,EAC5B,OAAwB,EACxB,aAAqC;QAFrC,cAAS,GAAT,SAAS,CAAmB;QAC5B,YAAO,GAAP,OAAO,CAAiB;QACxB,kBAAa,GAAb,aAAa,CAAwB;QAxBhD,SAAI,GAAG,KAAK,CAAC;QACb,YAAO,GAAG,KAAK,CAAC;QAChB,SAAI,GAAqC,MAAM,CAAC;QAChD,wBAAmB,GAAG,KAAK,CAAC;QAC5B,sBAAiB,GAAG,CAAC,CAAC;QACtB,WAAM,GAAwD,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QAChF,gBAAW,GAAgC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACjE,WAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAO9C,uBAAkB,GAAG,KAAK,CAAC;QAE3B,iBAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;QACzC,kBAAa,GAAG,KAAK,CAAC;QACtB,yBAAoB,GAA2B,EAAE,CAAC;IAOvD,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,SAAgC,EAAE;QACtC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC3B,MAAM,IAAI,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,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { FTValue } from './types.js';
2
+ export interface FTTransportResponse<T = FTValue> {
3
+ ok: boolean;
4
+ value?: T;
5
+ error?: string;
6
+ }
7
+ export interface FTNativeTransport {
8
+ readonly platform: 'android' | 'ios' | 'unsupported';
9
+ invoke<T = FTValue>(method: string, payload?: unknown): T | undefined;
10
+ }
11
+ export declare class FTNoopTransport implements FTNativeTransport {
12
+ readonly platform: "unsupported";
13
+ invoke<T = FTValue>(_method: string, _payload?: unknown): T | undefined;
14
+ }
15
+ export declare function parseTransportResponse<T>(raw: unknown): T | undefined;
16
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../../src/core/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,OAAO;IAC9C,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,KAAK,GAAG,aAAa,CAAC;IACrD,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,GAAG,SAAS,CAAC;CACvE;AAED,qBAAa,eAAgB,YAAW,iBAAiB;IACvD,QAAQ,CAAC,QAAQ,EAAG,aAAa,CAAU;IAE3C,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,CAAC,GAAG,SAAS;CAGxE;AAED,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,GAAG,CAAC,GAAG,SAAS,CAcrE"}
@@ -0,0 +1,27 @@
1
+ export class FTNoopTransport {
2
+ constructor() {
3
+ this.platform = 'unsupported';
4
+ }
5
+ invoke(_method, _payload) {
6
+ return undefined;
7
+ }
8
+ }
9
+ export function parseTransportResponse(raw) {
10
+ if (raw === undefined || raw === null || raw === '')
11
+ return undefined;
12
+ let response = raw;
13
+ if (typeof raw === 'string') {
14
+ response = JSON.parse(raw);
15
+ }
16
+ if (!isResponse(response)) {
17
+ return response;
18
+ }
19
+ if (!response.ok) {
20
+ throw new Error(response.error || 'Native bridge call failed');
21
+ }
22
+ return response.value;
23
+ }
24
+ function isResponse(value) {
25
+ return typeof value === 'object' && value !== null && 'ok' in value;
26
+ }
27
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../../../src/core/transport.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,eAAe;IAA5B;QACW,aAAQ,GAAG,aAAsB,CAAC;IAK7C,CAAC;IAHC,MAAM,CAAc,OAAe,EAAE,QAAkB;QACrD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED,MAAM,UAAU,sBAAsB,CAAI,GAAY;IACpD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IAEtE,IAAI,QAAQ,GAAY,GAAG,CAAC;IAC5B,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,QAAa,CAAC;IACvB,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,2BAA2B,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,QAAQ,CAAC,KAAsB,CAAC;AACzC,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,IAAI,IAAI,KAAK,CAAC;AACtE,CAAC"}