@quenty/cmdrservice 13.22.2-canary.547.ba47c62.0 → 13.22.3-canary.550.afa1b3b.0
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/CHANGELOG.md +9 -1
- package/LICENSE.md +1 -1
- package/package.json +10 -10
- package/src/Server/CmdrService.lua +27 -9
- package/src/Shared/CmdrTypes.lua +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [13.22.
|
|
6
|
+
## [13.22.3-canary.550.afa1b3b.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/cmdrservice@13.22.2...@quenty/cmdrservice@13.22.3-canary.550.afa1b3b.0) (2025-04-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/cmdrservice
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [13.22.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/cmdrservice@13.22.0...@quenty/cmdrservice@13.22.2) (2025-04-07)
|
|
7
15
|
|
|
8
16
|
|
|
9
17
|
### Bug Fixes
|
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2014-
|
|
3
|
+
Copyright (c) 2014-2025 James Onnen (Quenty)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/cmdrservice",
|
|
3
|
-
"version": "13.22.
|
|
3
|
+
"version": "13.22.3-canary.550.afa1b3b.0",
|
|
4
4
|
"description": "Bridge between cmdr and Nevermore services using servicebag",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/loader": "10.8.
|
|
29
|
-
"@quenty/maid": "3.4.
|
|
30
|
-
"@quenty/permissionprovider": "14.19.
|
|
31
|
-
"@quenty/promise": "10.10.
|
|
32
|
-
"@quenty/remoting": "12.18.
|
|
33
|
-
"@quenty/servicebag": "11.11.
|
|
34
|
-
"@quenty/string": "3.3.3
|
|
35
|
-
"@quenty/templateprovider": "11.18.
|
|
28
|
+
"@quenty/loader": "10.8.3-canary.550.afa1b3b.0",
|
|
29
|
+
"@quenty/maid": "3.4.3-canary.550.afa1b3b.0",
|
|
30
|
+
"@quenty/permissionprovider": "14.19.3-canary.550.afa1b3b.0",
|
|
31
|
+
"@quenty/promise": "10.10.4-canary.550.afa1b3b.0",
|
|
32
|
+
"@quenty/remoting": "12.18.3-canary.550.afa1b3b.0",
|
|
33
|
+
"@quenty/servicebag": "11.11.4-canary.550.afa1b3b.0",
|
|
34
|
+
"@quenty/string": "3.3.3",
|
|
35
|
+
"@quenty/templateprovider": "11.18.3-canary.550.afa1b3b.0",
|
|
36
36
|
"@quentystudios/cmdr": "^1.12.0-quenty.0"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "afa1b3b99b862698c3ab46009497bd507150867c"
|
|
42
42
|
}
|
|
@@ -16,18 +16,33 @@ local Promise = require("Promise")
|
|
|
16
16
|
local Maid = require("Maid")
|
|
17
17
|
local PermissionService = require("PermissionService")
|
|
18
18
|
local _ServiceBag = require("ServiceBag")
|
|
19
|
+
local _CmdrTypes = require("CmdrTypes")
|
|
19
20
|
|
|
20
21
|
local CmdrService = {}
|
|
21
22
|
CmdrService.ServiceName = "CmdrService"
|
|
22
23
|
|
|
24
|
+
export type CmdrService = typeof(setmetatable(
|
|
25
|
+
{} :: {
|
|
26
|
+
_maid: Maid.Maid,
|
|
27
|
+
_serviceBag: _ServiceBag.ServiceBag,
|
|
28
|
+
_serviceId: string,
|
|
29
|
+
_promiseCmdr: Promise.Promise<any>,
|
|
30
|
+
_cmdrTemplateProviderServer: any,
|
|
31
|
+
_permissionService: PermissionService.PermissionService,
|
|
32
|
+
_definitionData: { [string]: _CmdrTypes.CommandDefinition },
|
|
33
|
+
_executeData: { [string]: (context: _CmdrTypes.CommandContext, ...any) -> string? },
|
|
34
|
+
},
|
|
35
|
+
{} :: typeof({ __index = CmdrService })
|
|
36
|
+
))
|
|
37
|
+
|
|
23
38
|
local GLOBAL_REGISTRY = setmetatable({}, { __mode = "kv" })
|
|
24
39
|
|
|
25
40
|
--[=[
|
|
26
41
|
Initializes the CmdrService. Should be done via [ServiceBag].
|
|
27
42
|
@param serviceBag ServiceBag
|
|
28
43
|
]=]
|
|
29
|
-
function CmdrService
|
|
30
|
-
assert(not self._serviceBag, "Already initialized")
|
|
44
|
+
function CmdrService.Init(self: CmdrService, serviceBag: _ServiceBag.ServiceBag)
|
|
45
|
+
assert(not (self :: any)._serviceBag, "Already initialized")
|
|
31
46
|
self._maid = Maid.new()
|
|
32
47
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
33
48
|
|
|
@@ -55,7 +70,6 @@ function CmdrService:Init(serviceBag: _ServiceBag.ServiceBag)
|
|
|
55
70
|
resolve(cmdr)
|
|
56
71
|
end))
|
|
57
72
|
|
|
58
|
-
|
|
59
73
|
self._definitionData = {}
|
|
60
74
|
self._executeData = {}
|
|
61
75
|
|
|
@@ -100,7 +114,7 @@ end
|
|
|
100
114
|
Returns cmdr
|
|
101
115
|
@return Promise<Cmdr>
|
|
102
116
|
]=]
|
|
103
|
-
function CmdrService
|
|
117
|
+
function CmdrService.PromiseCmdr(self: CmdrService)
|
|
104
118
|
assert(self._promiseCmdr, "Not initialized")
|
|
105
119
|
|
|
106
120
|
return self._promiseCmdr
|
|
@@ -111,8 +125,12 @@ end
|
|
|
111
125
|
@param commandData table
|
|
112
126
|
@param execute (context: table, ... T)
|
|
113
127
|
]=]
|
|
114
|
-
function CmdrService
|
|
115
|
-
|
|
128
|
+
function CmdrService.RegisterCommand(
|
|
129
|
+
self: CmdrService,
|
|
130
|
+
commandData: _CmdrTypes.CommandDefinition,
|
|
131
|
+
execute: (context: _CmdrTypes.CommandContext, ...any) -> string?
|
|
132
|
+
): ()
|
|
133
|
+
assert((self :: any)._promiseCmdr, "Not initialized")
|
|
116
134
|
assert(commandData, "No commandData")
|
|
117
135
|
assert(commandData.Name, "No commandData.Name")
|
|
118
136
|
assert(execute, "No execute")
|
|
@@ -159,7 +177,7 @@ end
|
|
|
159
177
|
@param ... any
|
|
160
178
|
@private
|
|
161
179
|
]=]
|
|
162
|
-
function CmdrService
|
|
180
|
+
function CmdrService.__executeCommand(self: CmdrService, cmdrCommandId: string, ...): string?
|
|
163
181
|
assert(type(cmdrCommandId) == "string", "Bad cmdrCommandId")
|
|
164
182
|
assert(self._promiseCmdr, "CmdrService is not initialized yet")
|
|
165
183
|
|
|
@@ -178,13 +196,13 @@ end
|
|
|
178
196
|
@return CmdrService
|
|
179
197
|
@private
|
|
180
198
|
]=]
|
|
181
|
-
function CmdrService
|
|
199
|
+
function CmdrService.__getServiceFromId(_self: CmdrService, cmdrServiceId: string)
|
|
182
200
|
assert(type(cmdrServiceId) == "string", "Bad cmdrServiceId")
|
|
183
201
|
|
|
184
202
|
return GLOBAL_REGISTRY[cmdrServiceId]
|
|
185
203
|
end
|
|
186
204
|
|
|
187
|
-
function CmdrService
|
|
205
|
+
function CmdrService.Destroy(self: CmdrService)
|
|
188
206
|
self._maid:DoCleaning()
|
|
189
207
|
end
|
|
190
208
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
|
|
3
|
+
export type NamedObject = {
|
|
4
|
+
Name: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type TypeDefinition<T> = {
|
|
8
|
+
DisplayName: string?,
|
|
9
|
+
Prefixes: string?,
|
|
10
|
+
Transform: ((string, Player) -> T)?,
|
|
11
|
+
Validate: ((T) -> (boolean, string?) | boolean)?,
|
|
12
|
+
ValidateOnce: ((T) -> (boolean, string?) | boolean)?,
|
|
13
|
+
Autocomplete: ((T) -> ({ string }, { IsPartial: boolean? }?) | { string })?,
|
|
14
|
+
Parse: (T) -> any,
|
|
15
|
+
Default: ((Player) -> string)?,
|
|
16
|
+
Listable: boolean?,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type CommandArgument = {
|
|
20
|
+
Type: string | TypeDefinition<any>,
|
|
21
|
+
Name: string,
|
|
22
|
+
Description: string,
|
|
23
|
+
Optional: boolean?,
|
|
24
|
+
Default: any?,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type CommandContext = {
|
|
28
|
+
GetData: (self: CommandContext) -> any,
|
|
29
|
+
GetPlayer: (self: CommandContext) -> Player,
|
|
30
|
+
GetArgs: (self: CommandContext) -> { any },
|
|
31
|
+
GetCommandName: (self: CommandContext) -> string,
|
|
32
|
+
GetCommandId: (self: CommandContext) -> string,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type CommandDefinition = {
|
|
36
|
+
Name: string,
|
|
37
|
+
Aliases: { string }?,
|
|
38
|
+
Description: string,
|
|
39
|
+
Group: any?,
|
|
40
|
+
Args: { CommandArgument | (CommandContext) -> CommandArgument },
|
|
41
|
+
Data: ((CommandContext) -> any)?,
|
|
42
|
+
ClientRun: ((CommandContext, ...any) -> string?)?,
|
|
43
|
+
AutoExec: { string }?,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {}
|