Commit graph

211 commits

Author SHA1 Message Date
Milian Wolff
69c68b22b2 Also wrap langtype::Type::Struct in an Rc
This makes copying such types much cheaper and will allow us to
intern common struct types in the future too. This further
drops the sample cost for langtype.rs from ~6.6% down to 4.0%.

We are now also able to share/intern common struct types.

Before:
```
  Time (mean ± σ):      1.073 s ±  0.021 s    [User: 0.759 s, System: 0.215 s]
  Range (min … max):    1.034 s …  1.105 s    10 runs

        allocations:            3074261
```

After:
```
  Time (mean ± σ):      1.034 s ±  0.026 s    [User: 0.733 s, System: 0.201 s]
  Range (min … max):    1.000 s …  1.078 s    10 runs

        allocations:            2917476
```
2024-10-28 09:39:54 +01:00
Milian Wolff
efdecf0a13 Wrap langtype::Type::{Callback,Function} data in an Rc
This allows us to cheaply copy the langtype::Type values which
contain such a type. The runtime impact is small and barely noticable
but a sampling profiler shows a clear reduction in samples pointing
at langtype.rs, roughly reducing that from ~8.6% inclusive cost
down to 6.6% inclusive cost.

Furthermore, this allows us to share/intern common types.

Before:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
  Time (mean ± σ):      1.089 s ±  0.026 s    [User: 0.771 s, System: 0.216 s]
  Range (min … max):    1.046 s …  1.130 s    10 runs

        allocations:            3152149
```

After:
```
  Time (mean ± σ):      1.073 s ±  0.021 s    [User: 0.759 s, System: 0.215 s]
  Range (min … max):    1.034 s …  1.105 s    10 runs

        allocations:            3074261
```
2024-10-28 09:39:54 +01:00
FloVanGH
181739d624
node: add tests for color set (#6646) 2024-10-24 17:45:27 +00:00
Milian Wolff
0f6c3a4fd7 Use SmolStr in more places of the compiler infrastructure
This removes a lot of allocations and speeds up the compiler step
a bit. Sadly, this patch is very invasive as it touches a lot of
files. That said, each individual hunk is pretty trivial.

For a non-trivial real-world example, the impact is significant,
we get rid of ~29% of all allocations and improve the runtime by
about 4.8% (measured until the viewer loop would start).

Before:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
  Time (mean ± σ):     664.2 ms ±   6.7 ms    [User: 589.2 ms, System: 74.0 ms]
  Range (min … max):   659.0 ms … 682.4 ms    10 runs

        allocations:            4886888
        temporary allocations:  857508
```

After:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
  Time (mean ± σ):     639.5 ms ±  17.8 ms    [User: 556.9 ms, System: 76.2 ms]
  Range (min … max):   621.4 ms … 666.5 ms    10 runs

        allocations:            3544318
        temporary allocations:  495685
```
2024-10-17 18:04:58 +02:00
Simon Hausmann
feee9aa056 Clean up file loader callback
This will have to be async in the future in its entirety, not just smaller parts.
2024-10-14 14:31:52 +02:00
FloVanGH
fe596179da
node: added fileloader to LoadData. (#6530) 2024-10-14 07:33:42 +02:00
FloVanGH
300c66fef3
node: added getting started (bun) to cover.md (#6516)
* Update api/node/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-10-11 06:12:50 +00:00
FloVanGH
ccf5f04087
node: added initTranslations function (#6504) 2024-10-10 16:37:33 +02:00
FloVanGH
f01ac8fc39
node: added url support to loadFile (#6507) 2024-10-10 11:43:32 +00:00
Florian Blasius
610a23b487 removed slint tags from cover.md 2024-10-10 07:32:24 +02:00
Florian Blasius
99702779a6 node: added structs and enums doc to cover.md 2024-10-10 07:13:42 +02:00
FloVanGH
499a522f99
node: better ergonomics for structs and enums (#6500) 2024-10-10 04:12:32 +00:00
Nigel Breslaw
6beb0c3f02
chore: Update npm dependencies
Update biome
Update typescript
Update esbuild
2024-10-08 13:13:49 +03:00
Nigel Breslaw
a97b7c7d92
Replace npm with pnpm
Replaces the use of NPM with PNPM. This should make it quick and easy to update any of the dependencies as dependabot will now see everything in one go.
2024-10-07 15:38:26 +03:00
Olivier Goffart
1c3eb46752 Fixup dead links to the old tutorial 2024-10-03 10:15:52 +02:00
FloVanGH
9d3a8c9dd2
node: added support for enums (#6421) 2024-10-01 16:49:39 +02:00
Simon Hausmann
51a241edd6
Node.js: If a JS callback throws an exception, report the exception t… (#6416)
As a drive-by, this introduces a macro that allows for explicit logging to console.error (which goes to stderr). This is something we should gradually start using, as it allows for capturing on the Node.js side (by the user or our tests).
2024-10-01 13:57:50 +02:00
Simon Hausmann
fdec55cd47 Node.js: Fix tense in error messages produced when exceptions are throw
At this point the exception _was_ thrown.
2024-10-01 13:28:48 +02:00
Simon Hausmann
5c612cda61 Fix biome invocations after re-organizing the files
After commit 25ae55b5dd, ignore dist/ as
well as the .cjs file that `npm run format` would complain about.
2024-10-01 13:27:00 +02:00
FloVanGH
4b880a7b49
node: less unwraps (#6388)
* Update api/node/rust/interpreter/value.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-10-01 08:47:53 +00:00
FloVanGH
25ae55b5dd
Improve source structure in the node api (#6164)
* Update api/node/typescript/models.ts

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Code review feedback
---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-09-30 08:49:35 +00:00
Olivier Goffart
fc324a4db2 Update MSRV to 1.77 2024-09-26 09:14:58 +02:00
ogoffart
eb273a63ee Bump version number to 1.9.0 2024-09-25 11:49:15 +00:00
Nigel Breslaw
b36a66e405
Enable more js/tsc biome rules
noUselessConstructor
useNodejsImportProtocol
noImplicitAnyLet
2024-09-13 10:04:39 +02:00
Nigel Breslaw
2bee820ccf
Start to enable default javscript/typescript lint rules
This enables the recommended rules useConst and useImportType
2024-09-12 16:08:52 +02:00
Nigel Breslaw
a218c945ad
Use Biome across monorepo and for Slintpad (#6080)
Puts a shared biome.json in the root.
Deletes the prettier config files.
Deletes the unused pre-commit hooks.
Applies biome linting and formatting to the slintpad project.
2024-09-11 13:07:55 +02:00
FloVanGH
e79dcc4bec
Use same vscode-ext lint and format also for api/node (#6039)
* Use vscode ext lint and format also for api/node
* Re-use biome config file from VS code instead of duplicating it
* Remove package-lock.json again
* Don't bother running the biome formatter on Windows

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-09-09 09:22:33 +02:00
ogoffart
4dd7d96a28 Bump version number to 1.8.0 2024-08-15 12:44:46 +00:00
ogoffart
bbf7edc5a3 Bump version number to 1.7.2 2024-08-09 09:52:17 +00:00
ogoffart
aa25e3cd44 Bump version number to 1.7.1 2024-07-23 12:05:34 +00:00
Bedis Nbiba
62c55dd188
js: show diagnostics when erroring (#5651)
before
```
error: Uncaught (in promise) Error: Could not compile ui/appwindow.slint
    at loadSlint (file:///home/mrcool/.cache/deno/npm/registry.npmjs.org/slint-ui/1.7.0/index.js:464:19)
    at Module.loadFile (file:///home/mrcool/.cache/deno/npm/registry.npmjs.org/slint-ui/1.7.0/index.js:644:12)
    at file:///home/mrcool/dev/deno/lab/memory/src/main.ts:3:23
```

after
```
error: Uncaught (in promise) Error: Could not compile ui/appwindow.slint
Diagnostics:
[ui/appwindow.slint:4:5] Unknown type MemoryTile
    at loadSlint (file:///home/mrcool/.cache/deno/npm/registry.npmjs.org/slint-ui/1.7.0/index.js:468:19)
    at Module.loadFile (file:///home/mrcool/.cache/deno/npm/registry.npmjs.org/slint-ui/1.7.0/index.js:648:12)
    at file:///home/mrcool/dev/deno/lab/memory/src/main.ts:3:23
```
2024-07-19 16:58:56 +02:00
Simon Hausmann
e36eb6aba6 Document behaviour of globals when exporting multiple components
Fixes #5467
2024-07-18 13:43:13 +02:00
Simon Hausmann
29fdac89ab Node.js: Don't use deprecated syntax 2024-07-18 10:37:05 +02:00
Olivier Goffart
5dfa8d56dc API review of the slint interpreter Compiler api
Closes #5466
2024-07-05 17:20:08 +02:00
Danut Enachioiu
033e4de9b9
Update language-specific docs to document that public functions can be called from the backend code (#5522)
* Examples for calling public functions in language-specific docs.

* Update the function example so it actually uses its parameter.

(This broke some c++ tests because of the unused argument warning)
2024-07-03 12:13:08 +02:00
Olivier Goffart
c250865032 Javascript: Multiple components 2024-07-02 13:38:52 +02:00
Simon Hausmann
b45945a234
Add support for async unit testing and element handle click events (#5499)
This patch adds async click functions to ElementHandle and adds timer support to the testing backend's event loop.
2024-06-27 17:05:58 +02:00
Simon Hausmann
a0db821afd Fix build with latest napi
JsExternal is now marked as deprecated, which makes our warning-are-errors CI fail. Use External<T> instead.
2024-06-25 13:53:46 +02:00
Simon Hausmann
3be6e641c6 Python: Attempt to build python packages with the same features as the nodejs/tool/etc. binaries 2024-06-18 09:43:37 -07:00
Simon Hausmann
1066acac9d Node.js: Use the same defaults as the slint rust create and interpreter crate
Fixes winit build warning about unused function
2024-06-18 17:48:17 +02:00
Simon Hausmann
41094b242f Remove unused import 2024-06-05 14:06:10 -07:00
Simon Hausmann
8aaa388328 Node.js: Use new public interpreter API 2024-06-05 14:06:10 -07:00
ogoffart
3a6e34ba45 Bump version number to 1.7.0 2024-06-04 20:34:29 +00:00
Olivier Goffart
9978cb1c0f
node: expose functions 2024-06-04 17:55:14 +02:00
Tobias Hunger
d9224cd58f janitor: Use more workspace dependencies 2024-06-04 14:58:29 +02:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Olivier Goffart
65160638a1 Node: Struct conversion should allow conversion from incomplete struct
This is also what happens in slint itself.
2024-05-09 17:02:24 +02:00
Simon Hausmann
af070f306f Fix Node.js CI
After the Rust 1.78 release, napi-rs panics on zero-sized array buffers.

Work around it by not allocating a zero-sized array buffer for this specific test.

Upstream PR: napi-rs/napi-rs#2083
2024-05-03 14:46:52 +02:00
Olivier Goffart
d4741efac0 testing: rename the init function 2024-04-18 18:45:31 +02:00