Commit graph

819 commits

Author SHA1 Message Date
Tobias Hunger
7f95614a98
online editor: Only offer export options when appropriate
Gist: Whenever an editor is open.
permalink: Whenever exactly one editor is open.
2023-03-24 11:35:41 +01:00
Tobias Hunger
badd2730ee
online editor: Fix wrong name when adding a page
When the name of the new page did not end in .slint, then it would get
broken. Fix this.
2023-03-24 11:34:31 +01:00
Tobias Hunger
84fabee539 online editor: Allow exporting a project with multiple files to a gist 2023-03-24 10:58:40 +01:00
Tobias Hunger
973eae7d90 online editor: Allow to store a github access token
Not very comfortable, we should definitely allow for github logins! But
it gets us started.
2023-03-24 10:58:40 +01:00
Tobias Hunger
95dd7f862f online editor: Load slint files from gist
If a `slint.json` file is found, that one is parsed for extra
information like what is the main file and what extra mappings exists
(e.g. so you can redirect to images, etc. in different repositories).
2023-03-24 10:58:40 +01:00
Tobias Hunger
3c7587e972 online editor: Allow to add empty files to the edit session 2023-03-24 10:58:40 +01:00
Tobias Hunger
d4ebeb4718 online editor: Collect and expose information on mapped URLs and files
Expose more information on known (and unknown) files.
2023-03-24 10:58:40 +01:00
Tobias Hunger
bd17cf9433 online editor: Map file names to internal URLs
We have a lot of fun with the URLs/file names we use:

 * We need to map URLs (e.g. to store them in Gists), so we can not just use
   the external URLs everywhere :-(
 * We need some way to tell "internal" URLs from external ones
 * We want "https" as that works best in a browser: "file" tends to
   fail to load for security reasons, "inmemory" is no proper scheme.
 * LSP/Previewer and Editor disagree on the "inmemory" scheme, which has
   caused me headaches before.

So use https URLs with an authority of "<UUID>.slint.rs" and treat them
as internal URLs.
2023-03-24 10:58:40 +01:00
Tobias Hunger
dc391be74a online editor: Wait for service worker to be up in index.ts
Wait for the service worker to come up fully. The API is a bit unwieldy,
but we tell to not wait and to claim all clients, so it should come up
the first time round.
2023-03-24 10:58:40 +01:00
Tobias Hunger
4108d49430 online editor: Add a service worker
This service worker can be used to report and remap access to resources
from the previewer. We will need this feature to be able to meaningfully
export data.

This is not used yet!
2023-03-24 10:58:40 +01:00
Tobias Hunger
f7ea09e31c online editor: Update typescript config to newer JS flavor in lib
The code uses those features, so be explicit about them.
2023-03-24 10:58:40 +01:00
Simon Hausmann
128fb25629 Enable support for additional image formats (webp, etc.) in the viewer, previewer, and nodejs bindings 2023-03-23 15:35:13 +01:00
Olivier Goffart
ff89a38062 Update serde-wasm-bindgen 2023-03-22 09:49:54 +01:00
Tobias Hunger
fcf899cc6f online_editor: Add energy monitor demo 2023-03-20 15:31:51 +01:00
Tobias Hunger
babe3cae2a
online_editor: Do not raise alerts abouts errors opening URLs the user did not explicitly open (#2380)
Do not raise an alert for URLs the LSP/previewer requested. This prevents breaking the flow as the user types an import statement which the LSP/previewer then can not find.

Continue to alert about problems with URLs explicitly opened by the user. This is important so that we do not silently fail when trying to open a file from an URL.

Fixes: #2377
2023-03-19 19:54:45 +01:00
Tobias Hunger
45032716dd online-editor: Hard-code required versions in package.json
... and remove package-lock.json again.

This is what I saw Theia doing, and it does not hard-code the world,
just those parts we actually need to have hard-coded.
2023-03-16 12:53:39 +01:00
Tobias Hunger
334e62c549 online-editor: Add "open from Link"
Unfortunately this is not as useful as I had hoped: Download from pretty
much every git hoster fails due to CORS. The big exception is
github.com, which has raw.githubusercontent.com to work around this
problem.

I added automatic conversion to raw links (which allow CORS!) from
"normal" links to make this easier to use. Gists work, too, provided you
paste the link you get when clicking on "Raw" for the specific file of
the gist you want to view.
2023-03-16 12:53:00 +01:00
Tobias Hunger
e93ba87f03
online-editor: Remove ??? on unknown types (#2361)
Fixes: #1857
2023-03-12 11:28:26 +01:00
Tobias Hunger
a35ddbdbf9 online-editor: Add package-lock.json
The current latest versions of all our dependencies do not play well
together.

Monaco-languageclient claims to support monaco-editor 0.34.1 only, so
let's stick to that. We also need to make sure everybody agrees on using
the same vscode-jsonrpc version (which was recently updated in the
vscode dependencies), or the typescript code will fail to communicate
with our language server.

So include the package-lock.json for now, so that we can actually build
something.
2023-03-10 20:40:01 +01:00
Tobias Hunger
3ac01c3f07 clippy: Fix clippy warnings 2023-03-09 09:35:29 +01:00
Miłosz Kosobucki
839b5e8ee6 Improve LSP autocompletion formatting
Spaces are no longer inserted around the cursor when user autocompletes
a component or a callback handler.

These spaces result in a spurious whitespace and misaligned curly braces
right after the user presses enter. Since most components and callback
handlers are multi-line, this often requires additional keystrokes to
fix.

The problem is present even in Slint's own examples. Such as
examples/gallery/ui/side_bar.slint - line 127
2023-02-23 14:10:14 +01:00
Olivier Goffart
143ad8ab75 LSP: use the new syntax to create the previewed component
Avoid warnings when previewing
2023-02-21 19:47:08 +01:00
Olivier Goffart
8450e01a3f
Change the name of the compat feature (#2230)
And remove the compat-0-2-0 and compat-0-3-0 features
2023-02-16 09:40:44 +01:00
Tobias Hunger
255fe56c94
online_editor: Fix fake baseURI 2023-02-15 11:43:53 +01:00
Olivier Goffart
5b3cde87ab Update dependencies 2023-02-15 10:28:02 +01:00
Tobias Hunger
b33fd32002 online_editor: Fix firefox
Firefox does not handle modules in web workers yet, but that is what we
asked vite to build (to work around a compatibility issue after
upgrading to vite 4). So Chrome worked, but Firefox did not.

This PR adds a pretty ugly work around to that problem.

The good news is: Firefox will apparently be able to handle modules in
web workers starting with 111, so let's hope we do not need this for too
long!
2023-02-14 20:53:36 +01:00
Olivier Goffart
6889dfa5f5 Rust: Make new(), run() and show() report errors from the backend
Fixes #2198
2023-02-10 05:00:03 +01:00
Olivier Goffart
f6e4f16a14 LSP: Dont detect slint::slint! as slint macro in comments or stings
We already detected that `slint!` in a comment should not be interpreted
as a slint macro, but that detection failed for `slint::slint!` or if
`slint` was twice in the same line.
2023-02-09 08:52:51 +01:00
Simon Hausmann
a7eaf5a8bb Fix loading of the LSP worker script in the online editor
The update to vite 4 triggered the vite 3 bug vitejs/vite#9879
for us, where the wasm-pack generated .js is included as iife and
therefore the use of import.meta.url gets transpiled to some shim that
tries to access the document, assuming that the JS is running in the
browser instead of in a worker environment.

Explicitly set the output type for the worker to ES modules, so that no
changes are needed and import.meta.url remains in use. This matches the
worker invocation anyway, as we pass "type": "module" to the Worker
constructor.
2023-02-03 15:08:28 +01:00
Olivier Goffart
149fb81f30 Updater: Fix cargo.toml not having = sign
And therefore not ebing updated to the last version
2023-02-03 11:07:15 +01:00
ogoffart
e7f48512ee Bump version number to 1.0.0 2023-02-03 11:07:15 +01:00
Simon Hausmann
e430716adb Fix the online editor not loading the wasm-interpreter anymore
The upgrade of vite from 2 to 4 in commit
5951ae6272 also brought an update of
rollup to version three. That one documents that relative externals are
resolved to absolute paths by default, which explains the symptom that
the online editor tried to load /some/absolute/path/wasm_interpreter.js.

Resolving back to resolve paths fixes it.
2023-02-02 17:52:06 +01:00
Tobias Hunger
fb09dc5c1d
online editor: Improve waiting for setup to complete (#2133)
The code used to sometimes throw a strange exception indicating that the
previewer WASM module was not fully up yet when used.

Fix the LspWaiter to really wait for both LSP WASM web worker and WASM
previewer to report back that they are fully up. Previously it only
waited for the Lsp, which surprisingly often works on my machine.
2023-01-27 11:04:50 +01:00
Olivier Goffart
f2c680ac28 Update description in Cargo.toml 2023-01-27 08:54:13 +01:00
Olivier Goffart
5bb84c1d69 Remove deprecated Keys enum in slint language 2023-01-26 15:35:18 +01:00
Tobias Hunger
5951ae6272 online editor: Update tooling and dependencies
We bundle everything with vite, so treat all dependencies as
dev-dependencies.
2023-01-26 15:04:59 +01:00
Olivier Goffart
ae20ec59c8 Rename PointerEventButton::None to PointerEventButton::Other
And mark the enum non_exhaustive

closes #1903
2023-01-26 13:36:54 +01:00
Olivier Goffart
9b41b39b07 Update slunt-updater/Cargo.toml again 2023-01-25 14:21:19 +01:00
Olivier Goffart
900036db85 Get the cargo.toml of slint-updater ready for the upload 2023-01-25 14:20:09 +01:00
Olivier Goffart
4f3d0954fe Online code editor: add a "load_demo" url argument
that loads the demo based on the current version of the editor
2023-01-25 11:11:57 +01:00
Olivier Goffart
3a1c515200 LSP: Fix calculation of element position
Basically same as e88b07997f but in the
set_binding_command function.
(made the code more similar to remove_binding_command, I think the two
function should be merged in the future)

This fix editing binding within the root component when it inherits from
something.
2023-01-25 10:27:40 +01:00
Tobias Hunger
c56c484f2a online editor: Fix race on querying the properties from the LSP
When removing a property binding, the editor notified the Properties
Widget before the LSP was updated. So the LSP continued to provide the
old data on the Property Widgets request. So the removed property
binding was still shown as set.

Work around this by polling the LSP till it returns a source version we
expect (or something newer). This should be save enough I hope.
2023-01-24 21:03:32 +01:00
Tobias Hunger
e88b07997f LSP: Fix calculation of element position
Use map_node as that trimms out stray whitespaces.
2023-01-24 21:02:17 +01:00
Tobias Hunger
cc4539dfcd online editor: Fix incomplete information from LSP after opening a demo
This sets up the file reader, which has gone missing in action at some
point.

We used to open the main file of the printer demo. That trriggered
loading of all the helper files, but they all came back empty. So any
LSP request that came in got errors as the code was incomplete.

Afterwards the editor loads the files anyway, telling the LSP about the
loaded file each time, filling in the missing information. So after all
files are open in the editor, the information in the LSP is complete and
all LSP commands return proper information going forward.
2023-01-24 19:35:56 +01:00
Simon Hausmann
4dc62f1fdd doc: polish for the slint updater
Polish the readme a little, use sentences for the argument help and add a plural to the
declarations option.
2023-01-24 15:54:51 +01:00
Tobias Hunger
b718c9c043 tools: Remove progress reporting for file loading
Stop the LSP from reporting progress information on file loading. This
caused problems with VSCode: First it triggered popups in the UI and
secondly it caused problems for the LSP that was asked to process
requests while calling back into the client.

Adapt the online editor and the two VSCode plugins to work with the
updated code.

Note: I did leave in the progress reporting code that can be used to
handle progress initiated by the _client_ side. That is just
notifications which will not block the LSP in any way and we might need
to support that at some point.

I did remove the Middleware code from the client side though that acted
on the progress information.
2023-01-23 19:51:55 +01:00
Olivier Goffart
32c99177b8 LSP: fix document outline with vscode
Currently, the reported range is the range of the root element, which
doesn't include the name of the component itself.
While the Name of the component itself is used as the selection range.
Vscode assrts that the selection range is within the range:

```
ERR selectionRange must be contained in fullRange: Error: selectionRange must be contained in fullRange
```

So use the full component range for the range instead
2023-01-23 15:51:01 +01:00
Simon Hausmann
24dcef5fed
First stage of cleaning up the export handling of the slint root component (#2095)
We implicitly export the last component of a .slint file to the generator.
Issue a warning when that happens and suggest to export it explicitly.
2023-01-23 15:19:49 +01:00
Tobias Hunger
3290e58228 online editor: Make sure the editor tab bar is up to date
... even when monaco changes the models behind our backs.

Fixes: #1851
2023-01-23 13:00:32 +01:00
Simon Hausmann
629c7ed80e Remove undocumented and dysfunctional PathLayout
This type is poorly implemented and not documented. Let's remove it for now.
It shall remain available in the git history in the event of a resurrection.
2023-01-21 13:10:19 +01:00