Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include freedesktop sdk TypeScript extension #988

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
CI:
runs-on: ubuntu-24.04
runs-on: ubuntu-24.10
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SHELL:=/bin/bash -O globstar

setup:
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
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
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
# flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
# flatpak remote-add --user --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
# flatpak install --or-update --user --noninteractive gnome-nightly org.gnome.Sdk//master
Expand Down
5 changes: 3 additions & 2 deletions build-aux/re.sonny.Workbench.Devel.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"org.freedesktop.Sdk.Extension.vala",
"org.freedesktop.Sdk.Extension.rust-stable",
"org.freedesktop.Sdk.Extension.llvm18",
"org.freedesktop.Sdk.Extension.node20"
"org.freedesktop.Sdk.Extension.node20",
"org.freedesktop.Sdk.Extension.typescript"
],
"build-options": {
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node20/bin",
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node20/bin:/usr/lib/sdk/typescript/bin",
"append-ld-library-path": "/usr/lib/sdk/vala/lib"
},
"command": "workbench",
Expand Down
5 changes: 3 additions & 2 deletions build-aux/re.sonny.Workbench.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but why even do you have the non-Devel manifest here 🤔 it probably should only exist in the flathub repo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Occasional testing when they diverge.

The manifest in this repo is the source of truth for flathub. I copy it over to flathub when I release.

Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"org.freedesktop.Sdk.Extension.vala",
"org.freedesktop.Sdk.Extension.rust-stable",
"org.freedesktop.Sdk.Extension.llvm18",
"org.freedesktop.Sdk.Extension.node20"
"org.freedesktop.Sdk.Extension.node20",
"org.freedesktop.Sdk.Extension.typescript"
],
"build-options": {
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node20/bin",
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node20/bin:/usr/lib/sdk/typescript/bin",
"append-ld-library-path": "/usr/lib/sdk/vala/lib"
},
"command": "workbench",
Expand Down
14 changes: 7 additions & 7 deletions build-aux/wip/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ Gio._promisify(
"wait_check_finish",
);

// const path = GLib.get_current_dir();
const path = "/home/sonny/Projects/Workbench";
const path = GLib.get_current_dir();
console.debug(programInvocationName, programArgs);
const argv = minimist(programArgs, { boolean: true });
console.debug(argv);

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

// starts workbench
await runCommand([manifest.command]);
const command = arg.length ? arg : [manifest.command];
await runCommand(command);

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

// Non default permissions
// see Permissions.js
// consider getting installed overrides instead
// Non default permissions, see Permissions.js
// consider getting installed overrides instead with
// flatpak override --user --show re.sonny.Workbench.Devel
"--share=network",
"--socket=pulseaudio",
"--device=input",
Expand Down
4 changes: 4 additions & 0 deletions data/app.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
<p>Library:</p>
<ul>
<li>Add "Button Row" demo</li>
<li>Add "Gamepad" demo</li>
<li>Add "List View with Sections" demo</li>
<li>Add "List View with a Tree" demo</li>
<li>Add "Bottom Sheet" demo</li>
<li>Update "Spinner" to use AdwSpinner</li>
<li>Port "Dialog" to Python</li>
<li>Port "List View" to Python</li>
Expand Down Expand Up @@ -91,6 +94,7 @@
<li>Port "Actions" to Vala</li>
<li>Port "Dialog" to Vala</li>
<li>Port "CSS Gradients" to Vala</li>
<li>Port "Snapshot" to Vala</li>
</ul>
<p>Dependencies:</p>
<ul>
Expand Down
77 changes: 76 additions & 1 deletion src/cli/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ const window = new Adw.ApplicationWindow();

function createLSPClients({ root_uri }) {
return Object.fromEntries(
["javascript", "blueprint", "css", "vala", "rust", "python"].map((id) => {
[
"javascript",
"blueprint",
"css",
"vala",
"rust",
"python",
"typescript",
].map((id) => {
const lang = languages.find((language) => language.id === id);
const lspc = createLSPClient({
lang,
Expand Down Expand Up @@ -344,6 +352,73 @@ async function ci({ filenames }) {
});
}

const file_typescript = demo_dir.get_child("main.ts");
if (file_typescript.query_exists(null)) {
print(` ${file_typescript.get_path()}`);

const uri = file_typescript.get_uri();
const languageId = "typescript";
let version = 0;

const [contents] = await file_typescript.load_contents_async(null);
const text = new TextDecoder().decode(contents);

await lsp_clients.typescript._notify("textDocument/didOpen", {
textDocument: {
uri,
languageId,
version: version++,
text,
},
});

const diagnostics = await waitForDiagnostics({
uri,
lspc: lsp_clients.typescript,
});
if (diagnostics.length > 0) {
printerr(serializeDiagnostics({ diagnostics }));
return false;
}
print(` ✅ lints`);

const checks = await checkFile({
lspc: lsp_clients.typescript,
file: file_typescript,
lang: getLanguage("typescript"),
uri,
});
if (!checks) return false;

const js_object_ids = getCodeObjectIds(text);
for (const object_id of js_object_ids) {
if (!blueprint_object_ids.includes(object_id)) {
print(` ❌ Reference to inexistant object id "${object_id}"`);
return false;
}
}

globalThis.workbench = {
window,
application,
builder,
template,
resolve(path) {
return demo_dir.resolve_relative_path(path).get_uri();
},
preview() {},
};

await import(`file://${file_typescript.get_path()}`);
print(" ✅ runs");

await lsp_clients.typescript._notify("textDocument/didClose", {
textDocument: {
uri,
},
});
}

const file_vala = demo_dir.get_child("main.vala");
if (file_vala.query_exists(null)) {
print(` ${file_vala.get_path()}`);
Expand Down
2 changes: 1 addition & 1 deletion src/langs/css/CssDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class CssDocument extends Document {
},
});

// Biome doesn't support diff - it just returns one edit
// GTKCssLanguageServer doesn't support diff - it just returns one edit
// we don't want to loose the cursor position so we use this
const state = this.code_view.saveState();
applyTextEdits(text_edits, this.buffer);
Expand Down
3 changes: 2 additions & 1 deletion src/langs/javascript/biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"recommended": false,
"correctness": {
"noUndeclaredVariables": "error",
"noUnusedVariables": "warn"
"noUnusedVariables": "warn",
"noUnusedImports": "warn"
}
}
}
Expand Down
Loading