cluaupp 1.5.0 → 1.5.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/CHANGELOG.md +47 -0
- package/README.md +10 -5
- package/api/CHANGELOG.md +3 -0
- package/api/chat.js +74 -0
- package/api/fixtures/roblox/README.md +6 -0
- package/api/fixtures/roblox/aux/sample.d.luau +6 -0
- package/api/fixtures/roblox/mini/Mini-API-Dump.json +72 -0
- package/api/generated/bench-latest.json +39 -0
- package/api/generated/capability-profile.json +76 -0
- package/api/generated/lsp-index.json +1 -0
- package/api/generated/luau/classes.d.luau +11221 -0
- package/api/generated/luau/datatypes.d.luau +327 -0
- package/api/generated/luau/enums.d.luau +4918 -0
- package/api/generated/luau/globals.d.luau +12 -0
- package/api/manifests/roblox-target.manifest.json +22 -0
- package/api/normalized/roblox-target.profile.json +237461 -0
- package/api/overrides/classes.json +8 -0
- package/api/overrides/compatibility.json +9 -0
- package/api/overrides/datatypes.json +1579 -0
- package/api/overrides/enums.json +8 -0
- package/api/overrides/globals.json +8 -0
- package/api/overrides/type-mappings.json +9 -0
- package/api/roblox-api.lock.json +9 -0
- package/data/Mini-API-Dump.json +1 -0
- package/editors/vscode/README.md +12 -10
- package/editors/vscode/extension.js +82 -0
- package/editors/vscode/icons/axiom.svg +4 -0
- package/editors/vscode/icons/bloom.svg +5 -0
- package/editors/vscode/icons/helm.svg +4 -0
- package/editors/vscode/icons/hive.svg +5 -0
- package/editors/vscode/icons/mint.svg +4 -0
- package/editors/vscode/icons/shift.svg +6 -0
- package/editors/vscode/language-configuration-schema.json +24 -0
- package/editors/vscode/package.json +172 -12
- package/editors/vscode/snippets/axiom.json +12 -0
- package/editors/vscode/snippets/bloom.json +12 -0
- package/editors/vscode/snippets/helm.json +12 -0
- package/editors/vscode/snippets/hive.json +12 -0
- package/editors/vscode/snippets/mint.json +12 -0
- package/editors/vscode/snippets/shift.json +17 -0
- package/editors/vscode/syntaxes/axiom.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/bloom.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/helm.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/hive.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/mint.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/schema.tmLanguage.json +89 -0
- package/editors/vscode/syntaxes/shift.tmLanguage.json +5 -0
- package/examples/game/.cluaupp/compile-cache/ReplicatedStorage__Shared__Constants__Datas__TemplateData.clh.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Boot__DataBoot.server.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Configuration__ServerConfig.clp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Handlers__Guard.server.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Handlers__PlayerHandler.server.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/StarterPlayer__StarterCharacterScripts__Character__CharacterReady.client.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/StarterPlayer__StarterPlayerScripts__Controllers__DataController.client.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/index.json +12 -0
- package/examples/game/.cluaupp/datamodel-profile.json +94 -0
- package/examples/game/.vscode/settings.json +12 -1
- package/examples/game/include/clpp/datatypes.clh +337 -373
- package/examples/game/include/clpp/generated/datamodel.clh +25 -0
- package/examples/game/include/clpp/generated/enums.clh +1 -1
- package/examples/game/include/clpp/generated/instances.clh +41135 -41064
- package/examples/game/include/clpp/libs/axiom.clh +1 -1
- package/examples/game/include/clpp/libs/math.clh +14 -0
- package/examples/game/include/clpp/libs/spring.clh +17 -0
- package/examples/game/include/clpp/libs/ward.clh +1 -0
- package/examples/game/include/clpp/roblox.clh +3 -4
- package/examples/game/libs/ArrayIndexer/init.luau +209 -0
- package/examples/game/libs/Axiom/init.luau +608 -0
- package/examples/game/libs/Bloom/init.luau +433 -0
- package/examples/game/libs/Coil/init.luau +215 -0
- package/examples/game/libs/Crest/init.luau +426 -0
- package/examples/game/libs/Echo/init.luau +417 -0
- package/examples/game/libs/Ember/init.luau +365 -0
- package/examples/game/libs/Flare/init.luau +717 -0
- package/examples/game/libs/Gleam/init.luau +729 -0
- package/examples/game/libs/Guide/init.luau +215 -0
- package/examples/game/libs/Helm/init.luau +377 -0
- package/examples/game/libs/Hive/init.luau +241 -0
- package/examples/game/libs/Keep/Client.luau +114 -0
- package/examples/game/libs/Keep/Data.luau +883 -0
- package/examples/game/libs/Keep/Engine.luau +211 -0
- package/examples/game/libs/Keep/Enum.luau +6 -0
- package/examples/game/libs/Keep/Enums.luau +10 -0
- package/examples/game/libs/Keep/Path.luau +236 -0
- package/examples/game/libs/Keep/Replicator.luau +298 -0
- package/examples/game/libs/Keep/Server.luau +251 -0
- package/examples/game/libs/Keep/Store.luau +652 -0
- package/examples/game/libs/Keep/Trade.luau +455 -0
- package/examples/game/libs/Keep/init.luau +205 -0
- package/examples/game/libs/Lens/init.luau +609 -0
- package/examples/game/libs/Mint/init.luau +279 -0
- package/examples/game/libs/Net/init.luau +156 -0
- package/examples/game/libs/Net/src/codec.luau +224 -0
- package/examples/game/libs/Occlude/init.luau +117 -0
- package/examples/game/libs/Pin/init.luau +309 -0
- package/examples/game/libs/Promise/LICENSE +21 -0
- package/examples/game/libs/Promise/_impl/LICENSE +21 -0
- package/examples/game/libs/Promise/_impl/init.lua +1991 -0
- package/examples/game/libs/Promise/init.lua +1990 -0
- package/examples/game/libs/Promise/init.luau +13 -0
- package/examples/game/libs/Promise/types.luau +46 -0
- package/examples/game/libs/Roster/init.luau +686 -0
- package/examples/game/libs/SOURCES.md +31 -0
- package/examples/game/libs/Shift/init.luau +238 -0
- package/examples/game/libs/Spark/init.luau +487 -0
- package/examples/game/libs/Stage/init.luau +178 -0
- package/examples/game/libs/Sweep/init.luau +259 -0
- package/examples/game/libs/Trace/init.luau +213 -0
- package/examples/game/libs/Ward/init.luau +211 -0
- package/examples/game/out/ReplicatedStorage/Shared/Constants/Datas/TemplateData.luau +29 -0
- package/examples/game/out/ReplicatedStorage/Shared/Constants/Datas/TemplateData.luau.map.json +13 -0
- package/examples/game/out/ReplicatedStorage/Shared/Net/Net.luau +83 -0
- package/examples/game/out/ReplicatedStorage/Shared/Net/Net.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Boot/DataBoot.server.luau +18 -0
- package/examples/game/out/ServerScriptService/Boot/DataBoot.server.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Configuration/ServerConfig.luau +14 -0
- package/examples/game/out/ServerScriptService/Configuration/ServerConfig.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Handlers/Guard.server.luau +15 -0
- package/examples/game/out/ServerScriptService/Handlers/Guard.server.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Handlers/PlayerHandler.server.luau +50 -0
- package/examples/game/out/ServerScriptService/Handlers/PlayerHandler.server.luau.map.json +13 -0
- package/examples/game/out/StarterPlayer/StarterCharacterScripts/Character/CharacterReady.client.luau +12 -0
- package/examples/game/out/StarterPlayer/StarterCharacterScripts/Character/CharacterReady.client.luau.map.json +13 -0
- package/examples/game/out/StarterPlayer/StarterPlayerScripts/Controllers/DataController.client.luau +16 -0
- package/examples/game/out/StarterPlayer/StarterPlayerScripts/Controllers/DataController.client.luau.map.json +13 -0
- package/examples/game/src/ReplicatedStorage/Shared/Net/Net.clh +26 -0
- package/examples/game/src/ServerScriptService/Boot/DataBoot.server.clpp +1 -1
- package/examples/game/src/ServerScriptService/Handlers/PlayerHandler.server.clpp +1 -1
- package/examples/game/stylua.toml +9 -0
- package/generated/api/build-profile.js +115 -0
- package/generated/api/cache.js +44 -0
- package/generated/api/coverage.js +32 -0
- package/generated/api/diff.js +125 -0
- package/generated/api/generators/clpp-headers.js +353 -0
- package/generated/api/generators/docs-reference.js +7 -0
- package/generated/api/generators/lsp-index.js +81 -0
- package/generated/api/generators/luau-defs.js +94 -0
- package/generated/api/ide.js +76 -0
- package/generated/api/identifier.js +47 -0
- package/generated/api/index.js +324 -0
- package/generated/api/loader.js +57 -0
- package/generated/api/merge.js +88 -0
- package/generated/api/model.js +5 -0
- package/generated/api/normalize.js +231 -0
- package/generated/api/overrides-validate.js +58 -0
- package/generated/api/perf.js +12 -0
- package/generated/api/registry.js +136 -0
- package/generated/api/release.js +44 -0
- package/generated/api/resolver.js +250 -0
- package/generated/api/sources/aux-types-diff.js +75 -0
- package/generated/api/sources/client-tracker.js +11 -0
- package/generated/api/sources/creator-docs.js +42 -0
- package/generated/api/sources/luau-types.js +34 -0
- package/generated/api/sources/mini-dump.js +17 -0
- package/generated/api/sources/studio-api.js +8 -0
- package/generated/api/sources/studio-apiv2.js +11 -0
- package/generated/api/sources/studio-full-api.js +8 -0
- package/generated/api/studio-smoke.js +80 -0
- package/generated/api/type-parse.js +49 -0
- package/generated/api/understander.js +51 -0
- package/generated/api/validate.js +135 -0
- package/generated/api-cli.js +421 -0
- package/generated/cli.js +16 -5
- package/generated/clpp/contract.js +3 -3
- package/generated/clpp/format-luau.js +236 -0
- package/generated/clpp/index.js +13 -1
- package/generated/clpp/modules.js +227 -0
- package/generated/clpp/postprocess.js +86 -5
- package/generated/clpp/rewrite-janitor.js +145 -0
- package/generated/clpp/runner.js +14 -2
- package/generated/compile.js +82 -0
- package/generated/flare/parse.js +12 -1
- package/generated/intellisense.js +57 -1
- package/generated/native/index.js +217 -16
- package/generated/target/authority-check.js +136 -0
- package/generated/target/authority-graph.js +74 -0
- package/generated/target/build-cache.js +112 -0
- package/generated/target/capabilities.js +89 -0
- package/generated/target/capability-profile.js +30 -0
- package/generated/target/component-contracts.js +60 -0
- package/generated/target/context-check.js +160 -0
- package/generated/target/datamodel-check.js +170 -0
- package/generated/target/datamodel-generate.js +74 -0
- package/generated/target/datamodel.js +233 -0
- package/generated/target/diagnostics.js +63 -0
- package/generated/target/doctor.js +152 -0
- package/generated/target/flare-version.js +58 -0
- package/generated/target/get-service.js +69 -0
- package/generated/target/lifetime-check.js +47 -0
- package/generated/target/luau-stamp.js +39 -0
- package/generated/target/optimizer-advise.js +88 -0
- package/generated/target/optimizer-apply.js +44 -0
- package/generated/target/optimizer-soa.js +254 -0
- package/generated/target/parallel-check.js +136 -0
- package/generated/target/pgo.js +148 -0
- package/generated/target/project-docs.js +69 -0
- package/generated/target/project-graph.js +71 -0
- package/generated/target/roblox.js +63 -0
- package/generated/target/security-check.js +41 -0
- package/generated/target/source-map.js +25 -0
- package/generated/target/studio-bridge.js +112 -0
- package/generated/utils/project.js +178 -8
- package/generated/utils/rojo-mapper.js +11 -3
- package/include/clpp/datatypes.clh +337 -373
- package/include/clpp/generated/enums.clh +1 -1
- package/include/clpp/generated/instances.clh +41135 -41064
- package/include/clpp/libs/axiom.clh +1 -1
- package/include/clpp/libs/hive.clh +1 -0
- package/include/clpp/libs/keep.clh +2 -0
- package/include/clpp/libs/math.clh +14 -0
- package/include/clpp/libs/spring.clh +17 -0
- package/include/clpp/libs/ward.clh +1 -0
- package/include/clpp/roblox.clh +3 -4
- package/package.json +10 -3
- package/plugins/CluauppNav/Plugin.luau +207 -0
- package/plugins/CluauppNav/ProfileLogger.luau +27 -0
- package/plugins/CluauppNav/README.md +24 -0
- package/runtime/Axiom/init.luau +10 -7
- package/runtime/Coil/init.luau +8 -2
- package/runtime/Crest/init.luau +1 -0
- package/runtime/Flare/init.luau +2 -1
- package/runtime/Gleam/init.luau +15 -4
- package/runtime/Hive/init.luau +36 -14
- package/runtime/Pin/init.luau +5 -2
- package/runtime/Roster/init.luau +2 -0
- package/runtime/Spark/init.luau +3 -0
- package/runtime/Sweep/init.luau +2 -0
- package/runtime/Trace/init.luau +3 -0
- package/runtime/Ward/init.luau +38 -5
- package/scripts/postinstall-editor.js +17 -0
- package/skills/README.md +13 -0
- package/skills/clpp-hive-flare/SKILL.md +79 -0
- package/skills/clpp-language/SKILL.md +123 -0
- package/skills/clpp-language/compiler.md +89 -0
- package/skills/clpp-style/SKILL.md +95 -0
- package/src/api/build-profile.ts +138 -0
- package/src/api/cache.ts +45 -0
- package/src/api/coverage.ts +46 -0
- package/src/api/diff.ts +143 -0
- package/src/api/generators/clpp-headers.ts +377 -0
- package/src/api/generators/docs-reference.ts +11 -0
- package/src/api/generators/lsp-index.ts +106 -0
- package/src/api/generators/luau-defs.ts +98 -0
- package/src/api/ide.ts +87 -0
- package/src/api/identifier.ts +47 -0
- package/src/api/index.ts +269 -0
- package/src/api/loader.ts +60 -0
- package/src/api/merge.ts +126 -0
- package/src/api/model.ts +283 -0
- package/src/api/normalize.ts +257 -0
- package/src/api/overrides-validate.ts +58 -0
- package/src/api/perf.ts +15 -0
- package/src/api/registry.ts +162 -0
- package/src/api/release.ts +47 -0
- package/src/api/resolver.ts +255 -0
- package/src/api/sources/aux-types-diff.ts +81 -0
- package/src/api/sources/client-tracker.ts +10 -0
- package/src/api/sources/creator-docs.ts +37 -0
- package/src/api/sources/luau-types.ts +30 -0
- package/src/api/sources/mini-dump.ts +50 -0
- package/src/api/sources/studio-api.ts +7 -0
- package/src/api/sources/studio-apiv2.ts +10 -0
- package/src/api/sources/studio-full-api.ts +7 -0
- package/src/api/studio-smoke.ts +82 -0
- package/src/api/type-parse.ts +48 -0
- package/src/api/understander.ts +72 -0
- package/src/api/validate.ts +160 -0
- package/src/api-cli.ts +493 -0
- package/src/api.generated.js +37 -22
- package/src/cli.ts +21 -6
- package/src/clpp/contract.ts +34 -3
- package/src/clpp/format-luau.ts +262 -0
- package/src/clpp/index.ts +13 -2
- package/src/clpp/modules.ts +252 -0
- package/src/clpp/postprocess.ts +100 -5
- package/src/clpp/rewrite-janitor.ts +156 -0
- package/src/clpp/runner.ts +14 -2
- package/src/compile.ts +87 -0
- package/src/flare/parse.ts +14 -1
- package/src/flare/types.ts +2 -0
- package/src/intellisense.ts +58 -1
- package/src/native/index.ts +225 -16
- package/src/target/authority-check.ts +162 -0
- package/src/target/authority-graph.ts +80 -0
- package/src/target/build-cache.ts +129 -0
- package/src/target/capabilities.ts +115 -0
- package/src/target/capability-profile.ts +25 -0
- package/src/target/component-contracts.ts +64 -0
- package/src/target/context-check.ts +177 -0
- package/src/target/datamodel-check.ts +188 -0
- package/src/target/datamodel-generate.ts +78 -0
- package/src/target/datamodel.ts +261 -0
- package/src/target/diagnostics.ts +67 -0
- package/src/target/doctor.ts +171 -0
- package/src/target/flare-version.ts +61 -0
- package/src/target/get-service.ts +85 -0
- package/src/target/lifetime-check.ts +45 -0
- package/src/target/luau-stamp.ts +33 -0
- package/src/target/optimizer-advise.ts +93 -0
- package/src/target/optimizer-apply.ts +63 -0
- package/src/target/optimizer-soa.ts +270 -0
- package/src/target/parallel-check.ts +135 -0
- package/src/target/pgo.ts +157 -0
- package/src/target/project-docs.ts +68 -0
- package/src/target/project-graph.ts +75 -0
- package/src/target/roblox.ts +78 -0
- package/src/target/security-check.ts +40 -0
- package/src/target/source-map.ts +36 -0
- package/src/target/studio-bridge.ts +140 -0
- package/src/types.ts +14 -0
- package/src/utils/project.ts +183 -9
- package/src/utils/rojo-mapper.ts +12 -3
- package/stylua.toml +9 -0
- package/templates/game/.vscode/settings.json +7 -1
- package/templates/game/include/clpp/datatypes.clh +337 -373
- package/templates/game/include/clpp/generated/enums.clh +1 -1
- package/templates/game/include/clpp/generated/instances.clh +41135 -41064
- package/templates/game/include/clpp/libs/axiom.clh +1 -1
- package/templates/game/include/clpp/libs/ward.clh +1 -0
- package/templates/game/include/clpp/roblox.clh +3 -4
- package/templates/game/src/ServerScriptService/Boot/DataBoot.server.clpp +1 -1
- package/templates/game/src/ServerScriptService/Handlers/PlayerHandler.server.clpp +1 -1
- package/templates/game/stylua.toml +9 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
--!optimize 2
|
|
2
|
+
--!strict
|
|
3
|
+
-- Guide — onboarding. Each step owns a Sweep.
|
|
4
|
+
|
|
5
|
+
local Sweep = require(script.Parent.Sweep)
|
|
6
|
+
|
|
7
|
+
local Guide = {}
|
|
8
|
+
Guide.__index = Guide
|
|
9
|
+
|
|
10
|
+
export type GuideSweep = Sweep.Sweep
|
|
11
|
+
|
|
12
|
+
export type GuideStep = ((sweep: GuideSweep) -> ()) | {
|
|
13
|
+
Enter: ((sweep: GuideSweep) -> ())?,
|
|
14
|
+
Exit: ((sweep: GuideSweep) -> ())?,
|
|
15
|
+
Highlight: Instance?,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type GuideConfig = {
|
|
19
|
+
Render: ((step: number, sweep: GuideSweep, spec: any) -> ())?,
|
|
20
|
+
Highlight: ((target: Instance, sweep: GuideSweep) -> ())?,
|
|
21
|
+
OnStep: ((step: number, previous: number?) -> ())?,
|
|
22
|
+
OnComplete: (() -> ())?,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type GuideSession = {
|
|
26
|
+
Start: (self: GuideSession, at: number?) -> (),
|
|
27
|
+
GoTo: (self: GuideSession, step: number) -> boolean,
|
|
28
|
+
Advance: (self: GuideSession) -> boolean,
|
|
29
|
+
Back: (self: GuideSession) -> boolean,
|
|
30
|
+
Complete: (self: GuideSession) -> (),
|
|
31
|
+
GetStep: (self: GuideSession) -> number,
|
|
32
|
+
IsActive: (self: GuideSession) -> boolean,
|
|
33
|
+
Destroy: (self: GuideSession) -> (),
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
local function applyHighlight(target: Instance, sweep: GuideSweep)
|
|
37
|
+
local highlight = Instance.new("Highlight")
|
|
38
|
+
if target:IsA("Model") or target:IsA("BasePart") or target:IsA("Accessory") then
|
|
39
|
+
highlight.Adornee = target
|
|
40
|
+
end
|
|
41
|
+
highlight.FillColor = Color3.fromRGB(255, 210, 70)
|
|
42
|
+
highlight.FillTransparency = 0.65
|
|
43
|
+
highlight.OutlineColor = Color3.fromRGB(255, 230, 120)
|
|
44
|
+
highlight.OutlineTransparency = 0
|
|
45
|
+
highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
|
|
46
|
+
highlight.Parent = target
|
|
47
|
+
sweep:Add(highlight)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
local function enterStep(spec: any, sweep: GuideSweep, index: number, config: GuideConfig?)
|
|
51
|
+
if typeof(spec) == "function" then
|
|
52
|
+
spec(sweep)
|
|
53
|
+
elseif typeof(spec) == "table" then
|
|
54
|
+
local enter = spec.Enter
|
|
55
|
+
if typeof(enter) == "function" then
|
|
56
|
+
enter(sweep)
|
|
57
|
+
end
|
|
58
|
+
local target = spec.Highlight
|
|
59
|
+
if typeof(target) == "Instance" then
|
|
60
|
+
local hook = config and config.Highlight
|
|
61
|
+
if typeof(hook) == "function" then
|
|
62
|
+
hook(target, sweep)
|
|
63
|
+
else
|
|
64
|
+
applyHighlight(target, sweep)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
local render = config and config.Render
|
|
69
|
+
if typeof(render) == "function" then
|
|
70
|
+
render(index, sweep, spec)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
local function exitStep(spec: any, sweep: GuideSweep?)
|
|
75
|
+
if typeof(spec) == "table" then
|
|
76
|
+
local exit = spec.Exit
|
|
77
|
+
if typeof(exit) == "function" then
|
|
78
|
+
exit(sweep)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
if sweep then
|
|
82
|
+
sweep:Destroy()
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
function Guide.build(steps: { any }, config: GuideConfig?): GuideSession
|
|
87
|
+
local index = 0
|
|
88
|
+
local currentSweep: GuideSweep? = nil
|
|
89
|
+
local currentSpec: any = nil
|
|
90
|
+
local active = false
|
|
91
|
+
local destroyed = false
|
|
92
|
+
local session = {}
|
|
93
|
+
|
|
94
|
+
function session:GoTo(step: number): boolean
|
|
95
|
+
if destroyed then
|
|
96
|
+
return false
|
|
97
|
+
end
|
|
98
|
+
local spec = steps[step]
|
|
99
|
+
if spec == nil then
|
|
100
|
+
return false
|
|
101
|
+
end
|
|
102
|
+
if active and step == index then
|
|
103
|
+
return true
|
|
104
|
+
end
|
|
105
|
+
local previous = if active then index else nil
|
|
106
|
+
exitStep(currentSpec, currentSweep)
|
|
107
|
+
currentSweep = nil
|
|
108
|
+
currentSpec = nil
|
|
109
|
+
index = step
|
|
110
|
+
active = true
|
|
111
|
+
local sweep = Sweep.new()
|
|
112
|
+
currentSweep = sweep
|
|
113
|
+
currentSpec = spec
|
|
114
|
+
enterStep(spec, sweep, step, config)
|
|
115
|
+
local onStep = config and config.OnStep
|
|
116
|
+
if typeof(onStep) == "function" then
|
|
117
|
+
onStep(step, previous)
|
|
118
|
+
end
|
|
119
|
+
return true
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
function session:Start(at: number?)
|
|
123
|
+
if destroyed then
|
|
124
|
+
return
|
|
125
|
+
end
|
|
126
|
+
active = false
|
|
127
|
+
index = 0
|
|
128
|
+
self:GoTo(at or 1)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
function session:Advance(): boolean
|
|
132
|
+
if destroyed or not active then
|
|
133
|
+
return false
|
|
134
|
+
end
|
|
135
|
+
if steps[index + 1] == nil then
|
|
136
|
+
self:Complete()
|
|
137
|
+
return true
|
|
138
|
+
end
|
|
139
|
+
return self:GoTo(index + 1)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
function session:Back(): boolean
|
|
143
|
+
if destroyed or not active then
|
|
144
|
+
return false
|
|
145
|
+
end
|
|
146
|
+
return self:GoTo(index - 1)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
function session:Complete()
|
|
150
|
+
if destroyed then
|
|
151
|
+
return
|
|
152
|
+
end
|
|
153
|
+
exitStep(currentSpec, currentSweep)
|
|
154
|
+
currentSweep = nil
|
|
155
|
+
currentSpec = nil
|
|
156
|
+
active = false
|
|
157
|
+
local onComplete = config and config.OnComplete
|
|
158
|
+
if typeof(onComplete) == "function" then
|
|
159
|
+
onComplete()
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
function session:GetStep(): number
|
|
164
|
+
return index
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
function session:IsActive(): boolean
|
|
168
|
+
return active and not destroyed
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
function session:Destroy()
|
|
172
|
+
if destroyed then
|
|
173
|
+
return
|
|
174
|
+
end
|
|
175
|
+
self:Complete()
|
|
176
|
+
destroyed = true
|
|
177
|
+
active = false
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
return session :: GuideSession
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
Guide.Step = {
|
|
184
|
+
new = function(orderOrEnter: any, enter: any?): any
|
|
185
|
+
if typeof(orderOrEnter) == "function" then
|
|
186
|
+
return { Enter = orderOrEnter }
|
|
187
|
+
end
|
|
188
|
+
if typeof(orderOrEnter) == "number" then
|
|
189
|
+
if typeof(enter) == "function" then
|
|
190
|
+
return { Order = orderOrEnter, Enter = enter }
|
|
191
|
+
end
|
|
192
|
+
if typeof(enter) == "table" then
|
|
193
|
+
local spec = table.clone(enter)
|
|
194
|
+
spec.Order = orderOrEnter
|
|
195
|
+
return spec
|
|
196
|
+
end
|
|
197
|
+
return { Order = orderOrEnter }
|
|
198
|
+
end
|
|
199
|
+
if typeof(orderOrEnter) == "table" then
|
|
200
|
+
return orderOrEnter
|
|
201
|
+
end
|
|
202
|
+
return { orderOrEnter, enter }
|
|
203
|
+
end,
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function Guide.Start(steps: any?, config: any?): any
|
|
207
|
+
if typeof(steps) == "table" and steps.UserId == nil then
|
|
208
|
+
local session = Guide.build(steps, config)
|
|
209
|
+
session:Start()
|
|
210
|
+
return session
|
|
211
|
+
end
|
|
212
|
+
return Guide
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
return Guide
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
--!native
|
|
2
|
+
--!optimize 2
|
|
3
|
+
--!strict
|
|
4
|
+
-- Helm — typed commands. Args pack to buffers. Server is authority.
|
|
5
|
+
|
|
6
|
+
local Players = game:GetService("Players")
|
|
7
|
+
local RunService = game:GetService("RunService")
|
|
8
|
+
local Ward = require(script.Parent.Ward)
|
|
9
|
+
|
|
10
|
+
local Helm = {}
|
|
11
|
+
Helm.__index = Helm
|
|
12
|
+
|
|
13
|
+
local registry: { [string]: any } = {}
|
|
14
|
+
local types: { [string]: any } = {}
|
|
15
|
+
local hooks: { [string]: { (...any) -> any } } = {}
|
|
16
|
+
|
|
17
|
+
local function packArgs(args: { any }): buffer
|
|
18
|
+
local size = 1
|
|
19
|
+
for _, arg in args do
|
|
20
|
+
local kind = typeof(arg)
|
|
21
|
+
if kind == "number" then
|
|
22
|
+
size += 9
|
|
23
|
+
elseif kind == "string" then
|
|
24
|
+
size += 3 + #arg
|
|
25
|
+
elseif kind == "boolean" then
|
|
26
|
+
size += 2
|
|
27
|
+
elseif kind == "Instance" then
|
|
28
|
+
size += 5
|
|
29
|
+
else
|
|
30
|
+
size += 1
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
local buf = buffer.create(size)
|
|
34
|
+
buffer.writeu8(buf, 0, #args)
|
|
35
|
+
local cursor = 1
|
|
36
|
+
for _, arg in args do
|
|
37
|
+
local kind = typeof(arg)
|
|
38
|
+
if kind == "number" then
|
|
39
|
+
buffer.writeu8(buf, cursor, 1)
|
|
40
|
+
cursor += 1
|
|
41
|
+
buffer.writef64(buf, cursor, arg)
|
|
42
|
+
cursor += 8
|
|
43
|
+
elseif kind == "string" then
|
|
44
|
+
buffer.writeu8(buf, cursor, 2)
|
|
45
|
+
cursor += 1
|
|
46
|
+
buffer.writeu16(buf, cursor, #arg)
|
|
47
|
+
cursor += 2
|
|
48
|
+
buffer.writestring(buf, cursor, arg)
|
|
49
|
+
cursor += #arg
|
|
50
|
+
elseif kind == "boolean" then
|
|
51
|
+
buffer.writeu8(buf, cursor, 3)
|
|
52
|
+
cursor += 1
|
|
53
|
+
buffer.writeu8(buf, cursor, if arg then 1 else 0)
|
|
54
|
+
cursor += 1
|
|
55
|
+
elseif kind == "Instance" then
|
|
56
|
+
buffer.writeu8(buf, cursor, 4)
|
|
57
|
+
cursor += 1
|
|
58
|
+
local userId = 0
|
|
59
|
+
if arg:IsA("Player") then
|
|
60
|
+
userId = arg.UserId
|
|
61
|
+
end
|
|
62
|
+
buffer.writeu32(buf, cursor, userId)
|
|
63
|
+
cursor += 4
|
|
64
|
+
else
|
|
65
|
+
buffer.writeu8(buf, cursor, 0)
|
|
66
|
+
cursor += 1
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
return buf
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
local function unpackArgs(buf: buffer): { any }
|
|
73
|
+
local count = buffer.readu8(buf, 0)
|
|
74
|
+
local args = table.create(count)
|
|
75
|
+
local cursor = 1
|
|
76
|
+
local length = buffer.len(buf)
|
|
77
|
+
for index = 1, count do
|
|
78
|
+
if cursor >= length then
|
|
79
|
+
break
|
|
80
|
+
end
|
|
81
|
+
local tag = buffer.readu8(buf, cursor)
|
|
82
|
+
cursor += 1
|
|
83
|
+
if tag == 1 then
|
|
84
|
+
args[index] = buffer.readf64(buf, cursor)
|
|
85
|
+
cursor += 8
|
|
86
|
+
elseif tag == 2 then
|
|
87
|
+
local len = buffer.readu16(buf, cursor)
|
|
88
|
+
cursor += 2
|
|
89
|
+
args[index] = buffer.readstring(buf, cursor, len)
|
|
90
|
+
cursor += len
|
|
91
|
+
elseif tag == 3 then
|
|
92
|
+
args[index] = buffer.readu8(buf, cursor) == 1
|
|
93
|
+
cursor += 1
|
|
94
|
+
elseif tag == 4 then
|
|
95
|
+
local userId = buffer.readu32(buf, cursor)
|
|
96
|
+
cursor += 4
|
|
97
|
+
args[index] = Players:GetPlayerByUserId(userId)
|
|
98
|
+
else
|
|
99
|
+
args[index] = nil
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
return args
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
local function resolvePlayer(value: any): Player?
|
|
106
|
+
if typeof(value) == "Instance" and value:IsA("Player") then
|
|
107
|
+
return value
|
|
108
|
+
end
|
|
109
|
+
if typeof(value) == "number" then
|
|
110
|
+
return Players:GetPlayerByUserId(value)
|
|
111
|
+
end
|
|
112
|
+
if typeof(value) == "string" then
|
|
113
|
+
local asId = tonumber(value)
|
|
114
|
+
if asId then
|
|
115
|
+
return Players:GetPlayerByUserId(asId)
|
|
116
|
+
end
|
|
117
|
+
local child = Players:FindFirstChild(value)
|
|
118
|
+
if child and child:IsA("Player") then
|
|
119
|
+
return child
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
return nil
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
local function transformArg(typeName: string?, value: any): any
|
|
126
|
+
local def = if typeName then types[typeName] else nil
|
|
127
|
+
if def then
|
|
128
|
+
local transform = def.Transform or def.Parse or def
|
|
129
|
+
if typeof(transform) == "function" then
|
|
130
|
+
return transform(value)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
if typeName == "Player" then
|
|
134
|
+
return resolvePlayer(value)
|
|
135
|
+
end
|
|
136
|
+
if typeName == "i32" or typeName == "int" or typeName == "number" or typeName == "f64" then
|
|
137
|
+
local n = tonumber(value)
|
|
138
|
+
if n == nil then
|
|
139
|
+
return value
|
|
140
|
+
end
|
|
141
|
+
if typeName == "i32" or typeName == "int" then
|
|
142
|
+
return math.floor(n)
|
|
143
|
+
end
|
|
144
|
+
return n
|
|
145
|
+
end
|
|
146
|
+
if typeName == "boolean" or typeName == "bool" then
|
|
147
|
+
if typeof(value) == "boolean" then
|
|
148
|
+
return value
|
|
149
|
+
end
|
|
150
|
+
return value == 1 or value == "true"
|
|
151
|
+
end
|
|
152
|
+
if typeName == "string" and value ~= nil then
|
|
153
|
+
return tostring(value)
|
|
154
|
+
end
|
|
155
|
+
return value
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
local function applyTypes(command: any, args: { any }): { any }
|
|
159
|
+
local spec = command.Args
|
|
160
|
+
if typeof(spec) ~= "table" then
|
|
161
|
+
return args
|
|
162
|
+
end
|
|
163
|
+
for index, slot in spec do
|
|
164
|
+
if typeof(slot) == "table" then
|
|
165
|
+
args[index] = transformArg(slot.Type, args[index])
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
return args
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
local function hasPermission(player: Player, permission: string?): boolean
|
|
172
|
+
if permission == nil or permission == "" or permission == "None" or permission == "All" then
|
|
173
|
+
return true
|
|
174
|
+
end
|
|
175
|
+
if player:GetAttribute(permission) == true then
|
|
176
|
+
return true
|
|
177
|
+
end
|
|
178
|
+
local tagged = player:GetAttribute("Permission") or player:GetAttribute("Helm")
|
|
179
|
+
if tagged == permission then
|
|
180
|
+
return true
|
|
181
|
+
end
|
|
182
|
+
local rank = player:GetAttribute("HelmRank")
|
|
183
|
+
if typeof(rank) == "number" then
|
|
184
|
+
if permission == "Admin" and rank >= 254 then
|
|
185
|
+
return true
|
|
186
|
+
end
|
|
187
|
+
if (permission == "Mod" or permission == "Moderator") and rank >= 50 then
|
|
188
|
+
return true
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
if permission == "Admin" and player.UserId == game.CreatorId then
|
|
192
|
+
return true
|
|
193
|
+
end
|
|
194
|
+
return false
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
local function fireHooks(name: string, ...: any): any
|
|
198
|
+
local list = hooks[name]
|
|
199
|
+
if not list then
|
|
200
|
+
return nil
|
|
201
|
+
end
|
|
202
|
+
for _, fn in list do
|
|
203
|
+
local result = fn(...)
|
|
204
|
+
if result ~= nil then
|
|
205
|
+
return result
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
return nil
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
local function mergeCommand(name: string, command: any)
|
|
212
|
+
local existing = registry[name]
|
|
213
|
+
if existing then
|
|
214
|
+
for key, value in command do
|
|
215
|
+
if key ~= "Callback" then
|
|
216
|
+
existing[key] = value
|
|
217
|
+
elseif existing.Callback == nil then
|
|
218
|
+
existing.Callback = value
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
existing.Name = name
|
|
222
|
+
return existing
|
|
223
|
+
end
|
|
224
|
+
local copy = table.clone(command)
|
|
225
|
+
copy.Name = name
|
|
226
|
+
registry[name] = copy
|
|
227
|
+
return copy
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
function Helm.Register(schema: any)
|
|
231
|
+
if typeof(schema) ~= "table" then
|
|
232
|
+
return
|
|
233
|
+
end
|
|
234
|
+
for name, command in schema do
|
|
235
|
+
if typeof(name) == "string" and typeof(command) == "table" then
|
|
236
|
+
mergeCommand(name, command)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
local function runCommand(player: Player, schema: any, name: string, packedArgs: { any }): (boolean, any)
|
|
242
|
+
if RunService:IsServer() and not Ward.Allow(player, "helm", 6, 10) then
|
|
243
|
+
return false, "rate"
|
|
244
|
+
end
|
|
245
|
+
local command = registry[name]
|
|
246
|
+
if typeof(command) ~= "table" then
|
|
247
|
+
command = schema and schema[name]
|
|
248
|
+
end
|
|
249
|
+
if typeof(command) ~= "table" then
|
|
250
|
+
return false, "unknown command"
|
|
251
|
+
end
|
|
252
|
+
if not hasPermission(player, command.Permission) then
|
|
253
|
+
return false, "permission"
|
|
254
|
+
end
|
|
255
|
+
local packed = packArgs(packedArgs)
|
|
256
|
+
local unpacked = applyTypes(command, unpackArgs(packed))
|
|
257
|
+
local block = fireHooks("BeforeRun", player, name, unpacked)
|
|
258
|
+
if block == false or typeof(block) == "string" then
|
|
259
|
+
return false, if typeof(block) == "string" then block else "blocked"
|
|
260
|
+
end
|
|
261
|
+
local callback = command.Callback
|
|
262
|
+
if typeof(callback) ~= "function" then
|
|
263
|
+
if name == "Kick" then
|
|
264
|
+
callback = function(executor: Player, target: Player?, reason: string?)
|
|
265
|
+
if target and typeof(target) == "Instance" and target:IsA("Player") and target ~= executor then
|
|
266
|
+
target:Kick(reason or "Kicked")
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
elseif name == "Give" then
|
|
270
|
+
callback = function(executor: Player, target: Player?, amount: number)
|
|
271
|
+
if typeof(amount) ~= "number" or amount ~= amount or amount <= 0 or amount > 1e9 then
|
|
272
|
+
return
|
|
273
|
+
end
|
|
274
|
+
fireHooks("Give", executor, target, amount)
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
if typeof(callback) == "function" then
|
|
279
|
+
callback(player, table.unpack(unpacked, 1, #unpacked))
|
|
280
|
+
end
|
|
281
|
+
fireHooks("AfterRun", player, name, unpacked)
|
|
282
|
+
return true, packed
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
function Helm.Open(player: Player, schema: any)
|
|
286
|
+
Helm.Register(schema)
|
|
287
|
+
local session = {
|
|
288
|
+
Player = player,
|
|
289
|
+
Schema = schema,
|
|
290
|
+
}
|
|
291
|
+
function session:Run(name: string, ...: any)
|
|
292
|
+
return runCommand(player, schema, name, { ... })
|
|
293
|
+
end
|
|
294
|
+
return session
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
function Helm.Give(player: Player, target: Player, amount: number)
|
|
298
|
+
if not registry.Give then
|
|
299
|
+
Helm.RegisterDefaultCommands()
|
|
300
|
+
end
|
|
301
|
+
return Helm.Open(player, registry):Run("Give", target, amount)
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
function Helm.Kick(player: Player, target: Player, reason: string?)
|
|
305
|
+
if not registry.Kick then
|
|
306
|
+
Helm.RegisterDefaultCommands()
|
|
307
|
+
end
|
|
308
|
+
return Helm.Open(player, registry):Run("Kick", target, reason)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
function Helm.RegisterDefaultCommands()
|
|
312
|
+
Helm.Register({
|
|
313
|
+
Give = {
|
|
314
|
+
Id = 1,
|
|
315
|
+
Permission = "Admin",
|
|
316
|
+
Args = { { Type = "Player", Name = "target" }, { Type = "i32", Name = "amount" } },
|
|
317
|
+
Callback = function(player: Player, target: Player?, amount: number)
|
|
318
|
+
if typeof(amount) ~= "number" or amount ~= amount or amount <= 0 or amount > 1e9 then
|
|
319
|
+
return
|
|
320
|
+
end
|
|
321
|
+
fireHooks("Give", player, target, amount)
|
|
322
|
+
end,
|
|
323
|
+
},
|
|
324
|
+
Kick = {
|
|
325
|
+
Id = 2,
|
|
326
|
+
Permission = "Admin",
|
|
327
|
+
Args = { { Type = "Player", Name = "target" }, { Type = "string", Name = "reason" } },
|
|
328
|
+
Callback = function(player: Player, target: Player?, reason: string?)
|
|
329
|
+
if target and target ~= player then
|
|
330
|
+
target:Kick(reason or "Kicked")
|
|
331
|
+
end
|
|
332
|
+
end,
|
|
333
|
+
},
|
|
334
|
+
})
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
function Helm.RegisterHook(name: string, callback: (...any) -> ())
|
|
338
|
+
local list = hooks[name]
|
|
339
|
+
if not list then
|
|
340
|
+
list = {}
|
|
341
|
+
hooks[name] = list
|
|
342
|
+
end
|
|
343
|
+
table.insert(list, callback)
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
function Helm.RegisterType(name: string, typeDefinition: any)
|
|
347
|
+
types[name] = typeDefinition
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
function Helm.RegisterCommand(commandDefinition: any)
|
|
351
|
+
if typeof(commandDefinition) ~= "table" then
|
|
352
|
+
return
|
|
353
|
+
end
|
|
354
|
+
local name = commandDefinition.Name
|
|
355
|
+
if typeof(name) ~= "string" then
|
|
356
|
+
return
|
|
357
|
+
end
|
|
358
|
+
mergeCommand(name, commandDefinition)
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
function Helm.Registry()
|
|
362
|
+
return registry
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
function Helm.Dispatcher()
|
|
366
|
+
return {
|
|
367
|
+
Run = function(_self: any, player: Player, name: string, ...: any)
|
|
368
|
+
return Helm.Open(player, registry):Run(name, ...)
|
|
369
|
+
end,
|
|
370
|
+
}
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
Helm.RegisterType("Player", {
|
|
374
|
+
Transform = resolvePlayer,
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
return Helm
|