gdharness 1.3.8 → 1.3.10

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 (78) hide show
  1. package/build/cli.js +4668 -3229
  2. package/build/godot/addons/gdharness_editor/animation_reads.gd +115 -4
  3. package/build/godot/addons/gdharness_editor/declared_values.gd +272 -0
  4. package/build/godot/addons/gdharness_editor/file_reads.gd +115 -18
  5. package/build/godot/addons/gdharness_editor/headless_check.gd +49 -2
  6. package/build/godot/addons/gdharness_editor/property_paths.gd +89 -16
  7. package/build/godot/addons/gdharness_editor/property_values.gd +180 -121
  8. package/build/godot/addons/gdharness_editor/reading.gd +112 -6
  9. package/build/godot/addons/gdharness_editor/scene_file.gd +117 -174
  10. package/build/godot/addons/gdharness_editor/scene_uids.gd +107 -0
  11. package/build/godot/addons/gdharness_editor/scene_uids.gd.uid +1 -0
  12. package/build/godot/addons/gdharness_editor/serialisation.gd +19 -29
  13. package/build/godot/addons/gdharness_editor/setting_reads.gd +121 -0
  14. package/build/godot/addons/gdharness_editor/setting_reads.gd.uid +1 -0
  15. package/build/godot/addons/gdharness_editor/tool_executor.gd +39 -6
  16. package/build/godot/addons/gdharness_editor/tools/animation_states.gd +263 -0
  17. package/build/godot/addons/gdharness_editor/tools/animation_states.gd.uid +1 -0
  18. package/build/godot/addons/gdharness_editor/tools/animation_tools.gd +49 -414
  19. package/build/godot/addons/gdharness_editor/tools/animation_tracks.gd +464 -0
  20. package/build/godot/addons/gdharness_editor/tools/animation_tracks.gd.uid +1 -0
  21. package/build/godot/addons/gdharness_editor/tools/class_tools.gd +37 -0
  22. package/build/godot/addons/gdharness_editor/tools/navigation_bake.gd +221 -0
  23. package/build/godot/addons/gdharness_editor/tools/navigation_bake.gd.uid +1 -0
  24. package/build/godot/addons/gdharness_editor/tools/resource_tools.gd +162 -483
  25. package/build/godot/addons/gdharness_editor/tools/scene_groups.gd +16 -0
  26. package/build/godot/addons/gdharness_editor/tools/scene_kin.gd +8 -4
  27. package/build/godot/addons/gdharness_editor/tools/scene_paths.gd +2 -1
  28. package/build/godot/addons/gdharness_editor/tools/scene_placing.gd +10 -0
  29. package/build/godot/addons/gdharness_editor/tools/scene_tools.gd +151 -8
  30. package/build/godot/addons/gdharness_editor/tools/settings_tools.gd +7 -30
  31. package/build/godot/addons/gdharness_editor/tools/signal_tools.gd +190 -38
  32. package/build/godot/addons/gdharness_editor/tools/tileset_tools.gd +485 -0
  33. package/build/godot/addons/gdharness_editor/tools/tileset_tools.gd.uid +1 -0
  34. package/build/godot/addons/gdharness_editor/value_shapes.gd +128 -1
  35. package/build/godot/addons/gdharness_runtime/call_errors.gd +8 -2
  36. package/build/godot/addons/gdharness_runtime/declared_values.gd +272 -0
  37. package/build/godot/addons/gdharness_runtime/reading.gd +112 -6
  38. package/build/godot/addons/gdharness_runtime/runtime_autoload.gd +35 -3
  39. package/build/godot/addons/gdharness_runtime/runtime_capture.gd +5 -0
  40. package/build/godot/addons/gdharness_runtime/runtime_changes.gd +188 -30
  41. package/build/godot/addons/gdharness_runtime/runtime_input.gd +107 -104
  42. package/build/godot/addons/gdharness_runtime/runtime_mouse.gd +17 -0
  43. package/build/godot/addons/gdharness_runtime/runtime_pad.gd +13 -4
  44. package/build/godot/addons/gdharness_runtime/runtime_paths.gd +320 -27
  45. package/build/godot/addons/gdharness_runtime/runtime_queries.gd +165 -20
  46. package/build/godot/addons/gdharness_runtime/runtime_screen.gd +49 -3
  47. package/build/godot/addons/gdharness_runtime/runtime_targets.gd +31 -2
  48. package/build/godot/addons/gdharness_runtime/runtime_values.gd +250 -10
  49. package/build/godot/addons/gdharness_runtime/runtime_waits.gd +279 -11
  50. package/build/godot/addons/gdharness_runtime/runtime_words.gd +27 -0
  51. package/build/godot/addons/gdharness_runtime/serialisation.gd +19 -29
  52. package/build/godot/addons/gdharness_runtime/value_shapes.gd +128 -1
  53. package/build/godot/operations/animation_reads.gd +115 -4
  54. package/build/godot/operations/audio_buses.gd +93 -7
  55. package/build/godot/operations/classdb_queries.gd +119 -7
  56. package/build/godot/operations/declared_values.gd +272 -0
  57. package/build/godot/operations/dependencies.gd +154 -41
  58. package/build/godot/operations/editor_tools.gd +29 -13
  59. package/build/godot/operations/export_presets.gd +602 -4
  60. package/build/godot/operations/file_reads.gd +115 -18
  61. package/build/godot/operations/gdscript_analysis.gd +14 -0
  62. package/build/godot/operations/gdscript_authoring.gd +12 -2
  63. package/build/godot/operations/godot_operations.gd +18 -2
  64. package/build/godot/operations/import_pipeline.gd +20 -221
  65. package/build/godot/operations/input_actions.gd +127 -51
  66. package/build/godot/operations/project_config.gd +113 -68
  67. package/build/godot/operations/project_diagnostics.gd +4 -0
  68. package/build/godot/operations/project_validation.gd +266 -0
  69. package/build/godot/operations/property_paths.gd +89 -16
  70. package/build/godot/operations/property_values.gd +180 -121
  71. package/build/godot/operations/reading.gd +112 -6
  72. package/build/godot/operations/scene_connections.gd +222 -0
  73. package/build/godot/operations/serialisation.gd +19 -29
  74. package/build/godot/operations/setting_reads.gd +121 -0
  75. package/build/godot/operations/value_shapes.gd +128 -1
  76. package/build/godot/tests/listed.gd +20 -13
  77. package/build/keeper.js +1402 -707
  78. package/package.json +1 -1
@@ -78,12 +78,16 @@ func set_property(params: Dictionary) -> Dictionary:
78
78
  var unwritable: String = GdhPaths.unwritable_copy(chain)
79
79
  if not unwritable.is_empty():
80
80
  return {"type": "error", "message": unwritable}
81
- # The write alone, setter included, which is where a property's cost is.
81
+ # The write alone, setter included, which is where a property's cost is. Listened to as a call
82
+ # is, since a setter refusing a value says why only in what it reports.
83
+ var caught: GdhCallErrors = GdhCallErrors.new()
84
+ OS.add_logger(caught)
82
85
  var began: int = Time.get_ticks_usec()
83
86
  var written: Variant = GdhPaths.write(holder, named, given)
84
87
  if copied:
85
88
  GdhPaths.write_back(chain, written)
86
89
  var elapsed: int = Time.get_ticks_usec() - began
90
+ OS.remove_logger(caught)
87
91
  var now: Variant = GdhPaths.read_under(holder, named)
88
92
  if copied:
89
93
  var again: Dictionary = GdhPaths.walk_to(target, node_path, property)
@@ -122,20 +126,20 @@ func set_property(params: Dictionary) -> Dictionary:
122
126
  )
123
127
  % [named, str(slot["class"]), GdhValues.class_of(refused_object)]
124
128
  )
125
- return {
126
- "type": "error",
127
- "message":
128
- (
129
- "%s.%s was given %s and reads %s afterwards, as it did before: %s."
130
- % [
131
- reached["called"],
132
- named,
133
- JSON.stringify(_values.serialize(given), "", false),
134
- JSON.stringify(_values.serialize(now), "", false),
135
- why,
136
- ]
137
- )
138
- }
129
+ var refused: String = (
130
+ "%s.%s was given %s and reads %s afterwards, as it did before: %s."
131
+ % [
132
+ reached["called"],
133
+ named,
134
+ JSON.stringify(_values.serialize(given), "", false),
135
+ JSON.stringify(_values.serialize(now), "", false),
136
+ why,
137
+ ]
138
+ )
139
+ if not caught.raised.is_empty():
140
+ var reported: PackedStringArray = PackedStringArray(caught.raised.slice(0, ERRORS_KEPT))
141
+ refused += " While it was written the game reported: %s" % "; ".join(reported)
142
+ return {"type": "error", "message": refused}
139
143
 
140
144
  var answer: Dictionary = {
141
145
  "type": "property_set",
@@ -147,6 +151,8 @@ func set_property(params: Dictionary) -> Dictionary:
147
151
  }
148
152
  if already and unmoved:
149
153
  answer["unchanged"] = true
154
+ _keep_reported(answer, "errors", caught.raised)
155
+ _keep_reported(answer, "warnings", caught.warned)
150
156
  # The engine stores a number past an export range, or one no enum value has, as given; only the
151
157
  # inspector holds a property to them, so the game now holds a value its own script never expected.
152
158
  if holder is Object:
@@ -169,6 +175,33 @@ func _argument_for(
169
175
  var holder: Object = reached["holder"]
170
176
  var called: String = reached["called"]
171
177
  var wants: int = _values.parameter_type(holder, named, index)
178
+ var choices: Dictionary = _values.parameter_enum(holder, named, index)
179
+ var values: Dictionary = choices.get("values", {})
180
+ if not choices.is_empty() and sent is String and not str(sent).strip_edges().is_valid_int():
181
+ var chosen: Variant = GdhDeclared.enum_named(values, str(sent))
182
+ if chosen == null:
183
+ return {
184
+ "type": "error",
185
+ "message":
186
+ GdhDeclared.enum_argument_refusal(
187
+ "%s.%s" % [called, named], index, str(choices["enum"]), str(sent), values
188
+ )
189
+ }
190
+ return {"value": chosen}
191
+ # A packed list's elements are fitted one by one, and one that cannot become what the list holds
192
+ # is named: converted whole, a word or a fraction among them became 0 or was cut, and the call ran.
193
+ var packed: Variant = GdhValues.packed_template(wants)
194
+ if packed != null and sent is Array:
195
+ var elements: Dictionary = _values.typed_like(sent, packed, _element_object.bind(node, node_path))
196
+ if elements.has("message"):
197
+ return {
198
+ "type": "error",
199
+ "message":
200
+ (
201
+ "%s.%s takes %s as argument %d: %s"
202
+ % [called, named, type_string(wants), index + 1, elements["message"]]
203
+ )
204
+ }
172
205
  if GdhValues.cuts(sent, wants):
173
206
  return {
174
207
  "type": "error",
@@ -259,6 +292,14 @@ func _value_for(
259
292
  return {"value": by_name[1]}
260
293
  if not str(by_name[1]).is_empty():
261
294
  return {"type": "error", "message": by_name[1]}
295
+ var packed: Variant = GdhValues.packed_template(wanted)
296
+ if packed != null and value is Array:
297
+ var elements: Dictionary = _values.typed_like(value, packed, _element_object.bind(node, node_path))
298
+ if elements.has("message"):
299
+ return {
300
+ "type": "error",
301
+ "message": "%s.%s holds %s: %s" % [called, named, type_string(wanted), elements["message"]]
302
+ }
262
303
  var holds_objects: bool = (
263
304
  declared == TYPE_OBJECT or (declared == TYPE_NIL and (old_value == null or old_value is Object))
264
305
  )
@@ -335,6 +376,52 @@ static func held_already(given: Variant, held: Variant) -> bool:
335
376
  return PackedFloat32Array([given])[0] == PackedFloat32Array([held])[0]
336
377
 
337
378
 
379
+ ## What to do instead of the call [param method] makes on [param sort], the list or map [param
380
+ ## reached] ends on, which a path does not make. A method of the list itself is the likelier aim
381
+ ## than one of what it holds when the list has it: told to call append() on an element, a caller
382
+ ## adding to a list has nowhere to go.
383
+ static func _instead_of_a_call(reached: Dictionary, method: String, sort: String) -> String:
384
+ var own: String = GdhPaths.method_of(str(reached["name"]))
385
+ if own.is_empty():
386
+ own = str(reached["name"])
387
+ var steps: PackedStringArray = GdhPaths.steps_of(method)
388
+ var _shortened: int = steps.resize(steps.size() - 1)
389
+ var holding: String = ":".join(steps)
390
+ var through_a_call: bool = false
391
+ for step: String in steps:
392
+ through_a_call = through_a_call or not GdhPaths.method_of(step).is_empty()
393
+ var the: String = "the " + sort.trim_prefix("a ")
394
+ match GdhPaths.container_method(reached["holder"], own):
395
+ "changes":
396
+ if through_a_call:
397
+ return (
398
+ (
399
+ "%s() changes %s: to change it, call a method of the game that changes it, since %s"
400
+ + " is returned by a call, and runtime_invoke set does not write into what a call returns"
401
+ )
402
+ % [own, the, reached["called"]]
403
+ )
404
+ return (
405
+ (
406
+ "%s() changes %s: to change it, give %s its new value whole with runtime_invoke set,"
407
+ + " property %s, or call a method of the game that changes it"
408
+ )
409
+ % [own, the, reached["called"], holding]
410
+ )
411
+ "reads":
412
+ return (
413
+ (
414
+ "To look in %s with %s(), read %s whole with runtime_inspect property, property %s, and"
415
+ + " look in what comes back"
416
+ )
417
+ % [the, own, reached["called"], holding]
418
+ )
419
+ return (
420
+ "A method of what %s holds is called on the element, as in %s:0:%s"
421
+ % [sort, reached["called"], reached["name"]]
422
+ )
423
+
424
+
338
425
  func call_method(params: Dictionary) -> Dictionary:
339
426
  var node_path: String = str(params.get("path", ""))
340
427
  var method: String = str(params.get("method", ""))
@@ -343,7 +430,33 @@ func call_method(params: Dictionary) -> Dictionary:
343
430
  if node_path.is_empty() or method.is_empty():
344
431
  return {"type": "error", "message": "Node path and method required"}
345
432
 
346
- var standing: Dictionary = GdhValues.target_at(_host.get_tree().root, node_path)
433
+ var root: Node = _host.get_tree().root
434
+ var standing: Dictionary = GdhValues.class_at(root, node_path)
435
+ if standing.is_empty():
436
+ standing = GdhValues.target_at(root, node_path)
437
+ if standing.has("message") and node_path.is_valid_ascii_identifier():
438
+ var classes: Array[String] = []
439
+ for declared: Dictionary in ProjectSettings.get_global_class_list():
440
+ classes.append(str(declared.get("class", "")))
441
+ var close: PackedStringArray = GdhRead.nearest(node_path, PackedStringArray(classes))
442
+ standing["message"] = (
443
+ (
444
+ "%s. No global class is called %s either%s; a static function is called with its"
445
+ + " class's name or its script's res:// path as the path."
446
+ )
447
+ % [
448
+ str(standing["message"]).trim_suffix("."),
449
+ node_path,
450
+ (
451
+ ""
452
+ if close.is_empty()
453
+ else (
454
+ ", and the nearest %s %s"
455
+ % ["is" if close.size() == 1 else "are", ", ".join(close)]
456
+ )
457
+ ),
458
+ ]
459
+ )
347
460
  if standing.has("message"):
348
461
  return standing
349
462
  var node: Node = standing["node"]
@@ -368,13 +481,24 @@ func call_method(params: Dictionary) -> Dictionary:
368
481
  var spelled: String = str(reached["name"])
369
482
  if GdhPaths.method_of(spelled).is_empty():
370
483
  spelled += "()"
371
- # A vector or a transform has no element to call a method on: it is read by its components.
372
- if GdhPaths.composite(reached["holder"]):
484
+ # A vector or a transform has no element to call a method on, so a call it does not answer is
485
+ # refused without the advice about elements below.
486
+ var answers: bool = GdhPaths.can_read(reached["holder"], spelled)
487
+ var called_on: Variant = reached["holder"]
488
+ if (
489
+ (GdhPaths.composite(called_on) or GdhPaths.textual(called_on))
490
+ and not (args.is_empty() and answers)
491
+ ):
373
492
  return {
374
493
  "type": "error",
375
- "message": GdhPaths.nothing_there(reached["holder"], spelled, str(reached["called"]))
494
+ "message":
495
+ (
496
+ "%s:%s takes no arguments" % [reached["called"], spelled]
497
+ if answers
498
+ else GdhPaths.nothing_there(reached["holder"], spelled, str(reached["called"]))
499
+ )
376
500
  }
377
- if args.is_empty() and GdhPaths.can_read(reached["holder"], spelled):
501
+ if args.is_empty() and answers:
378
502
  var read_from: int = Time.get_ticks_usec()
379
503
  var answered: Variant = GdhPaths.read_under(reached["holder"], spelled)
380
504
  var read_for: int = Time.get_ticks_usec() - read_from
@@ -394,20 +518,19 @@ func call_method(params: Dictionary) -> Dictionary:
394
518
  if GdhPaths.can_read(reached["holder"], spelled)
395
519
  else GdhPaths.nothing_there(reached["holder"], spelled, str(reached["called"]))
396
520
  )
397
- return {
398
- "type": "error",
399
- "message":
400
- (
401
- "%s. A method of what %s holds is called on the element, as in %s:0:%s"
402
- % [why, sort, reached["called"], reached["name"]]
403
- )
404
- }
521
+ return {"type": "error", "message": "%s. %s" % [why, _instead_of_a_call(reached, method, sort)]}
405
522
  var holder: Object = reached["holder"]
406
523
  var named: String = reached["name"]
407
524
  # The method a call ends on is the one being called whether or not it carries the brackets a
408
525
  # step along the way would: "get_viewport():gui_get_focus_owner()" is the same call as without
409
526
  # the last pair.
410
- var not_called: String = _not_a_method_to_call(holder, named, str(reached["called"]))
527
+ var not_called: String = _instance_method(
528
+ holder,
529
+ named if GdhPaths.method_of(named).is_empty() else GdhPaths.method_of(named),
530
+ str(reached["called"])
531
+ )
532
+ if not_called.is_empty():
533
+ not_called = _not_a_method_to_call(holder, named, str(reached["called"]))
411
534
  if not not_called.is_empty():
412
535
  return {"type": "error", "message": not_called}
413
536
  if not GdhPaths.method_of(named).is_empty():
@@ -424,6 +547,9 @@ func call_method(params: Dictionary) -> Dictionary:
424
547
  # The object arguments checked only against the engine class, by position from 1, for the refusal
425
548
  # the engine may still make: see [method GdhValues.slot_declared].
426
549
  var by_engine_class: Dictionary = {}
550
+ # The enum arguments given a number none of their values has, said beside the answer: the engine
551
+ # passes any number on, and a write of the same number to a property already said so.
552
+ var outside: PackedStringArray = []
427
553
  for index: int in args.size():
428
554
  var wants: int = _values.parameter_type(holder, named, index)
429
555
  if wants == TYPE_OBJECT and (args[index] is String or args[index] is Dictionary):
@@ -444,6 +570,14 @@ func call_method(params: Dictionary) -> Dictionary:
444
570
  if argument.has("message"):
445
571
  return argument
446
572
  deserialized_args.append(argument["value"])
573
+ var choices: Dictionary = _values.parameter_enum(holder, named, index)
574
+ if not choices.is_empty():
575
+ var values: Dictionary = choices["values"]
576
+ var stray: String = GdhDeclared.outside_enum_argument(
577
+ index, str(choices["enum"]), argument["value"], values
578
+ )
579
+ if not stray.is_empty():
580
+ var _noted: bool = outside.append(stray)
447
581
 
448
582
  # Timed around the call alone, since the bridge's round trip is a second or more and swamps what
449
583
  # one click's work costs; the frame metrics read whichever frame is last, which is not this one.
@@ -491,8 +625,13 @@ func call_method(params: Dictionary) -> Dictionary:
491
625
  }
492
626
  if awaited:
493
627
  answer["awaited"] = true
628
+ if not outside.is_empty():
629
+ answer["outside_declared"] = " ".join(outside)
494
630
  _keep_reported(answer, "errors", caught.raised)
495
631
  _keep_reported(answer, "warnings", caught.warned)
632
+ # Main.explode, ended at a null it called into, answered result 0 as if it had counted something.
633
+ if caught.ended_at.has(named):
634
+ answer["ended_by_error_at"] = caught.ended_at[named]
496
635
  var asked: Variant = params.get("properties")
497
636
  if _reads_the_result(asked):
498
637
  answer.merge(_read_off_result(result, asked))
@@ -529,6 +668,25 @@ static func _not_a_method_to_call(holder: Object, named: String, called: String)
529
668
  return GdhPaths.with_methods_offered("%s has no method %s" % [called, method], holder, method)
530
669
 
531
670
 
671
+ ## Why [param method] cannot be called on [param holder], a script named by its class or its path,
672
+ ## or "": a function that is not static runs on an instance of the class, which the script is not.
673
+ static func _instance_method(holder: Object, method: String, called: String) -> String:
674
+ if not holder is Script:
675
+ return ""
676
+ var script: Script = holder
677
+ for entry: Dictionary in script.get_script_method_list():
678
+ if str(entry.get("name", "")) != method or GdhRead.as_int(entry.get("flags", 0)) & METHOD_FLAG_STATIC:
679
+ continue
680
+ return (
681
+ (
682
+ "%s.%s is not static, so it runs on an instance of the class: call it on a node carrying %s,"
683
+ + " or on an object a path from one reaches"
684
+ )
685
+ % [called, method, script.resource_path]
686
+ )
687
+ return ""
688
+
689
+
532
690
  ## Whether a call's `properties` asks for its result to be read: true, or a list of names.
533
691
  static func _reads_the_result(asked: Variant) -> bool:
534
692
  return asked is Array or (asked is bool and asked)
@@ -610,7 +768,7 @@ static func _argument_count_refused(holder: Object, method: String, given: int)
610
768
  # of the game's frame; a call giving exactly the arguments the method declares needs no walk.
611
769
  if given == holder.get_method_argument_count(method):
612
770
  return ""
613
- for entry: Dictionary in holder.get_method_list():
771
+ for entry: Dictionary in GdhValues.methods_of(holder):
614
772
  if str(entry.get("name", "")) != method:
615
773
  continue
616
774
  var parameters: Array = entry.get("args", [])