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,138 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { projectRoot } from "../package-info.js";
|
|
4
|
+
import { pkg } from "../package-info.js";
|
|
5
|
+
import { overridesHash, readOverrideFile } from "./loader.js";
|
|
6
|
+
import type {
|
|
7
|
+
GlobalDefinition,
|
|
8
|
+
LibraryDefinition,
|
|
9
|
+
RobloxTargetProfile,
|
|
10
|
+
SourceMeta,
|
|
11
|
+
} from "./model.js";
|
|
12
|
+
import { ROBLOX_TARGET_SCHEMA_VERSION } from "./model.js";
|
|
13
|
+
import { normalizeMiniDump } from "./normalize.js";
|
|
14
|
+
import { applyDatatypeOverrides, applyGlobalsOverrides, applyLibraryOverrides, applyClassOverrides } from "./merge.js";
|
|
15
|
+
import { deriveServices } from "./registry.js";
|
|
16
|
+
import { hashBuffer } from "./resolver.js";
|
|
17
|
+
import { loadMiniDump } from "./sources/mini-dump.js";
|
|
18
|
+
import { assertValid } from "./validate.js";
|
|
19
|
+
|
|
20
|
+
const DEFAULT_GLOBALS: Record<string, GlobalDefinition> = {
|
|
21
|
+
game: { name: "game", type: { kind: "Class", name: "DataModel" }, layer: "roblox-engine" },
|
|
22
|
+
workspace: { name: "workspace", type: { kind: "Class", name: "Workspace" }, layer: "roblox-engine" },
|
|
23
|
+
script: { name: "script", type: { kind: "Class", name: "LuaSourceContainer" }, layer: "roblox-engine" },
|
|
24
|
+
plugin: { name: "plugin", type: { kind: "Class", name: "Plugin" }, layer: "roblox-engine" },
|
|
25
|
+
typeof: { name: "typeof", type: { kind: "Function", parameters: [{ kind: "Any" }], returns: [{ kind: "Primitive", name: "string" }] }, layer: "luau-core" },
|
|
26
|
+
print: { name: "print", type: { kind: "Function", parameters: [{ kind: "Any" }], returns: [{ kind: "Primitive", name: "void" }], variadic: true }, layer: "luau-core" },
|
|
27
|
+
warn: { name: "warn", type: { kind: "Function", parameters: [{ kind: "Any" }], returns: [{ kind: "Primitive", name: "void" }], variadic: true }, layer: "luau-core" },
|
|
28
|
+
error: { name: "error", type: { kind: "Function", parameters: [{ kind: "Any" }], returns: [{ kind: "Never" }], variadic: true }, layer: "luau-core" },
|
|
29
|
+
require: { name: "require", type: { kind: "Function", parameters: [{ kind: "Any" }], returns: [{ kind: "Any" }] }, layer: "luau-core" },
|
|
30
|
+
task: { name: "task", type: { kind: "Any" }, layer: "roblox-engine", description: "Roblox task library" },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const DEFAULT_LIBRARIES: Record<string, LibraryDefinition> = {
|
|
34
|
+
math: { name: "math", layer: "luau-core" },
|
|
35
|
+
string: { name: "string", layer: "luau-core" },
|
|
36
|
+
table: { name: "table", layer: "luau-core" },
|
|
37
|
+
bit32: { name: "bit32", layer: "luau-core" },
|
|
38
|
+
buffer: { name: "buffer", layer: "luau-core" },
|
|
39
|
+
coroutine: { name: "coroutine", layer: "luau-core" },
|
|
40
|
+
debug: { name: "debug", layer: "luau-core" },
|
|
41
|
+
os: { name: "os", layer: "luau-core" },
|
|
42
|
+
utf8: { name: "utf8", layer: "luau-core" },
|
|
43
|
+
task: { name: "task", layer: "roblox-engine" },
|
|
44
|
+
Hive: { name: "Hive", layer: "cluaupp-runtime", bind: "Hive" },
|
|
45
|
+
Flare: { name: "Flare", layer: "cluaupp-runtime", bind: "Flare" },
|
|
46
|
+
Roster: { name: "Roster", layer: "cluaupp-runtime", bind: "Roster" },
|
|
47
|
+
Ward: { name: "Ward", layer: "cluaupp-runtime", bind: "Ward" },
|
|
48
|
+
Axiom: { name: "Axiom", layer: "cluaupp-runtime", bind: "Axiom" },
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export interface BuildProfileOptions {
|
|
52
|
+
dumpPath?: string;
|
|
53
|
+
skipValidate?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function buildRobloxTargetProfile(options: BuildProfileOptions = {}): RobloxTargetProfile {
|
|
57
|
+
const loaded = loadMiniDump(options.dumpPath);
|
|
58
|
+
const { classes, enums, unsupported } = normalizeMiniDump(loaded.data);
|
|
59
|
+
|
|
60
|
+
const datatypeFile = readOverrideFile<{ datatypes?: Record<string, import("./merge.js").RawDatatypeOverride> }>(
|
|
61
|
+
"datatypes.json",
|
|
62
|
+
);
|
|
63
|
+
const datatypes = applyDatatypeOverrides({}, datatypeFile.data.datatypes || {});
|
|
64
|
+
|
|
65
|
+
const globalsFile = readOverrideFile<Record<string, { type?: string; layer?: GlobalDefinition["layer"]; description?: string }>>(
|
|
66
|
+
"globals.json",
|
|
67
|
+
);
|
|
68
|
+
const globals = applyGlobalsOverrides(DEFAULT_GLOBALS, stripMeta(globalsFile.data));
|
|
69
|
+
|
|
70
|
+
const libsFile = readOverrideFile<Record<string, LibraryDefinition>>("libraries.json");
|
|
71
|
+
const libraries = applyLibraryOverrides(DEFAULT_LIBRARIES, stripMeta(libsFile.data) as Record<string, LibraryDefinition>);
|
|
72
|
+
|
|
73
|
+
const classesFile = readOverrideFile<Record<string, Partial<(typeof classes)[string]>>>("classes.json");
|
|
74
|
+
applyClassOverrides(classes, stripMeta(classesFile.data) as Record<string, Partial<(typeof classes)[string]>>);
|
|
75
|
+
|
|
76
|
+
const services = deriveServices(classes);
|
|
77
|
+
|
|
78
|
+
const sources: Record<string, SourceMeta> = {
|
|
79
|
+
[loaded.meta.id]: loaded.meta,
|
|
80
|
+
overrides: {
|
|
81
|
+
id: "overrides",
|
|
82
|
+
hash: overridesHash(),
|
|
83
|
+
loadedAt: new Date().toISOString(),
|
|
84
|
+
path: path.join(projectRoot, "api", "overrides"),
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const profile: RobloxTargetProfile = {
|
|
89
|
+
target: "roblox",
|
|
90
|
+
schemaVersion: ROBLOX_TARGET_SCHEMA_VERSION,
|
|
91
|
+
robloxApiVersion: loaded.meta.version != null ? String(loaded.meta.version) : undefined,
|
|
92
|
+
generatorVersion: pkg.version,
|
|
93
|
+
sources,
|
|
94
|
+
classes,
|
|
95
|
+
enums,
|
|
96
|
+
datatypes,
|
|
97
|
+
globals,
|
|
98
|
+
libraries,
|
|
99
|
+
services,
|
|
100
|
+
aliases: {},
|
|
101
|
+
constructors: Object.fromEntries(
|
|
102
|
+
Object.values(datatypes)
|
|
103
|
+
.filter((d) => d.constructors.length)
|
|
104
|
+
.map((d) => [d.name, d.constructors]),
|
|
105
|
+
),
|
|
106
|
+
security: {},
|
|
107
|
+
deprecations: {},
|
|
108
|
+
unsupported,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
if (!options.skipValidate) {
|
|
112
|
+
assertValid(profile);
|
|
113
|
+
}
|
|
114
|
+
return profile;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function stripMeta<T extends Record<string, unknown>>(data: T): T {
|
|
118
|
+
const { _meta: _, ...rest } = data as T & { _meta?: unknown };
|
|
119
|
+
return rest as T;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function writeProfileCache(profile: RobloxTargetProfile, outPath?: string): string {
|
|
123
|
+
const target = outPath || path.join(projectRoot, "api", "normalized", "roblox-target.profile.json");
|
|
124
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
125
|
+
const json = `${JSON.stringify(profile, null, "\t")}\n`;
|
|
126
|
+
const tmp = `${target}.${process.pid}.tmp`;
|
|
127
|
+
fs.writeFileSync(tmp, json, "utf8");
|
|
128
|
+
fs.renameSync(tmp, target);
|
|
129
|
+
return target;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function profileContentHash(profile: RobloxTargetProfile): string {
|
|
133
|
+
const clone = { ...profile, sources: { ...profile.sources } };
|
|
134
|
+
for (const key of Object.keys(clone.sources)) {
|
|
135
|
+
clone.sources[key] = { ...clone.sources[key], loadedAt: "" };
|
|
136
|
+
}
|
|
137
|
+
return hashBuffer(JSON.stringify(clone));
|
|
138
|
+
}
|
package/src/api/cache.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { projectRoot } from "../package-info.js";
|
|
4
|
+
import { hashBuffer } from "../api/resolver.js";
|
|
5
|
+
import { overridesHash } from "../api/loader.js";
|
|
6
|
+
import { buildRobloxTargetProfile, profileContentHash } from "../api/build-profile.js";
|
|
7
|
+
|
|
8
|
+
export interface CacheKey {
|
|
9
|
+
sourceHash: string;
|
|
10
|
+
overridesHash: string;
|
|
11
|
+
generatorVersion: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function computeCacheKey(generatorVersion: string, dumpPath?: string): CacheKey {
|
|
15
|
+
const profile = buildRobloxTargetProfile({ dumpPath, skipValidate: true });
|
|
16
|
+
return {
|
|
17
|
+
sourceHash: profile.sources["mini-api-dump"]?.hash || profileContentHash(profile),
|
|
18
|
+
overridesHash: overridesHash(),
|
|
19
|
+
generatorVersion,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function cacheDir(): string {
|
|
24
|
+
return path.join(projectRoot, "api", ".cache");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function readCache<T>(key: string): T | null {
|
|
28
|
+
const file = path.join(cacheDir(), `${key}.json`);
|
|
29
|
+
if (!fs.existsSync(file)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return JSON.parse(fs.readFileSync(file, "utf8")) as T;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function writeCache(key: string, value: unknown): void {
|
|
36
|
+
fs.mkdirSync(cacheDir(), { recursive: true });
|
|
37
|
+
const file = path.join(cacheDir(), `${key}.json`);
|
|
38
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
39
|
+
fs.writeFileSync(tmp, `${JSON.stringify(value)}\n`, "utf8");
|
|
40
|
+
fs.renameSync(tmp, file);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function cacheKeyHash(parts: CacheKey): string {
|
|
44
|
+
return hashBuffer(`${parts.sourceHash}:${parts.overridesHash}:${parts.generatorVersion}`);
|
|
45
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ApiRegistry } from "./registry.js";
|
|
2
|
+
import type { UnsupportedRepresentation } from "./model.js";
|
|
3
|
+
|
|
4
|
+
export interface CoverageReport {
|
|
5
|
+
classes: number;
|
|
6
|
+
enums: number;
|
|
7
|
+
datatypes: number;
|
|
8
|
+
services: number;
|
|
9
|
+
properties: number;
|
|
10
|
+
methods: number;
|
|
11
|
+
events: number;
|
|
12
|
+
callbacks: number;
|
|
13
|
+
unsupported: UnsupportedRepresentation[];
|
|
14
|
+
coveragePercent: number;
|
|
15
|
+
gaps: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function computeCoverage(registry: ApiRegistry): CoverageReport {
|
|
19
|
+
let properties = 0;
|
|
20
|
+
let methods = 0;
|
|
21
|
+
let events = 0;
|
|
22
|
+
let callbacks = 0;
|
|
23
|
+
for (const cls of registry.classes.values()) {
|
|
24
|
+
properties += cls.properties.length;
|
|
25
|
+
methods += cls.methods.length;
|
|
26
|
+
events += cls.events.length;
|
|
27
|
+
callbacks += cls.callbacks.length;
|
|
28
|
+
}
|
|
29
|
+
const unsupported = registry.profile.unsupported;
|
|
30
|
+
const totalMembers = properties + methods + events + callbacks;
|
|
31
|
+
const gapCount = unsupported.filter((u) => u.severity !== "info").length;
|
|
32
|
+
const coveragePercent = totalMembers === 0 ? 100 : Math.max(0, Math.round(((totalMembers - gapCount) / totalMembers) * 10000) / 100);
|
|
33
|
+
return {
|
|
34
|
+
classes: registry.classes.size,
|
|
35
|
+
enums: registry.enums.size,
|
|
36
|
+
datatypes: registry.datatypes.size,
|
|
37
|
+
services: registry.services.size,
|
|
38
|
+
properties,
|
|
39
|
+
methods,
|
|
40
|
+
events,
|
|
41
|
+
callbacks,
|
|
42
|
+
unsupported,
|
|
43
|
+
coveragePercent,
|
|
44
|
+
gaps: unsupported.map((u) => `${u.symbol}: ${u.reason}`),
|
|
45
|
+
};
|
|
46
|
+
}
|
package/src/api/diff.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { ApiDiffEntry, RobloxTargetProfile } from "./model.js";
|
|
2
|
+
import { typeToClpp } from "./resolver.js";
|
|
3
|
+
|
|
4
|
+
export function diffProfiles(before: RobloxTargetProfile, after: RobloxTargetProfile): ApiDiffEntry[] {
|
|
5
|
+
const out: ApiDiffEntry[] = [];
|
|
6
|
+
const beforeClasses = new Set(Object.keys(before.classes));
|
|
7
|
+
const afterClasses = new Set(Object.keys(after.classes));
|
|
8
|
+
|
|
9
|
+
for (const name of afterClasses) {
|
|
10
|
+
if (!beforeClasses.has(name)) {
|
|
11
|
+
out.push({ kind: "ADDED_CLASS", symbol: name });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
for (const name of beforeClasses) {
|
|
15
|
+
if (!afterClasses.has(name)) {
|
|
16
|
+
out.push({ kind: "REMOVED_CLASS", symbol: name });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
for (const name of afterClasses) {
|
|
21
|
+
if (!beforeClasses.has(name)) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const a = before.classes[name];
|
|
25
|
+
const b = after.classes[name];
|
|
26
|
+
if ((a.superclass || null) !== (b.superclass || null)) {
|
|
27
|
+
out.push({
|
|
28
|
+
kind: "CHANGED_SUPERCLASS",
|
|
29
|
+
symbol: name,
|
|
30
|
+
oldValue: a.superclass || undefined,
|
|
31
|
+
newValue: b.superclass || undefined,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
diffProps(a.name, a.properties, b.properties, out);
|
|
35
|
+
diffMethods(a.name, a.methods, b.methods, out);
|
|
36
|
+
diffEvents(a.name, a.events, b.events, out);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const beforeEnums = new Set(Object.keys(before.enums));
|
|
40
|
+
const afterEnums = new Set(Object.keys(after.enums));
|
|
41
|
+
for (const name of afterEnums) {
|
|
42
|
+
if (!beforeEnums.has(name)) {
|
|
43
|
+
out.push({ kind: "ADDED_ENUM", symbol: name });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for (const name of beforeEnums) {
|
|
47
|
+
if (!afterEnums.has(name)) {
|
|
48
|
+
out.push({ kind: "REMOVED_ENUM", symbol: name });
|
|
49
|
+
} else {
|
|
50
|
+
const aItems = new Set(before.enums[name].items.map((i) => i.name));
|
|
51
|
+
const bItems = new Set(after.enums[name].items.map((i) => i.name));
|
|
52
|
+
for (const item of bItems) {
|
|
53
|
+
if (!aItems.has(item)) {
|
|
54
|
+
out.push({ kind: "ADDED_ENUM_ITEM", symbol: `${name}.${item}` });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (const item of aItems) {
|
|
58
|
+
if (!bItems.has(item)) {
|
|
59
|
+
out.push({ kind: "REMOVED_ENUM_ITEM", symbol: `${name}.${item}` });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function diffProps(
|
|
69
|
+
owner: string,
|
|
70
|
+
before: RobloxTargetProfile["classes"][string]["properties"],
|
|
71
|
+
after: RobloxTargetProfile["classes"][string]["properties"],
|
|
72
|
+
out: ApiDiffEntry[],
|
|
73
|
+
): void {
|
|
74
|
+
const bMap = new Map(before.map((p) => [p.name, p]));
|
|
75
|
+
const aMap = new Map(after.map((p) => [p.name, p]));
|
|
76
|
+
for (const [name, prop] of aMap) {
|
|
77
|
+
if (!bMap.has(name)) {
|
|
78
|
+
out.push({ kind: "ADDED_PROPERTY", symbol: `${owner}.${name}` });
|
|
79
|
+
} else {
|
|
80
|
+
const old = bMap.get(name)!;
|
|
81
|
+
if (typeToClpp(old.valueType) !== typeToClpp(prop.valueType)) {
|
|
82
|
+
out.push({
|
|
83
|
+
kind: "CHANGED_PROPERTY_TYPE",
|
|
84
|
+
symbol: `${owner}.${name}`,
|
|
85
|
+
oldValue: typeToClpp(old.valueType),
|
|
86
|
+
newValue: typeToClpp(prop.valueType),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
for (const name of bMap.keys()) {
|
|
92
|
+
if (!aMap.has(name)) {
|
|
93
|
+
out.push({ kind: "REMOVED_PROPERTY", symbol: `${owner}.${name}` });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function diffMethods(
|
|
99
|
+
owner: string,
|
|
100
|
+
before: RobloxTargetProfile["classes"][string]["methods"],
|
|
101
|
+
after: RobloxTargetProfile["classes"][string]["methods"],
|
|
102
|
+
out: ApiDiffEntry[],
|
|
103
|
+
): void {
|
|
104
|
+
const key = (m: { name: string; overloadIndex: number }) => `${m.name}#${m.overloadIndex}`;
|
|
105
|
+
const bSet = new Set(before.map(key));
|
|
106
|
+
const aSet = new Set(after.map(key));
|
|
107
|
+
for (const k of aSet) {
|
|
108
|
+
if (!bSet.has(k)) {
|
|
109
|
+
out.push({ kind: "ADDED_METHOD_OVERLOAD", symbol: `${owner}.${k}` });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (const k of bSet) {
|
|
113
|
+
if (!aSet.has(k)) {
|
|
114
|
+
out.push({ kind: "REMOVED_METHOD_OVERLOAD", symbol: `${owner}.${k}` });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function diffEvents(
|
|
120
|
+
owner: string,
|
|
121
|
+
before: RobloxTargetProfile["classes"][string]["events"],
|
|
122
|
+
after: RobloxTargetProfile["classes"][string]["events"],
|
|
123
|
+
out: ApiDiffEntry[],
|
|
124
|
+
): void {
|
|
125
|
+
const bMap = new Map(before.map((e) => [e.name, e]));
|
|
126
|
+
const aMap = new Map(after.map((e) => [e.name, e]));
|
|
127
|
+
for (const [name, ev] of aMap) {
|
|
128
|
+
if (!bMap.has(name)) {
|
|
129
|
+
out.push({ kind: "ADDED_EVENT", symbol: `${owner}.${name}` });
|
|
130
|
+
} else {
|
|
131
|
+
const oldSig = bMap.get(name)!.parameters.map((p) => typeToClpp(p.type)).join(",");
|
|
132
|
+
const newSig = ev.parameters.map((p) => typeToClpp(p.type)).join(",");
|
|
133
|
+
if (oldSig !== newSig) {
|
|
134
|
+
out.push({
|
|
135
|
+
kind: "CHANGED_EVENT_SIGNATURE",
|
|
136
|
+
symbol: `${owner}.${name}`,
|
|
137
|
+
oldValue: oldSig,
|
|
138
|
+
newValue: newSig,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|