Skip to content

Commit 2057f39

Browse files
authored
Include freedesktop sdk TypeScript extension (#988)
Closes #975 TypeScript is still disabled by default for now but it's just a gsetting.
1 parent d9badbe commit 2057f39

File tree

8 files changed

+97
-15
lines changed

8 files changed

+97
-15
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SHELL:=/bin/bash -O globstar
44

55
setup:
66
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
7-
flatpak install --or-update --user --noninteractive flathub org.gnome.Sdk//47 org.flatpak.Builder org.freedesktop.Sdk.Extension.rust-stable//24.08 org.freedesktop.Sdk.Extension.vala//24.08 org.freedesktop.Sdk.Extension.llvm18//24.08 org.freedesktop.Sdk.Extension.node20//24.08 #org.freedesktop.Sdk.Extension.typescript//24.08
7+
flatpak install --or-update --user --noninteractive flathub org.gnome.Sdk//47 org.flatpak.Builder org.freedesktop.Sdk.Extension.rust-stable//24.08 org.freedesktop.Sdk.Extension.vala//24.08 org.freedesktop.Sdk.Extension.llvm18//24.08 org.freedesktop.Sdk.Extension.node20//24.08 org.freedesktop.Sdk.Extension.typescript//24.08
88
# flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
99
# flatpak remote-add --user --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
1010
# flatpak install --or-update --user --noninteractive gnome-nightly org.gnome.Sdk//master

build-aux/re.sonny.Workbench.Devel.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
"org.freedesktop.Sdk.Extension.vala",
99
"org.freedesktop.Sdk.Extension.rust-stable",
1010
"org.freedesktop.Sdk.Extension.llvm18",
11-
"org.freedesktop.Sdk.Extension.node20"
11+
"org.freedesktop.Sdk.Extension.node20",
12+
"org.freedesktop.Sdk.Extension.typescript"
1213
],
1314
"build-options": {
14-
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node20/bin",
15+
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node20/bin:/usr/lib/sdk/typescript/bin",
1516
"append-ld-library-path": "/usr/lib/sdk/vala/lib"
1617
},
1718
"command": "workbench",

build-aux/re.sonny.Workbench.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
"org.freedesktop.Sdk.Extension.vala",
99
"org.freedesktop.Sdk.Extension.rust-stable",
1010
"org.freedesktop.Sdk.Extension.llvm18",
11-
"org.freedesktop.Sdk.Extension.node20"
11+
"org.freedesktop.Sdk.Extension.node20",
12+
"org.freedesktop.Sdk.Extension.typescript"
1213
],
1314
"build-options": {
14-
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node20/bin",
15+
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node20/bin:/usr/lib/sdk/typescript/bin",
1516
"append-ld-library-path": "/usr/lib/sdk/vala/lib"
1617
},
1718
"command": "workbench",

build-aux/wip/run.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ Gio._promisify(
1919
"wait_check_finish",
2020
);
2121

22-
// const path = GLib.get_current_dir();
23-
const path = "/home/sonny/Projects/Workbench";
22+
const path = GLib.get_current_dir();
2423
console.debug(programInvocationName, programArgs);
2524
const argv = minimist(programArgs, { boolean: true });
2625
console.debug(argv);
2726

28-
const [manifest_path] = argv._;
27+
const [manifest_path, ...arg] = argv._;
2928
if (!manifest_path) {
3029
// eslint-disable-next-line no-restricted-globals
3130
print(`${programInvocationName} [--verbose] [--debug] MANIFEST`);
@@ -124,7 +123,8 @@ await buildCommand(["meson", "install", "-C", "_build"]);
124123
// ]);
125124

126125
// starts workbench
127-
await runCommand([manifest.command]);
126+
const command = arg.length ? arg : [manifest.command];
127+
await runCommand(command);
128128

129129
function buildCommand(argv) {
130130
let PATH =
@@ -165,9 +165,9 @@ async function runCommand(argv) {
165165
`--bind-mount=/run/user/1000/doc=/run/user/1000/doc/by-app/${flatpak_id}`,
166166
...manifest["finish-args"],
167167

168-
// Non default permissions
169-
// see Permissions.js
170-
// consider getting installed overrides instead
168+
// Non default permissions, see Permissions.js
169+
// consider getting installed overrides instead with
170+
// flatpak override --user --show re.sonny.Workbench.Devel
171171
"--share=network",
172172
"--socket=pulseaudio",
173173
"--device=input",

data/app.metainfo.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@
5555
<p>Library:</p>
5656
<ul>
5757
<li>Add "Button Row" demo</li>
58+
<li>Add "Gamepad" demo</li>
5859
<li>Add "List View with Sections" demo</li>
60+
<li>Add "List View with a Tree" demo</li>
61+
<li>Add "Bottom Sheet" demo</li>
5962
<li>Update "Spinner" to use AdwSpinner</li>
6063
<li>Port "Dialog" to Python</li>
6164
<li>Port "List View" to Python</li>
@@ -91,6 +94,7 @@
9194
<li>Port "Actions" to Vala</li>
9295
<li>Port "Dialog" to Vala</li>
9396
<li>Port "CSS Gradients" to Vala</li>
97+
<li>Port "Snapshot" to Vala</li>
9498
</ul>
9599
<p>Dependencies:</p>
96100
<ul>

src/cli/main.js

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ const window = new Adw.ApplicationWindow();
8787

8888
function createLSPClients({ root_uri }) {
8989
return Object.fromEntries(
90-
["javascript", "blueprint", "css", "vala", "rust", "python"].map((id) => {
90+
[
91+
"javascript",
92+
"blueprint",
93+
"css",
94+
"vala",
95+
"rust",
96+
"python",
97+
"typescript",
98+
].map((id) => {
9199
const lang = languages.find((language) => language.id === id);
92100
const lspc = createLSPClient({
93101
lang,
@@ -344,6 +352,73 @@ async function ci({ filenames }) {
344352
});
345353
}
346354

355+
const file_typescript = demo_dir.get_child("main.ts");
356+
if (file_typescript.query_exists(null)) {
357+
print(` ${file_typescript.get_path()}`);
358+
359+
const uri = file_typescript.get_uri();
360+
const languageId = "typescript";
361+
let version = 0;
362+
363+
const [contents] = await file_typescript.load_contents_async(null);
364+
const text = new TextDecoder().decode(contents);
365+
366+
await lsp_clients.typescript._notify("textDocument/didOpen", {
367+
textDocument: {
368+
uri,
369+
languageId,
370+
version: version++,
371+
text,
372+
},
373+
});
374+
375+
const diagnostics = await waitForDiagnostics({
376+
uri,
377+
lspc: lsp_clients.typescript,
378+
});
379+
if (diagnostics.length > 0) {
380+
printerr(serializeDiagnostics({ diagnostics }));
381+
return false;
382+
}
383+
print(` ✅ lints`);
384+
385+
const checks = await checkFile({
386+
lspc: lsp_clients.typescript,
387+
file: file_typescript,
388+
lang: getLanguage("typescript"),
389+
uri,
390+
});
391+
if (!checks) return false;
392+
393+
const js_object_ids = getCodeObjectIds(text);
394+
for (const object_id of js_object_ids) {
395+
if (!blueprint_object_ids.includes(object_id)) {
396+
print(` ❌ Reference to inexistant object id "${object_id}"`);
397+
return false;
398+
}
399+
}
400+
401+
globalThis.workbench = {
402+
window,
403+
application,
404+
builder,
405+
template,
406+
resolve(path) {
407+
return demo_dir.resolve_relative_path(path).get_uri();
408+
},
409+
preview() {},
410+
};
411+
412+
await import(`file://${file_typescript.get_path()}`);
413+
print(" ✅ runs");
414+
415+
await lsp_clients.typescript._notify("textDocument/didClose", {
416+
textDocument: {
417+
uri,
418+
},
419+
});
420+
}
421+
347422
const file_vala = demo_dir.get_child("main.vala");
348423
if (file_vala.query_exists(null)) {
349424
print(` ${file_vala.get_path()}`);

src/langs/css/CssDocument.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class CssDocument extends Document {
2525
},
2626
});
2727

28-
// Biome doesn't support diff - it just returns one edit
28+
// GTKCssLanguageServer doesn't support diff - it just returns one edit
2929
// we don't want to loose the cursor position so we use this
3030
const state = this.code_view.saveState();
3131
applyTextEdits(text_edits, this.buffer);

src/langs/javascript/biome.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"recommended": false,
1313
"correctness": {
1414
"noUndeclaredVariables": "error",
15-
"noUnusedVariables": "warn"
15+
"noUnusedVariables": "warn",
16+
"noUnusedImports": "warn"
1617
}
1718
}
1819
}

0 commit comments

Comments
 (0)