@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 @@
1
+ {"version":3,"file":"capture.js","sourceRoot":"","sources":["../../../../../src/creator3/capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAG9G,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,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AAC,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC;QACzD,KAAK,CAAC,UAAU,CAAC,SAAS,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC;QAClE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { FTCocosSDK } from '../core/client.js';
2
+ /** Shared SDK entry point for Cocos Creator 3.x applications. */
3
+ export declare const truewatchSdk: FTCocosSDK;
4
+ /**
5
+ * Selects the Cocos Creator 3 camera used to capture Session Replay frames.
6
+ * Call this after the camera is available and before starting Replay.
7
+ *
8
+ * @param camera - Active Cocos `Camera` component.
9
+ */
10
+ export declare function setReplayCamera(camera: unknown): void;
11
+ export * from '../core/index.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/creator3/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAgB/C,iEAAiE;AACjE,eAAO,MAAM,YAAY,YAA0D,CAAC;AAEpF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAErD;AAED,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { FTDefaultAutoTracking } from '../core/auto-tracking.js';
2
+ import { FTCocosSDK } from '../core/client.js';
3
+ import { FTLogger, FTRUM, FTTrace } from '../core/modules.js';
4
+ import { FTCreator3TrackingHooks } from './auto.js';
5
+ import { FTCreator3CanvasCapture } from './capture.js';
6
+ import { FTCreator3Transport } from './transport.js';
7
+ const transport = new FTCreator3Transport();
8
+ const capture = new FTCreator3CanvasCapture();
9
+ const hooks = new FTCreator3TrackingHooks();
10
+ const autoTracking = new FTDefaultAutoTracking(new FTRUM(transport), new FTLogger(transport), new FTTrace(transport), hooks);
11
+ /** Shared SDK entry point for Cocos Creator 3.x applications. */
12
+ export const truewatchSdk = new FTCocosSDK(transport, capture, autoTracking, hooks);
13
+ /**
14
+ * Selects the Cocos Creator 3 camera used to capture Session Replay frames.
15
+ * Call this after the camera is available and before starting Replay.
16
+ *
17
+ * @param camera - Active Cocos `Camera` component.
18
+ */
19
+ export function setReplayCamera(camera) {
20
+ capture.setCamera(camera);
21
+ }
22
+ export * from '../core/index.js';
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/creator3/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,SAAS,GAAG,IAAI,mBAAmB,EAAE,CAAC;AAC5C,MAAM,OAAO,GAAG,IAAI,uBAAuB,EAAE,CAAC;AAC9C,MAAM,KAAK,GAAG,IAAI,uBAAuB,EAAE,CAAC;AAC5C,MAAM,YAAY,GAAG,IAAI,qBAAqB,CAC5C,IAAI,KAAK,CAAC,SAAS,CAAC,EACpB,IAAI,QAAQ,CAAC,SAAS,CAAC,EACvB,IAAI,OAAO,CAAC,SAAS,CAAC,EACtB,KAAK,CACN,CAAC;AAEF,iEAAiE;AACjE,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,UAAU,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;AAEpF;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAe;IAC7C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Waits until a newly attached native RenderTexture is safe to read back.
3
+ *
4
+ * Creator 3 can submit the first draw while the target attachment is still
5
+ * being applied by the native renderer. Keeping the target attached for a
6
+ * second complete draw prevents an empty first Session Replay snapshot.
7
+ */
8
+ export declare function waitForRenderTextureReadback(drawCycle: () => Promise<void>): Promise<void>;
9
+ //# sourceMappingURL=replay-render-cycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-render-cycle.d.ts","sourceRoot":"","sources":["../../../../../src/creator3/replay-render-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAAC,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhG"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Waits until a newly attached native RenderTexture is safe to read back.
3
+ *
4
+ * Creator 3 can submit the first draw while the target attachment is still
5
+ * being applied by the native renderer. Keeping the target attached for a
6
+ * second complete draw prevents an empty first Session Replay snapshot.
7
+ */
8
+ export async function waitForRenderTextureReadback(drawCycle) {
9
+ await drawCycle();
10
+ await drawCycle();
11
+ }
12
+ //# sourceMappingURL=replay-render-cycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-render-cycle.js","sourceRoot":"","sources":["../../../../../src/creator3/replay-render-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,SAA8B;IAC/E,MAAM,SAAS,EAAE,CAAC;IAClB,MAAM,SAAS,EAAE,CAAC;AACpB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type FTNativeTransport } from '../core/transport.js';
2
+ import type { FTValue } from '../core/types.js';
3
+ export declare class FTCreator3Transport implements FTNativeTransport {
4
+ readonly platform: 'android' | 'ios' | 'unsupported';
5
+ invokeAsync<T = FTValue>(method: string, payload?: unknown): Promise<T | undefined>;
6
+ constructor();
7
+ invoke<T = FTValue>(method: string, payload?: unknown): T | undefined;
8
+ }
9
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../../src/creator3/transport.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGhD,qBAAa,mBAAoB,YAAW,iBAAiB;IAC3D,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,KAAK,GAAG,aAAa,CAAC;IAErD,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;;IAcnF,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,GAAG,SAAS;CActE"}
@@ -0,0 +1,28 @@
1
+ import { native, sys } from 'cc';
2
+ import { NATIVE } from 'cc/env';
3
+ import { parseTransportResponse } from '../core/transport.js';
4
+ import { invokeReplayAsync } from '../core/replay-async-transport.js';
5
+ export class FTCreator3Transport {
6
+ invokeAsync(method, payload) {
7
+ return invokeReplayAsync(this, method, payload);
8
+ }
9
+ constructor() {
10
+ this.platform = !NATIVE
11
+ ? 'unsupported'
12
+ : sys.os === sys.OS.ANDROID
13
+ ? 'android'
14
+ : sys.os === sys.OS.IOS
15
+ ? 'ios'
16
+ : 'unsupported';
17
+ }
18
+ invoke(method, payload) {
19
+ if (this.platform === 'unsupported')
20
+ return undefined;
21
+ const json = payload === undefined ? '{}' : JSON.stringify(payload);
22
+ const raw = this.platform === 'android'
23
+ ? native.reflection.callStaticMethod('com/ft/sdk/cocos/FTCocosBridge', 'invoke', '(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;', method, json)
24
+ : native.reflection.callStaticMethod('FTCocosBridge', 'invoke:payload:', method, json);
25
+ return parseTransportResponse(raw);
26
+ }
27
+ }
28
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../../../src/creator3/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,MAAM,OAAO,mBAAmB;IAG9B,WAAW,CAAc,MAAc,EAAE,OAAiB;QACxD,OAAO,iBAAiB,CAAI,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED;QACE,IAAI,CAAC,QAAQ,GAAG,CAAC,MAAM;YACrB,CAAC,CAAC,aAAa;YACf,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,OAAO;gBACzB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,GAAG;oBACrB,CAAC,CAAC,KAAK;oBACP,CAAC,CAAC,aAAa,CAAC;IACxB,CAAC;IAED,MAAM,CAAc,MAAc,EAAE,OAAiB;QACnD,IAAI,IAAI,CAAC,QAAQ,KAAK,aAAa;YAAE,OAAO,SAAS,CAAC;QACtD,MAAM,IAAI,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,KAAK,SAAS;YACrC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAChC,gCAAgC,EAChC,QAAQ,EACR,0DAA0D,EAC1D,MAAM,EACN,IAAI,CACL;YACH,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,eAAe,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QACzF,OAAO,sBAAsB,CAAI,GAAG,CAAC,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,385 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { execFileSync } = require('child_process');
6
+
7
+ const BEGIN = '/* COCOS_SDK_BEGIN */';
8
+ const END = '/* COCOS_SDK_END */';
9
+ const POD_BEGIN = '# COCOS_SDK_BEGIN';
10
+ const POD_END = '# COCOS_SDK_END';
11
+ const XCCONFIG_BEGIN = '// COCOS_SDK_BEGIN';
12
+ const XCCONFIG_END = '// COCOS_SDK_END';
13
+ const LEGACY_BEGIN = '/* FT_COCOS_SDK_BEGIN */';
14
+ const LEGACY_END = '/* FT_COCOS_SDK_END */';
15
+ const LEGACY_POD_BEGIN = '# FT_COCOS_SDK_BEGIN';
16
+ const LEGACY_POD_END = '# FT_COCOS_SDK_END';
17
+ const LEGACY_XCCONFIG_BEGIN = '// FT_COCOS_SDK_BEGIN';
18
+ const LEGACY_XCCONFIG_END = '// FT_COCOS_SDK_END';
19
+
20
+ function installNative(buildRoot, extensionRoot, logger = console) {
21
+ if (!buildRoot) return;
22
+ buildRoot = path.resolve(buildRoot);
23
+ extensionRoot = path.resolve(extensionRoot);
24
+ if (!fs.existsSync(buildRoot)) return;
25
+ const nativeSource = path.join(extensionRoot, 'native');
26
+ if (!fs.existsSync(nativeSource)) {
27
+ logger.warn(`[cocos-sdk] Native bridge not found at ${nativeSource}`);
28
+ return;
29
+ }
30
+ const buildNative = path.join(buildRoot, 'cocos-sdk-native');
31
+ copyDirectory(nativeSource, buildNative);
32
+ const files = findFiles(buildRoot, 7);
33
+ const replayHeader = path.join(buildNative, 'shared', 'FTReplayFileBridge.h');
34
+ if (fs.existsSync(replayHeader)) {
35
+ findReplayEntryFiles(files)
36
+ .forEach((file) => patchReplayFileBridge(file, replayHeader));
37
+ }
38
+ const gradlePropertiesFiles = files.filter((file) => path.basename(file) === 'gradle.properties');
39
+ const gradleFiles = uniqueFiles([
40
+ ...files.filter((file) => /(?:^|\/)app\/build\.gradle$/.test(normalize(file))),
41
+ ...gradlePropertiesFiles.flatMap(findNativeAppGradleFiles),
42
+ ]);
43
+ const podfiles = files.filter((file) => path.basename(file) === 'Podfile');
44
+ const xcodeProjects = files.filter((file) => (
45
+ path.basename(file) === 'project.pbxproj' && path.extname(path.dirname(file)) === '.xcodeproj'
46
+ ));
47
+ const iosApplicationProjects = xcodeProjects
48
+ .map((projectFile) => ({ projectFile, target: findIosApplicationTarget(projectFile) }))
49
+ .filter((project) => project.target);
50
+ if (podfiles.length === 0) {
51
+ iosApplicationProjects.forEach(({ projectFile, target }) => {
52
+ const projectDirectory = path.dirname(path.dirname(projectFile));
53
+ const podfile = path.join(projectDirectory, 'Podfile');
54
+ if (!fs.existsSync(podfile)) createPodfile(podfile, projectFile, target);
55
+ podfiles.push(podfile);
56
+ });
57
+ }
58
+ iosApplicationProjects.forEach(({ projectFile, target }) => {
59
+ patchCocos2IosConfiguration(projectFile, target);
60
+ });
61
+ gradleFiles.forEach((file) => patchGradle(file, buildNative));
62
+ gradlePropertiesFiles.forEach(patchGradleProperties);
63
+ podfiles.forEach((file) => patchPodfile(file, buildNative));
64
+ logger.info(
65
+ `[cocos-sdk] Installed native bridge (${gradleFiles.length} Android, ${podfiles.length} iOS project files).`,
66
+ );
67
+ }
68
+
69
+ function patchReplayFileBridge(file, header) {
70
+ const original = fs.readFileSync(file, 'utf8');
71
+ const includeBegin = '// COCOS_SDK_REPLAY_INCLUDE_BEGIN';
72
+ const includeEnd = '// COCOS_SDK_REPLAY_INCLUDE_END';
73
+ const initBegin = '// COCOS_SDK_REPLAY_INIT_BEGIN';
74
+ const initEnd = '// COCOS_SDK_REPLAY_INIT_END';
75
+ // Creator 3 shares Game.cpp across iOS/Android builds. Keep its include stable
76
+ // when another platform's build directory is cleaned or regenerated.
77
+ const sharedDirectory = path.join(path.dirname(file), 'cocos-sdk-replay');
78
+ const include = `${includeBegin}\n#include "cocos-sdk-replay/FTReplayFileBridge.h"\n${includeEnd}`;
79
+ const init = `${initBegin}\n ft_cocos::installReplayFileBridge();\n ${initEnd}\n `;
80
+ let next = original;
81
+ if (markedPattern(initBegin, initEnd).test(next)) {
82
+ next = next.replace(markedPattern(initBegin, initEnd), init.trimEnd());
83
+ } else {
84
+ const anchor = path.basename(file) === 'Game.cpp'
85
+ ? /\b(?:return\s+)?BaseGame::init\(\);/
86
+ : /\b(?:return\s+)?se->start\(\);/;
87
+ if (!anchor.test(next)) return;
88
+ next = next.replace(anchor, (value) => init + value);
89
+ }
90
+ next = markedPattern(includeBegin, includeEnd).test(next)
91
+ ? next.replace(markedPattern(includeBegin, includeEnd), include)
92
+ : `${include}\n${next}`;
93
+ copyDirectory(path.dirname(header), sharedDirectory);
94
+ if (next !== original) fs.writeFileSync(file, next);
95
+ }
96
+
97
+ function findReplayEntryFiles(files) {
98
+ const entries = files.filter((file) => ['AppDelegate.cpp', 'Game.cpp'].includes(path.basename(file)));
99
+ for (const file of files) {
100
+ let nativeDirectory;
101
+ if (path.basename(file) === 'gradle.properties') {
102
+ const value = readProperty(fs.readFileSync(file, 'utf8'), 'NATIVE_DIR');
103
+ if (value) nativeDirectory = path.resolve(path.dirname(file), value);
104
+ } else if (path.basename(file) === 'CMakeCache.txt') {
105
+ const match = fs.readFileSync(file, 'utf8').match(/^CMAKE_HOME_DIRECTORY:INTERNAL=(.+)$/m);
106
+ if (match) nativeDirectory = match[1].trim();
107
+ }
108
+ if (nativeDirectory) {
109
+ const game = path.resolve(nativeDirectory, '..', 'common', 'Classes', 'Game.cpp');
110
+ if (fs.existsSync(game)) entries.push(game);
111
+ }
112
+ }
113
+ return uniqueFiles(entries);
114
+ }
115
+
116
+ function patchCocos2IosConfiguration(projectFile, target) {
117
+ const projectDirectory = path.dirname(path.dirname(projectFile));
118
+ const iosDirectory = path.join(projectDirectory, 'ios');
119
+ const configurations = ['debug', 'release'];
120
+ const configFiles = configurations.map((configuration) => ({
121
+ configuration,
122
+ file: path.join(iosDirectory, `UserConfigIOS.${configuration}.xcconfig`),
123
+ }));
124
+ if (!configFiles.some(({ file }) => fs.existsSync(file))) return;
125
+
126
+ configFiles.forEach(({ configuration, file }) => {
127
+ if (!fs.existsSync(file)) return;
128
+ replaceMarkedBlock(file, [
129
+ XCCONFIG_BEGIN,
130
+ `#include? "../Pods/Target Support Files/Pods-${target}/Pods-${target}.${configuration}.xcconfig"`,
131
+ `OTHER_LDFLAGS = $(inherited) ${cocos2CompatibilityLinkerFlags()}`,
132
+ XCCONFIG_END,
133
+ ].join('\n'), XCCONFIG_BEGIN, XCCONFIG_END, [
134
+ [LEGACY_XCCONFIG_BEGIN, LEGACY_XCCONFIG_END],
135
+ ]);
136
+ });
137
+
138
+ const original = fs.readFileSync(projectFile, 'utf8');
139
+ let next = quoteWhitespaceProductNames(original).replace(
140
+ /(\b(?:HEADER|LIBRARY)_SEARCH_PATHS\s*=\s*)"([^"]*)";/g,
141
+ (line, prefix, value) => value.includes('$(inherited)')
142
+ ? line
143
+ : `${prefix}"${`$(inherited) ${value}`.trim()}";`,
144
+ );
145
+ next = next.replace(
146
+ /(\bIPHONEOS_DEPLOYMENT_TARGET\s*=\s*)(\d+(?:\.\d+)*)(\s*;)/g,
147
+ (line, prefix, version, suffix) => compareVersions(version, '12.0') < 0
148
+ ? `${prefix}12.0${suffix}`
149
+ : line,
150
+ );
151
+ if (next !== original) fs.writeFileSync(projectFile, next);
152
+ }
153
+
154
+ function quoteWhitespaceProductNames(contents) {
155
+ return contents.replace(
156
+ /^([ \t]*productName[ \t]*=)([^;\r\n]*)(;)$/gm,
157
+ (line, prefix, value, suffix) => {
158
+ const productName = value.trim();
159
+ if (!/[ \t]/.test(productName) || (productName.startsWith('"') && productName.endsWith('"'))) {
160
+ return line;
161
+ }
162
+ const spacing = value.match(/^[ \t]*/)?.[0] || ' ';
163
+ return `${prefix}${spacing}"${productName.replace(/"/g, '\\"')}"${suffix}`;
164
+ },
165
+ );
166
+ }
167
+
168
+ function cocos2CompatibilityLinkerFlags() {
169
+ const flags = ['-lwebp'];
170
+ if (process.platform !== 'darwin') return flags.join(' ');
171
+ try {
172
+ const version = execFileSync('xcodebuild', ['-version'], { encoding: 'utf8' });
173
+ const major = Number((version.match(/^Xcode\s+(\d+)/m) || [])[1]);
174
+ if (major >= 15) flags.push('-Wl,-ld_classic');
175
+ } catch {
176
+ // Xcode is optional when only generating or testing non-iOS projects.
177
+ }
178
+ return flags.join(' ');
179
+ }
180
+
181
+ function patchGradleProperties(file) {
182
+ let contents = fs.readFileSync(file, 'utf8');
183
+ contents = raiseNumericProperty(contents, 'PROP_COMPILE_SDK_VERSION', 34);
184
+ contents = raiseNumericProperty(contents, 'PROP_MIN_SDK_VERSION', 21);
185
+ contents = raiseNumericProperty(contents, 'PROP_TARGET_SDK_VERSION', 34);
186
+ contents = raiseVersionProperty(contents, 'PROP_BUILD_TOOLS_VERSION', '34.0.0');
187
+ contents = enableBooleanProperty(contents, 'android.useAndroidX');
188
+ if (contents !== fs.readFileSync(file, 'utf8')) fs.writeFileSync(file, contents);
189
+ }
190
+
191
+ function findNativeAppGradleFiles(propertiesFile) {
192
+ const contents = fs.readFileSync(propertiesFile, 'utf8');
193
+ const nativeDirectoryValue = readProperty(contents, 'NATIVE_DIR');
194
+ if (!nativeDirectoryValue) return [];
195
+ const nativeDirectory = path.isAbsolute(nativeDirectoryValue)
196
+ ? nativeDirectoryValue
197
+ : path.resolve(path.dirname(propertiesFile), nativeDirectoryValue);
198
+ const gradleFile = path.join(nativeDirectory, 'app', 'build.gradle');
199
+ return fs.existsSync(gradleFile) ? [gradleFile] : [];
200
+ }
201
+
202
+ function readProperty(contents, key) {
203
+ const match = contents.match(new RegExp(`^\\s*${escapeRegExp(key)}\\s*=\\s*(.+?)\\s*$`, 'm'));
204
+ return match && match[1] ? match[1].trim() : null;
205
+ }
206
+
207
+ function uniqueFiles(files) {
208
+ return [...new Set(files.map((file) => path.resolve(file)))];
209
+ }
210
+
211
+ function enableBooleanProperty(contents, key) {
212
+ const pattern = new RegExp(`^(\\s*${escapeRegExp(key)}\\s*=\\s*)(?:true|false)(\\s*)$`, 'mi');
213
+ if (pattern.test(contents)) {
214
+ return contents.replace(pattern, (line, prefix, suffix) => `${prefix}true${suffix}`);
215
+ }
216
+ return `${contents.replace(/\s*$/, '')}\n${key}=true\n`;
217
+ }
218
+
219
+ function raiseNumericProperty(contents, key, minimum) {
220
+ const pattern = new RegExp(`^(\\s*${escapeRegExp(key)}\\s*=\\s*)(-?\\d+)(\\s*)$`, 'm');
221
+ return contents.replace(pattern, (line, prefix, value, suffix) => (
222
+ Number(value) < minimum ? `${prefix}${minimum}${suffix}` : line
223
+ ));
224
+ }
225
+
226
+ function raiseVersionProperty(contents, key, minimum) {
227
+ const pattern = new RegExp(`^(\\s*${escapeRegExp(key)}\\s*=\\s*)(\\d+(?:\\.\\d+)*)(\\s*)$`, 'm');
228
+ return contents.replace(pattern, (line, prefix, value, suffix) => (
229
+ compareVersions(value, minimum) < 0 ? `${prefix}${minimum}${suffix}` : line
230
+ ));
231
+ }
232
+
233
+ function compareVersions(left, right) {
234
+ const leftParts = left.split('.').map(Number);
235
+ const rightParts = right.split('.').map(Number);
236
+ const length = Math.max(leftParts.length, rightParts.length);
237
+ for (let index = 0; index < length; index += 1) {
238
+ const difference = (leftParts[index] || 0) - (rightParts[index] || 0);
239
+ if (difference !== 0) return difference;
240
+ }
241
+ return 0;
242
+ }
243
+
244
+ function patchGradle(file, nativeRoot) {
245
+ const javaDir = normalize(path.join(nativeRoot, 'android', 'src', 'main', 'java'));
246
+ replaceMarkedBlock(file, [
247
+ BEGIN,
248
+ 'android {',
249
+ ` sourceSets { main.java.srcDirs += ['${escapeGroovy(javaDir)}'] }`,
250
+ '}',
251
+ 'repositories {',
252
+ " maven { url 'https://mvnrepo.truewatch.com/repository/maven-releases' }",
253
+ '}',
254
+ 'dependencies {',
255
+ " implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-sdk:1.7.6-alpha02'",
256
+ " implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-native:1.1.3'",
257
+ " implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-session-replay:0.1.9-alpha03'",
258
+ " implementation 'com.google.code.gson:gson:2.10.1'",
259
+ " implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.22')",
260
+ " implementation 'androidx.appcompat:appcompat:1.1.0'",
261
+ " implementation 'androidx.fragment:fragment:1.8.0'",
262
+ '}',
263
+ END,
264
+ ].join('\n'), BEGIN, END, [[LEGACY_BEGIN, LEGACY_END]]);
265
+ }
266
+
267
+ function patchPodfile(file, nativeRoot) {
268
+ const iosDir = normalize(path.join(nativeRoot, 'ios'));
269
+ const block = [
270
+ POD_BEGIN,
271
+ `pod 'FTCocosBridge', :path => '${escapeRuby(iosDir)}'`,
272
+ POD_END,
273
+ ].join('\n');
274
+ const original = fs.readFileSync(file, 'utf8');
275
+ const currentPattern = markedPattern(POD_BEGIN, POD_END);
276
+ const legacyPodPattern = markedPattern(LEGACY_POD_BEGIN, LEGACY_POD_END);
277
+ const legacyPattern = markedPattern(LEGACY_BEGIN, LEGACY_END);
278
+ let next;
279
+ if (currentPattern.test(original)) {
280
+ next = replaceIndentedMarkedBlock(original, POD_BEGIN, POD_END, block);
281
+ } else if (legacyPodPattern.test(original)) {
282
+ next = replaceIndentedMarkedBlock(original, LEGACY_POD_BEGIN, LEGACY_POD_END, block);
283
+ } else if (legacyPattern.test(original)) {
284
+ next = replaceIndentedMarkedBlock(original, LEGACY_BEGIN, LEGACY_END, block);
285
+ } else {
286
+ const targetPattern = /(^[ \t]*target\s+['"][^'"]+['"]\s+do\s*$)/m;
287
+ next = targetPattern.test(original)
288
+ ? original.replace(targetPattern, `$1\n ${block.replace(/\n/g, '\n ')}`)
289
+ : `${original.replace(/\s*$/, '')}\n\n${block}\n`;
290
+ }
291
+ if (next !== original) fs.writeFileSync(file, next);
292
+ }
293
+
294
+ function replaceIndentedMarkedBlock(contents, begin, end, block) {
295
+ const pattern = new RegExp(`(^[\\t ]*)${escapeRegExp(begin)}[\\s\\S]*?${escapeRegExp(end)}`, 'm');
296
+ return contents.replace(pattern, (match, indent) => `${indent}${block.replace(/\n/g, `\n${indent}`)}`);
297
+ }
298
+
299
+ function findIosApplicationTarget(projectFile) {
300
+ const contents = fs.readFileSync(projectFile, 'utf8');
301
+ const nativeTarget = /\/\* ([^*]+) \*\/ = \{\s*isa = PBXNativeTarget;([\s\S]*?)\n\s*\};/g;
302
+ const targets = [];
303
+ let match;
304
+ while ((match = nativeTarget.exec(contents))) {
305
+ if (!/productType = ["']?com\.apple\.product-type\.application["']?;/.test(match[2])) continue;
306
+ const nameMatch = match[2].match(/\n\s*name = ("(?:[^"\\]|\\.)*"|[^;]+);/);
307
+ targets.push(unquotePbxValue(nameMatch ? nameMatch[1] : match[1]));
308
+ }
309
+ return targets.find((target) => /(?:^|[-_.])mobile$/i.test(target))
310
+ || targets.find((target) => /(?:^|[-_.])ios(?:$|[-_.])/i.test(target))
311
+ || targets[0]
312
+ || null;
313
+ }
314
+
315
+ function unquotePbxValue(value) {
316
+ const trimmed = value.trim();
317
+ return trimmed.startsWith('"') && trimmed.endsWith('"')
318
+ ? trimmed.slice(1, -1).replace(/\\"/g, '"')
319
+ : trimmed;
320
+ }
321
+
322
+ function createPodfile(file, projectFile, target) {
323
+ const projectName = path.basename(path.dirname(projectFile));
324
+ fs.writeFileSync(file, [
325
+ "platform :ios, '12.0'",
326
+ `project '${escapeRuby(projectName)}'`,
327
+ '',
328
+ `target '${escapeRuby(target)}' do`,
329
+ 'end',
330
+ '',
331
+ ].join('\n'));
332
+ }
333
+
334
+ function replaceMarkedBlock(file, block, begin = BEGIN, end = END, legacyMarkers = []) {
335
+ const original = fs.readFileSync(file, 'utf8');
336
+ const pattern = markedPattern(begin, end);
337
+ let next;
338
+ if (pattern.test(original)) {
339
+ next = original.replace(pattern, block);
340
+ } else {
341
+ const legacy = legacyMarkers.find(([legacyBegin, legacyEnd]) => (
342
+ markedPattern(legacyBegin, legacyEnd).test(original)
343
+ ));
344
+ next = legacy
345
+ ? original.replace(markedPattern(legacy[0], legacy[1]), block)
346
+ : `${original.replace(/\s*$/, '')}\n\n${block}\n`;
347
+ }
348
+ if (next !== original) fs.writeFileSync(file, next);
349
+ }
350
+
351
+ function markedPattern(begin, end) {
352
+ return new RegExp(`${escapeRegExp(begin)}[\\s\\S]*?${escapeRegExp(end)}`, 'm');
353
+ }
354
+
355
+ function copyDirectory(source, destination) {
356
+ fs.mkdirSync(destination, { recursive: true });
357
+ for (const entry of fs.readdirSync(source, { withFileTypes: true })) {
358
+ const from = path.join(source, entry.name);
359
+ const to = path.join(destination, entry.name);
360
+ if (entry.isDirectory()) copyDirectory(from, to);
361
+ else fs.copyFileSync(from, to);
362
+ }
363
+ }
364
+
365
+ function findFiles(root, maxDepth) {
366
+ const result = [];
367
+ function visit(directory, depth) {
368
+ if (depth > maxDepth) return;
369
+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
370
+ if (entry.name === 'node_modules' || entry.name === '.git') continue;
371
+ const child = path.join(directory, entry.name);
372
+ if (entry.isDirectory()) visit(child, depth + 1);
373
+ else result.push(child);
374
+ }
375
+ }
376
+ visit(root, 0);
377
+ return result;
378
+ }
379
+
380
+ function normalize(value) { return value.split(path.sep).join('/'); }
381
+ function escapeGroovy(value) { return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'"); }
382
+ function escapeRuby(value) { return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'"); }
383
+ function escapeRegExp(value) { return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
384
+
385
+ module.exports = { installNative };
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const { installNative } = require('./install-native.cjs');
5
+
6
+ function onBuildFinished(options, callback) {
7
+ try {
8
+ installNative(options && (options.dest || options.buildPath), __dirname, Editor);
9
+ callback();
10
+ } catch (error) {
11
+ Editor.error(`[cocos-sdk] ${error && error.stack ? error.stack : error}`);
12
+ callback(error);
13
+ }
14
+ }
15
+
16
+ module.exports = {
17
+ load() {
18
+ Editor.Builder.on('build-finished', onBuildFinished);
19
+ },
20
+ unload() {
21
+ Editor.Builder.removeListener('build-finished', onBuildFinished);
22
+ },
23
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "truewatch-cocos-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Observability SDK native build integration for Cocos Creator",
5
+ "main": "main.js"
6
+ }
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ exports.load = function load() {};
4
+ exports.unload = function unload() {};
5
+ exports.configs = {
6
+ '*': {
7
+ hooks: './hooks',
8
+ },
9
+ };
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { installNative } = require('../install-native.cjs');
6
+
7
+ function addCandidate(candidates, value) {
8
+ if (typeof value === 'string' && value.trim() && !/^[a-z][a-z0-9+.-]*:\/\//i.test(value)) {
9
+ candidates.push(value);
10
+ }
11
+ }
12
+
13
+ function collectCandidates(input, candidates) {
14
+ if (typeof input === 'string') {
15
+ addCandidate(candidates, input);
16
+ return;
17
+ }
18
+ if (!input || typeof input !== 'object') return;
19
+ ['dest', 'buildPath', 'outputPath'].forEach((key) => {
20
+ addCandidate(candidates, input[key]);
21
+ });
22
+ if (input.paths && typeof input.paths === 'object') {
23
+ Object.values(input.paths).forEach((value) => addCandidate(candidates, value));
24
+ }
25
+ const projectPath = input.projectPath || input.project;
26
+ if (typeof projectPath === 'string' && typeof input.outputName === 'string') {
27
+ addCandidate(candidates, path.join(projectPath, 'build', input.outputName));
28
+ }
29
+ }
30
+
31
+ function install(...inputs) {
32
+ const candidates = [];
33
+ inputs.forEach((input) => collectCandidates(input, candidates));
34
+ const projectPath = globalThis.Editor && globalThis.Editor.Project && globalThis.Editor.Project.path;
35
+ const taskOptions = inputs.find((input) => input && typeof input === 'object' && input.outputName);
36
+ if (projectPath && taskOptions) {
37
+ addCandidate(candidates, path.join(projectPath, 'build', taskOptions.outputName));
38
+ }
39
+
40
+ candidates.slice().forEach((candidate) => {
41
+ const buildParent = path.dirname(candidate);
42
+ if (path.basename(buildParent) === 'build') addCandidate(candidates, path.dirname(buildParent));
43
+ });
44
+
45
+ const visited = new Set();
46
+ const normalizedCandidates = candidates.map((candidate) => {
47
+ let normalized = path.resolve(candidate);
48
+ if (fs.existsSync(normalized) && fs.statSync(normalized).isFile()) {
49
+ normalized = path.dirname(normalized);
50
+ }
51
+ return normalized;
52
+ }).sort((left, right) => left.split(path.sep).length - right.split(path.sep).length);
53
+ normalizedCandidates.forEach((normalized) => {
54
+ if (visited.has(normalized)) return;
55
+ visited.add(normalized);
56
+ installNative(normalized, path.resolve(__dirname, '..'), console);
57
+ });
58
+ }
59
+
60
+ exports.onBeforeMake = async function onBeforeMake(root) {
61
+ install(root);
62
+ };
63
+
64
+ exports.onAfterMake = async function onAfterMake(root) {
65
+ install(root);
66
+ };
67
+
68
+ exports.onAfterBuild = async function onAfterBuild(options, result) {
69
+ install(options, result);
70
+ };
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ exports.load = function load() {};
4
+ exports.unload = function unload() {};