gdharness 0.4.1
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.
- package/LICENSE +22 -0
- package/README.md +125 -0
- package/build/cli.js +30353 -0
- package/build/godot/addons/auto_reload/auto_reload.gd +89 -0
- package/build/godot/addons/auto_reload/plugin.cfg +6 -0
- package/build/godot/addons/gdharness_editor/bridge_client.gd +197 -0
- package/build/godot/addons/gdharness_editor/plugin.cfg +6 -0
- package/build/godot/addons/gdharness_editor/plugin.gd +88 -0
- package/build/godot/addons/gdharness_editor/tool_executor.gd +104 -0
- package/build/godot/addons/gdharness_editor/tools/animation_tools.gd +397 -0
- package/build/godot/addons/gdharness_editor/tools/play_tools.gd +85 -0
- package/build/godot/addons/gdharness_editor/tools/resource_tools.gd +427 -0
- package/build/godot/addons/gdharness_editor/tools/scene_tools.gd +885 -0
- package/build/godot/addons/gdharness_runtime/runtime_autoload.gd +292 -0
- package/build/godot/addons/gdharness_runtime/runtime_capture.gd +77 -0
- package/build/godot/addons/gdharness_runtime/runtime_input.gd +254 -0
- package/build/godot/addons/gdharness_runtime/runtime_queries.gd +283 -0
- package/build/godot/addons/gdharness_runtime/runtime_values.gd +169 -0
- package/build/godot/addons/gdharness_runtime/runtime_waits.gd +119 -0
- package/build/godot/operations/audio_buses.gd +125 -0
- package/build/godot/operations/class_cache.gd +180 -0
- package/build/godot/operations/classdb_queries.gd +252 -0
- package/build/godot/operations/dependencies.gd +293 -0
- package/build/godot/operations/file_walk.gd +55 -0
- package/build/godot/operations/gdscript_analysis.gd +288 -0
- package/build/godot/operations/gdscript_authoring.gd +419 -0
- package/build/godot/operations/godot_operations.gd +186 -0
- package/build/godot/operations/import_pipeline.gd +390 -0
- package/build/godot/operations/input_actions.gd +237 -0
- package/build/godot/operations/logger.gd +33 -0
- package/build/godot/operations/plugins.gd +159 -0
- package/build/godot/operations/project_config.gd +153 -0
- package/build/godot/operations/project_diagnostics.gd +159 -0
- package/build/godot/operations/resource_files.gd +132 -0
- package/build/godot/operations/serialisation.gd +154 -0
- package/build/index.js +29252 -0
- package/package.json +57 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
extends RefCounted
|
|
2
|
+
|
|
3
|
+
# What each Godot type becomes on the wire, as one table you can read rather than an order you
|
|
4
|
+
# have to trust. Keyed on typeof() rather than written as a chain of `is` tests, because the
|
|
5
|
+
# order mattered: Resource had to be tested before Object or every resource came back as a bare
|
|
6
|
+
# class name with its path dropped, and nothing but a comment said so.
|
|
7
|
+
#
|
|
8
|
+
# Method names rather than Callables: a table of Callables bound to this object is a reference
|
|
9
|
+
# cycle that nothing breaks, so the object outlives the run and the engine reports its script as
|
|
10
|
+
# a resource still in use at exit, on the same stderr the server reads failures off.
|
|
11
|
+
const SERIALISERS: Dictionary = {
|
|
12
|
+
TYPE_NIL: "_serialize_nil",
|
|
13
|
+
TYPE_VECTOR2: "_serialize_vector2",
|
|
14
|
+
TYPE_VECTOR3: "_serialize_vector3",
|
|
15
|
+
TYPE_VECTOR2I: "_serialize_vector2i",
|
|
16
|
+
TYPE_VECTOR3I: "_serialize_vector3i",
|
|
17
|
+
TYPE_COLOR: "_serialize_color",
|
|
18
|
+
TYPE_NODE_PATH: "_serialize_node_path",
|
|
19
|
+
TYPE_ARRAY: "_serialize_array",
|
|
20
|
+
TYPE_RECT2: "_serialize_rect2",
|
|
21
|
+
TYPE_TRANSFORM2D: "_serialize_transform2d",
|
|
22
|
+
TYPE_TRANSFORM3D: "_serialize_transform3d",
|
|
23
|
+
TYPE_DICTIONARY: "_serialize_dictionary",
|
|
24
|
+
TYPE_OBJECT: "_serialize_object",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Converts a Godot value into something JSON can carry. A type with no entry in the table
|
|
29
|
+
# passes through as itself, which is what the JSON-native ones want.
|
|
30
|
+
func serialize_value(value: Variant) -> Variant:
|
|
31
|
+
var serialiser: String = SERIALISERS.get(typeof(value), "")
|
|
32
|
+
return call(serialiser, value) if not serialiser.is_empty() else value
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# Rebuilds a Godot value from the shape serialize_value gave it.
|
|
36
|
+
func deserialize_value(value: Variant) -> Variant:
|
|
37
|
+
if value == null:
|
|
38
|
+
return null
|
|
39
|
+
if value is Array:
|
|
40
|
+
var items: Array = value
|
|
41
|
+
var rebuilt: Array = []
|
|
42
|
+
for item: Variant in items:
|
|
43
|
+
rebuilt.append(deserialize_value(item))
|
|
44
|
+
return rebuilt
|
|
45
|
+
if not value is Dictionary:
|
|
46
|
+
return value
|
|
47
|
+
|
|
48
|
+
var fields: Dictionary = value
|
|
49
|
+
if not fields.has("_type"):
|
|
50
|
+
var rebuilt: Dictionary = {}
|
|
51
|
+
for key: Variant in fields:
|
|
52
|
+
rebuilt[key] = deserialize_value(fields[key])
|
|
53
|
+
return rebuilt
|
|
54
|
+
|
|
55
|
+
match fields["_type"]:
|
|
56
|
+
"Vector2":
|
|
57
|
+
return Vector2(fields.get("x", 0), fields.get("y", 0))
|
|
58
|
+
"Vector3":
|
|
59
|
+
return Vector3(fields.get("x", 0), fields.get("y", 0), fields.get("z", 0))
|
|
60
|
+
"Vector2i":
|
|
61
|
+
return Vector2i(fields.get("x", 0), fields.get("y", 0))
|
|
62
|
+
"Vector3i":
|
|
63
|
+
return Vector3i(fields.get("x", 0), fields.get("y", 0), fields.get("z", 0))
|
|
64
|
+
"Color":
|
|
65
|
+
return Color(fields.get("r", 0), fields.get("g", 0), fields.get("b", 0), fields.get("a", 1))
|
|
66
|
+
"Rect2":
|
|
67
|
+
var position: Variant = deserialize_value(fields.get("position", {}))
|
|
68
|
+
var size: Variant = deserialize_value(fields.get("size", {}))
|
|
69
|
+
return Rect2(position, size)
|
|
70
|
+
"NodePath":
|
|
71
|
+
return NodePath(fields.get("path", ""))
|
|
72
|
+
return fields
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
func _serialize_nil(_value: Variant) -> Variant:
|
|
76
|
+
return null
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
func _serialize_vector2(value: Vector2) -> Dictionary:
|
|
80
|
+
return {"x": value.x, "y": value.y, "_type": "Vector2"}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
func _serialize_vector3(value: Vector3) -> Dictionary:
|
|
84
|
+
return {"x": value.x, "y": value.y, "z": value.z, "_type": "Vector3"}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
func _serialize_vector2i(value: Vector2i) -> Dictionary:
|
|
88
|
+
return {"x": value.x, "y": value.y, "_type": "Vector2i"}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
func _serialize_vector3i(value: Vector3i) -> Dictionary:
|
|
92
|
+
return {"x": value.x, "y": value.y, "z": value.z, "_type": "Vector3i"}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
func _serialize_color(value: Color) -> Dictionary:
|
|
96
|
+
return {"r": value.r, "g": value.g, "b": value.b, "a": value.a, "_type": "Color"}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
func _serialize_node_path(value: NodePath) -> Dictionary:
|
|
100
|
+
return {"path": str(value), "_type": "NodePath"}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
func _serialize_array(value: Array) -> Array:
|
|
104
|
+
return value.map(serialize_value)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
func _serialize_rect2(value: Rect2) -> Dictionary:
|
|
108
|
+
return {
|
|
109
|
+
"position": serialize_value(value.position), "size": serialize_value(value.size), "_type": "Rect2"
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
func _serialize_transform2d(value: Transform2D) -> Dictionary:
|
|
114
|
+
return {
|
|
115
|
+
"origin": serialize_value(value.origin),
|
|
116
|
+
"x": serialize_value(value.x),
|
|
117
|
+
"y": serialize_value(value.y),
|
|
118
|
+
"_type": "Transform2D"
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
func _serialize_transform3d(value: Transform3D) -> Dictionary:
|
|
123
|
+
return {
|
|
124
|
+
"origin": serialize_value(value.origin),
|
|
125
|
+
"basis":
|
|
126
|
+
{
|
|
127
|
+
"x": serialize_value(value.basis.x),
|
|
128
|
+
"y": serialize_value(value.basis.y),
|
|
129
|
+
"z": serialize_value(value.basis.z)
|
|
130
|
+
},
|
|
131
|
+
"_type": "Transform3D"
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
func _serialize_dictionary(value: Dictionary) -> Dictionary:
|
|
136
|
+
var serialised: Dictionary = {}
|
|
137
|
+
for key: Variant in value:
|
|
138
|
+
serialised[str(key)] = serialize_value(value[key])
|
|
139
|
+
return serialised
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
# A pathless Resource says so rather than inventing an empty path for the caller to load.
|
|
143
|
+
#
|
|
144
|
+
# A property that holds no object is Object-typed and null rather than nil, which is most of
|
|
145
|
+
# what a node's property list is, so this is the branch that runs the most.
|
|
146
|
+
func _serialize_object(value: Object) -> Variant:
|
|
147
|
+
if not is_instance_valid(value):
|
|
148
|
+
return null
|
|
149
|
+
if not value is Resource:
|
|
150
|
+
return {"_type": "Object", "class": value.get_class()}
|
|
151
|
+
var resource: Resource = value
|
|
152
|
+
if resource.resource_path.is_empty():
|
|
153
|
+
return {"_type": "Resource", "class": resource.get_class()}
|
|
154
|
+
return {"path": resource.resource_path, "_type": "Resource", "class": resource.get_class()}
|