@cloudcare/cocos-session-replay 0.1.0-alpha.6

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 +53 -0
  3. package/THIRD_PARTY_NOTICES +5 -0
  4. package/components/creator2/ReplayPrivacy.ts +23 -0
  5. package/components/creator3/ReplayPrivacy.ts +25 -0
  6. package/creator2/package.json +4 -0
  7. package/creator3/package.json +5 -0
  8. package/dist/creator2/core/client.d.ts +30 -0
  9. package/dist/creator2/core/client.d.ts.map +1 -0
  10. package/dist/creator2/core/client.js +115 -0
  11. package/dist/creator2/core/client.js.map +1 -0
  12. package/dist/creator2/core/replay-async-transport.d.ts +4 -0
  13. package/dist/creator2/core/replay-async-transport.d.ts.map +1 -0
  14. package/dist/creator2/core/replay-async-transport.js +67 -0
  15. package/dist/creator2/core/replay-async-transport.js.map +1 -0
  16. package/dist/creator2/core/replay-budget.d.ts +28 -0
  17. package/dist/creator2/core/replay-budget.d.ts.map +1 -0
  18. package/dist/creator2/core/replay-budget.js +126 -0
  19. package/dist/creator2/core/replay-budget.js.map +1 -0
  20. package/dist/creator2/core/replay-diagnostics.d.ts +36 -0
  21. package/dist/creator2/core/replay-diagnostics.d.ts.map +1 -0
  22. package/dist/creator2/core/replay-diagnostics.js +40 -0
  23. package/dist/creator2/core/replay-diagnostics.js.map +1 -0
  24. package/dist/creator2/core/replay-encoding.d.ts +31 -0
  25. package/dist/creator2/core/replay-encoding.d.ts.map +1 -0
  26. package/dist/creator2/core/replay-encoding.js +63 -0
  27. package/dist/creator2/core/replay-encoding.js.map +1 -0
  28. package/dist/creator2/core/replay-file.d.ts +5 -0
  29. package/dist/creator2/core/replay-file.d.ts.map +1 -0
  30. package/dist/creator2/core/replay-file.js +101 -0
  31. package/dist/creator2/core/replay-file.js.map +1 -0
  32. package/dist/creator2/core/replay-pixels.d.ts +3 -0
  33. package/dist/creator2/core/replay-pixels.d.ts.map +1 -0
  34. package/dist/creator2/core/replay-pixels.js +16 -0
  35. package/dist/creator2/core/replay-pixels.js.map +1 -0
  36. package/dist/creator2/core/replay-privacy-nodes.d.ts +14 -0
  37. package/dist/creator2/core/replay-privacy-nodes.d.ts.map +1 -0
  38. package/dist/creator2/core/replay-privacy-nodes.js +18 -0
  39. package/dist/creator2/core/replay-privacy-nodes.js.map +1 -0
  40. package/dist/creator2/core/replay-privacy.d.ts +15 -0
  41. package/dist/creator2/core/replay-privacy.d.ts.map +1 -0
  42. package/dist/creator2/core/replay-privacy.js +36 -0
  43. package/dist/creator2/core/replay-privacy.js.map +1 -0
  44. package/dist/creator2/core/replay.d.ts +102 -0
  45. package/dist/creator2/core/replay.d.ts.map +1 -0
  46. package/dist/creator2/core/replay.js +653 -0
  47. package/dist/creator2/core/replay.js.map +1 -0
  48. package/dist/creator2/core/transport.d.ts +3 -0
  49. package/dist/creator2/core/transport.d.ts.map +1 -0
  50. package/dist/creator2/core/transport.js +22 -0
  51. package/dist/creator2/core/transport.js.map +1 -0
  52. package/dist/creator2/core/types.d.ts +82 -0
  53. package/dist/creator2/core/types.d.ts.map +1 -0
  54. package/dist/creator2/core/types.js +3 -0
  55. package/dist/creator2/core/types.js.map +1 -0
  56. package/dist/creator2/core/validation.d.ts +13 -0
  57. package/dist/creator2/core/validation.d.ts.map +1 -0
  58. package/dist/creator2/core/validation.js +75 -0
  59. package/dist/creator2/core/validation.js.map +1 -0
  60. package/dist/creator2/core/version.d.ts +2 -0
  61. package/dist/creator2/core/version.d.ts.map +1 -0
  62. package/dist/creator2/core/version.js +5 -0
  63. package/dist/creator2/core/version.js.map +1 -0
  64. package/dist/creator2/creator2/capture.d.ts +17 -0
  65. package/dist/creator2/creator2/capture.d.ts.map +1 -0
  66. package/dist/creator2/creator2/capture.js +168 -0
  67. package/dist/creator2/creator2/capture.js.map +1 -0
  68. package/dist/creator2/creator2/index.d.ts +8 -0
  69. package/dist/creator2/creator2/index.d.ts.map +1 -0
  70. package/dist/creator2/creator2/index.js +19 -0
  71. package/dist/creator2/creator2/index.js.map +1 -0
  72. package/dist/creator2/creator2/pointer.d.ts +5 -0
  73. package/dist/creator2/creator2/pointer.d.ts.map +1 -0
  74. package/dist/creator2/creator2/pointer.js +49 -0
  75. package/dist/creator2/creator2/pointer.js.map +1 -0
  76. package/dist/creator2/creator2/transport.d.ts +8 -0
  77. package/dist/creator2/creator2/transport.d.ts.map +1 -0
  78. package/dist/creator2/creator2/transport.js +38 -0
  79. package/dist/creator2/creator2/transport.js.map +1 -0
  80. package/dist/creator3/core/client.d.ts +30 -0
  81. package/dist/creator3/core/client.d.ts.map +1 -0
  82. package/dist/creator3/core/client.js +97 -0
  83. package/dist/creator3/core/client.js.map +1 -0
  84. package/dist/creator3/core/replay-async-transport.d.ts +4 -0
  85. package/dist/creator3/core/replay-async-transport.d.ts.map +1 -0
  86. package/dist/creator3/core/replay-async-transport.js +16 -0
  87. package/dist/creator3/core/replay-async-transport.js.map +1 -0
  88. package/dist/creator3/core/replay-budget.d.ts +28 -0
  89. package/dist/creator3/core/replay-budget.d.ts.map +1 -0
  90. package/dist/creator3/core/replay-budget.js +118 -0
  91. package/dist/creator3/core/replay-budget.js.map +1 -0
  92. package/dist/creator3/core/replay-diagnostics.d.ts +36 -0
  93. package/dist/creator3/core/replay-diagnostics.d.ts.map +1 -0
  94. package/dist/creator3/core/replay-diagnostics.js +36 -0
  95. package/dist/creator3/core/replay-diagnostics.js.map +1 -0
  96. package/dist/creator3/core/replay-encoding.d.ts +31 -0
  97. package/dist/creator3/core/replay-encoding.d.ts.map +1 -0
  98. package/dist/creator3/core/replay-encoding.js +62 -0
  99. package/dist/creator3/core/replay-encoding.js.map +1 -0
  100. package/dist/creator3/core/replay-file.d.ts +5 -0
  101. package/dist/creator3/core/replay-file.d.ts.map +1 -0
  102. package/dist/creator3/core/replay-file.js +31 -0
  103. package/dist/creator3/core/replay-file.js.map +1 -0
  104. package/dist/creator3/core/replay-pixels.d.ts +3 -0
  105. package/dist/creator3/core/replay-pixels.d.ts.map +1 -0
  106. package/dist/creator3/core/replay-pixels.js +13 -0
  107. package/dist/creator3/core/replay-pixels.js.map +1 -0
  108. package/dist/creator3/core/replay-privacy-nodes.d.ts +14 -0
  109. package/dist/creator3/core/replay-privacy-nodes.d.ts.map +1 -0
  110. package/dist/creator3/core/replay-privacy-nodes.js +15 -0
  111. package/dist/creator3/core/replay-privacy-nodes.js.map +1 -0
  112. package/dist/creator3/core/replay-privacy.d.ts +15 -0
  113. package/dist/creator3/core/replay-privacy.d.ts.map +1 -0
  114. package/dist/creator3/core/replay-privacy.js +33 -0
  115. package/dist/creator3/core/replay-privacy.js.map +1 -0
  116. package/dist/creator3/core/replay.d.ts +102 -0
  117. package/dist/creator3/core/replay.d.ts.map +1 -0
  118. package/dist/creator3/core/replay.js +576 -0
  119. package/dist/creator3/core/replay.js.map +1 -0
  120. package/dist/creator3/core/transport.d.ts +3 -0
  121. package/dist/creator3/core/transport.d.ts.map +1 -0
  122. package/dist/creator3/core/transport.js +19 -0
  123. package/dist/creator3/core/transport.js.map +1 -0
  124. package/dist/creator3/core/types.d.ts +82 -0
  125. package/dist/creator3/core/types.d.ts.map +1 -0
  126. package/dist/creator3/core/types.js +2 -0
  127. package/dist/creator3/core/types.js.map +1 -0
  128. package/dist/creator3/core/validation.d.ts +13 -0
  129. package/dist/creator3/core/validation.d.ts.map +1 -0
  130. package/dist/creator3/core/validation.js +70 -0
  131. package/dist/creator3/core/validation.js.map +1 -0
  132. package/dist/creator3/core/version.d.ts +2 -0
  133. package/dist/creator3/core/version.d.ts.map +1 -0
  134. package/dist/creator3/core/version.js +2 -0
  135. package/dist/creator3/core/version.js.map +1 -0
  136. package/dist/creator3/creator3/capture.d.ts +17 -0
  137. package/dist/creator3/creator3/capture.d.ts.map +1 -0
  138. package/dist/creator3/creator3/capture.js +112 -0
  139. package/dist/creator3/creator3/capture.js.map +1 -0
  140. package/dist/creator3/creator3/index.d.ts +8 -0
  141. package/dist/creator3/creator3/index.d.ts.map +1 -0
  142. package/dist/creator3/creator3/index.js +14 -0
  143. package/dist/creator3/creator3/index.js.map +1 -0
  144. package/dist/creator3/creator3/pointer.d.ts +5 -0
  145. package/dist/creator3/creator3/pointer.d.ts.map +1 -0
  146. package/dist/creator3/creator3/pointer.js +29 -0
  147. package/dist/creator3/creator3/pointer.js.map +1 -0
  148. package/dist/creator3/creator3/replay-render-cycle.d.ts +9 -0
  149. package/dist/creator3/creator3/replay-render-cycle.d.ts.map +1 -0
  150. package/dist/creator3/creator3/replay-render-cycle.js +12 -0
  151. package/dist/creator3/creator3/replay-render-cycle.js.map +1 -0
  152. package/dist/creator3/creator3/transport.d.ts +9 -0
  153. package/dist/creator3/creator3/transport.d.ts.map +1 -0
  154. package/dist/creator3/creator3/transport.js +28 -0
  155. package/dist/creator3/creator3/transport.js.map +1 -0
  156. package/dist/creator3/package.json +1 -0
  157. package/native/android/src/main/java/com/ft/sdk/cocos/FTCocosReplayBridge.java +168 -0
  158. package/native/android/src/main/java/com/ft/sdk/cocos/FTCocosReplayImageJobs.java +55 -0
  159. package/native/ios/FTCocosReplayBridge.h +10 -0
  160. package/native/ios/FTCocosReplayBridge.m +275 -0
  161. package/native/ios/FTCocosReplayBridge.podspec +18 -0
  162. package/native/ios/FTCocosReplayImageJobs.h +11 -0
  163. package/native/ios/FTCocosReplayImageJobs.m +54 -0
  164. package/native/ios/Package.swift +26 -0
  165. package/native/ios/include/FTCocosReplayBridge.h +10 -0
  166. package/native/shared/FTReplayFileBridge.h +62 -0
  167. package/native/shared/FTReplayFileWorker.h +88 -0
  168. package/native-integration.json +9 -0
  169. package/package.json +58 -0
@@ -0,0 +1,576 @@
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
+ // Approximate comparisons must not hide small animations indefinitely.
7
+ const MAX_APPROXIMATE_STATIC_MS = 2000;
8
+ const SAMPLE_TILE_SIZE = 32;
9
+ /** Cocos canvas Session Replay controls. */
10
+ export class FTSessionReplay {
11
+ constructor(transport, capture, pointerSource, validateNative) {
12
+ this.transport = transport;
13
+ this.capture = capture;
14
+ this.pointerSource = pointerSource;
15
+ this.validateNative = validateNative;
16
+ this.busy = false;
17
+ this.running = false;
18
+ this.mode = 'idle';
19
+ this.hybridReplayEnabled = false;
20
+ this.captureGeneration = 0;
21
+ this.config = { captureFps: 1 };
22
+ this.imagePolicy = replayImagePolicy({});
23
+ this.budget = new FTReplayBudget(this.imagePolicy);
24
+ this.imagePolicyEnabled = false;
25
+ this.recordCounts = new Map();
26
+ this.recordTouches = false;
27
+ this.pendingPointerEvents = [];
28
+ }
29
+ /**
30
+ * Enables native Session Replay and starts Cocos canvas capture for a
31
+ * standalone application.
32
+ *
33
+ * @param config - Replay sampling, capture, and touch-privacy settings.
34
+ */
35
+ start(config = {}) {
36
+ var _a;
37
+ if (this.mode === 'hybrid') {
38
+ throw new Error('Hybrid Replay is managed by enterCocos() and leaveCocos()');
39
+ }
40
+ if (this.mode === 'standalone')
41
+ return;
42
+ samplingRate(config.sampleRate, 'replay.sampleRate');
43
+ samplingRate(config.sessionOnErrorSampleRate, 'replay.sessionOnErrorSampleRate');
44
+ this.configureCapture(config);
45
+ (_a = this.validateNative) === null || _a === void 0 ? void 0 : _a.call(this);
46
+ this.transport.invoke('replay.configure', config);
47
+ this.mode = 'standalone';
48
+ this.startCapture();
49
+ }
50
+ /** @internal */
51
+ attachHybrid(config) {
52
+ if (this.mode === 'standalone') {
53
+ throw new Error('Standalone Replay and Hybrid Replay are mutually exclusive');
54
+ }
55
+ if (this.mode === 'hybrid')
56
+ return;
57
+ this.configureCapture(config || {});
58
+ this.hybridReplayEnabled = config !== undefined;
59
+ this.mode = 'hybrid';
60
+ }
61
+ /** @internal */
62
+ detachHybrid() {
63
+ if (this.mode !== 'hybrid')
64
+ return;
65
+ this.stopCapture();
66
+ this.hybridReplayEnabled = false;
67
+ this.mode = 'idle';
68
+ }
69
+ /** @internal */
70
+ enterHybrid() {
71
+ if (this.mode !== 'hybrid') {
72
+ throw new Error('Call attach() before entering Hybrid Replay');
73
+ }
74
+ if (!this.hybridReplayEnabled || this.running)
75
+ return;
76
+ this.transport.invoke('hybrid.setExternalRecorderActive', { active: true });
77
+ this.startCapture();
78
+ }
79
+ /** @internal */
80
+ leaveHybrid() {
81
+ if (this.mode !== 'hybrid' || !this.hybridReplayEnabled)
82
+ return;
83
+ this.stopCapture();
84
+ this.transport.invoke('hybrid.setExternalRecorderActive', { active: false });
85
+ }
86
+ configureCapture(config) {
87
+ if (config.touchPrivacy !== undefined && config.touchPrivacy !== 'show' && config.touchPrivacy !== 'hide') {
88
+ throw new TypeError("touchPrivacy must be either 'show' or 'hide'");
89
+ }
90
+ this.config = { captureFps: captureFps(config.captureFps) };
91
+ this.imagePolicy = replayImagePolicy(config);
92
+ this.budget = new FTReplayBudget(this.imagePolicy);
93
+ // Lossy image MIME must be validated against the deployed player before
94
+ // becoming an implicit default. Supplying imagePolicy opts into V2 now.
95
+ this.imagePolicyEnabled = config.imagePolicy !== undefined;
96
+ this.recordTouches = config.touchPrivacy === 'show';
97
+ }
98
+ /** Stops standalone Cocos canvas capture and native Session Replay. */
99
+ stop() {
100
+ if (this.mode === 'hybrid') {
101
+ throw new Error('Hybrid Replay is managed by enterCocos() and leaveCocos()');
102
+ }
103
+ if (this.mode === 'idle')
104
+ return;
105
+ this.stopCapture();
106
+ this.transport.invoke('replay.stop');
107
+ this.mode = 'idle';
108
+ }
109
+ /**
110
+ * Changes the Session Replay privacy treatment for a Cocos node.
111
+ *
112
+ * `mask` obscures the node, `hide` removes the region from the replay, and
113
+ * `unmask` clears an earlier code override, restoring any ReplayPrivacy
114
+ * component rule or default input masking. Code overrides take priority over
115
+ * a component on the same node. The node must belong to the active Cocos scene.
116
+ *
117
+ * @param node - Cocos node whose rendered bounds receive the privacy rule.
118
+ * @param mode - Privacy treatment to apply.
119
+ */
120
+ setPrivacy(node, mode) {
121
+ this.capture.setPrivacy(node, mode);
122
+ }
123
+ /** @internal */
124
+ async captureNow() {
125
+ var _a, _b, _c, _d;
126
+ if (this.busy) {
127
+ emitReplayDiagnostic({ type: 'capture_skipped', timestamp: Date.now(), reason: 'busy' });
128
+ return false;
129
+ }
130
+ const generation = this.captureGeneration;
131
+ this.busy = true;
132
+ let stored;
133
+ let context;
134
+ let pointerSize = this.lastImageSize;
135
+ try {
136
+ context = this.readContext();
137
+ if (!context)
138
+ return false;
139
+ const contextKey = `${context.applicationId}:${context.sessionId}:${context.viewId}`;
140
+ const contextChanged = contextKey !== this.lastContextKey;
141
+ const viewportSize = (_b = (_a = this.capture).getViewportSize) === null || _b === void 0 ? void 0 : _b.call(_a);
142
+ const viewportChanged = this.lastViewportSize !== undefined
143
+ && viewportSize !== undefined
144
+ && (viewportSize.width !== this.lastViewportSize.width
145
+ || viewportSize.height !== this.lastViewportSize.height);
146
+ const priorityKey = contextChanged
147
+ ? contextKey
148
+ : viewportChanged && viewportSize
149
+ ? `${contextKey}:${viewportSize.width}x${viewportSize.height}`
150
+ : undefined;
151
+ const now = Date.now();
152
+ const decision = this.budget.decide(now, priorityKey);
153
+ emitReplayDiagnostic({
154
+ type: 'capture_attempt',
155
+ timestamp: now,
156
+ usedBytes: decision.usedBytes,
157
+ maxBytesPerMinute: this.imagePolicy.maxBytesPerMinute,
158
+ });
159
+ if (!decision.allowed) {
160
+ emitReplayDiagnostic({
161
+ type: 'capture_skipped',
162
+ timestamp: now,
163
+ reason: decision.reason || 'budget',
164
+ });
165
+ return pointerSize ? this.writePendingPointers(context, pointerSize.width, pointerSize.height) : false;
166
+ }
167
+ const frame = await this.capture.capture(decision.maxImageDimension);
168
+ if (generation !== this.captureGeneration)
169
+ return false;
170
+ if (!frame)
171
+ return false;
172
+ pointerSize = { width: frame.width, height: frame.height };
173
+ applyPrivacyRegions(frame.rgba, frame.width, frame.height, frame.privacyRegions || []);
174
+ const fingerprint = frameFingerprint(frame.rgba);
175
+ const privacyKey = privacyRegionsKey(frame.privacyRegions || []);
176
+ const sample = sampleReplayFrame(frame.rgba, frame.width, frame.height);
177
+ const comparable = contextKey === this.lastContextKey
178
+ && !viewportChanged
179
+ && frame.width === ((_c = this.lastFrameSample) === null || _c === void 0 ? void 0 : _c.width)
180
+ && frame.height === ((_d = this.lastFrameSample) === null || _d === void 0 ? void 0 : _d.height)
181
+ && privacyKey === this.lastPrivacyKey;
182
+ const duplicate = comparable && fingerprint === this.lastFingerprint;
183
+ const approximatelyStatic = comparable
184
+ && !duplicate
185
+ && this.lastImageTimestamp !== undefined
186
+ && now - this.lastImageTimestamp < MAX_APPROXIMATE_STATIC_MS
187
+ && replayFramesLookSimilar(this.lastFrameSample, sample);
188
+ if (duplicate || approximatelyStatic) {
189
+ emitReplayDiagnostic({
190
+ type: 'capture_skipped',
191
+ timestamp: now,
192
+ reason: duplicate ? 'dedupe' : 'approx_static',
193
+ });
194
+ return this.writePendingPointers(context, frame.width, frame.height);
195
+ }
196
+ stored = await this.capture.persist(frame, fingerprint);
197
+ if (generation !== this.captureGeneration)
198
+ return false;
199
+ const saved = await this.saveImage(stored, decision.compressionQuality, decision.maxFrameBytes);
200
+ if (generation !== this.captureGeneration)
201
+ return false;
202
+ if (!saved) {
203
+ emitReplayDiagnostic({ type: 'capture_skipped', timestamp: now, reason: 'budget' });
204
+ return this.writePendingPointers(context, frame.width, frame.height);
205
+ }
206
+ const pendingPointers = this.scaledPendingPointers(saved.width, saved.height);
207
+ const encoded = encodeReplayImageRecord({
208
+ context,
209
+ resourceId: saved.resourceId,
210
+ width: saved.width,
211
+ height: saved.height,
212
+ ...(saved.mimeType ? { mimeType: saved.mimeType } : {}),
213
+ timestamp: stored.timestamp,
214
+ contextChanged,
215
+ pointerEvents: pendingPointers,
216
+ });
217
+ this.transport.invoke('replay.writeSegment', {
218
+ viewId: context.viewId,
219
+ segment: encoded.segment,
220
+ });
221
+ emitReplayDiagnostic({
222
+ type: 'segment_encoded',
223
+ timestamp: now,
224
+ byteSize: replayUtf8ByteLength(encoded.segment),
225
+ recordCount: encoded.recordCount,
226
+ pointerRecordCount: pendingPointers.length,
227
+ hasImage: true,
228
+ });
229
+ this.updateRecordCount(context.viewId, encoded.recordCount);
230
+ this.pendingPointerEvents.splice(0, pendingPointers.length);
231
+ this.budget.record(now, saved.byteSize, priorityKey);
232
+ emitReplayDiagnostic({
233
+ type: 'image_saved',
234
+ timestamp: now,
235
+ byteSize: saved.byteSize,
236
+ width: saved.width,
237
+ height: saved.height,
238
+ ...(saved.mimeType ? { mimeType: saved.mimeType } : {}),
239
+ priority: decision.priority,
240
+ byteSizeSource: saved.byteSizeSource,
241
+ });
242
+ this.lastFingerprint = fingerprint;
243
+ this.lastContextKey = contextKey;
244
+ this.lastPrivacyKey = privacyKey;
245
+ this.lastFrameSample = sample;
246
+ this.lastImageTimestamp = now;
247
+ this.lastImageSize = { width: saved.width, height: saved.height };
248
+ this.lastViewportSize = viewportSize;
249
+ return true;
250
+ }
251
+ catch (error) {
252
+ if (generation !== this.captureGeneration)
253
+ return false;
254
+ emitReplayDiagnostic({ type: 'capture_skipped', timestamp: Date.now(), reason: 'error' });
255
+ console.error('[cocos-sdk] Session Replay frame dropped:', error);
256
+ if (context && pointerSize) {
257
+ try {
258
+ return this.writePendingPointers(context, pointerSize.width, pointerSize.height);
259
+ }
260
+ catch (pointerError) {
261
+ console.error('[cocos-sdk] Session Replay pointer segment dropped:', pointerError);
262
+ }
263
+ }
264
+ return false;
265
+ }
266
+ finally {
267
+ try {
268
+ if (stored)
269
+ await this.capture.disposeStoredFrame(stored);
270
+ }
271
+ finally {
272
+ this.busy = false;
273
+ }
274
+ }
275
+ }
276
+ startCapture() {
277
+ this.captureGeneration += 1;
278
+ this.running = true;
279
+ this.lastFingerprint = undefined;
280
+ this.lastContextKey = undefined;
281
+ this.lastPrivacyKey = undefined;
282
+ this.lastFrameSample = undefined;
283
+ this.lastImageTimestamp = undefined;
284
+ this.lastImageSize = undefined;
285
+ this.lastViewportSize = undefined;
286
+ this.budget.reset();
287
+ this.recordCounts.clear();
288
+ this.pendingPointerEvents = [];
289
+ if (this.recordTouches && this.pointerSource) {
290
+ this.stopPointerTracking = this.pointerSource.onReplayPointer((event) => {
291
+ emitReplayDiagnostic({
292
+ type: 'pointer_received',
293
+ timestamp: event.timestamp,
294
+ eventType: event.eventType,
295
+ });
296
+ this.pendingPointerEvents.push(event);
297
+ if (this.pendingPointerEvents.length > MAX_PENDING_POINTER_EVENTS) {
298
+ this.pendingPointerEvents.splice(0, this.pendingPointerEvents.length - MAX_PENDING_POINTER_EVENTS);
299
+ }
300
+ });
301
+ }
302
+ this.schedule(0, this.captureGeneration);
303
+ }
304
+ stopCapture() {
305
+ var _a;
306
+ const wasRunning = this.running;
307
+ this.captureGeneration += 1;
308
+ this.running = false;
309
+ (_a = this.stopPointerTracking) === null || _a === void 0 ? void 0 : _a.call(this);
310
+ this.stopPointerTracking = undefined;
311
+ this.pendingPointerEvents = [];
312
+ if (this.timer !== undefined)
313
+ clearTimeout(this.timer);
314
+ this.timer = undefined;
315
+ if (wasRunning)
316
+ emitReplayDiagnostic({ type: 'replay_stopped', timestamp: Date.now() });
317
+ }
318
+ schedule(delay, generation) {
319
+ if (!this.running)
320
+ return;
321
+ this.timer = setTimeout(async () => {
322
+ if (!this.running || generation !== this.captureGeneration)
323
+ return;
324
+ try {
325
+ await this.captureNow();
326
+ }
327
+ catch (error) {
328
+ console.error('[cocos-sdk] Session Replay frame dropped:', error);
329
+ }
330
+ finally {
331
+ if (this.running && generation === this.captureGeneration) {
332
+ this.schedule(1000 / this.config.captureFps, generation);
333
+ }
334
+ }
335
+ }, delay);
336
+ }
337
+ readContext() {
338
+ const value = this.transport.invoke('replay.getContext');
339
+ return normalizeRumContext(value);
340
+ }
341
+ async saveImage(stored, compressionQuality, maxFrameBytes) {
342
+ if (this.imagePolicyEnabled && this.supportsSaveImageV2 !== false) {
343
+ try {
344
+ const value = await this.invokeSaveImage('replay.saveImageV2', {
345
+ path: stored.path,
346
+ width: stored.width,
347
+ height: stored.height,
348
+ quality: compressionQuality,
349
+ maxFrameBytes,
350
+ });
351
+ if (value !== undefined) {
352
+ this.supportsSaveImageV2 = true;
353
+ if (isRejectedSaveImageV2(value))
354
+ return undefined;
355
+ return { ...normalizeSaveImageV2Result(value), byteSizeSource: 'native' };
356
+ }
357
+ this.supportsSaveImageV2 = false;
358
+ }
359
+ catch (error) {
360
+ if (!isUnknownBridgeMethod(error))
361
+ throw error;
362
+ this.supportsSaveImageV2 = false;
363
+ }
364
+ }
365
+ const resourceId = await this.invokeSaveImage('replay.saveImage', {
366
+ path: stored.path,
367
+ width: stored.width,
368
+ height: stored.height,
369
+ });
370
+ if (!resourceId)
371
+ return undefined;
372
+ return {
373
+ resourceId,
374
+ // V1 cannot report encoded size. A conservative frame-limit estimate
375
+ // still prevents configured captureFps from multiplying traffic freely.
376
+ byteSize: maxFrameBytes,
377
+ width: stored.width,
378
+ height: stored.height,
379
+ byteSizeSource: 'frame_limit_estimate',
380
+ ...(this.transport.platform === 'ios' ? { mimeType: 'image/png' } : {}),
381
+ };
382
+ }
383
+ invokeSaveImage(method, payload) {
384
+ return this.transport.invokeAsync
385
+ ? this.transport.invokeAsync(method, payload)
386
+ : Promise.resolve(this.transport.invoke(method, payload));
387
+ }
388
+ writePendingPointers(context, width, height) {
389
+ const pointerEvents = this.scaledPendingPointers(width, height);
390
+ if (pointerEvents.length === 0)
391
+ return false;
392
+ const encoded = encodeReplayPointerRecords({ context, pointerEvents });
393
+ this.transport.invoke('replay.writeSegment', {
394
+ viewId: context.viewId,
395
+ segment: encoded.segment,
396
+ });
397
+ emitReplayDiagnostic({
398
+ type: 'segment_encoded',
399
+ timestamp: Date.now(),
400
+ byteSize: replayUtf8ByteLength(encoded.segment),
401
+ recordCount: encoded.recordCount,
402
+ pointerRecordCount: pointerEvents.length,
403
+ hasImage: false,
404
+ });
405
+ this.updateRecordCount(context.viewId, encoded.recordCount);
406
+ this.pendingPointerEvents.splice(0, pointerEvents.length);
407
+ return true;
408
+ }
409
+ scaledPendingPointers(width, height) {
410
+ return this.pendingPointerEvents.map((event) => ({
411
+ eventType: event.eventType,
412
+ pointerId: event.pointerId,
413
+ x: Math.round(clamp(event.normalizedX, 0, 1) * width),
414
+ y: Math.round(clamp(event.normalizedY, 0, 1) * height),
415
+ timestamp: event.timestamp,
416
+ }));
417
+ }
418
+ updateRecordCount(viewId, added) {
419
+ const count = (this.recordCounts.get(viewId) || 0) + added;
420
+ this.recordCounts.set(viewId, count);
421
+ this.transport.invoke('replay.setRecordCount', { viewId, count });
422
+ }
423
+ }
424
+ function normalizeRumContext(value) {
425
+ if (!value || typeof value !== 'object')
426
+ return undefined;
427
+ const context = value;
428
+ const applicationId = stringValue(context.applicationId, context.application_id);
429
+ const sessionId = stringValue(context.sessionId, context.session_id);
430
+ const viewId = stringValue(context.viewId, context.view_id);
431
+ if (!applicationId || !sessionId || !viewId)
432
+ return undefined;
433
+ const globalContext = context.globalContext;
434
+ return {
435
+ applicationId,
436
+ sessionId,
437
+ viewId,
438
+ ...(globalContext && typeof globalContext === 'object'
439
+ ? { globalContext: globalContext }
440
+ : {}),
441
+ };
442
+ }
443
+ function stringValue(...values) {
444
+ return values.find((value) => typeof value === 'string' && value.length > 0);
445
+ }
446
+ export function normalizeSaveImageV2Result(value) {
447
+ if (!value || typeof value !== 'object')
448
+ throw new TypeError('Invalid replay.saveImageV2 result');
449
+ const result = value;
450
+ const resourceId = stringValue(result.resourceId, result.resource_id);
451
+ const byteSize = numberValue(result.byteSize, result.byte_size);
452
+ const width = numberValue(result.width);
453
+ const height = numberValue(result.height);
454
+ const mimeType = stringValue(result.mimeType, result.mime_type);
455
+ if (!resourceId || !isPositiveInteger(byteSize) || !isPositiveInteger(width) || !isPositiveInteger(height)) {
456
+ throw new TypeError('Invalid replay.saveImageV2 result');
457
+ }
458
+ if (mimeType && !mimeType.startsWith('image/')) {
459
+ throw new TypeError('Invalid replay.saveImageV2 mimeType');
460
+ }
461
+ return {
462
+ resourceId,
463
+ byteSize,
464
+ width,
465
+ height,
466
+ ...(mimeType ? { mimeType: mimeType } : {}),
467
+ };
468
+ }
469
+ function isRejectedSaveImageV2(value) {
470
+ return typeof value === 'object' && value !== null && value.accepted === false;
471
+ }
472
+ function isUnknownBridgeMethod(error) {
473
+ return error instanceof Error && /unknown bridge method|unrecognized selector/i.test(error.message);
474
+ }
475
+ function numberValue(...values) {
476
+ return values.find((value) => typeof value === 'number' && Number.isFinite(value));
477
+ }
478
+ function isPositiveInteger(value) {
479
+ return value !== undefined && Number.isInteger(value) && value > 0;
480
+ }
481
+ export function sampleReplayFrame(rgba, width, height, maximumSamples = 4096) {
482
+ const pixelCount = width * height;
483
+ if (width < 1 || height < 1 || rgba.length < pixelCount * 4) {
484
+ throw new RangeError('Replay frame RGBA data does not match its dimensions');
485
+ }
486
+ const sampleCount = Math.min(maximumSamples, pixelCount);
487
+ const luminance = new Uint8Array(sampleCount);
488
+ const rgb = new Uint8Array(sampleCount * 3);
489
+ for (let index = 0; index < sampleCount; index += 1) {
490
+ const pixel = Math.min(pixelCount - 1, Math.floor(index * pixelCount / sampleCount));
491
+ const offset = pixel * 4;
492
+ rgb[index * 3] = rgba[offset];
493
+ rgb[index * 3 + 1] = rgba[offset + 1];
494
+ rgb[index * 3 + 2] = rgba[offset + 2];
495
+ luminance[index] = Math.round((rgba[offset] * 54 + rgba[offset + 1] * 183 + rgba[offset + 2] * 19) / 256);
496
+ }
497
+ return { width, height, luminance, rgb };
498
+ }
499
+ export function replayFramesLookSimilar(previous, current) {
500
+ if (!previous
501
+ || previous.width !== current.width
502
+ || previous.height !== current.height
503
+ || previous.luminance.length !== current.luminance.length)
504
+ return false;
505
+ let totalDifference = 0;
506
+ let changedSamples = 0;
507
+ const tileColumns = Math.ceil(current.width / SAMPLE_TILE_SIZE);
508
+ const tileCount = tileColumns * Math.ceil(current.height / SAMPLE_TILE_SIZE);
509
+ const tileSamples = new Uint16Array(tileCount);
510
+ const tileChanges = new Uint16Array(tileCount);
511
+ for (let index = 0; index < current.luminance.length; index += 1) {
512
+ const difference = Math.abs(current.luminance[index] - previous.luminance[index]);
513
+ totalDifference += difference;
514
+ if (difference >= 12)
515
+ changedSamples += 1;
516
+ const pixel = Math.floor(index * current.width * current.height / current.luminance.length);
517
+ const tile = Math.floor(Math.floor(pixel / current.width) / SAMPLE_TILE_SIZE) * tileColumns
518
+ + Math.floor((pixel % current.width) / SAMPLE_TILE_SIZE);
519
+ tileSamples[tile] += 1;
520
+ const offset = index * 3;
521
+ // Color-only changes also matter, even when their luminance is unchanged.
522
+ if (Math.max(Math.abs(current.rgb[offset] - previous.rgb[offset]), Math.abs(current.rgb[offset + 1] - previous.rgb[offset + 1]), Math.abs(current.rgb[offset + 2] - previous.rgb[offset + 2])) >= 12)
523
+ tileChanges[tile] += 1;
524
+ }
525
+ for (let tile = 0; tile < tileCount; tile += 1) {
526
+ // A moving sprite can occupy much less than 1% of the whole screen.
527
+ if (tileChanges[tile] >= 2 && tileChanges[tile] / tileSamples[tile] >= 0.1)
528
+ return false;
529
+ }
530
+ const averageDifference = totalDifference / current.luminance.length;
531
+ const changedRatio = changedSamples / current.luminance.length;
532
+ return averageDifference <= 2.5 && changedRatio <= 0.01;
533
+ }
534
+ function privacyRegionsKey(regions) {
535
+ return regions.map((region) => (`${region.mode}:${region.x}:${region.y}:${region.width}:${region.height}`)).join('|');
536
+ }
537
+ export function frameFingerprint(bytes) {
538
+ let hash = 2166136261;
539
+ // Sparse hashing can classify changes between sampled bytes as duplicates,
540
+ // bypassing both local motion detection and the approximate refresh limit.
541
+ // Read RGBA words without copying normal capture buffers to keep this cheap
542
+ // on the Cocos JS thread. Mix high bits down so every color channel matters.
543
+ const aligned = bytes.byteOffset % 4 === 0 ? bytes : bytes.slice();
544
+ const words = new Uint32Array(aligned.buffer, aligned.byteOffset, Math.floor(aligned.length / 4));
545
+ for (let index = 0; index < words.length; index += 1) {
546
+ hash = Math.imul(hash ^ words[index], 16777619);
547
+ hash ^= hash >>> 16;
548
+ }
549
+ for (let index = words.length * 4; index < bytes.length; index += 1) {
550
+ hash ^= bytes[index];
551
+ hash = Math.imul(hash, 16777619);
552
+ }
553
+ return `${bytes.length.toString(16)}-${(hash >>> 0).toString(16)}`;
554
+ }
555
+ export function applyPrivacyRegions(rgba, width, height, regions) {
556
+ regions.forEach((region) => {
557
+ const startX = clamp(Math.floor(region.x), 0, width);
558
+ const startY = clamp(Math.floor(region.y), 0, height);
559
+ const endX = clamp(Math.ceil(region.x + region.width), 0, width);
560
+ const endY = clamp(Math.ceil(region.y + region.height), 0, height);
561
+ const color = region.mode === 'hide' ? 0 : 128;
562
+ for (let y = startY; y < endY; y += 1) {
563
+ for (let x = startX; x < endX; x += 1) {
564
+ const offset = (y * width + x) * 4;
565
+ rgba[offset] = color;
566
+ rgba[offset + 1] = color;
567
+ rgba[offset + 2] = color;
568
+ rgba[offset + 3] = 255;
569
+ }
570
+ }
571
+ });
572
+ }
573
+ function clamp(value, minimum, maximum) {
574
+ return Math.min(maximum, Math.max(minimum, value));
575
+ }
576
+ //# sourceMappingURL=replay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.js","sourceRoot":"","sources":["../../../../../src/session-replay/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;AACvC,uEAAuE;AACvE,MAAM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,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtC,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;gBACnC,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;gBACrB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;gBACzB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;gBACzB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,OAAe,EAAE,OAAe;IAC5D,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type { FTNativeTransport } from '@cloudcare/cocos-sdk/plugin-api';
2
+ export declare function parseTransportResponse<T>(raw: unknown): T | undefined;
3
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../../src/session-replay/core/transport.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGzE,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,GAAG,CAAC,GAAG,SAAS,CAcrE"}
@@ -0,0 +1,19 @@
1
+ export function parseTransportResponse(raw) {
2
+ if (raw === undefined || raw === null || raw === '')
3
+ return undefined;
4
+ let response = raw;
5
+ if (typeof raw === 'string') {
6
+ response = JSON.parse(raw);
7
+ }
8
+ if (!isResponse(response)) {
9
+ return response;
10
+ }
11
+ if (!response.ok) {
12
+ throw new Error(response.error || 'Native bridge call failed');
13
+ }
14
+ return response.value;
15
+ }
16
+ function isResponse(value) {
17
+ return typeof value === 'object' && value !== null && 'ok' in value;
18
+ }
19
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../../../src/session-replay/core/transport.ts"],"names":[],"mappings":"AAIA,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"}