cluaupp 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +12 -7
- package/bin/cluau.js +1 -1
- package/bin/cluaupp.js +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture.md +52 -77
- package/docs/cli.md +29 -9
- package/docs/comparison.md +3 -3
- package/docs/config.md +6 -6
- package/docs/cpp-organization.md +2 -2
- package/docs/examples/index.md +2 -0
- package/docs/getting-started.md +7 -5
- package/docs/intellisense.md +49 -31
- package/docs/intro.md +2 -2
- package/docs/oop/file-tags.md +16 -17
- package/docs/oop/index.md +2 -2
- package/docs/oop/modules.md +3 -1
- package/docs/oop/services.md +7 -14
- package/docs/syntax.md +6 -5
- package/editors/vscode/extension.js +97 -146
- package/editors/vscode/package.json +6 -6
- package/examples/README.md +18 -0
- package/examples/game/.clangd +25 -0
- package/examples/game/.vscode/c_cpp_properties.json +27 -0
- package/examples/game/.vscode/extensions.json +5 -0
- package/examples/game/.vscode/settings.json +27 -0
- package/examples/game/Packages/.gitkeep +0 -0
- package/examples/game/cluaupp.config.json +6 -0
- package/examples/game/compile_flags.txt +6 -0
- package/examples/game/default.project.json +39 -0
- package/examples/game/package.json +9 -0
- package/examples/game/rokit.toml +5 -0
- package/examples/game/src/client/hud.client.cpp +12 -0
- package/{src → examples/game/src}/client/init.client.cpp +1 -0
- package/examples/game/src/server/combat.server.cpp +23 -0
- package/{src → examples/game/src}/server/leaderstats.server.cpp +1 -0
- package/examples/game/wally.toml +11 -0
- package/generated/api.js +51 -0
- package/generated/architecture.js +473 -0
- package/generated/ast.js +2 -0
- package/generated/cli.js +191 -0
- package/generated/compile.js +115 -0
- package/generated/editor-install.js +170 -0
- package/generated/emit.js +503 -0
- package/generated/emitter/luau-codegen.js +167 -0
- package/generated/emitter/translators.js +164 -0
- package/generated/headers.js +220 -0
- package/generated/index.html +49 -0
- package/generated/intellisense.js +277 -0
- package/generated/layout.js +112 -0
- package/generated/lex.js +146 -0
- package/generated/libs.js +484 -0
- package/generated/lsp.js +55 -0
- package/generated/package-info.js +11 -0
- package/generated/parse.js +607 -0
- package/generated/parser/collector.js +100 -0
- package/generated/parser/index.js +30 -0
- package/generated/preprocess.js +181 -0
- package/generated/system-understander.js +443 -0
- package/generated/transpile.js +66 -0
- package/generated/types.js +2 -0
- package/generated/understand.js +298 -0
- package/generated/utils/process-orchestrator.js +63 -0
- package/generated/utils/project.js +491 -0
- package/generated/utils/rojo-mapper.js +181 -0
- package/generated/utils/safe-paths.js +104 -0
- package/package.json +25 -8
- package/src/api.ts +53 -0
- package/src/{architecture.js → architecture.ts} +80 -33
- package/src/ast.ts +37 -0
- package/src/cli.ts +214 -0
- package/src/compile.ts +118 -0
- package/src/editor-install.ts +182 -0
- package/src/{emit.js → emit.ts} +5 -6
- package/src/emitter/luau-codegen.ts +187 -0
- package/src/emitter/translators.ts +168 -0
- package/src/headers.ts +233 -0
- package/src/intellisense.ts +286 -0
- package/src/{layout.js → layout.ts} +114 -129
- package/src/{lex.js → lex.ts} +4 -6
- package/src/{libs.js → libs.ts} +119 -46
- package/src/lsp.ts +60 -0
- package/src/package-info.ts +7 -0
- package/src/{parse.js → parse.ts} +3 -4
- package/src/parser/collector.ts +115 -0
- package/src/parser/index.ts +27 -0
- package/src/{preprocess.js → preprocess.ts} +64 -32
- package/src/system-understander.ts +501 -0
- package/src/transpile.ts +64 -0
- package/src/tree-sitter-cpp.d.ts +4 -0
- package/src/types.ts +81 -0
- package/src/{understand.js → understand.ts} +24 -213
- package/src/utils/process-orchestrator.ts +72 -0
- package/src/utils/project.ts +506 -0
- package/src/utils/rojo-mapper.ts +190 -0
- package/src/utils/safe-paths.ts +98 -0
- package/templates/game/.clangd +9 -0
- package/templates/game/.vscode/c_cpp_properties.json +1 -1
- package/templates/game/.vscode/extensions.json +5 -6
- package/templates/game/.vscode/settings.json +7 -6
- package/templates/game/cluaupp.config.json +2 -2
- package/templates/game/compile_flags.txt +1 -0
- package/templates/game/rokit.toml +5 -0
- package/templates/game/src/client/init.client.cpp +1 -0
- package/templates/game/src/server/leaderstats.server.cpp +1 -0
- package/src/api.js +0 -57
- package/src/cli.js +0 -481
- package/src/compile.js +0 -56
- package/src/editor-install.js +0 -218
- package/src/intellisense.js +0 -1368
- package/src/lsp.js +0 -227
- /package/{src → examples/game/src}/shared/config.cpp +0 -0
- /package/{src → examples/game/src}/shared/config.h +0 -0
package/src/editor-install.js
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const os = require("os");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const https = require("https");
|
|
7
|
-
const { spawnSync } = require("child_process");
|
|
8
|
-
|
|
9
|
-
const CPPTOOLS_ID = "ms-vscode.cpptools";
|
|
10
|
-
const GITHUB_LATEST = "https://api.github.com/repos/microsoft/vscode-cpptools/releases/latest";
|
|
11
|
-
|
|
12
|
-
function which(command) {
|
|
13
|
-
const finder = process.platform === "win32" ? "where" : "which";
|
|
14
|
-
const result = spawnSync(finder, [command], { encoding: "utf8", windowsHide: true });
|
|
15
|
-
if (result.status !== 0) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return String(result.stdout || "")
|
|
19
|
-
.split(/\r?\n/)
|
|
20
|
-
.map((line) => line.trim())
|
|
21
|
-
.find((line) => line && !line.toLowerCase().includes("info:"));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function editorBin() {
|
|
25
|
-
const found = which("cursor") || which("code");
|
|
26
|
-
if (found) {
|
|
27
|
-
return found;
|
|
28
|
-
}
|
|
29
|
-
const local = process.env.LOCALAPPDATA || "";
|
|
30
|
-
const fallbacks = [
|
|
31
|
-
path.join(local, "Programs", "cursor", "resources", "app", "bin", "cursor.cmd"),
|
|
32
|
-
path.join(local, "Programs", "Microsoft VS Code", "bin", "code.cmd"),
|
|
33
|
-
"/usr/bin/cursor",
|
|
34
|
-
"/usr/local/bin/cursor",
|
|
35
|
-
"/usr/bin/code",
|
|
36
|
-
"/usr/local/bin/code",
|
|
37
|
-
];
|
|
38
|
-
return fallbacks.find((file) => fs.existsSync(file)) || null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function extensionHomes() {
|
|
42
|
-
return [
|
|
43
|
-
path.join(os.homedir(), ".cursor", "extensions"),
|
|
44
|
-
path.join(os.homedir(), ".vscode", "extensions"),
|
|
45
|
-
];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function isCppToolsInstalled() {
|
|
49
|
-
for (const home of extensionHomes()) {
|
|
50
|
-
if (!fs.existsSync(home)) {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
if (fs.readdirSync(home).some((name) => name.startsWith(CPPTOOLS_ID + "-"))) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
} catch {
|
|
58
|
-
// ignore
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const bin = editorBin();
|
|
62
|
-
if (!bin) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
const listed = spawnSync(bin, ["--list-extensions"], { encoding: "utf8", windowsHide: true, timeout: 20000 });
|
|
66
|
-
return String(listed.stdout || "").split(/\r?\n/).includes(CPPTOOLS_ID);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function vsixAssetName(platform = process.platform, arch = process.arch) {
|
|
70
|
-
const cpu = arch === "arm64" ? "arm64" : "x64";
|
|
71
|
-
if (platform === "win32") {
|
|
72
|
-
return `cpptools-windows-${cpu}.vsix`;
|
|
73
|
-
}
|
|
74
|
-
if (platform === "darwin") {
|
|
75
|
-
return `cpptools-macOS-${cpu}.vsix`;
|
|
76
|
-
}
|
|
77
|
-
return `cpptools-linux-${cpu}.vsix`;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function httpsJson(url) {
|
|
81
|
-
return new Promise((resolve, reject) => {
|
|
82
|
-
const request = https.get(
|
|
83
|
-
url,
|
|
84
|
-
{ headers: { "User-Agent": "cluaupp", Accept: "application/vnd.github+json" } },
|
|
85
|
-
(response) => {
|
|
86
|
-
if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
|
|
87
|
-
response.resume();
|
|
88
|
-
httpsJson(response.headers.location).then(resolve, reject);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const chunks = [];
|
|
92
|
-
response.on("data", (chunk) => chunks.push(chunk));
|
|
93
|
-
response.on("end", () => {
|
|
94
|
-
if (response.statusCode !== 200) {
|
|
95
|
-
reject(new Error("GitHub " + response.statusCode));
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
resolve(JSON.parse(Buffer.concat(chunks).toString("utf8")));
|
|
100
|
-
} catch (err) {
|
|
101
|
-
reject(err);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
);
|
|
106
|
-
request.on("error", reject);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function downloadFile(url, dest) {
|
|
111
|
-
return new Promise((resolve, reject) => {
|
|
112
|
-
const follow = (current) => {
|
|
113
|
-
https
|
|
114
|
-
.get(current, { headers: { "User-Agent": "cluaupp" } }, (response) => {
|
|
115
|
-
if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
|
|
116
|
-
response.resume();
|
|
117
|
-
follow(response.headers.location);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (response.statusCode !== 200) {
|
|
121
|
-
reject(new Error("download failed " + response.statusCode));
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
const out = fs.createWriteStream(dest);
|
|
125
|
-
response.pipe(out);
|
|
126
|
-
out.on("finish", () => out.close(() => resolve(dest)));
|
|
127
|
-
out.on("error", reject);
|
|
128
|
-
})
|
|
129
|
-
.on("error", reject);
|
|
130
|
-
};
|
|
131
|
-
follow(url);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async function downloadCppToolsVsix() {
|
|
136
|
-
const name = vsixAssetName();
|
|
137
|
-
const dest = path.join(os.tmpdir(), name);
|
|
138
|
-
if (fs.existsSync(dest) && fs.statSync(dest).size > 1_000_000) {
|
|
139
|
-
return dest;
|
|
140
|
-
}
|
|
141
|
-
const release = await httpsJson(GITHUB_LATEST);
|
|
142
|
-
const asset = (release.assets || []).find((item) => item.name === name);
|
|
143
|
-
if (!asset || !asset.browser_download_url) {
|
|
144
|
-
throw new Error("no " + name + " in vscode-cpptools " + (release.tag_name || "latest"));
|
|
145
|
-
}
|
|
146
|
-
console.log("cluaupp: downloading", name, release.tag_name || "");
|
|
147
|
-
return downloadFile(asset.browser_download_url, dest);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function spawnInstall(bin, target) {
|
|
151
|
-
const result = spawnSync(bin, ["--install-extension", target, "--force"], {
|
|
152
|
-
encoding: "utf8",
|
|
153
|
-
windowsHide: true,
|
|
154
|
-
timeout: 180000,
|
|
155
|
-
});
|
|
156
|
-
return {
|
|
157
|
-
ok: result.status === 0 && !/not found/i.test(String(result.stderr || "") + String(result.stdout || "")),
|
|
158
|
-
stdout: String(result.stdout || ""),
|
|
159
|
-
stderr: String(result.stderr || ""),
|
|
160
|
-
status: result.status,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
async function installCppTools() {
|
|
165
|
-
if (isCppToolsInstalled()) {
|
|
166
|
-
return { status: "already", id: CPPTOOLS_ID };
|
|
167
|
-
}
|
|
168
|
-
const bin = editorBin();
|
|
169
|
-
if (!bin) {
|
|
170
|
-
return { status: "missing-editor", id: CPPTOOLS_ID };
|
|
171
|
-
}
|
|
172
|
-
console.log("cluaupp: installing", CPPTOOLS_ID);
|
|
173
|
-
const marketplace = spawnInstall(bin, CPPTOOLS_ID);
|
|
174
|
-
if (marketplace.ok) {
|
|
175
|
-
return { status: "installed", id: CPPTOOLS_ID, how: "marketplace" };
|
|
176
|
-
}
|
|
177
|
-
try {
|
|
178
|
-
const vsix = await downloadCppToolsVsix();
|
|
179
|
-
const fromFile = spawnInstall(bin, vsix);
|
|
180
|
-
if (fromFile.ok) {
|
|
181
|
-
return { status: "installed", id: CPPTOOLS_ID, how: "vsix", file: vsix };
|
|
182
|
-
}
|
|
183
|
-
return { status: "failed", id: CPPTOOLS_ID, detail: fromFile.stderr || fromFile.stdout || marketplace.stderr };
|
|
184
|
-
} catch (err) {
|
|
185
|
-
return { status: "failed", id: CPPTOOLS_ID, detail: err.message };
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function reportCppTools(result) {
|
|
190
|
-
if (!result) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
if (result.status === "already") {
|
|
194
|
-
console.log("cluaupp: Microsoft C/C++ already installed");
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
if (result.status === "installed") {
|
|
198
|
-
console.log("cluaupp: installed", CPPTOOLS_ID, result.how === "vsix" ? "(VSIX — Cursor marketplace does not list it)" : "");
|
|
199
|
-
console.log("cluaupp: reload the editor (Ctrl+Shift+P → Developer: Reload Window)");
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
if (result.status === "missing-editor") {
|
|
203
|
-
console.error("cluaupp: Cursor/VS Code CLI not found. Install ms-vscode.cpptools from the VSIX at");
|
|
204
|
-
console.error(" https://github.com/microsoft/vscode-cpptools/releases");
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
console.error("cluaupp: could not install", CPPTOOLS_ID + ":", result.detail || "unknown error");
|
|
208
|
-
console.error(" download https://github.com/microsoft/vscode-cpptools/releases and: cursor --install-extension cpptools-windows-x64.vsix");
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
module.exports = {
|
|
212
|
-
CPPTOOLS_ID,
|
|
213
|
-
editorBin,
|
|
214
|
-
isCppToolsInstalled,
|
|
215
|
-
vsixAssetName,
|
|
216
|
-
installCppTools,
|
|
217
|
-
reportCppTools,
|
|
218
|
-
};
|