gdharness 1.1.21 → 1.1.23

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/build/cli.js +1470 -726
  2. package/build/godot/addons/gdharness_editor/bridge_client.gd +12 -2
  3. package/build/godot/addons/gdharness_editor/property_values.gd +484 -65
  4. package/build/godot/addons/gdharness_editor/reading.gd +17 -0
  5. package/build/godot/addons/gdharness_editor/scene_file.gd +229 -0
  6. package/build/godot/addons/gdharness_editor/scene_file.gd.uid +1 -0
  7. package/build/godot/addons/gdharness_editor/serialisation.gd +116 -7
  8. package/build/godot/addons/gdharness_editor/tool_executor.gd +10 -3
  9. package/build/godot/addons/gdharness_editor/tools/animation_tools.gd +374 -242
  10. package/build/godot/addons/gdharness_editor/tools/class_tools.gd +47 -9
  11. package/build/godot/addons/gdharness_editor/tools/filesystem_tools.gd +206 -0
  12. package/build/godot/addons/gdharness_editor/tools/filesystem_tools.gd.uid +1 -0
  13. package/build/godot/addons/gdharness_editor/tools/play_tools.gd +90 -15
  14. package/build/godot/addons/gdharness_editor/tools/resource_tools.gd +373 -140
  15. package/build/godot/addons/gdharness_editor/tools/scene_tools.gd +566 -472
  16. package/build/godot/addons/gdharness_runtime/call_errors.gd +42 -0
  17. package/build/godot/addons/gdharness_runtime/call_errors.gd.uid +1 -0
  18. package/build/godot/addons/gdharness_runtime/reading.gd +17 -0
  19. package/build/godot/addons/gdharness_runtime/runtime_autoload.gd +15 -5
  20. package/build/godot/addons/gdharness_runtime/runtime_capture.gd +51 -5
  21. package/build/godot/addons/gdharness_runtime/runtime_changes.gd +440 -0
  22. package/build/godot/addons/gdharness_runtime/runtime_changes.gd.uid +1 -0
  23. package/build/godot/addons/gdharness_runtime/runtime_input.gd +184 -338
  24. package/build/godot/addons/gdharness_runtime/runtime_paths.gd +89 -16
  25. package/build/godot/addons/gdharness_runtime/runtime_queries.gd +107 -343
  26. package/build/godot/addons/gdharness_runtime/runtime_screen.gd +13 -1
  27. package/build/godot/addons/gdharness_runtime/runtime_targets.gd +90 -24
  28. package/build/godot/addons/gdharness_runtime/runtime_typing.gd +351 -0
  29. package/build/godot/addons/gdharness_runtime/runtime_typing.gd.uid +1 -0
  30. package/build/godot/addons/gdharness_runtime/runtime_values.gd +92 -33
  31. package/build/godot/addons/gdharness_runtime/runtime_waits.gd +61 -28
  32. package/build/godot/addons/gdharness_runtime/serialisation.gd +116 -7
  33. package/build/godot/operations/audio_buses.gd +47 -11
  34. package/build/godot/operations/class_cache.gd +18 -2
  35. package/build/godot/operations/classdb_queries.gd +28 -17
  36. package/build/godot/operations/dependencies.gd +128 -17
  37. package/build/godot/operations/file_walk.gd +20 -0
  38. package/build/godot/operations/gdscript_analysis.gd +59 -20
  39. package/build/godot/operations/gdscript_authoring.gd +127 -60
  40. package/build/godot/operations/godot_operations.gd +24 -5
  41. package/build/godot/operations/import_pipeline.gd +179 -19
  42. package/build/godot/operations/logger.gd +2 -2
  43. package/build/godot/operations/plugins.gd +88 -70
  44. package/build/godot/operations/project_config.gd +41 -6
  45. package/build/godot/operations/project_diagnostics.gd +27 -11
  46. package/build/godot/operations/reading.gd +17 -0
  47. package/build/godot/operations/resource_files.gd +60 -17
  48. package/build/godot/operations/serialisation.gd +116 -7
  49. package/build/index.js +1385 -553
  50. package/build/keeper.js +4 -0
  51. package/package.json +1 -1
@@ -53,6 +53,9 @@ const LIST_TYPES: Array[int] = [
53
53
  # type it wanted.
54
54
  const SERIALISERS: Dictionary = {
55
55
  TYPE_NIL: "_serialize_nil",
56
+ TYPE_FLOAT: "_serialize_float",
57
+ TYPE_PACKED_FLOAT32_ARRAY: "_serialize_floats",
58
+ TYPE_PACKED_FLOAT64_ARRAY: "_serialize_floats",
56
59
  TYPE_VECTOR2: "_serialize_vector2",
57
60
  TYPE_VECTOR2I: "_serialize_vector2i",
58
61
  TYPE_VECTOR3: "_serialize_vector3",
@@ -105,6 +108,8 @@ const BUILDERS: Dictionary = {
105
108
  "Color": "_build_color",
106
109
  "NodePath": "_build_node_path",
107
110
  "PackedByteArray": "_build_bytes",
111
+ "float": "_build_float",
112
+ "Dictionary": "_build_dictionary",
108
113
  }
109
114
 
110
115
  # What each tag has to carry before it is built. A tag naming a type whose keys are not there is a
@@ -130,6 +135,8 @@ const REQUIRED: Dictionary = {
130
135
  "Color": [["r", "g", "b"]],
131
136
  "NodePath": [["path"]],
132
137
  "PackedByteArray": [["base64"]],
138
+ "float": [["value"]],
139
+ "Dictionary": [["entries"]],
133
140
  }
134
141
 
135
142
 
@@ -145,7 +152,58 @@ func serialize_value(value: Variant) -> Variant:
145
152
  if typeof(value) == TYPE_OBJECT and not is_instance_valid(value):
146
153
  return null
147
154
  var serialiser: String = SERIALISERS.get(typeof(value), "")
148
- return call(serialiser, value) if not serialiser.is_empty() else value
155
+ if serialiser.is_empty():
156
+ return value
157
+ var carried: Variant = call(serialiser, value)
158
+ # The fixed shapes carry their components as bare floats, so an infinite one in a Vector2 is
159
+ # tagged here; containers reach their members through this function already.
160
+ return carried if typeof(value) in [TYPE_ARRAY, TYPE_DICTIONARY] else _finite(carried)
161
+
162
+
163
+ # [param carried] with every non-finite float in it tagged. JSON has no spelling for infinity or
164
+ # NaN: the engine writes 1e99999 and null, and the server, reading 1e99999 as Infinity, writes it
165
+ # back out as null, so a property holding INF was answered as holding nothing.
166
+ func _finite(carried: Variant) -> Variant:
167
+ if carried is float:
168
+ var number: float = carried
169
+ return _serialize_float(number)
170
+ if carried is Dictionary:
171
+ var fields: Dictionary = carried
172
+ var tagged: Dictionary = {}
173
+ for key: Variant in fields:
174
+ tagged[key] = _finite(fields[key])
175
+ return tagged
176
+ if carried is Array:
177
+ var items: Array = carried
178
+ var tagged_items: Array = []
179
+ for item: Variant in items:
180
+ tagged_items.append(_finite(item))
181
+ return tagged_items
182
+ return carried
183
+
184
+
185
+ func _serialize_float(value: float) -> Variant:
186
+ if is_finite(value):
187
+ return value
188
+ return {"_type": "float", "value": "nan" if is_nan(value) else ("inf" if value > 0 else "-inf")}
189
+
190
+
191
+ # A packed float array stays the JSON list it is unless something in it has no JSON spelling.
192
+ func _serialize_floats(value: Variant) -> Variant:
193
+ var numbers: Array = []
194
+ if value is PackedFloat32Array:
195
+ var single: PackedFloat32Array = value
196
+ numbers = Array(single)
197
+ else:
198
+ var double: PackedFloat64Array = value
199
+ numbers = Array(double)
200
+ for number: float in numbers:
201
+ if not is_finite(number):
202
+ var items: Array = []
203
+ for each: float in numbers:
204
+ items.append(_serialize_float(each))
205
+ return items
206
+ return value
149
207
 
150
208
 
151
209
  # Rebuilds a Godot value from the shape serialize_value gave it.
@@ -181,9 +239,27 @@ func deserialize_value(value: Variant) -> Variant:
181
239
  var needed: Array = REQUIRED.get(tag, [])
182
240
  if builder.is_empty() or not _carries(fields, needed):
183
241
  return fields
242
+ if tag == "float" and str(fields["value"]) not in ["inf", "-inf", "nan"]:
243
+ return fields
244
+ if tag == "Dictionary" and not pairs(fields["entries"]):
245
+ return fields
184
246
  return call(builder, fields)
185
247
 
186
248
 
249
+ ## Whether [param entries] is a list of [key, value] pairs, as a Dictionary tag carries them.
250
+ static func pairs(entries: Variant) -> bool:
251
+ if not entries is Array:
252
+ return false
253
+ var listed: Array = entries
254
+ for entry: Variant in listed:
255
+ if not entry is Array:
256
+ return false
257
+ var pair: Array = entry
258
+ if pair.size() != 2:
259
+ return false
260
+ return true
261
+
262
+
187
263
  ## Whether two values can be compared without the comparison itself failing.
188
264
  ##
189
265
  ## GDScript's `==` is not total. An Object against a String is a hard error rather than false, and
@@ -193,16 +269,19 @@ func deserialize_value(value: Variant) -> Variant:
193
269
  ## nothing anywhere naming the argument that did it. A wrong argument costs a refusal, never the
194
270
  ## session's game.
195
271
  ##
196
- ## Only an object is special. Every other pair the engine answers, false where they differ, and
197
- ## refusing those would refuse calls that work: an int against a float is the same number to a
198
- ## caller waiting for 1 on a property holding 1.0.
272
+ ## Measured on 4.7.2 over every pair of built-in types: two values of different types compare only
273
+ ## as an int against a float, a String against a StringName, or anything against null. Every other
274
+ ## pair is that error, a word against a number as much as an object against a word, and so is a bool
275
+ ## against an int and a NodePath against a String. An int against a float is kept because it is the
276
+ ## same number to a caller waiting for 1 on a property holding 1.0.
199
277
  static func comparable(one: Variant, other: Variant) -> bool:
200
278
  var left: int = typeof(one)
201
279
  var right: int = typeof(other)
202
- if left != TYPE_OBJECT and right != TYPE_OBJECT:
280
+ if left == right or left == TYPE_NIL or right == TYPE_NIL:
203
281
  return true
204
- # An object compares with another object and with null. Anything else is the error above.
205
- return (left == TYPE_OBJECT or left == TYPE_NIL) and (right == TYPE_OBJECT or right == TYPE_NIL)
282
+ var numbers: Array[int] = [TYPE_INT, TYPE_FLOAT]
283
+ var texts: Array[int] = [TYPE_STRING, TYPE_STRING_NAME]
284
+ return (left in numbers and right in numbers) or (left in texts and right in texts)
206
285
 
207
286
 
208
287
  ## Whether [param value] can be given to something declared as [param type] without damage.
@@ -400,7 +479,16 @@ func _serialize_signal(value: Signal) -> Dictionary:
400
479
  return described
401
480
 
402
481
 
482
+ ## A dictionary keyed by text as itself, and any other as its entries. JSON keys are text, so an
483
+ ## int or Vector2 key was answered as its text, and a dictionary read and written back had its keys
484
+ ## replaced by words: `{1: "a"}` came back as `{"1": "a"}`.
403
485
  func _serialize_dictionary(value: Dictionary) -> Dictionary:
486
+ var texts: bool = value.keys().all(func(key: Variant) -> bool: return key is String or key is StringName)
487
+ if not texts:
488
+ var entries: Array = []
489
+ for key: Variant in value:
490
+ entries.append([serialize_value(key), serialize_value(value[key])])
491
+ return {"_type": "Dictionary", "entries": entries}
404
492
  var serialised: Dictionary = {}
405
493
  for key: Variant in value:
406
494
  serialised[str(key)] = serialize_value(value[key])
@@ -621,6 +709,27 @@ func _build_bytes(fields: Dictionary) -> PackedByteArray:
621
709
  return Marshalls.base64_to_raw(str(fields.get("base64", "")))
622
710
 
623
711
 
712
+ func _build_float(fields: Dictionary) -> float:
713
+ return Read.as_float(fields)
714
+
715
+
716
+ ## The entries of a dictionary whose keys are not all text. JSON carries every number as a float,
717
+ ## and a dictionary keys 1.0 apart from 1, so a whole-number key is built as an int: the key a
718
+ ## game uses far more often, and one JSON cannot tell from the float.
719
+ func _build_dictionary(fields: Dictionary) -> Dictionary:
720
+ var built: Dictionary = {}
721
+ var entries: Array = fields["entries"]
722
+ for entry: Variant in entries:
723
+ var pair: Array = entry
724
+ var key: Variant = deserialize_value(pair[0])
725
+ if key is float:
726
+ var number: float = key
727
+ if is_finite(number) and number == floorf(number):
728
+ key = int(number)
729
+ built[key] = deserialize_value(pair[1])
730
+ return built
731
+
732
+
624
733
  ## One component of a compound value, as the type its constructor wants.
625
734
  ##
626
735
  ## Their own functions because a constructor refuses a Variant under `unsafe_call_argument`, and