dominus-cli 2.0.0 → 2.1.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.
@@ -0,0 +1,2 @@
1
+ -- Replaced with a user-specific token by dominus-install-plugin.
2
+ return "__DOMINUS_BRIDGE_TOKEN__"
@@ -0,0 +1,94 @@
1
+ local Explorer = require(script.Parent.Explorer)
2
+ local InstanceRegistry = require(script.Parent.InstanceRegistry)
3
+ local Mutation = require(script.Parent.Mutation)
4
+ local Properties = require(script.Parent.Properties)
5
+ local Reflection = require(script.Parent.Reflection)
6
+ local TestRunner = require(script.Parent.TestRunner)
7
+ local UIBuilder = require(script.Parent.UIBuilder)
8
+ local Watcher = require(script.Parent.Watcher)
9
+
10
+ local CommandRouter = {}
11
+
12
+ local handlers = {
13
+ ["studio:v2:get_tree"] = function(payload)
14
+ return Explorer.getTreeV2(payload)
15
+ end,
16
+ ["studio:v2:inspect"] = function(payload)
17
+ return Properties.inspectV2(payload)
18
+ end,
19
+ ["studio:v2:get_selection"] = function()
20
+ local Selection = game:GetService("Selection")
21
+ local selected = {}
22
+ for _, instance in Selection:Get() do
23
+ table.insert(selected, {
24
+ name = instance.Name,
25
+ className = instance.ClassName,
26
+ ref = InstanceRegistry.toRef(instance),
27
+ })
28
+ end
29
+ return { success = true, selection = selected }
30
+ end,
31
+ ["studio:v2:read_script"] = function(payload)
32
+ return Explorer.readScriptV2(payload)
33
+ end,
34
+ ["studio:v2:update_script"] = function(payload)
35
+ return Explorer.updateScriptV2(payload)
36
+ end,
37
+ ["studio:v2:apply"] = function(payload)
38
+ return Mutation.apply(payload)
39
+ end,
40
+ ["studio:v2:delete"] = function(payload)
41
+ return Mutation.delete(payload)
42
+ end,
43
+ ["studio:v2:build_ui"] = function(payload)
44
+ return UIBuilder.buildV2(payload)
45
+ end,
46
+ ["studio:v2:snapshot_ui"] = function(payload)
47
+ return UIBuilder.snapshotV2(payload)
48
+ end,
49
+ ["studio:v2:run_test"] = function(payload)
50
+ return TestRunner.executeV2(payload)
51
+ end,
52
+ ["studio:v2:get_output"] = function(payload)
53
+ local result = Watcher.getRecentOutput(math.clamp(payload.limit or 100, 1, 500), payload.level)
54
+ result.success = true
55
+ return result
56
+ end,
57
+ ["studio:v2:get_reflection"] = function(payload)
58
+ if type(payload.className) ~= "string" then
59
+ return { success = false, error = "className must be a string" }
60
+ end
61
+ return Reflection.getClassInfo(payload.className)
62
+ end,
63
+ }
64
+
65
+ function CommandRouter.handle(message, sendResponse)
66
+ if type(message) ~= "table" or type(message.id) ~= "string" or #message.id > 128 then
67
+ return false, "Invalid Dominus request envelope"
68
+ end
69
+ if type(message.type) ~= "string" or type(message.payload) ~= "table" then
70
+ return false, "Invalid Dominus request type or payload"
71
+ end
72
+
73
+ local handler = handlers[message.type]
74
+ if not handler then
75
+ sendResponse(message.id, {
76
+ success = false,
77
+ error = "Command is not allowed by the Dominus 2 plugin: " .. message.type,
78
+ })
79
+ return true
80
+ end
81
+
82
+ task.spawn(function()
83
+ local ok, result = pcall(handler, message.payload)
84
+ if not ok then
85
+ result = { success = false, error = "Command failed: " .. tostring(result) }
86
+ elseif type(result) ~= "table" then
87
+ result = { success = false, error = "Command returned an invalid result" }
88
+ end
89
+ sendResponse(message.id, result)
90
+ end)
91
+ return true
92
+ end
93
+
94
+ return CommandRouter