@truewatchtech/cocos-sdk 0.1.0-alpha.4

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 (200) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +31 -0
  3. package/THIRD_PARTY_NOTICES +5 -0
  4. package/bin/cli.cjs +138 -0
  5. package/components/creator2/ReplayPrivacy.ts +23 -0
  6. package/components/creator3/ReplayPrivacy.ts +25 -0
  7. package/creator2/package.json +4 -0
  8. package/creator3/package.json +5 -0
  9. package/dist/creator2/core/auto-tracking.d.ts +35 -0
  10. package/dist/creator2/core/auto-tracking.d.ts.map +1 -0
  11. package/dist/creator2/core/auto-tracking.js +337 -0
  12. package/dist/creator2/core/auto-tracking.js.map +1 -0
  13. package/dist/creator2/core/client.d.ts +74 -0
  14. package/dist/creator2/core/client.d.ts.map +1 -0
  15. package/dist/creator2/core/client.js +176 -0
  16. package/dist/creator2/core/client.js.map +1 -0
  17. package/dist/creator2/core/index.d.ts +3 -0
  18. package/dist/creator2/core/index.d.ts.map +1 -0
  19. package/dist/creator2/core/index.js +6 -0
  20. package/dist/creator2/core/index.js.map +1 -0
  21. package/dist/creator2/core/modules.d.ts +159 -0
  22. package/dist/creator2/core/modules.d.ts.map +1 -0
  23. package/dist/creator2/core/modules.js +319 -0
  24. package/dist/creator2/core/modules.js.map +1 -0
  25. package/dist/creator2/core/replay-async-transport.d.ts +4 -0
  26. package/dist/creator2/core/replay-async-transport.d.ts.map +1 -0
  27. package/dist/creator2/core/replay-async-transport.js +67 -0
  28. package/dist/creator2/core/replay-async-transport.js.map +1 -0
  29. package/dist/creator2/core/replay-budget.d.ts +28 -0
  30. package/dist/creator2/core/replay-budget.d.ts.map +1 -0
  31. package/dist/creator2/core/replay-budget.js +113 -0
  32. package/dist/creator2/core/replay-budget.js.map +1 -0
  33. package/dist/creator2/core/replay-diagnostics.d.ts +36 -0
  34. package/dist/creator2/core/replay-diagnostics.d.ts.map +1 -0
  35. package/dist/creator2/core/replay-diagnostics.js +40 -0
  36. package/dist/creator2/core/replay-diagnostics.js.map +1 -0
  37. package/dist/creator2/core/replay-encoding.d.ts +31 -0
  38. package/dist/creator2/core/replay-encoding.d.ts.map +1 -0
  39. package/dist/creator2/core/replay-encoding.js +63 -0
  40. package/dist/creator2/core/replay-encoding.js.map +1 -0
  41. package/dist/creator2/core/replay-file.d.ts +5 -0
  42. package/dist/creator2/core/replay-file.d.ts.map +1 -0
  43. package/dist/creator2/core/replay-file.js +101 -0
  44. package/dist/creator2/core/replay-file.js.map +1 -0
  45. package/dist/creator2/core/replay-pixels.d.ts +3 -0
  46. package/dist/creator2/core/replay-pixels.d.ts.map +1 -0
  47. package/dist/creator2/core/replay-pixels.js +16 -0
  48. package/dist/creator2/core/replay-pixels.js.map +1 -0
  49. package/dist/creator2/core/replay-privacy-nodes.d.ts +14 -0
  50. package/dist/creator2/core/replay-privacy-nodes.d.ts.map +1 -0
  51. package/dist/creator2/core/replay-privacy-nodes.js +18 -0
  52. package/dist/creator2/core/replay-privacy-nodes.js.map +1 -0
  53. package/dist/creator2/core/replay-privacy.d.ts +15 -0
  54. package/dist/creator2/core/replay-privacy.d.ts.map +1 -0
  55. package/dist/creator2/core/replay-privacy.js +36 -0
  56. package/dist/creator2/core/replay-privacy.js.map +1 -0
  57. package/dist/creator2/core/replay.d.ts +99 -0
  58. package/dist/creator2/core/replay.d.ts.map +1 -0
  59. package/dist/creator2/core/replay.js +611 -0
  60. package/dist/creator2/core/replay.js.map +1 -0
  61. package/dist/creator2/core/transport.d.ts +17 -0
  62. package/dist/creator2/core/transport.d.ts.map +1 -0
  63. package/dist/creator2/core/transport.js +33 -0
  64. package/dist/creator2/core/transport.js.map +1 -0
  65. package/dist/creator2/core/types.d.ts +260 -0
  66. package/dist/creator2/core/types.d.ts.map +1 -0
  67. package/dist/creator2/core/types.js +3 -0
  68. package/dist/creator2/core/types.js.map +1 -0
  69. package/dist/creator2/core/validation.d.ts +14 -0
  70. package/dist/creator2/core/validation.d.ts.map +1 -0
  71. package/dist/creator2/core/validation.js +81 -0
  72. package/dist/creator2/core/validation.js.map +1 -0
  73. package/dist/creator2/core/version.d.ts +9 -0
  74. package/dist/creator2/core/version.d.ts.map +1 -0
  75. package/dist/creator2/core/version.js +14 -0
  76. package/dist/creator2/core/version.js.map +1 -0
  77. package/dist/creator2/creator2/auto.d.ts +9 -0
  78. package/dist/creator2/creator2/auto.d.ts.map +1 -0
  79. package/dist/creator2/creator2/auto.js +65 -0
  80. package/dist/creator2/creator2/auto.js.map +1 -0
  81. package/dist/creator2/creator2/capture.d.ts +17 -0
  82. package/dist/creator2/creator2/capture.d.ts.map +1 -0
  83. package/dist/creator2/creator2/capture.js +168 -0
  84. package/dist/creator2/creator2/capture.js.map +1 -0
  85. package/dist/creator2/creator2/index.d.ts +12 -0
  86. package/dist/creator2/creator2/index.d.ts.map +1 -0
  87. package/dist/creator2/creator2/index.js +41 -0
  88. package/dist/creator2/creator2/index.js.map +1 -0
  89. package/dist/creator2/creator2/transport.d.ts +8 -0
  90. package/dist/creator2/creator2/transport.d.ts.map +1 -0
  91. package/dist/creator2/creator2/transport.js +38 -0
  92. package/dist/creator2/creator2/transport.js.map +1 -0
  93. package/dist/creator3/core/auto-tracking.d.ts +35 -0
  94. package/dist/creator3/core/auto-tracking.d.ts.map +1 -0
  95. package/dist/creator3/core/auto-tracking.js +247 -0
  96. package/dist/creator3/core/auto-tracking.js.map +1 -0
  97. package/dist/creator3/core/client.d.ts +74 -0
  98. package/dist/creator3/core/client.d.ts.map +1 -0
  99. package/dist/creator3/core/client.js +158 -0
  100. package/dist/creator3/core/client.js.map +1 -0
  101. package/dist/creator3/core/index.d.ts +3 -0
  102. package/dist/creator3/core/index.d.ts.map +1 -0
  103. package/dist/creator3/core/index.js +2 -0
  104. package/dist/creator3/core/index.js.map +1 -0
  105. package/dist/creator3/core/modules.d.ts +159 -0
  106. package/dist/creator3/core/modules.d.ts.map +1 -0
  107. package/dist/creator3/core/modules.js +293 -0
  108. package/dist/creator3/core/modules.js.map +1 -0
  109. package/dist/creator3/core/replay-async-transport.d.ts +4 -0
  110. package/dist/creator3/core/replay-async-transport.d.ts.map +1 -0
  111. package/dist/creator3/core/replay-async-transport.js +16 -0
  112. package/dist/creator3/core/replay-async-transport.js.map +1 -0
  113. package/dist/creator3/core/replay-budget.d.ts +28 -0
  114. package/dist/creator3/core/replay-budget.d.ts.map +1 -0
  115. package/dist/creator3/core/replay-budget.js +105 -0
  116. package/dist/creator3/core/replay-budget.js.map +1 -0
  117. package/dist/creator3/core/replay-diagnostics.d.ts +36 -0
  118. package/dist/creator3/core/replay-diagnostics.d.ts.map +1 -0
  119. package/dist/creator3/core/replay-diagnostics.js +36 -0
  120. package/dist/creator3/core/replay-diagnostics.js.map +1 -0
  121. package/dist/creator3/core/replay-encoding.d.ts +31 -0
  122. package/dist/creator3/core/replay-encoding.d.ts.map +1 -0
  123. package/dist/creator3/core/replay-encoding.js +62 -0
  124. package/dist/creator3/core/replay-encoding.js.map +1 -0
  125. package/dist/creator3/core/replay-file.d.ts +5 -0
  126. package/dist/creator3/core/replay-file.d.ts.map +1 -0
  127. package/dist/creator3/core/replay-file.js +31 -0
  128. package/dist/creator3/core/replay-file.js.map +1 -0
  129. package/dist/creator3/core/replay-pixels.d.ts +3 -0
  130. package/dist/creator3/core/replay-pixels.d.ts.map +1 -0
  131. package/dist/creator3/core/replay-pixels.js +13 -0
  132. package/dist/creator3/core/replay-pixels.js.map +1 -0
  133. package/dist/creator3/core/replay-privacy-nodes.d.ts +14 -0
  134. package/dist/creator3/core/replay-privacy-nodes.d.ts.map +1 -0
  135. package/dist/creator3/core/replay-privacy-nodes.js +15 -0
  136. package/dist/creator3/core/replay-privacy-nodes.js.map +1 -0
  137. package/dist/creator3/core/replay-privacy.d.ts +15 -0
  138. package/dist/creator3/core/replay-privacy.d.ts.map +1 -0
  139. package/dist/creator3/core/replay-privacy.js +33 -0
  140. package/dist/creator3/core/replay-privacy.js.map +1 -0
  141. package/dist/creator3/core/replay.d.ts +99 -0
  142. package/dist/creator3/core/replay.d.ts.map +1 -0
  143. package/dist/creator3/core/replay.js +534 -0
  144. package/dist/creator3/core/replay.js.map +1 -0
  145. package/dist/creator3/core/transport.d.ts +17 -0
  146. package/dist/creator3/core/transport.d.ts.map +1 -0
  147. package/dist/creator3/core/transport.js +27 -0
  148. package/dist/creator3/core/transport.js.map +1 -0
  149. package/dist/creator3/core/types.d.ts +260 -0
  150. package/dist/creator3/core/types.d.ts.map +1 -0
  151. package/dist/creator3/core/types.js +2 -0
  152. package/dist/creator3/core/types.js.map +1 -0
  153. package/dist/creator3/core/validation.d.ts +14 -0
  154. package/dist/creator3/core/validation.d.ts.map +1 -0
  155. package/dist/creator3/core/validation.js +75 -0
  156. package/dist/creator3/core/validation.js.map +1 -0
  157. package/dist/creator3/core/version.d.ts +9 -0
  158. package/dist/creator3/core/version.d.ts.map +1 -0
  159. package/dist/creator3/core/version.js +11 -0
  160. package/dist/creator3/core/version.js.map +1 -0
  161. package/dist/creator3/creator3/auto.d.ts +9 -0
  162. package/dist/creator3/creator3/auto.d.ts.map +1 -0
  163. package/dist/creator3/creator3/auto.js +73 -0
  164. package/dist/creator3/creator3/auto.js.map +1 -0
  165. package/dist/creator3/creator3/capture.d.ts +17 -0
  166. package/dist/creator3/creator3/capture.d.ts.map +1 -0
  167. package/dist/creator3/creator3/capture.js +112 -0
  168. package/dist/creator3/creator3/capture.js.map +1 -0
  169. package/dist/creator3/creator3/index.d.ts +12 -0
  170. package/dist/creator3/creator3/index.d.ts.map +1 -0
  171. package/dist/creator3/creator3/index.js +23 -0
  172. package/dist/creator3/creator3/index.js.map +1 -0
  173. package/dist/creator3/creator3/replay-render-cycle.d.ts +9 -0
  174. package/dist/creator3/creator3/replay-render-cycle.d.ts.map +1 -0
  175. package/dist/creator3/creator3/replay-render-cycle.js +12 -0
  176. package/dist/creator3/creator3/replay-render-cycle.js.map +1 -0
  177. package/dist/creator3/creator3/transport.d.ts +9 -0
  178. package/dist/creator3/creator3/transport.d.ts.map +1 -0
  179. package/dist/creator3/creator3/transport.js +28 -0
  180. package/dist/creator3/creator3/transport.js.map +1 -0
  181. package/dist/creator3/package.json +1 -0
  182. package/extensions/creator2/install-native.cjs +385 -0
  183. package/extensions/creator2/main.js +23 -0
  184. package/extensions/creator2/package.json +6 -0
  185. package/extensions/creator3/dist/builder.js +9 -0
  186. package/extensions/creator3/dist/hooks.js +70 -0
  187. package/extensions/creator3/dist/main.js +4 -0
  188. package/extensions/creator3/install-native.cjs +385 -0
  189. package/extensions/creator3/package.json +10 -0
  190. package/native/android/src/main/java/com/ft/sdk/cocos/FTCocosBridge.java +536 -0
  191. package/native/android/src/main/java/com/ft/sdk/cocos/FTCocosBridgeProvider.java +70 -0
  192. package/native/android/src/main/java/com/ft/sdk/cocos/FTCocosReplayImageJobs.java +55 -0
  193. package/native/ios/FTCocosBridge.h +10 -0
  194. package/native/ios/FTCocosBridge.m +487 -0
  195. package/native/ios/FTCocosBridge.podspec +18 -0
  196. package/native/ios/FTCocosReplayImageJobs.h +11 -0
  197. package/native/ios/FTCocosReplayImageJobs.m +54 -0
  198. package/native/shared/FTReplayFileBridge.h +62 -0
  199. package/native/shared/FTReplayFileWorker.h +88 -0
  200. package/package.json +61 -0
@@ -0,0 +1,534 @@
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 code override, restoring any ReplayPrivacy
108
+ * component rule or default input masking. Code overrides take priority over
109
+ * a component on the same node. The node must belong to the active Cocos scene.
110
+ *
111
+ * @param node - Cocos node whose rendered bounds receive the privacy rule.
112
+ * @param mode - Privacy treatment to apply.
113
+ */
114
+ setPrivacy(node, mode) {
115
+ this.capture.setPrivacy(node, mode);
116
+ }
117
+ /** @internal */
118
+ async captureNow() {
119
+ var _a, _b;
120
+ if (this.busy) {
121
+ emitReplayDiagnostic({ type: 'capture_skipped', timestamp: Date.now(), reason: 'busy' });
122
+ return false;
123
+ }
124
+ const generation = this.captureGeneration;
125
+ this.busy = true;
126
+ let stored;
127
+ let context;
128
+ let pointerSize = this.lastImageSize;
129
+ try {
130
+ context = this.readContext();
131
+ if (!context)
132
+ return false;
133
+ const contextKey = `${context.applicationId}:${context.sessionId}:${context.viewId}`;
134
+ const contextChanged = contextKey !== this.lastContextKey;
135
+ const viewportSize = (_b = (_a = this.capture).getViewportSize) === null || _b === void 0 ? void 0 : _b.call(_a);
136
+ const viewportChanged = this.lastViewportSize !== undefined
137
+ && viewportSize !== undefined
138
+ && (viewportSize.width !== this.lastViewportSize.width
139
+ || viewportSize.height !== this.lastViewportSize.height);
140
+ const priorityKey = contextChanged
141
+ ? contextKey
142
+ : viewportChanged && viewportSize
143
+ ? `${contextKey}:${viewportSize.width}x${viewportSize.height}`
144
+ : undefined;
145
+ const now = Date.now();
146
+ const decision = this.budget.decide(now, priorityKey);
147
+ emitReplayDiagnostic({
148
+ type: 'capture_attempt',
149
+ timestamp: now,
150
+ usedBytes: decision.usedBytes,
151
+ maxBytesPerMinute: this.imagePolicy.maxBytesPerMinute,
152
+ });
153
+ if (!decision.allowed) {
154
+ emitReplayDiagnostic({
155
+ type: 'capture_skipped',
156
+ timestamp: now,
157
+ reason: decision.reason || 'budget',
158
+ });
159
+ return pointerSize ? this.writePendingPointers(context, pointerSize.width, pointerSize.height) : false;
160
+ }
161
+ const frame = await this.capture.capture(decision.maxImageDimension);
162
+ if (generation !== this.captureGeneration)
163
+ return false;
164
+ if (!frame)
165
+ return false;
166
+ pointerSize = { width: frame.width, height: frame.height };
167
+ applyPrivacyRegions(frame.rgba, frame.width, frame.height, frame.privacyRegions || []);
168
+ const fingerprint = frameFingerprint(frame.rgba);
169
+ const privacyKey = privacyRegionsKey(frame.privacyRegions || []);
170
+ const sample = sampleReplayFrame(frame.rgba, frame.width, frame.height);
171
+ const comparable = contextKey === this.lastContextKey
172
+ && !viewportChanged
173
+ && privacyKey === this.lastPrivacyKey;
174
+ const duplicate = comparable && fingerprint === this.lastFingerprint;
175
+ const approximatelyStatic = comparable
176
+ && !duplicate
177
+ && replayFramesLookSimilar(this.lastFrameSample, sample);
178
+ if (duplicate || approximatelyStatic) {
179
+ emitReplayDiagnostic({
180
+ type: 'capture_skipped',
181
+ timestamp: now,
182
+ reason: duplicate ? 'dedupe' : 'approx_static',
183
+ });
184
+ return this.writePendingPointers(context, frame.width, frame.height);
185
+ }
186
+ stored = await this.capture.persist(frame, fingerprint);
187
+ if (generation !== this.captureGeneration)
188
+ return false;
189
+ const saved = await this.saveImage(stored, decision.compressionQuality, decision.maxFrameBytes);
190
+ if (generation !== this.captureGeneration)
191
+ return false;
192
+ if (!saved) {
193
+ emitReplayDiagnostic({ type: 'capture_skipped', timestamp: now, reason: 'budget' });
194
+ return this.writePendingPointers(context, frame.width, frame.height);
195
+ }
196
+ const pendingPointers = this.scaledPendingPointers(saved.width, saved.height);
197
+ const encoded = encodeReplayImageRecord({
198
+ context,
199
+ resourceId: saved.resourceId,
200
+ width: saved.width,
201
+ height: saved.height,
202
+ ...(saved.mimeType ? { mimeType: saved.mimeType } : {}),
203
+ timestamp: stored.timestamp,
204
+ contextChanged,
205
+ pointerEvents: pendingPointers,
206
+ });
207
+ this.transport.invoke('replay.writeSegment', {
208
+ viewId: context.viewId,
209
+ segment: encoded.segment,
210
+ });
211
+ emitReplayDiagnostic({
212
+ type: 'segment_encoded',
213
+ timestamp: now,
214
+ byteSize: replayUtf8ByteLength(encoded.segment),
215
+ recordCount: encoded.recordCount,
216
+ pointerRecordCount: pendingPointers.length,
217
+ hasImage: true,
218
+ });
219
+ this.updateRecordCount(context.viewId, encoded.recordCount);
220
+ this.pendingPointerEvents.splice(0, pendingPointers.length);
221
+ this.budget.record(now, saved.byteSize, priorityKey);
222
+ emitReplayDiagnostic({
223
+ type: 'image_saved',
224
+ timestamp: now,
225
+ byteSize: saved.byteSize,
226
+ width: saved.width,
227
+ height: saved.height,
228
+ ...(saved.mimeType ? { mimeType: saved.mimeType } : {}),
229
+ priority: decision.priority,
230
+ byteSizeSource: saved.byteSizeSource,
231
+ });
232
+ this.lastFingerprint = fingerprint;
233
+ this.lastContextKey = contextKey;
234
+ this.lastPrivacyKey = privacyKey;
235
+ this.lastFrameSample = sample;
236
+ this.lastImageSize = { width: saved.width, height: saved.height };
237
+ this.lastViewportSize = viewportSize;
238
+ return true;
239
+ }
240
+ catch (error) {
241
+ if (generation !== this.captureGeneration)
242
+ return false;
243
+ emitReplayDiagnostic({ type: 'capture_skipped', timestamp: Date.now(), reason: 'error' });
244
+ console.error('[cocos-sdk] Session Replay frame dropped:', error);
245
+ if (context && pointerSize) {
246
+ try {
247
+ return this.writePendingPointers(context, pointerSize.width, pointerSize.height);
248
+ }
249
+ catch (pointerError) {
250
+ console.error('[cocos-sdk] Session Replay pointer segment dropped:', pointerError);
251
+ }
252
+ }
253
+ return false;
254
+ }
255
+ finally {
256
+ try {
257
+ if (stored)
258
+ await this.capture.disposeStoredFrame(stored);
259
+ }
260
+ finally {
261
+ this.busy = false;
262
+ }
263
+ }
264
+ }
265
+ startCapture() {
266
+ this.captureGeneration += 1;
267
+ this.running = true;
268
+ this.lastFingerprint = undefined;
269
+ this.lastContextKey = undefined;
270
+ this.lastPrivacyKey = undefined;
271
+ this.lastFrameSample = undefined;
272
+ this.lastImageSize = undefined;
273
+ this.lastViewportSize = undefined;
274
+ this.budget.reset();
275
+ this.recordCounts.clear();
276
+ this.pendingPointerEvents = [];
277
+ if (this.recordTouches && this.pointerSource) {
278
+ this.stopPointerTracking = this.pointerSource.onReplayPointer((event) => {
279
+ emitReplayDiagnostic({
280
+ type: 'pointer_received',
281
+ timestamp: event.timestamp,
282
+ eventType: event.eventType,
283
+ });
284
+ this.pendingPointerEvents.push(event);
285
+ if (this.pendingPointerEvents.length > MAX_PENDING_POINTER_EVENTS) {
286
+ this.pendingPointerEvents.splice(0, this.pendingPointerEvents.length - MAX_PENDING_POINTER_EVENTS);
287
+ }
288
+ });
289
+ }
290
+ this.schedule(0, this.captureGeneration);
291
+ }
292
+ stopCapture() {
293
+ var _a;
294
+ const wasRunning = this.running;
295
+ this.captureGeneration += 1;
296
+ this.running = false;
297
+ (_a = this.stopPointerTracking) === null || _a === void 0 ? void 0 : _a.call(this);
298
+ this.stopPointerTracking = undefined;
299
+ this.pendingPointerEvents = [];
300
+ if (this.timer !== undefined)
301
+ clearTimeout(this.timer);
302
+ this.timer = undefined;
303
+ if (wasRunning)
304
+ emitReplayDiagnostic({ type: 'replay_stopped', timestamp: Date.now() });
305
+ }
306
+ schedule(delay, generation) {
307
+ if (!this.running)
308
+ return;
309
+ this.timer = setTimeout(async () => {
310
+ if (!this.running || generation !== this.captureGeneration)
311
+ return;
312
+ try {
313
+ await this.captureNow();
314
+ }
315
+ catch (error) {
316
+ console.error('[cocos-sdk] Session Replay frame dropped:', error);
317
+ }
318
+ finally {
319
+ if (this.running && generation === this.captureGeneration) {
320
+ this.schedule(1000 / this.config.captureFps, generation);
321
+ }
322
+ }
323
+ }, delay);
324
+ }
325
+ readContext() {
326
+ const value = this.transport.invoke('replay.getContext');
327
+ return normalizeRumContext(value);
328
+ }
329
+ async saveImage(stored, compressionQuality, maxFrameBytes) {
330
+ if (this.imagePolicyEnabled && this.supportsSaveImageV2 !== false) {
331
+ try {
332
+ const value = await this.invokeSaveImage('replay.saveImageV2', {
333
+ path: stored.path,
334
+ width: stored.width,
335
+ height: stored.height,
336
+ quality: compressionQuality,
337
+ maxFrameBytes,
338
+ });
339
+ if (value !== undefined) {
340
+ this.supportsSaveImageV2 = true;
341
+ if (isRejectedSaveImageV2(value))
342
+ return undefined;
343
+ return { ...normalizeSaveImageV2Result(value), byteSizeSource: 'native' };
344
+ }
345
+ this.supportsSaveImageV2 = false;
346
+ }
347
+ catch (error) {
348
+ if (!isUnknownBridgeMethod(error))
349
+ throw error;
350
+ this.supportsSaveImageV2 = false;
351
+ }
352
+ }
353
+ const resourceId = await this.invokeSaveImage('replay.saveImage', {
354
+ path: stored.path,
355
+ width: stored.width,
356
+ height: stored.height,
357
+ });
358
+ if (!resourceId)
359
+ return undefined;
360
+ return {
361
+ resourceId,
362
+ // V1 cannot report encoded size. A conservative frame-limit estimate
363
+ // still prevents configured captureFps from multiplying traffic freely.
364
+ byteSize: maxFrameBytes,
365
+ width: stored.width,
366
+ height: stored.height,
367
+ byteSizeSource: 'frame_limit_estimate',
368
+ ...(this.transport.platform === 'ios' ? { mimeType: 'image/png' } : {}),
369
+ };
370
+ }
371
+ invokeSaveImage(method, payload) {
372
+ return this.transport.invokeAsync
373
+ ? this.transport.invokeAsync(method, payload)
374
+ : Promise.resolve(this.transport.invoke(method, payload));
375
+ }
376
+ writePendingPointers(context, width, height) {
377
+ const pointerEvents = this.scaledPendingPointers(width, height);
378
+ if (pointerEvents.length === 0)
379
+ return false;
380
+ const encoded = encodeReplayPointerRecords({ context, pointerEvents });
381
+ this.transport.invoke('replay.writeSegment', {
382
+ viewId: context.viewId,
383
+ segment: encoded.segment,
384
+ });
385
+ emitReplayDiagnostic({
386
+ type: 'segment_encoded',
387
+ timestamp: Date.now(),
388
+ byteSize: replayUtf8ByteLength(encoded.segment),
389
+ recordCount: encoded.recordCount,
390
+ pointerRecordCount: pointerEvents.length,
391
+ hasImage: false,
392
+ });
393
+ this.updateRecordCount(context.viewId, encoded.recordCount);
394
+ this.pendingPointerEvents.splice(0, pointerEvents.length);
395
+ return true;
396
+ }
397
+ scaledPendingPointers(width, height) {
398
+ return this.pendingPointerEvents.map((event) => ({
399
+ eventType: event.eventType,
400
+ pointerId: event.pointerId,
401
+ x: Math.round(clamp(event.normalizedX, 0, 1) * width),
402
+ y: Math.round(clamp(event.normalizedY, 0, 1) * height),
403
+ timestamp: event.timestamp,
404
+ }));
405
+ }
406
+ updateRecordCount(viewId, added) {
407
+ const count = (this.recordCounts.get(viewId) || 0) + added;
408
+ this.recordCounts.set(viewId, count);
409
+ this.transport.invoke('replay.setRecordCount', { viewId, count });
410
+ }
411
+ }
412
+ function normalizeRumContext(value) {
413
+ if (!value || typeof value !== 'object')
414
+ return undefined;
415
+ const context = value;
416
+ const applicationId = stringValue(context.applicationId, context.application_id);
417
+ const sessionId = stringValue(context.sessionId, context.session_id);
418
+ const viewId = stringValue(context.viewId, context.view_id);
419
+ if (!applicationId || !sessionId || !viewId)
420
+ return undefined;
421
+ const globalContext = context.globalContext;
422
+ return {
423
+ applicationId,
424
+ sessionId,
425
+ viewId,
426
+ ...(globalContext && typeof globalContext === 'object'
427
+ ? { globalContext: globalContext }
428
+ : {}),
429
+ };
430
+ }
431
+ function stringValue(...values) {
432
+ return values.find((value) => typeof value === 'string' && value.length > 0);
433
+ }
434
+ export function normalizeSaveImageV2Result(value) {
435
+ if (!value || typeof value !== 'object')
436
+ throw new TypeError('Invalid replay.saveImageV2 result');
437
+ const result = value;
438
+ const resourceId = stringValue(result.resourceId, result.resource_id);
439
+ const byteSize = numberValue(result.byteSize, result.byte_size);
440
+ const width = numberValue(result.width);
441
+ const height = numberValue(result.height);
442
+ const mimeType = stringValue(result.mimeType, result.mime_type);
443
+ if (!resourceId || !isPositiveInteger(byteSize) || !isPositiveInteger(width) || !isPositiveInteger(height)) {
444
+ throw new TypeError('Invalid replay.saveImageV2 result');
445
+ }
446
+ if (mimeType && !mimeType.startsWith('image/')) {
447
+ throw new TypeError('Invalid replay.saveImageV2 mimeType');
448
+ }
449
+ return {
450
+ resourceId,
451
+ byteSize,
452
+ width,
453
+ height,
454
+ ...(mimeType ? { mimeType: mimeType } : {}),
455
+ };
456
+ }
457
+ function isRejectedSaveImageV2(value) {
458
+ return typeof value === 'object' && value !== null && value.accepted === false;
459
+ }
460
+ function isUnknownBridgeMethod(error) {
461
+ return error instanceof Error && /unknown bridge method|unrecognized selector/i.test(error.message);
462
+ }
463
+ function numberValue(...values) {
464
+ return values.find((value) => typeof value === 'number' && Number.isFinite(value));
465
+ }
466
+ function isPositiveInteger(value) {
467
+ return value !== undefined && Number.isInteger(value) && value > 0;
468
+ }
469
+ export function sampleReplayFrame(rgba, width, height, maximumSamples = 4096) {
470
+ const pixelCount = width * height;
471
+ if (width < 1 || height < 1 || rgba.length < pixelCount * 4) {
472
+ throw new RangeError('Replay frame RGBA data does not match its dimensions');
473
+ }
474
+ const sampleCount = Math.min(maximumSamples, pixelCount);
475
+ const luminance = new Uint8Array(sampleCount);
476
+ for (let index = 0; index < sampleCount; index += 1) {
477
+ const pixel = Math.min(pixelCount - 1, Math.floor(index * pixelCount / sampleCount));
478
+ const offset = pixel * 4;
479
+ luminance[index] = Math.round((rgba[offset] * 54 + rgba[offset + 1] * 183 + rgba[offset + 2] * 19) / 256);
480
+ }
481
+ return { width, height, luminance };
482
+ }
483
+ export function replayFramesLookSimilar(previous, current) {
484
+ if (!previous
485
+ || previous.width !== current.width
486
+ || previous.height !== current.height
487
+ || previous.luminance.length !== current.luminance.length)
488
+ return false;
489
+ let totalDifference = 0;
490
+ let changedSamples = 0;
491
+ for (let index = 0; index < current.luminance.length; index += 1) {
492
+ const difference = Math.abs(current.luminance[index] - previous.luminance[index]);
493
+ totalDifference += difference;
494
+ if (difference >= 12)
495
+ changedSamples += 1;
496
+ }
497
+ const averageDifference = totalDifference / current.luminance.length;
498
+ const changedRatio = changedSamples / current.luminance.length;
499
+ return averageDifference <= 2.5 && changedRatio <= 0.01;
500
+ }
501
+ function privacyRegionsKey(regions) {
502
+ return regions.map((region) => (`${region.mode}:${region.x}:${region.y}:${region.width}:${region.height}`)).join('|');
503
+ }
504
+ export function frameFingerprint(bytes) {
505
+ let hash = 2166136261;
506
+ const stride = Math.max(1, Math.floor(bytes.length / 8192));
507
+ for (let index = 0; index < bytes.length; index += stride) {
508
+ hash ^= bytes[index] || 0;
509
+ hash = Math.imul(hash, 16777619);
510
+ }
511
+ return `${bytes.length.toString(16)}-${(hash >>> 0).toString(16)}`;
512
+ }
513
+ export function applyPrivacyRegions(rgba, width, height, regions) {
514
+ regions.forEach((region) => {
515
+ const startX = clamp(Math.floor(region.x), 0, width);
516
+ const startY = clamp(Math.floor(region.y), 0, height);
517
+ const endX = clamp(Math.ceil(region.x + region.width), 0, width);
518
+ const endY = clamp(Math.ceil(region.y + region.height), 0, height);
519
+ const color = region.mode === 'hide' ? 0 : 128;
520
+ for (let y = startY; y < endY; y += 1) {
521
+ for (let x = startX; x < endX; x += 1) {
522
+ const offset = (y * width + x) * 4;
523
+ rgba[offset] = color;
524
+ rgba[offset + 1] = color;
525
+ rgba[offset + 2] = color;
526
+ rgba[offset + 3] = 255;
527
+ }
528
+ }
529
+ });
530
+ }
531
+ function clamp(value, minimum, maximum) {
532
+ return Math.min(maximum, Math.max(minimum, value));
533
+ }
534
+ //# 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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CAAC,CAAC,CAAC,GAAG,CAAC;QAC/C,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACtC,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE,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,17 @@
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
+ invokeAsync?<T = FTValue>(method: string, payload?: unknown): Promise<T | undefined>;
11
+ }
12
+ export declare class FTNoopTransport implements FTNativeTransport {
13
+ readonly platform: "unsupported";
14
+ invoke<T = FTValue>(_method: string, _payload?: unknown): T | undefined;
15
+ }
16
+ export declare function parseTransportResponse<T>(raw: unknown): T | undefined;
17
+ //# 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;IACtE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CACtF;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":"AAcA,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"}