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,211 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
-- Kernel bridge for CL++ Server/Client. Path tokens, Keep Store, Data,
|
|
3
|
+
-- tagged-buffer replication, and Spark stay Luau — CL++ 0.3.2 cannot express
|
|
4
|
+
-- type functions, metatable path tokens, or rawset overlays.
|
|
5
|
+
|
|
6
|
+
local RunService = game:GetService("RunService")
|
|
7
|
+
|
|
8
|
+
local Path = require(script.Parent.Path)
|
|
9
|
+
local Data = require(script.Parent.Data)
|
|
10
|
+
local Enums = require(script.Parent.Enums)
|
|
11
|
+
local EnumModule = require(script.Parent.Enum)
|
|
12
|
+
local Store = require(script.Parent.Store)
|
|
13
|
+
local Trade = require(script.Parent.Trade)
|
|
14
|
+
local ReplicatorModule = require(script.Parent.Replicator)
|
|
15
|
+
local Spark = require(script.Parent.Parent.Spark)
|
|
16
|
+
|
|
17
|
+
local Engine = {}
|
|
18
|
+
|
|
19
|
+
Engine.Path = Path
|
|
20
|
+
Engine.Data = Data
|
|
21
|
+
Engine.ProfileStore = Store
|
|
22
|
+
Engine.Store = Store
|
|
23
|
+
Engine.Trade = Trade
|
|
24
|
+
Engine.Enums = Enums
|
|
25
|
+
Engine.Enum = EnumModule
|
|
26
|
+
Engine.Signal = Spark
|
|
27
|
+
Engine.Spark = Spark
|
|
28
|
+
Engine.Replicator = if RunService:IsServer() then ReplicatorModule.Server else ReplicatorModule.Client
|
|
29
|
+
|
|
30
|
+
function Engine:mapNew()
|
|
31
|
+
return {}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
function Engine:mapSet(map: any, key: any, value: any)
|
|
35
|
+
if map then
|
|
36
|
+
map[key] = value
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
function Engine:mapGet(map: any, key: any): any
|
|
41
|
+
if map == nil then
|
|
42
|
+
return nil
|
|
43
|
+
end
|
|
44
|
+
return map[key]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
function Engine:mapClear(map: any, key: any)
|
|
48
|
+
if map then
|
|
49
|
+
map[key] = nil
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
function Engine:createTemplatePaths(tmpl: any)
|
|
54
|
+
return Path.createTemplatePaths(tmpl)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
function Engine:rootToken()
|
|
58
|
+
return Path.rootToken()
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
function Engine:toKey(path: any): string
|
|
62
|
+
return Path.toKey(path)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
function Engine:parentPath(path: any)
|
|
66
|
+
return Path.parent(path)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
function Engine:emptyPath()
|
|
70
|
+
return {}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
function Engine:dataNew(initial: any, writable: boolean, strictPaths: boolean?, autoCreate: boolean?, tmpl: any)
|
|
74
|
+
return Data.new(initial, writable, {
|
|
75
|
+
StrictPaths = if strictPaths ~= nil then strictPaths else true,
|
|
76
|
+
AutoCreateMissingTables = if autoCreate ~= nil then autoCreate else false,
|
|
77
|
+
Template = if tmpl ~= nil then tmpl else initial,
|
|
78
|
+
})
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
function Engine:applySet(data: any, path: any, value: any)
|
|
82
|
+
Data._applySet(data, path, value)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
function Engine:applyArrayInsert(data: any, path: any, value: any, index: number?)
|
|
86
|
+
Data._applyArrayInsert(data, path, value, index)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
function Engine:applyArrayRemove(data: any, path: any, index: number)
|
|
90
|
+
Data._applyArrayRemove(data, path, index)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
function Engine:applyTransientSet(data: any, path: any, value: any)
|
|
94
|
+
Data._applyTransientSet(data, path, value)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
function Engine:applyTransientArrayInsert(data: any, path: any, value: any, index: number?)
|
|
98
|
+
Data._applyTransientArrayInsert(data, path, value, index)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
function Engine:applyTransientArrayRemove(data: any, path: any, index: number)
|
|
102
|
+
Data._applyTransientArrayRemove(data, path, index)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
function Engine:applyTransientClear(data: any, path: any)
|
|
106
|
+
Data._applyTransientClear(data, path)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
function Engine:profileStoreNew(storeName: string, tmpl: any)
|
|
110
|
+
return Store.New(storeName, tmpl)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
function Engine:startSession(store: any, key: string, player: Player, players: Players)
|
|
114
|
+
local profile = store:StartSessionAsync(key, {
|
|
115
|
+
Cancel = function()
|
|
116
|
+
return player.Parent ~= players
|
|
117
|
+
end,
|
|
118
|
+
})
|
|
119
|
+
if profile then
|
|
120
|
+
profile:AddUserId(player.UserId)
|
|
121
|
+
Trade.Ensure(profile.Data)
|
|
122
|
+
profile:MessageHandler(function(message, processed)
|
|
123
|
+
Trade.HandleMessage(profile, message, processed)
|
|
124
|
+
end)
|
|
125
|
+
end
|
|
126
|
+
return profile
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
function Engine:abortActiveTrade(profile: any)
|
|
130
|
+
Trade.AbortIfActive(profile)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
function Engine:signalNew()
|
|
134
|
+
return Spark.new()
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
function Engine:isExcluded(excluded: { [string]: boolean }?, path: any): boolean
|
|
138
|
+
if not path or #path == 0 then
|
|
139
|
+
return false
|
|
140
|
+
end
|
|
141
|
+
if not excluded then
|
|
142
|
+
return false
|
|
143
|
+
end
|
|
144
|
+
for i = 1, #path do
|
|
145
|
+
local prefix = table.create(i)
|
|
146
|
+
for j = 1, i do
|
|
147
|
+
prefix[j] = path[j]
|
|
148
|
+
end
|
|
149
|
+
if excluded[Path.toKey(prefix)] then
|
|
150
|
+
return true
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
return false
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
function Engine:buildSnapshot(excluded: { [string]: boolean }?, value: any, prefix: any): any
|
|
157
|
+
local path = prefix or {}
|
|
158
|
+
if Engine:isExcluded(excluded, path) then
|
|
159
|
+
return nil
|
|
160
|
+
end
|
|
161
|
+
if type(value) ~= "table" then
|
|
162
|
+
return value
|
|
163
|
+
end
|
|
164
|
+
local out = {}
|
|
165
|
+
for k, v in value do
|
|
166
|
+
local newPath = table.clone(path)
|
|
167
|
+
newPath[#newPath + 1] = k
|
|
168
|
+
if not Engine:isExcluded(excluded, newPath) then
|
|
169
|
+
out[k] = Engine:buildSnapshot(excluded, v, newPath)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
return out
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
function Engine:watchData(data: any, player: Player, ready: { [Player]: boolean }, excluded: { [string]: boolean })
|
|
176
|
+
return data.Changed:Connect(function(action, path, ...)
|
|
177
|
+
if not ready[player] then
|
|
178
|
+
return
|
|
179
|
+
end
|
|
180
|
+
if Engine:isExcluded(excluded, path) then
|
|
181
|
+
return
|
|
182
|
+
end
|
|
183
|
+
Engine.Replicator:Send(player, action, path, ...)
|
|
184
|
+
end)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
function Engine:replicatorOn(action: string, handler: any)
|
|
188
|
+
Engine.Replicator:On(action, handler)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
function Engine:replicatorNotifyReady()
|
|
192
|
+
Engine.Replicator:NotifyReady()
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
function Engine:replicatorSend(player: Player, action: string, path: any, ...)
|
|
196
|
+
Engine.Replicator:Send(player, action, path, ...)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
function Engine:replicatorGetBufferStats(player: Player?)
|
|
200
|
+
return Engine.Replicator:GetBufferStats(player)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
function Engine:replicatorForgetPlayer(player: Player)
|
|
204
|
+
Engine.Replicator:ForgetPlayer(player)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
function Engine:replicatorDestroy()
|
|
208
|
+
Engine.Replicator:Destroy()
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
return Engine
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
const Path = {}
|
|
2
|
+
|
|
3
|
+
export type Path = { string | number }
|
|
4
|
+
|
|
5
|
+
type function PathOf(templateType: type): type
|
|
6
|
+
local function unwrapOptional(valueType: type): type
|
|
7
|
+
if not valueType:is("union") then
|
|
8
|
+
return valueType
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
local resolved = nil
|
|
12
|
+
for _, component in valueType:components() do
|
|
13
|
+
if not (component:is("singleton") and component:value() == nil) then
|
|
14
|
+
resolved = if resolved then types.unionof(resolved, component) else component
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
return resolved or valueType
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
local function mapValue(valueType: type): type
|
|
22
|
+
valueType = unwrapOptional(valueType)
|
|
23
|
+
|
|
24
|
+
if valueType:is("any") or valueType:is("unknown") then
|
|
25
|
+
return types.newtable()
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
if valueType:is("union") then
|
|
29
|
+
for _, component in valueType:components() do
|
|
30
|
+
if component:is("table") then
|
|
31
|
+
return mapValue(component)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
return types.newtable()
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
if valueType:is("intersection") then
|
|
38
|
+
local mapped = types.newtable()
|
|
39
|
+
local hasMembers = false
|
|
40
|
+
|
|
41
|
+
for _, component in valueType:components() do
|
|
42
|
+
if component:is("table") then
|
|
43
|
+
local sub = mapValue(component)
|
|
44
|
+
for key in sub:properties() do
|
|
45
|
+
local childType = sub:readproperty(key)
|
|
46
|
+
if childType then
|
|
47
|
+
mapped:setproperty(key, childType)
|
|
48
|
+
hasMembers = true
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
local indexerInfo = sub:indexer()
|
|
53
|
+
if indexerInfo then
|
|
54
|
+
mapped:setindexer(indexerInfo.index, indexerInfo.readresult)
|
|
55
|
+
hasMembers = true
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if hasMembers then
|
|
61
|
+
return mapped
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
if not valueType:is("table") then
|
|
66
|
+
local token = types.newtable()
|
|
67
|
+
token:setproperty("__pathValue", valueType)
|
|
68
|
+
return token
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
local mapped = types.newtable()
|
|
72
|
+
local hasMembers = false
|
|
73
|
+
|
|
74
|
+
for key in valueType:properties() do
|
|
75
|
+
local childType = valueType:readproperty(key)
|
|
76
|
+
if childType then
|
|
77
|
+
mapped:setproperty(key, mapValue(unwrapOptional(childType)))
|
|
78
|
+
hasMembers = true
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
local indexerInfo = valueType:indexer()
|
|
83
|
+
if indexerInfo then
|
|
84
|
+
mapped:setindexer(indexerInfo.index, mapValue(indexerInfo.readresult))
|
|
85
|
+
hasMembers = true
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
if hasMembers then
|
|
89
|
+
return mapped
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
return types.newtable()
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
return mapValue(templateType)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
-- PathTree<T> mirrors the template shape for navigation (Paths).
|
|
99
|
+
export type PathTree<T> = PathOf<T>
|
|
100
|
+
-- PathToken<V> is the typed handle for a leaf path targeting value type V.
|
|
101
|
+
export type PathToken<V> = { __pathValue: V }
|
|
102
|
+
export type TemplatePaths<T> = PathTree<T>
|
|
103
|
+
|
|
104
|
+
local ROOT_TOKEN: PathTree<{}>? = nil
|
|
105
|
+
|
|
106
|
+
const clone = function(path: Path?): Path
|
|
107
|
+
if not path then
|
|
108
|
+
return {}
|
|
109
|
+
end
|
|
110
|
+
local out = table.create(#path)
|
|
111
|
+
for i, v in path do
|
|
112
|
+
out[i] = v
|
|
113
|
+
end
|
|
114
|
+
return out
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
local function createToken(segments: Path): any
|
|
118
|
+
local token = {}
|
|
119
|
+
rawset(token, "__kdsv2_path_token", true)
|
|
120
|
+
rawset(token, "__segments", table.freeze(clone(segments)))
|
|
121
|
+
rawset(token, "__children", nil)
|
|
122
|
+
|
|
123
|
+
return setmetatable(token, {
|
|
124
|
+
__index = function(self, key)
|
|
125
|
+
if type(key) ~= "string" and type(key) ~= "number" then
|
|
126
|
+
return nil
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
local children = rawget(self, "__children")
|
|
130
|
+
if not children then
|
|
131
|
+
children = {}
|
|
132
|
+
rawset(self, "__children", children)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
local cached = children[key]
|
|
136
|
+
if cached then
|
|
137
|
+
return cached
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
local nextSegments = clone(rawget(self, "__segments"))
|
|
141
|
+
nextSegments[#nextSegments + 1] = key
|
|
142
|
+
local child = createToken(nextSegments)
|
|
143
|
+
children[key] = child
|
|
144
|
+
return child
|
|
145
|
+
end,
|
|
146
|
+
})
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
function Path.rootToken(): PathTree<{}>
|
|
150
|
+
if not ROOT_TOKEN then
|
|
151
|
+
ROOT_TOKEN = createToken({})
|
|
152
|
+
end
|
|
153
|
+
return ROOT_TOKEN :: PathTree<{}>
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
function Path.createTemplatePaths<T>(template: T, currentSegments: Path?): PathTree<T>
|
|
157
|
+
local token = createToken(clone(currentSegments))
|
|
158
|
+
|
|
159
|
+
if type(template) ~= "table" then
|
|
160
|
+
rawset(token, "__pathValue", template)
|
|
161
|
+
return token :: PathTree<T>
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
local children = {}
|
|
165
|
+
rawset(token, "__children", children)
|
|
166
|
+
|
|
167
|
+
for key, value in template do
|
|
168
|
+
local keyType = type(key)
|
|
169
|
+
if keyType == "string" or keyType == "number" then
|
|
170
|
+
local nextSegments = clone(currentSegments)
|
|
171
|
+
nextSegments[#nextSegments + 1] = key
|
|
172
|
+
|
|
173
|
+
local child = Path.createTemplatePaths(value, nextSegments)
|
|
174
|
+
children[key] = child
|
|
175
|
+
rawset(token, key, child)
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
return token :: PathTree<T>
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
function Path.isToken(value: any): boolean
|
|
183
|
+
return type(value) == "table" and rawget(value, "__kdsv2_path_token") == true
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
function Path.toArray(path: Path | PathTree<{}>?): Path?
|
|
187
|
+
if path == nil then
|
|
188
|
+
return nil
|
|
189
|
+
end
|
|
190
|
+
if Path.isToken(path) then
|
|
191
|
+
return clone(rawget(path :: any, "__segments"))
|
|
192
|
+
end
|
|
193
|
+
return clone(path :: Path)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
function Path.validate(path: Path?): boolean
|
|
197
|
+
if not path then
|
|
198
|
+
return true
|
|
199
|
+
end
|
|
200
|
+
for _, segment in path do
|
|
201
|
+
local kind = type(segment)
|
|
202
|
+
if kind ~= "string" and kind ~= "number" then
|
|
203
|
+
return false
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
return true
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
function Path.toKey(path: Path?): string
|
|
210
|
+
if not path or #path == 0 then
|
|
211
|
+
return ""
|
|
212
|
+
end
|
|
213
|
+
local parts = table.create(#path)
|
|
214
|
+
for i, v in path do
|
|
215
|
+
if type(v) == "string" then
|
|
216
|
+
parts[i] = "s\1" .. v
|
|
217
|
+
else
|
|
218
|
+
parts[i] = "n\1" .. tostring(v)
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
return table.concat(parts, "\0")
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
function Path.clone(path: Path?): Path
|
|
225
|
+
return clone(path)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
function Path.parent(path: Path): Path
|
|
229
|
+
local out = table.create(math.max(#path - 1, 0))
|
|
230
|
+
for i = 1, #path - 1 do
|
|
231
|
+
out[i] = path[i]
|
|
232
|
+
end
|
|
233
|
+
return out
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
return Path
|