@mflrevan/ucp 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +1 -1
  2. package/bridge/com.ucp.bridge/CHANGELOG.md +48 -0
  3. package/bridge/com.ucp.bridge/Editor/Bridge/BridgeServer.cs +55 -6
  4. package/bridge/com.ucp.bridge/Editor/Bridge/EditorStateSummary.cs +165 -0
  5. package/bridge/com.ucp.bridge/Editor/Bridge/EditorStateSummary.cs.meta +11 -0
  6. package/bridge/com.ucp.bridge/Editor/Compatibility/UnityObjectCompat.cs +22 -5
  7. package/bridge/com.ucp.bridge/Editor/Controllers/EditorController.cs +1 -0
  8. package/bridge/com.ucp.bridge/Editor/Controllers/HierarchyController.cs +10 -10
  9. package/bridge/com.ucp.bridge/Editor/Controllers/LogsController.cs +71 -0
  10. package/bridge/com.ucp.bridge/Editor/Controllers/MaterialController.cs +2 -2
  11. package/bridge/com.ucp.bridge/Editor/Controllers/ObjectLocator.cs +4 -4
  12. package/bridge/com.ucp.bridge/Editor/Controllers/ObjectReferenceResolver.cs +3 -3
  13. package/bridge/com.ucp.bridge/Editor/Controllers/PrefabController.cs +6 -6
  14. package/bridge/com.ucp.bridge/Editor/Controllers/PropertyController.cs +7 -7
  15. package/bridge/com.ucp.bridge/Editor/Controllers/RecordingController.cs +8 -0
  16. package/bridge/com.ucp.bridge/Editor/Controllers/SceneChangeTracker.cs +3 -3
  17. package/bridge/com.ucp.bridge/Editor/Controllers/SceneController.cs +3 -3
  18. package/bridge/com.ucp.bridge/Editor/Controllers/SnapshotController.cs +5 -5
  19. package/bridge/com.ucp.bridge/Editor/Controllers/TestRunnerController.cs +1 -1
  20. package/bridge/com.ucp.bridge/Editor/Controllers/TransformController.cs +1 -1
  21. package/bridge/com.ucp.bridge/Editor/Controllers/UiController.cs +70 -0
  22. package/bridge/com.ucp.bridge/Editor/Controllers/UiController.cs.meta +11 -0
  23. package/bridge/com.ucp.bridge/Editor/Controllers/ViewController.cs +1 -1
  24. package/bridge/com.ucp.bridge/Editor/Protocol/MiniJson.cs +1 -1
  25. package/bridge/com.ucp.bridge/Editor/Ui/UiHost.cs +468 -0
  26. package/bridge/com.ucp.bridge/Editor/Ui/UiHost.cs.meta +11 -0
  27. package/bridge/com.ucp.bridge/Editor/Ui/UiLintService.cs +554 -0
  28. package/bridge/com.ucp.bridge/Editor/Ui/UiLintService.cs.meta +11 -0
  29. package/bridge/com.ucp.bridge/Editor/Ui/UiOperationManager.cs +870 -0
  30. package/bridge/com.ucp.bridge/Editor/Ui/UiOperationManager.cs.meta +11 -0
  31. package/bridge/com.ucp.bridge/Editor/Ui/UiScenarioApplier.cs +496 -0
  32. package/bridge/com.ucp.bridge/Editor/Ui/UiScenarioApplier.cs.meta +11 -0
  33. package/bridge/com.ucp.bridge/Editor/Ui/UiScenarioLoader.cs +854 -0
  34. package/bridge/com.ucp.bridge/Editor/Ui/UiScenarioLoader.cs.meta +11 -0
  35. package/bridge/com.ucp.bridge/Editor/Ui/UiScenarioModels.cs +374 -0
  36. package/bridge/com.ucp.bridge/Editor/Ui/UiScenarioModels.cs.meta +11 -0
  37. package/bridge/com.ucp.bridge/Editor/Ui/UiVisualTreeInspector.cs +690 -0
  38. package/bridge/com.ucp.bridge/Editor/Ui/UiVisualTreeInspector.cs.meta +11 -0
  39. package/bridge/com.ucp.bridge/{Runtime.meta → Editor/Ui.meta} +1 -1
  40. package/bridge/com.ucp.bridge/Tests/Editor/ControllerSmokeTests.cs +79 -4
  41. package/bridge/com.ucp.bridge/Tests/Editor/SpatialVisualControllerTests.cs +2 -2
  42. package/bridge/com.ucp.bridge/Tests/Editor/UiControllerTests.cs +547 -0
  43. package/bridge/com.ucp.bridge/Tests/Editor/UiControllerTests.cs.meta +11 -0
  44. package/bridge/com.ucp.bridge/Tests/Editor/UiLintServiceTests.cs +253 -0
  45. package/bridge/com.ucp.bridge/Tests/Editor/UiLintServiceTests.cs.meta +11 -0
  46. package/bridge/com.ucp.bridge/Tests/Editor/UiScenarioTests.cs +587 -0
  47. package/bridge/com.ucp.bridge/Tests/Editor/UiScenarioTests.cs.meta +11 -0
  48. package/bridge/com.ucp.bridge/package.json +1 -1
  49. package/package.json +1 -1
  50. package/bridge/com.ucp.bridge/Runtime/UCP.Bridge.Runtime.asmdef +0 -14
  51. package/bridge/com.ucp.bridge/Runtime/UCP.Bridge.Runtime.asmdef.meta +0 -7
@@ -39,7 +39,7 @@ namespace UCP.Bridge
39
39
  if (value is Dictionary<string, object> reference)
40
40
  {
41
41
  if (reference.TryGetValue("instanceId", out var instanceId) && instanceId != null)
42
- return ResolveByInstanceId(Convert.ToInt32(instanceId), propertyName);
42
+ return ResolveByInstanceId(Convert.ToInt64(instanceId), propertyName);
43
43
 
44
44
  if (reference.TryGetValue("path", out var path) && path != null)
45
45
  return ResolveByPath(path.ToString(), propertyName);
@@ -58,12 +58,12 @@ namespace UCP.Bridge
58
58
  }
59
59
 
60
60
  if (value is sbyte || value is byte || value is short || value is ushort || value is int || value is uint || value is long || value is ulong)
61
- return ResolveByInstanceId(Convert.ToInt32(value), propertyName);
61
+ return ResolveByInstanceId(Convert.ToInt64(value), propertyName);
62
62
 
63
63
  throw new ArgumentException($"Unsupported object reference value for '{propertyName}'");
64
64
  }
65
65
 
66
- private static UnityEngine.Object ResolveByInstanceId(int instanceId, string propertyName)
66
+ private static UnityEngine.Object ResolveByInstanceId(long instanceId, string propertyName)
67
67
  {
68
68
  var resolved = UnityObjectCompat.ResolveByInstanceId(instanceId);
69
69
  if (resolved == null)
@@ -26,7 +26,7 @@ namespace UCP.Bridge
26
26
  if (p == null || !p.TryGetValue("instanceId", out var idObj))
27
27
  throw new ArgumentException("Missing 'instanceId' parameter");
28
28
 
29
- var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt32(idObj));
29
+ var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt64(idObj));
30
30
  if (go == null)
31
31
  throw new ArgumentException($"GameObject not found: {idObj}");
32
32
 
@@ -63,7 +63,7 @@ namespace UCP.Bridge
63
63
  if (p == null || !p.TryGetValue("instanceId", out var idObj))
64
64
  throw new ArgumentException("Missing 'instanceId' parameter");
65
65
 
66
- var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt32(idObj));
66
+ var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt64(idObj));
67
67
  if (go == null)
68
68
  throw new ArgumentException($"GameObject not found: {idObj}");
69
69
 
@@ -88,7 +88,7 @@ namespace UCP.Bridge
88
88
  if (p == null || !p.TryGetValue("instanceId", out var idObj))
89
89
  throw new ArgumentException("Missing 'instanceId' parameter");
90
90
 
91
- var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt32(idObj));
91
+ var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt64(idObj));
92
92
  if (go == null)
93
93
  throw new ArgumentException($"GameObject not found: {idObj}");
94
94
 
@@ -116,7 +116,7 @@ namespace UCP.Bridge
116
116
  if (p.TryGetValue("completely", out var compObj))
117
117
  completely = Convert.ToBoolean(compObj);
118
118
 
119
- var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt32(idObj));
119
+ var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt64(idObj));
120
120
  if (go == null)
121
121
  throw new ArgumentException($"GameObject not found: {idObj}");
122
122
 
@@ -147,7 +147,7 @@ namespace UCP.Bridge
147
147
  if (!p.TryGetValue("path", out var pathObj))
148
148
  throw new ArgumentException("Missing 'path' parameter");
149
149
 
150
- var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt32(idObj));
150
+ var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt64(idObj));
151
151
  if (go == null)
152
152
  throw new ArgumentException($"GameObject not found: {idObj}");
153
153
 
@@ -191,7 +191,7 @@ namespace UCP.Bridge
191
191
  if (p == null || !p.TryGetValue("instanceId", out var idObj))
192
192
  throw new ArgumentException("Missing 'instanceId' parameter");
193
193
 
194
- var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt32(idObj));
194
+ var go = UnityObjectCompat.ResolveByInstanceId<GameObject>(Convert.ToInt64(idObj));
195
195
  if (go == null)
196
196
  throw new ArgumentException($"GameObject not found: {idObj}");
197
197
 
@@ -27,7 +27,7 @@ namespace UCP.Bridge
27
27
  throw new ArgumentException("Missing 'instanceId' parameter");
28
28
 
29
29
  var componentType = p.TryGetValue("component", out var cObj) ? cObj?.ToString() : null;
30
- int instanceId = Convert.ToInt32(idObj);
30
+ long instanceId = Convert.ToInt64(idObj);
31
31
  var go = FindGameObject(instanceId);
32
32
 
33
33
  if (componentType != null)
@@ -72,7 +72,7 @@ namespace UCP.Bridge
72
72
  if (!p.TryGetValue("property", out var propObj) || propObj == null)
73
73
  throw new ArgumentException("Missing 'property' parameter");
74
74
 
75
- int instanceId = Convert.ToInt32(idObj);
75
+ long instanceId = Convert.ToInt64(idObj);
76
76
  var go = FindGameObject(instanceId);
77
77
  var comp = FindComponent(go, cObj.ToString());
78
78
  string propName = propObj.ToString();
@@ -100,7 +100,7 @@ namespace UCP.Bridge
100
100
  if (!p.ContainsKey("value"))
101
101
  throw new ArgumentException("Missing 'value' parameter");
102
102
 
103
- int instanceId = Convert.ToInt32(idObj);
103
+ long instanceId = Convert.ToInt64(idObj);
104
104
  var go = FindGameObject(instanceId);
105
105
  var comp = FindComponent(go, cObj.ToString());
106
106
  string propName = propObj.ToString();
@@ -128,7 +128,7 @@ namespace UCP.Bridge
128
128
  if (!p.TryGetValue("active", out var activeObj))
129
129
  throw new ArgumentException("Missing 'active' parameter");
130
130
 
131
- int instanceId = Convert.ToInt32(idObj);
131
+ long instanceId = Convert.ToInt64(idObj);
132
132
  var go = FindGameObject(instanceId);
133
133
 
134
134
  Undo.RecordObject(go, "UCP Set Active");
@@ -153,7 +153,7 @@ namespace UCP.Bridge
153
153
  if (!p.TryGetValue("name", out var nameObj) || nameObj == null)
154
154
  throw new ArgumentException("Missing 'name' parameter");
155
155
 
156
- int instanceId = Convert.ToInt32(idObj);
156
+ long instanceId = Convert.ToInt64(idObj);
157
157
  var go = FindGameObject(instanceId);
158
158
 
159
159
  Undo.RecordObject(go, "UCP Rename");
@@ -532,7 +532,7 @@ namespace UCP.Bridge
532
532
  return Convert.ChangeType(jsonValue, targetType);
533
533
  }
534
534
 
535
- private static GameObject FindGameObject(int instanceId)
535
+ private static GameObject FindGameObject(long instanceId)
536
536
  {
537
537
  var obj = UnityObjectCompat.ResolveByInstanceId<GameObject>(instanceId);
538
538
  if (obj != null) return obj;
@@ -552,7 +552,7 @@ namespace UCP.Bridge
552
552
  throw new ArgumentException($"GameObject not found: {instanceId}");
553
553
  }
554
554
 
555
- private static GameObject FindInHierarchy(GameObject go, int instanceId)
555
+ private static GameObject FindInHierarchy(GameObject go, long instanceId)
556
556
  {
557
557
  if (go.GetId() == instanceId) return go;
558
558
  for (int i = 0; i < go.transform.childCount; i++)
@@ -69,6 +69,14 @@ namespace UCP.Bridge
69
69
  }
70
70
  }
71
71
 
72
+ /// <summary>"recording", "armed", or null when idle -- for the per-response editor summary.</summary>
73
+ internal static string StateForSummary()
74
+ {
75
+ if (s_encoder != null) return "recording";
76
+ if (s_armed != null) return "armed";
77
+ return null;
78
+ }
79
+
72
80
  public static void Shutdown()
73
81
  {
74
82
  if (s_encoder == null) return;
@@ -12,7 +12,7 @@ namespace UCP.Bridge
12
12
  {
13
13
  private sealed class TrackedSceneChange
14
14
  {
15
- public int? InstanceId;
15
+ public long? InstanceId;
16
16
  public string Name;
17
17
  public HashSet<string> Components = new();
18
18
  }
@@ -36,7 +36,7 @@ namespace UCP.Bridge
36
36
  RecordSceneChange(gameObject.scene, gameObject.GetId(), gameObject.name, componentName);
37
37
  }
38
38
 
39
- public static void RecordDeletedObject(Scene scene, int instanceId, string name, string componentName)
39
+ public static void RecordDeletedObject(Scene scene, long instanceId, string name, string componentName)
40
40
  {
41
41
  RecordSceneChange(scene, instanceId, name, componentName);
42
42
  }
@@ -135,7 +135,7 @@ namespace UCP.Bridge
135
135
  }
136
136
  }
137
137
 
138
- private static void RecordSceneChange(Scene scene, int? instanceId, string name, string componentName)
138
+ private static void RecordSceneChange(Scene scene, long? instanceId, string name, string componentName)
139
139
  {
140
140
  if (!scene.IsValid() || !scene.isLoaded)
141
141
  return;
@@ -138,7 +138,7 @@ namespace UCP.Bridge
138
138
  if (parameters == null || !parameters.TryGetValue("instanceId", out var idObj))
139
139
  throw new System.ArgumentException("Missing 'instanceId' parameter");
140
140
 
141
- var instanceId = System.Convert.ToInt32(idObj);
141
+ var instanceId = System.Convert.ToInt64(idObj);
142
142
  var target = FindGameObject(instanceId);
143
143
  var bounds = CalculateFocusBounds(target);
144
144
  var sceneView = SceneView.lastActiveSceneView ?? EditorWindow.GetWindow<SceneView>();
@@ -267,7 +267,7 @@ namespace UCP.Bridge
267
267
  return bounds;
268
268
  }
269
269
 
270
- private static GameObject FindGameObject(int instanceId)
270
+ private static GameObject FindGameObject(long instanceId)
271
271
  {
272
272
  var direct = UnityObjectCompat.ResolveByInstanceId<GameObject>(instanceId);
273
273
  if (direct != null)
@@ -290,7 +290,7 @@ namespace UCP.Bridge
290
290
  throw new System.ArgumentException($"GameObject not found: {instanceId}");
291
291
  }
292
292
 
293
- private static GameObject FindInHierarchy(GameObject gameObject, int instanceId)
293
+ private static GameObject FindInHierarchy(GameObject gameObject, long instanceId)
294
294
  {
295
295
  if (gameObject.GetId() == instanceId)
296
296
  return gameObject;
@@ -156,7 +156,7 @@ namespace UCP.Bridge
156
156
  if (p == null || !p.TryGetValue("instanceId", out var idObj))
157
157
  throw new ArgumentException("Missing 'instanceId' parameter");
158
158
 
159
- int instanceId = Convert.ToInt32(idObj);
159
+ long instanceId = Convert.ToInt64(idObj);
160
160
  int maxDepth = 1;
161
161
  if (p.TryGetValue("depth", out var depthObj))
162
162
  maxDepth = Math.Max(1, Convert.ToInt32(depthObj));
@@ -349,7 +349,7 @@ namespace UCP.Bridge
349
349
  if (p == null || !p.TryGetValue("instanceId", out var idObj))
350
350
  throw new System.ArgumentException("Missing 'instanceId' parameter");
351
351
 
352
- int instanceId = System.Convert.ToInt32(idObj);
352
+ long instanceId = System.Convert.ToInt64(idObj);
353
353
  var go = FindByInstanceId(instanceId);
354
354
  if (go == null)
355
355
  throw new System.Exception($"GameObject not found: {instanceId}");
@@ -383,7 +383,7 @@ namespace UCP.Bridge
383
383
  if (p == null || !p.TryGetValue("instanceId", out var idObj))
384
384
  throw new System.ArgumentException("Missing 'instanceId' parameter");
385
385
 
386
- int instanceId = System.Convert.ToInt32(idObj);
386
+ long instanceId = System.Convert.ToInt64(idObj);
387
387
  var go = FindByInstanceId(instanceId);
388
388
  if (go == null)
389
389
  throw new System.Exception($"GameObject not found: {instanceId}");
@@ -401,7 +401,7 @@ namespace UCP.Bridge
401
401
  };
402
402
  }
403
403
 
404
- private static GameObject FindByInstanceId(int id)
404
+ private static GameObject FindByInstanceId(long id)
405
405
  {
406
406
  var direct = UnityObjectCompat.ResolveByInstanceId<GameObject>(id);
407
407
  if (direct != null)
@@ -424,7 +424,7 @@ namespace UCP.Bridge
424
424
  return null;
425
425
  }
426
426
 
427
- private static GameObject FindInHierarchy(GameObject go, int instanceId)
427
+ private static GameObject FindInHierarchy(GameObject go, long instanceId)
428
428
  {
429
429
  if (go.GetId() == instanceId)
430
430
  return go;
@@ -154,7 +154,7 @@ namespace UCP.Bridge
154
154
  _failed = 0;
155
155
  _skipped = 0;
156
156
  CollectLeafResults(result);
157
- var logSummary = LogsController.BuildStatusSummary(_logCursor);
157
+ var logSummary = LogsController.BuildTestGuardSummary(_logCursor);
158
158
  var consoleWarnings = GetLevelCount(logSummary, "warning");
159
159
  var consoleErrors = GetLevelCount(logSummary, "error") + GetLevelCount(logSummary, "exception");
160
160
 
@@ -148,7 +148,7 @@ namespace UCP.Bridge
148
148
  var list = new List<object>();
149
149
  foreach (var idObj in ids)
150
150
  {
151
- var go = ObjectLocator.FindByInstanceId(Convert.ToInt32(idObj));
151
+ var go = ObjectLocator.FindByInstanceId(Convert.ToInt64(idObj));
152
152
  if (go == null) continue;
153
153
  list.Add(DescribeTransform(go));
154
154
  }
@@ -0,0 +1,70 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+
4
+ namespace UCP.Bridge
5
+ {
6
+ /// <summary>Registers the UI Toolkit discovery, lint, and asynchronous harness methods.</summary>
7
+ public static class UiController
8
+ {
9
+ public static void Register(CommandRouter router)
10
+ {
11
+ #if UNITY_6000_0_OR_NEWER
12
+ router.Register("ui/list", HandleList);
13
+ router.Register("ui/lint", HandleLint);
14
+ router.Register("ui/inspect", parameters => Start("inspect", parameters));
15
+ router.Register("ui/screenshot", parameters => Start("screenshot", parameters));
16
+ router.Register("ui/check", parameters => Start("check", parameters));
17
+ router.Register("ui/status", HandleStatus);
18
+ #else
19
+ router.Register("ui/list", Unsupported);
20
+ router.Register("ui/lint", Unsupported);
21
+ router.Register("ui/inspect", Unsupported);
22
+ router.Register("ui/screenshot", Unsupported);
23
+ router.Register("ui/check", Unsupported);
24
+ router.Register("ui/status", Unsupported);
25
+ #endif
26
+ }
27
+
28
+ #if UNITY_6000_0_OR_NEWER
29
+ private static object HandleList(string paramsJson)
30
+ {
31
+ return UiScenarioLoader.List(ParseParameters(paramsJson));
32
+ }
33
+
34
+ private static object HandleLint(string paramsJson)
35
+ {
36
+ return UiLintService.Run(ParseParameters(paramsJson));
37
+ }
38
+
39
+ private static object Start(string operation, string paramsJson)
40
+ {
41
+ return UiOperationManager.Start(operation, ParseParameters(paramsJson));
42
+ }
43
+
44
+ private static object HandleStatus(string paramsJson)
45
+ {
46
+ var parameters = ParseParameters(paramsJson);
47
+ var operationId = parameters.TryGetValue("operationId", out var value)
48
+ ? value?.ToString()
49
+ : null;
50
+ return UiOperationManager.Status(operationId);
51
+ }
52
+
53
+ private static Dictionary<string, object> ParseParameters(string paramsJson)
54
+ {
55
+ if (string.IsNullOrWhiteSpace(paramsJson))
56
+ return new Dictionary<string, object>(StringComparer.Ordinal);
57
+ var value = MiniJson.Deserialize(paramsJson);
58
+ if (value is not Dictionary<string, object> parameters)
59
+ throw new ArgumentException("UI command parameters must be a JSON object");
60
+ return parameters;
61
+ }
62
+ #else
63
+ private static object Unsupported(string paramsJson)
64
+ {
65
+ throw new ArgumentException(
66
+ "The ucp ui command family requires Unity 6.0 or newer; this project uses an older Unity Editor");
67
+ }
68
+ #endif
69
+ }
70
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 30511693445d48c6a76ea2262ed6ddbf
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -51,7 +51,7 @@ namespace UCP.Bridge
51
51
  Camera cam = null;
52
52
  if (p != null && (p.TryGetValue("camera", out var camObj)) && camObj != null)
53
53
  {
54
- var go = ObjectLocator.FindByInstanceId(Convert.ToInt32(camObj));
54
+ var go = ObjectLocator.FindByInstanceId(Convert.ToInt64(camObj));
55
55
  if (go != null) cam = go.GetComponent<Camera>();
56
56
  if (cam == null) throw new ArgumentException($"No Camera component on object {camObj}");
57
57
  }
@@ -516,7 +516,7 @@ namespace UCP.Bridge
516
516
  }
517
517
 
518
518
  string name;
519
- int id;
519
+ long id;
520
520
  try
521
521
  {
522
522
  name = uo.name;