Commit graph

798 commits

Author SHA1 Message Date
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
Tobias Hunger
9ccf6c3bdf ci: Turn of cypress tests of the online editor
The two tests provide somewhat limited value at this time: The Firefox
tests were green before, but we think that should not have been the case
as firefox does not accept the imports in the webworker when serving
with vite in dev mode -- which we did.

Trying to change the test to use the actual generated site fails for
unknown reason: Cypress claims the page reported by `vite prefix` as up
is returning 404 in CI. It works fine locally:-/
2023-01-20 18:27:11 +01:00
Tobias Hunger
15bd48d2fa tools: Add highlight feature to wasm-interpreter
... and use it.
2023-01-20 18:27:11 +01:00
Tobias Hunger
d45d14af8b janitor: online editor: Reorder imports
This might make firefox a bit happier as the (now) last import defines
some constants. That used to happen between imports and is after all
other imports now.

Ugly work-around, but maybe it helps?
2023-01-20 18:27:11 +01:00
Tobias Hunger
d6e5a3ea54 online editor: Treat failure to load files gracefully
Pretend the file was empty when it failed to load. This stops the LSP
from blocking in some error cases, e.g. in the Printerdemo when reading
fonts.
2023-01-20 18:27:11 +01:00
Tobias Hunger
afdd450d86 vscode: Fix some lints 2023-01-20 18:27:11 +01:00
Tobias Hunger
c79cd21baf LSP: Support highlighting via call-out into javascript
This adds a new "preview-api" feature so that this can be turned on in
WASM without dragging in lots of extra dependencies:-/
2023-01-20 18:27:11 +01:00
Tobias Hunger
fb7a5b80ca online editor: Allow LSP to trigger highlight function in Previewer 2023-01-20 18:27:11 +01:00
Tobias Hunger
c7e10446c1 online editor: Split Preview class into a frontend and backend
... that communicate with each other over a channel. This means we can
pass one side into a web worker and still have this work.

Short-term this is mean to enable the LSP running in a web worker take
control of the Preview. Mid-term we might be able to also move the
preview into a web worker, but that needs OffScreenCanvas, which is not
available in Safari-based browsers at this time.
2023-01-20 18:27:11 +01:00
Tobias Hunger
ae77ad3e39 online editor: Move previewer code into the Previewer class
... in lsp.
2023-01-20 18:27:11 +01:00
Tobias Hunger
4c250331a2 online editor: Move previewer out of preview widget into lsp setup 2023-01-20 18:27:11 +01:00
Tobias Hunger
105d751a67 online editor: Factor out code to set up LSP 2023-01-20 18:27:11 +01:00
Tobias Hunger
f0b4bce3d6 janitor: Make LSP clippy clean 2023-01-16 14:42:36 +01:00
Tobias Hunger
248212711e online editor: Fix preview rendering sub components instead of main one
I had the mental model of "updating the preview with the new code" since
that is how the LSP works. That is of course wrong here: The Previewer always
compiles again from scratch.

So always feed the main source file to the preview, not the currently
edited one.

Fixes: #2057
2023-01-12 18:45:17 +01:00
Tobias Hunger
e456008c8e lsp: Fix document symbols not working
This changes how the selection range is picked: Instead of using the
`QualifiedName` of the root element, look at the Component's
`DeclaredIdentifier`.

This fixes component declarations without `inherits` clause and is also
nicer than the old approach: We would use the Component id as a name of
the DocumentSymbol and set the inherited type name as selection range.
2023-01-12 17:01:11 +01:00
Tobias Hunger
303b8f7c9d lsp: Update unit tests to new slint syntax 2023-01-12 17:01:11 +01:00
Tobias Hunger
7d702c947b online editor: Shrink border around the preview 2023-01-12 13:04:58 +01:00
Olivier Goffart
7cacb78bd9 Rename syntax_updater -> slint-updater 2023-01-11 18:27:47 +01:00
Tobias Hunger
06657eb79a lsp: Improve text range selection on binding removal
Try to delete entire lines if possible. This way we do not keep empty
lines around anymore.
2023-01-11 17:38:15 +01:00
Tobias Hunger
81d605e5d6 lsp: Simplify (left|right)_extend
This is simpler than the previous version and will be easier to
reuse for line-wise deletion, too.

It does sacrifice indention level based (line-) comment splitting, but I
think that will not be missed...

Any comments up to a blank line _before_ a property will be considered to
belong to that property and any comment _after_ the property that starts
without a line break are part of a property now.

There is some extra magic to work when several properties are in the
same line: Basically all comments then refer to the following property.

Update tests accordingly...
2023-01-11 17:38:15 +01:00
Tobias Hunger
47dbfb5327 lsp: Extract code to find the property binding 2023-01-11 17:38:15 +01:00
Tobias Hunger
a9aea470fd lsp: Rename delete_range to selection_range
I want to eventually use that to highlight the text the property editor
will work on. That is not done yet though.
2023-01-11 17:38:15 +01:00