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,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Roblox Luau style for Cluaupp emit: tabs, indent blocks, leave inner spacing alone.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.formatLuauRoblox = formatLuauRoblox;
|
|
5
|
+
const TAB = "\t";
|
|
6
|
+
function longClose(eq) {
|
|
7
|
+
return `]${"=".repeat(eq)}]`;
|
|
8
|
+
}
|
|
9
|
+
function longOpenEq(text, index) {
|
|
10
|
+
if (text[index] !== "[") {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
let i = index + 1;
|
|
14
|
+
let eq = 0;
|
|
15
|
+
while (text[i] === "=") {
|
|
16
|
+
eq += 1;
|
|
17
|
+
i += 1;
|
|
18
|
+
}
|
|
19
|
+
if (text[i] === "[") {
|
|
20
|
+
return eq;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function skipLong(text, start, eq) {
|
|
25
|
+
const close = longClose(eq);
|
|
26
|
+
const found = text.indexOf(close, start);
|
|
27
|
+
if (found === -1) {
|
|
28
|
+
return { next: text.length, closed: false };
|
|
29
|
+
}
|
|
30
|
+
return { next: found + close.length, closed: true };
|
|
31
|
+
}
|
|
32
|
+
function firstToken(text) {
|
|
33
|
+
const match = text.match(/^[A-Za-z_][A-Za-z0-9_]*|^\}/);
|
|
34
|
+
return match ? match[0] : "";
|
|
35
|
+
}
|
|
36
|
+
function identAt(text, from) {
|
|
37
|
+
let j = from;
|
|
38
|
+
while (j < text.length && /[A-Za-z0-9_]/.test(text[j] || "")) {
|
|
39
|
+
j += 1;
|
|
40
|
+
}
|
|
41
|
+
return text.slice(from, j);
|
|
42
|
+
}
|
|
43
|
+
function scanDelta(text, carry) {
|
|
44
|
+
let i = 0;
|
|
45
|
+
let delta = 0;
|
|
46
|
+
let long = carry.long;
|
|
47
|
+
let eq = carry.eq;
|
|
48
|
+
const consumeLong = (kind, depth, from) => {
|
|
49
|
+
const skipped = skipLong(text, from, depth);
|
|
50
|
+
if (!skipped.closed) {
|
|
51
|
+
long = kind;
|
|
52
|
+
eq = depth;
|
|
53
|
+
i = text.length;
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
long = "none";
|
|
57
|
+
eq = 0;
|
|
58
|
+
i = skipped.next;
|
|
59
|
+
return true;
|
|
60
|
+
};
|
|
61
|
+
if (long === "string") {
|
|
62
|
+
consumeLong("string", eq, 0);
|
|
63
|
+
}
|
|
64
|
+
else if (long === "comment") {
|
|
65
|
+
consumeLong("comment", eq, 0);
|
|
66
|
+
}
|
|
67
|
+
while (i < text.length) {
|
|
68
|
+
const ch = text[i] || "";
|
|
69
|
+
if (ch === "-" && text[i + 1] === "-") {
|
|
70
|
+
const commentEq = longOpenEq(text, i + 2);
|
|
71
|
+
if (commentEq !== null) {
|
|
72
|
+
const openEnd = i + 4 + commentEq;
|
|
73
|
+
if (!consumeLong("comment", commentEq, openEnd)) {
|
|
74
|
+
return { delta, carry: { long, eq } };
|
|
75
|
+
}
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
if (ch === "'" || ch === '"') {
|
|
81
|
+
const quote = ch;
|
|
82
|
+
i += 1;
|
|
83
|
+
while (i < text.length) {
|
|
84
|
+
if (text[i] === "\\") {
|
|
85
|
+
i += 2;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (text[i] === quote) {
|
|
89
|
+
i += 1;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
i += 1;
|
|
93
|
+
}
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const strEq = longOpenEq(text, i);
|
|
97
|
+
if (strEq !== null) {
|
|
98
|
+
const openEnd = i + 2 + strEq;
|
|
99
|
+
if (!consumeLong("string", strEq, openEnd)) {
|
|
100
|
+
return { delta, carry: { long, eq } };
|
|
101
|
+
}
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (ch === "{") {
|
|
105
|
+
delta += 1;
|
|
106
|
+
i += 1;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (ch === "}") {
|
|
110
|
+
delta -= 1;
|
|
111
|
+
i += 1;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (/[A-Za-z_]/.test(ch)) {
|
|
115
|
+
const word = identAt(text, i);
|
|
116
|
+
i += word.length;
|
|
117
|
+
if (word === "function" || word === "then" || word === "do" || word === "repeat") {
|
|
118
|
+
delta += 1;
|
|
119
|
+
}
|
|
120
|
+
else if (word === "end" || word === "until") {
|
|
121
|
+
delta -= 1;
|
|
122
|
+
}
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
i += 1;
|
|
126
|
+
}
|
|
127
|
+
return { delta, carry: { long, eq } };
|
|
128
|
+
}
|
|
129
|
+
function formatLuauRoblox(source) {
|
|
130
|
+
const lines = String(source).split(/\r?\n/);
|
|
131
|
+
const out = [];
|
|
132
|
+
let indent = 0;
|
|
133
|
+
let carry = { long: "none", eq: 0 };
|
|
134
|
+
for (const raw of lines) {
|
|
135
|
+
if (raw.trim() === "") {
|
|
136
|
+
out.push("");
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (carry.long !== "none") {
|
|
140
|
+
out.push(raw.trimEnd());
|
|
141
|
+
carry = scanDelta(raw, carry).carry;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const trimmed = raw.trim();
|
|
145
|
+
const lead = firstToken(trimmed);
|
|
146
|
+
const closer = lead === "end" || lead === "until" || lead === "else" || lead === "elseif" || lead === "}";
|
|
147
|
+
if (closer) {
|
|
148
|
+
indent = Math.max(0, indent - 1);
|
|
149
|
+
}
|
|
150
|
+
out.push(`${TAB.repeat(indent)}${trimmed}`);
|
|
151
|
+
const rest = closer ? trimmed.slice(lead.length) : trimmed;
|
|
152
|
+
const scanned = scanDelta(rest, carry);
|
|
153
|
+
indent = Math.max(0, indent + scanned.delta);
|
|
154
|
+
if (lead === "else") {
|
|
155
|
+
indent += 1;
|
|
156
|
+
}
|
|
157
|
+
carry = scanned.carry;
|
|
158
|
+
}
|
|
159
|
+
return `${collapseBlanks(compactTableFields(spaceScopes(out))).join("\n").replace(/[ \t]+$/gm, "").replace(/\n+$/, "")}\n`;
|
|
160
|
+
}
|
|
161
|
+
function lineIndent(line) {
|
|
162
|
+
const match = line.match(/^\t*/);
|
|
163
|
+
return match ? match[0].length : 0;
|
|
164
|
+
}
|
|
165
|
+
function isComment(line) {
|
|
166
|
+
return line.trimStart().startsWith("--");
|
|
167
|
+
}
|
|
168
|
+
function spaceScopes(lines) {
|
|
169
|
+
const out = [];
|
|
170
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
171
|
+
const line = lines[i] || "";
|
|
172
|
+
const next = lines[i + 1];
|
|
173
|
+
out.push(line);
|
|
174
|
+
if (next === undefined || line.trim() === "" || next.trim() === "") {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (lineIndent(line) !== lineIndent(next)) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const lead = firstToken(line.trim());
|
|
181
|
+
const nextLead = firstToken(next.trim());
|
|
182
|
+
const nextCloses = nextLead === "else" || nextLead === "elseif" || nextLead === "end" || nextLead === "until" || nextLead === "}";
|
|
183
|
+
if ((lead === "end" || lead === "until" || lead === "}") && !nextCloses) {
|
|
184
|
+
out.push("");
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const nextOpens = nextLead === "if" || nextLead === "for" || nextLead === "while" || nextLead === "repeat";
|
|
188
|
+
const prevOpens = lead === "if" || lead === "for" || lead === "while" || lead === "repeat" || lead === "else" || lead === "elseif";
|
|
189
|
+
if (nextOpens && !prevOpens && lead !== "end" && lead !== "until" && lead !== "}" && !isComment(line)) {
|
|
190
|
+
out.push("");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return out;
|
|
194
|
+
}
|
|
195
|
+
function collapseBlanks(lines) {
|
|
196
|
+
const out = [];
|
|
197
|
+
for (const line of lines) {
|
|
198
|
+
if (line.trim() === "" && out.length > 0 && (out[out.length - 1] || "").trim() === "") {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
out.push(line);
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
function tableName(line) {
|
|
206
|
+
const trimmed = line.trim();
|
|
207
|
+
const field = trimmed.match(/^([A-Za-z_][A-Za-z0-9_]*)\.[A-Za-z_][A-Za-z0-9_]*\s*=/);
|
|
208
|
+
if (field) {
|
|
209
|
+
return field[1];
|
|
210
|
+
}
|
|
211
|
+
const ctor = trimmed.match(/^(?:local|const)\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*\{\s*\}\s*$/);
|
|
212
|
+
return ctor ? ctor[1] : null;
|
|
213
|
+
}
|
|
214
|
+
function compactTableFields(lines) {
|
|
215
|
+
const out = [];
|
|
216
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
217
|
+
const line = lines[i] || "";
|
|
218
|
+
if (line.trim() !== "") {
|
|
219
|
+
out.push(line);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const prev = out[out.length - 1];
|
|
223
|
+
let nextIndex = i + 1;
|
|
224
|
+
while (nextIndex < lines.length && (lines[nextIndex] || "").trim() === "") {
|
|
225
|
+
nextIndex += 1;
|
|
226
|
+
}
|
|
227
|
+
const next = lines[nextIndex];
|
|
228
|
+
const prevTable = prev ? tableName(prev) : null;
|
|
229
|
+
const nextTable = next !== undefined ? tableName(next) : null;
|
|
230
|
+
if (prevTable && nextTable && prevTable === nextTable) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
out.push(line);
|
|
234
|
+
}
|
|
235
|
+
return out;
|
|
236
|
+
}
|
package/generated/clpp/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toLuauPath = exports.siblingHeader = exports.scriptKind = exports.isTaggedScript = exports.isSourceFile = exports.isImplFile = exports.isHeaderFile = exports.isEngineStub = exports.fileStem = exports.emitKind = exports.collectSources = exports.SOURCE_EXTS = exports.shouldSkipInit = exports.clppLuauToGame = exports.resolveClppBinary = exports.hasClpp = exports.clppVersion = exports.clppManifest = exports.compileViaClppAsync = exports.compileViaClpp = exports.MIN_CLPP_VERSION = exports.CLPP_INSTALL_HINT = void 0;
|
|
3
|
+
exports.rewriteGameRootedRequires = exports.resolveModuleFile = exports.resolveLanguageDeps = exports.planLayoutFromHints = exports.fingerprintSourceWithDeps = exports.ensureGameServices = exports.collectModuleRefs = exports.collectLanguageModulePaths = exports.applyNativeHintsToLuau = exports.toLuauPath = exports.siblingHeader = exports.scriptKind = exports.isTaggedScript = exports.isSourceFile = exports.isImplFile = exports.isHeaderFile = exports.isEngineStub = exports.fileStem = exports.emitKind = exports.collectSources = exports.SOURCE_EXTS = exports.shouldSkipInit = exports.rewriteClppEmit = exports.formatLuauRoblox = exports.clppLuauToGame = exports.resolveClppBinary = exports.hasClpp = exports.clppVersion = exports.clppManifest = exports.compileViaClppAsync = exports.compileViaClpp = exports.MIN_CLPP_VERSION = exports.CLPP_INSTALL_HINT = void 0;
|
|
4
4
|
var contract_js_1 = require("./contract.js");
|
|
5
5
|
Object.defineProperty(exports, "CLPP_INSTALL_HINT", { enumerable: true, get: function () { return contract_js_1.CLPP_INSTALL_HINT; } });
|
|
6
6
|
Object.defineProperty(exports, "MIN_CLPP_VERSION", { enumerable: true, get: function () { return contract_js_1.MIN_CLPP_VERSION; } });
|
|
@@ -13,6 +13,8 @@ Object.defineProperty(exports, "hasClpp", { enumerable: true, get: function () {
|
|
|
13
13
|
Object.defineProperty(exports, "resolveClppBinary", { enumerable: true, get: function () { return runner_js_1.resolveClppBinary; } });
|
|
14
14
|
var postprocess_js_1 = require("./postprocess.js");
|
|
15
15
|
Object.defineProperty(exports, "clppLuauToGame", { enumerable: true, get: function () { return postprocess_js_1.clppLuauToGame; } });
|
|
16
|
+
Object.defineProperty(exports, "formatLuauRoblox", { enumerable: true, get: function () { return postprocess_js_1.formatLuauRoblox; } });
|
|
17
|
+
Object.defineProperty(exports, "rewriteClppEmit", { enumerable: true, get: function () { return postprocess_js_1.rewriteClppEmit; } });
|
|
16
18
|
Object.defineProperty(exports, "shouldSkipInit", { enumerable: true, get: function () { return postprocess_js_1.shouldSkipInit; } });
|
|
17
19
|
var paths_js_1 = require("./paths.js");
|
|
18
20
|
Object.defineProperty(exports, "SOURCE_EXTS", { enumerable: true, get: function () { return paths_js_1.SOURCE_EXTS; } });
|
|
@@ -27,3 +29,13 @@ Object.defineProperty(exports, "isTaggedScript", { enumerable: true, get: functi
|
|
|
27
29
|
Object.defineProperty(exports, "scriptKind", { enumerable: true, get: function () { return paths_js_1.scriptKind; } });
|
|
28
30
|
Object.defineProperty(exports, "siblingHeader", { enumerable: true, get: function () { return paths_js_1.siblingHeader; } });
|
|
29
31
|
Object.defineProperty(exports, "toLuauPath", { enumerable: true, get: function () { return paths_js_1.toLuauPath; } });
|
|
32
|
+
var modules_js_1 = require("./modules.js");
|
|
33
|
+
Object.defineProperty(exports, "applyNativeHintsToLuau", { enumerable: true, get: function () { return modules_js_1.applyNativeHintsToLuau; } });
|
|
34
|
+
Object.defineProperty(exports, "collectLanguageModulePaths", { enumerable: true, get: function () { return modules_js_1.collectLanguageModulePaths; } });
|
|
35
|
+
Object.defineProperty(exports, "collectModuleRefs", { enumerable: true, get: function () { return modules_js_1.collectModuleRefs; } });
|
|
36
|
+
Object.defineProperty(exports, "ensureGameServices", { enumerable: true, get: function () { return modules_js_1.ensureGameServices; } });
|
|
37
|
+
Object.defineProperty(exports, "fingerprintSourceWithDeps", { enumerable: true, get: function () { return modules_js_1.fingerprintSourceWithDeps; } });
|
|
38
|
+
Object.defineProperty(exports, "planLayoutFromHints", { enumerable: true, get: function () { return modules_js_1.planLayoutFromHints; } });
|
|
39
|
+
Object.defineProperty(exports, "resolveLanguageDeps", { enumerable: true, get: function () { return modules_js_1.resolveLanguageDeps; } });
|
|
40
|
+
Object.defineProperty(exports, "resolveModuleFile", { enumerable: true, get: function () { return modules_js_1.resolveModuleFile; } });
|
|
41
|
+
Object.defineProperty(exports, "rewriteGameRootedRequires", { enumerable: true, get: function () { return modules_js_1.rewriteGameRootedRequires; } });
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CL++ 0.8 module surface for the Cluaupp host.
|
|
4
|
+
* Canonical: `import { Name } from "./path.clh"` — `#include` remains legacy / angle prelude.
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.collectModuleRefs = collectModuleRefs;
|
|
11
|
+
exports.collectLanguageModulePaths = collectLanguageModulePaths;
|
|
12
|
+
exports.isAnglePlatformInclude = isAnglePlatformInclude;
|
|
13
|
+
exports.resolveModuleFile = resolveModuleFile;
|
|
14
|
+
exports.resolveLanguageDeps = resolveLanguageDeps;
|
|
15
|
+
exports.fingerprintSourceWithDeps = fingerprintSourceWithDeps;
|
|
16
|
+
exports.rewriteGameRootedRequires = rewriteGameRootedRequires;
|
|
17
|
+
exports.ensureGameServices = ensureGameServices;
|
|
18
|
+
exports.applyNativeHintsToLuau = applyNativeHintsToLuau;
|
|
19
|
+
exports.planLayoutFromHints = planLayoutFromHints;
|
|
20
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
21
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
22
|
+
const IMPORT_RE = /\bimport\s*\{([^}]*)\}\s*from\s*"([^"]+)"\s*;?/g;
|
|
23
|
+
const INCLUDE_RE = /#\s*include\s*(?:<([^>]+)>|"([^"]+)")/g;
|
|
24
|
+
function parseBindings(inner) {
|
|
25
|
+
const out = [];
|
|
26
|
+
for (const part of inner.split(",")) {
|
|
27
|
+
const piece = part.trim();
|
|
28
|
+
if (!piece)
|
|
29
|
+
continue;
|
|
30
|
+
const asMatch = /^([A-Za-z_]\w*)\s+as\s+([A-Za-z_]\w*)$/.exec(piece);
|
|
31
|
+
if (asMatch) {
|
|
32
|
+
out.push({ name: asMatch[1], alias: asMatch[2] });
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const ident = /^([A-Za-z_]\w*)$/.exec(piece);
|
|
36
|
+
if (ident) {
|
|
37
|
+
out.push({ name: ident[1], alias: ident[1] });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/** Collect every `import { … } from` and quoted/angle `#include` in source order. */
|
|
43
|
+
function collectModuleRefs(source) {
|
|
44
|
+
const refs = [];
|
|
45
|
+
const text = String(source);
|
|
46
|
+
IMPORT_RE.lastIndex = 0;
|
|
47
|
+
let m;
|
|
48
|
+
while ((m = IMPORT_RE.exec(text))) {
|
|
49
|
+
refs.push({
|
|
50
|
+
kind: "import",
|
|
51
|
+
modulePath: m[2].replace(/\\/g, "/"),
|
|
52
|
+
angled: false,
|
|
53
|
+
bindings: parseBindings(m[1]),
|
|
54
|
+
index: m.index,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
INCLUDE_RE.lastIndex = 0;
|
|
58
|
+
while ((m = INCLUDE_RE.exec(text))) {
|
|
59
|
+
const angled = Boolean(m[1]);
|
|
60
|
+
const modulePath = (m[1] || m[2] || "").replace(/\\/g, "/");
|
|
61
|
+
if (!modulePath)
|
|
62
|
+
continue;
|
|
63
|
+
refs.push({
|
|
64
|
+
kind: "include",
|
|
65
|
+
modulePath,
|
|
66
|
+
angled,
|
|
67
|
+
bindings: [],
|
|
68
|
+
index: m.index,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
refs.sort((a, b) => a.index - b.index);
|
|
72
|
+
return refs;
|
|
73
|
+
}
|
|
74
|
+
/** Language modules only — named imports + quoted includes (not angle `<clpp/…>`). */
|
|
75
|
+
function collectLanguageModulePaths(source) {
|
|
76
|
+
const out = [];
|
|
77
|
+
const seen = new Set();
|
|
78
|
+
for (const ref of collectModuleRefs(source)) {
|
|
79
|
+
if (ref.angled)
|
|
80
|
+
continue;
|
|
81
|
+
if (seen.has(ref.modulePath))
|
|
82
|
+
continue;
|
|
83
|
+
seen.add(ref.modulePath);
|
|
84
|
+
out.push(ref.modulePath);
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
function isAnglePlatformInclude(modulePath) {
|
|
89
|
+
const p = modulePath.replace(/\\/g, "/").toLowerCase();
|
|
90
|
+
return (p.startsWith("clpp/") ||
|
|
91
|
+
p.startsWith("cluaupp/") ||
|
|
92
|
+
p.startsWith("cluau/") ||
|
|
93
|
+
p === "roblox.clh" ||
|
|
94
|
+
p.endsWith("/roblox.clh"));
|
|
95
|
+
}
|
|
96
|
+
/** Resolve a module path relative to the importing file (and optional src root). */
|
|
97
|
+
function resolveModuleFile(modulePath, fromFile, srcDir) {
|
|
98
|
+
const raw = modulePath.replace(/[<>'"]/g, "").trim();
|
|
99
|
+
if (!raw || isAnglePlatformInclude(raw)) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const bases = [node_path_1.default.dirname(fromFile)];
|
|
103
|
+
if (srcDir) {
|
|
104
|
+
bases.push(srcDir);
|
|
105
|
+
}
|
|
106
|
+
for (const base of bases) {
|
|
107
|
+
const candidate = node_path_1.default.resolve(base, raw);
|
|
108
|
+
if (node_fs_1.default.existsSync(candidate) && node_fs_1.default.statSync(candidate).isFile()) {
|
|
109
|
+
return candidate;
|
|
110
|
+
}
|
|
111
|
+
// Allow omitting extension when the stem matches a source file.
|
|
112
|
+
for (const ext of [".clh", ".clp", ".clpp"]) {
|
|
113
|
+
const withExt = candidate.endsWith(ext) ? candidate : candidate + ext;
|
|
114
|
+
if (node_fs_1.default.existsSync(withExt) && node_fs_1.default.statSync(withExt).isFile()) {
|
|
115
|
+
return withExt;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
/** Absolute paths of language deps (one hop). */
|
|
122
|
+
function resolveLanguageDeps(source, fromFile, srcDir) {
|
|
123
|
+
const out = [];
|
|
124
|
+
const seen = new Set();
|
|
125
|
+
for (const mod of collectLanguageModulePaths(source)) {
|
|
126
|
+
const resolved = resolveModuleFile(mod, fromFile, srcDir);
|
|
127
|
+
if (!resolved)
|
|
128
|
+
continue;
|
|
129
|
+
const key = node_path_1.default.resolve(resolved);
|
|
130
|
+
if (seen.has(key))
|
|
131
|
+
continue;
|
|
132
|
+
seen.add(key);
|
|
133
|
+
out.push(key);
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Fingerprint source + one-hop language deps so import/include edits invalidate incremental cache.
|
|
139
|
+
*/
|
|
140
|
+
function fingerprintSourceWithDeps(source, fromFile, configKey, srcDir, hashText) {
|
|
141
|
+
const parts = [configKey, source];
|
|
142
|
+
for (const dep of resolveLanguageDeps(source, fromFile, srcDir)) {
|
|
143
|
+
try {
|
|
144
|
+
parts.push(`\n//dep:${dep.replace(/\\/g, "/")}\n`);
|
|
145
|
+
parts.push(node_fs_1.default.readFileSync(dep, "utf8"));
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
parts.push(`\n//dep-missing:${dep.replace(/\\/g, "/")}\n`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return hashText(parts.join(""));
|
|
152
|
+
}
|
|
153
|
+
/** Rewrite CL++ `script.Parent…Service…` walks to game-rooted requires. */
|
|
154
|
+
function rewriteGameRootedRequires(luau) {
|
|
155
|
+
let next = String(luau);
|
|
156
|
+
const services = [
|
|
157
|
+
"ReplicatedStorage",
|
|
158
|
+
"ReplicatedFirst",
|
|
159
|
+
"ServerScriptService",
|
|
160
|
+
"ServerStorage",
|
|
161
|
+
"StarterPlayer",
|
|
162
|
+
"StarterGui",
|
|
163
|
+
"Workspace",
|
|
164
|
+
];
|
|
165
|
+
for (const svc of services) {
|
|
166
|
+
const re = new RegExp(`script(?:\\.Parent)+\\.${svc}\\.`, "g");
|
|
167
|
+
next = next.replace(re, `${svc}.`);
|
|
168
|
+
}
|
|
169
|
+
return next;
|
|
170
|
+
}
|
|
171
|
+
/** Ensure GetService lines exist for any game-rooted require used. */
|
|
172
|
+
function ensureGameServices(luau) {
|
|
173
|
+
let next = String(luau);
|
|
174
|
+
const needed = [];
|
|
175
|
+
for (const svc of ["ReplicatedStorage", "ReplicatedFirst", "ServerScriptService", "ServerStorage", "StarterPlayer"]) {
|
|
176
|
+
if (new RegExp(`require\\(${svc}\\.`).test(next) && !new RegExp(`GetService\\(\\s*"${svc}"\\s*\\)`).test(next)) {
|
|
177
|
+
needed.push(svc);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (needed.length === 0) {
|
|
181
|
+
return next;
|
|
182
|
+
}
|
|
183
|
+
const block = needed.map((svc) => `const ${svc} = game:GetService("${svc}")`).join("\n");
|
|
184
|
+
const match = next.match(/^(?:--[^\n]*\n)+/);
|
|
185
|
+
if (!match) {
|
|
186
|
+
return `${block}\n${next}`;
|
|
187
|
+
}
|
|
188
|
+
const insertAt = match[0].length;
|
|
189
|
+
const rest = next.slice(insertAt).replace(/^\n*/, "\n");
|
|
190
|
+
return `${next.slice(0, insertAt)}\n${block}\n${rest}`;
|
|
191
|
+
}
|
|
192
|
+
/** Selective `@native` from CompileArtifact.nativeHints (never blanket). */
|
|
193
|
+
function applyNativeHintsToLuau(luau, hints) {
|
|
194
|
+
const set = new Set((hints || []).filter(Boolean));
|
|
195
|
+
if (set.size === 0) {
|
|
196
|
+
return luau;
|
|
197
|
+
}
|
|
198
|
+
const lines = luau.split(/\r?\n/);
|
|
199
|
+
const out = [];
|
|
200
|
+
for (let i = 0; i < lines.length; i++) {
|
|
201
|
+
const line = lines[i];
|
|
202
|
+
const m = line.match(/^(\s*)(local\s+function|function)\s+([A-Za-z_][\w.:]*)/);
|
|
203
|
+
if (m) {
|
|
204
|
+
const short = m[3].includes(":") ? m[3].split(":").pop() : m[3].split(".").pop();
|
|
205
|
+
if ((set.has(m[3]) || set.has(short)) && (i === 0 || !lines[i - 1].includes("@native"))) {
|
|
206
|
+
out.push(`${m[1]}@native`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
out.push(line);
|
|
210
|
+
}
|
|
211
|
+
return out.join("\n");
|
|
212
|
+
}
|
|
213
|
+
function planLayoutFromHints(layoutHints) {
|
|
214
|
+
const soa = [];
|
|
215
|
+
const buffer = [];
|
|
216
|
+
for (const h of layoutHints || []) {
|
|
217
|
+
if (h.startsWith("SoA:") || h.startsWith("SoACandidate:")) {
|
|
218
|
+
soa.push(h.replace(/^SoA(Candidate)?:/, ""));
|
|
219
|
+
}
|
|
220
|
+
else if (h.startsWith("BufferSpecialize:") ||
|
|
221
|
+
h.startsWith("BufferCandidate:") ||
|
|
222
|
+
h.startsWith("DenseNumeric:")) {
|
|
223
|
+
buffer.push(h.split(":")[1] ?? h);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return { soa, buffer };
|
|
227
|
+
}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatLuauRoblox = void 0;
|
|
4
|
+
exports.rewriteClppEmit = rewriteClppEmit;
|
|
3
5
|
exports.shouldSkipInit = shouldSkipInit;
|
|
4
6
|
exports.clppLuauToGame = clppLuauToGame;
|
|
5
7
|
const libs_js_1 = require("../libs.js");
|
|
8
|
+
const format_luau_js_1 = require("./format-luau.js");
|
|
9
|
+
const modules_js_1 = require("./modules.js");
|
|
10
|
+
const get_service_js_1 = require("../target/get-service.js");
|
|
6
11
|
const paths_js_1 = require("./paths.js");
|
|
12
|
+
const rewrite_janitor_js_1 = require("./rewrite-janitor.js");
|
|
13
|
+
var format_luau_js_2 = require("./format-luau.js");
|
|
14
|
+
Object.defineProperty(exports, "formatLuauRoblox", { enumerable: true, get: function () { return format_luau_js_2.formatLuauRoblox; } });
|
|
7
15
|
function insertAfterHeader(luau, block) {
|
|
8
16
|
const match = String(luau).match(/^(?:--[^\n]*\n)+/);
|
|
9
17
|
if (!match) {
|
|
@@ -51,14 +59,86 @@ function rewriteClppLibs(luau, relativeName) {
|
|
|
51
59
|
}
|
|
52
60
|
return next;
|
|
53
61
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
62
|
+
function rewriteReplicatedStorageRequires(luau) {
|
|
63
|
+
let next = (0, modules_js_1.rewriteGameRootedRequires)(luau);
|
|
64
|
+
next = (0, modules_js_1.ensureGameServices)(next);
|
|
65
|
+
return next;
|
|
66
|
+
}
|
|
67
|
+
function rewriteRosterNew(luau) {
|
|
68
|
+
return String(luau)
|
|
69
|
+
.replace(/Instance\.new\(\s*["']Roster["']\s*\)/g, "Roster.new()")
|
|
70
|
+
.replace(/Instance\.new\(\s*["']Roster["']\s*,/g, "Roster.new(")
|
|
71
|
+
.replace(/\bRoster\.New\s*\(/g, "Roster.new(")
|
|
72
|
+
.replace(/\bSweep\.New\s*\(/g, "Sweep.new(")
|
|
73
|
+
.replace(/\bSpark\.New\s*\(/g, "Spark.new(")
|
|
74
|
+
.replace(/\bCoil\.New\s*\(/g, "Coil.new(")
|
|
75
|
+
.replace(/\bPin\.new_\s*\(/g, "Pin.new(")
|
|
76
|
+
.replace(/\bCrest\.new_\s*\(/g, "Crest.new(")
|
|
77
|
+
.replace(/\bStage\.new_\s*\(/g, "Stage.new(");
|
|
78
|
+
}
|
|
79
|
+
function rewriteCamelColon(luau) {
|
|
80
|
+
// CL++ emits instance calls as `.Method(` without self. Any camelCase receiver +
|
|
81
|
+
// PascalCase call needs `:`. Static calls stay on PascalCase modules (Roster.New, Trace.Display).
|
|
82
|
+
let next = String(luau).replace(/\b([a-z][A-Za-z0-9]*)(?<!:)\.([A-Z][A-Za-z0-9]*)\s*\(/g, "$1:$2(");
|
|
83
|
+
const lowerMethods = ["setName", "setLabel", "getStatus", "display", "andThen", "catch_", "finally"];
|
|
84
|
+
for (const name of lowerMethods) {
|
|
85
|
+
next = next.replace(new RegExp(`\\b([a-z][A-Za-z0-9]*)(?<!:)\\.${name}\\s*\\(`, "g"), `$1:${name}(`);
|
|
86
|
+
}
|
|
87
|
+
return next;
|
|
88
|
+
}
|
|
89
|
+
function rewriteHiveWorldType(luau) {
|
|
90
|
+
if (!/\bHiveWorld\b/.test(luau)) {
|
|
56
91
|
return luau;
|
|
57
92
|
}
|
|
58
|
-
|
|
93
|
+
let next = String(luau).replace(/(?<![\w.])HiveWorld\b/g, "Hive.HiveWorld");
|
|
94
|
+
const hasHive = /CluauppLibs\.Hive\b/.test(next) || /\b(?:const|local)\s+Hive\b/.test(next);
|
|
95
|
+
if (!hasHive) {
|
|
96
|
+
next = next.replace(/\bHive\.HiveWorld\b/g, "any");
|
|
97
|
+
}
|
|
98
|
+
return next;
|
|
99
|
+
}
|
|
100
|
+
function rewriteCFrameColon(luau) {
|
|
101
|
+
const methods = [
|
|
102
|
+
"ToWorldSpace",
|
|
103
|
+
"ToObjectSpace",
|
|
104
|
+
"PointToWorldSpace",
|
|
105
|
+
"PointToObjectSpace",
|
|
106
|
+
"VectorToWorldSpace",
|
|
107
|
+
"VectorToObjectSpace",
|
|
108
|
+
"IsStudio",
|
|
109
|
+
"IsClient",
|
|
110
|
+
"IsServer",
|
|
111
|
+
];
|
|
112
|
+
let next = String(luau);
|
|
113
|
+
for (const name of methods) {
|
|
114
|
+
next = next.replace(new RegExp(`(?<!:)\\.${name}\\s*\\(`, "g"), `:${name}(`);
|
|
115
|
+
}
|
|
116
|
+
return next;
|
|
117
|
+
}
|
|
118
|
+
function rewritePlayerTemplateCtor(luau) {
|
|
119
|
+
if (!/const TemplateData = require\(/.test(luau)) {
|
|
59
120
|
return luau;
|
|
60
121
|
}
|
|
61
|
-
return
|
|
122
|
+
return String(luau).replace(/\bPlayerTemplate\s*\(/g, "TemplateData(");
|
|
123
|
+
}
|
|
124
|
+
function rewriteClppEmit(luau) {
|
|
125
|
+
let next = rewriteRosterNew(luau);
|
|
126
|
+
next = rewriteHiveWorldType(next);
|
|
127
|
+
next = rewriteCFrameColon(next);
|
|
128
|
+
next = rewriteCamelColon(next);
|
|
129
|
+
next = rewritePlayerTemplateCtor(next);
|
|
130
|
+
next = (0, rewrite_janitor_js_1.rewriteSweepJanitor)(next);
|
|
131
|
+
next = (0, get_service_js_1.rewriteGetServiceLuau)(next);
|
|
132
|
+
next = rewriteReplicatedStorageRequires(next);
|
|
133
|
+
next = ensureReplicatedStorage(next);
|
|
134
|
+
const stamp = "-- cluaupp: Roster.new / GetService ReplicatedStorage / self.janitor";
|
|
135
|
+
if (!next.includes(stamp)) {
|
|
136
|
+
next = insertAfterHeader(next, stamp);
|
|
137
|
+
}
|
|
138
|
+
return (0, format_luau_js_1.formatLuauRoblox)(next);
|
|
139
|
+
}
|
|
140
|
+
function ensureReplicatedStorage(luau) {
|
|
141
|
+
return (0, modules_js_1.ensureGameServices)(luau);
|
|
62
142
|
}
|
|
63
143
|
function stripInitCall(luau) {
|
|
64
144
|
return String(luau).replace(/\ninit\(\)\s*\n?$/m, "\n");
|
|
@@ -123,7 +203,8 @@ function shouldSkipInit(fileName, hasSiblingHeader) {
|
|
|
123
203
|
}
|
|
124
204
|
function clppLuauToGame(artifact, options) {
|
|
125
205
|
let luau = rewriteClppLibs(artifact.luau || "", options.relativeName);
|
|
126
|
-
luau =
|
|
206
|
+
luau = rewriteClppEmit(luau);
|
|
207
|
+
luau = (0, modules_js_1.applyNativeHintsToLuau)(luau, options.nativeHints || artifact.nativeHints);
|
|
127
208
|
if (options.skipInit) {
|
|
128
209
|
luau = stripInitCall(luau);
|
|
129
210
|
}
|