Commit graph

46 commits

Author SHA1 Message Date
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
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
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
Olivier Goffart
c250865032 Javascript: Multiple components 2024-07-02 13:38:52 +02:00
Olivier Goffart
9978cb1c0f
node: expose functions 2024-06-04 17:55:14 +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
Simon Hausmann
63f1114ff2 Run Node.js tests with the testing backend
Add the ability to depend on the testing backend and opt into it
when running tests/cases, like we do for the other drivers.

The testing backend dependency is removed in the packaging step, as
we don't publish i-slint-backend-testing.
2024-04-16 07:05:03 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Simon Hausmann
2d9eff53f4 Node.js: Simplify ArrayModel handling in tests
Add a convenience pop() function (we already have push...) and re-use the model
instead of fetching it.
Previously we fetched it because it was converted to
a new array every time.
2024-02-26 15:02:41 +01:00
Simon Hausmann
a211a104a1 Node.js: Implement Iterable<T> for Model<T>
This makes it much easier to extra data from Models, such as using them
in for loops. This is the equivalent of Model::iter() in Rust.
2024-02-26 15:02:41 +01:00
Simon Hausmann
fa8e847f7c Fix bi-directional mapping of Model<T> from Node.js to Rust
A Model<T> stores a reference to a External<Rc<ModelNotify>>.
Every time such a Model<T> needs to be exposed to Slint/Rust, we create
a TypedRustModel that wraps the Rc<ModelNotify>, a strong reference to
the JS object, and the Type field for the expected data type (the
interpreter expects). The Model trait is implemented on TypedRustModel,
which means it is allocated every time the conversion is needed, but the
underlying Rc<ModelNotify> is shared and thus the (forwarded) ModelNotify.

When converting back to JavaScript, we downcast_ref to the
TypedRustModel and fetch the original JavaScript object - if available.
2024-02-26 15:02:41 +01:00
Florian Blasius
c952b028fd Use this pointer for RustModel model reference 2024-02-26 15:02:41 +01:00
Florian Blasius
e54dd09604 Start with node RustModel 2024-02-26 15:02:41 +01:00
Ralph Minderhoud
9cb1a4a4e0
Add API for minimize/maximize on Window component (#4581)
Closes #4400
2024-02-22 10:40:36 +01:00
Simon Hausmann
2d6edfbd6c Node.js: Fix MapModel rowData() calling map function even if the source model returned undefined
Also fix the function signature, which was wrong.
2024-02-07 19:15:02 +01:00
Florian Blasius
39106acbdc
Added runEventLoopUntilQuit for node (#4444)
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-01-30 05:46:46 +00:00
Olivier Goffart
573d4a3b50 Remove the test function for sending double_click
They are not commonly used so no need to use semi-public api for that
and it's really easy to similate with ust two clicks anyway

The previous test function were added before there was public way to
send events
2024-01-24 10:20:06 +01:00
Tobias Hunger
f2025ecf2d Test: Add explicit test for our time mocking infrastructure 2024-01-10 11:41:55 +01:00
Simon Hausmann
29621043f7 Node.js: Add fullscreen setter for Window
Amends 779aff0b39
2024-01-09 18:55:28 +01:00
Simon Hausmann
55e3a0418a Fix typedoc warning about unused parameters 2024-01-02 10:58:18 +01:00
Simon Hausmann
cdc2ccec3b Fix missing types from Node.js API docs
Commit 84fd6dc08c changed the import
from "rust-module" to "rust-module.cjs", which unfortunately broke
typedoc's visibility into the types. Revert back to using the import
without extension. With the given tsconfig files that works now and
typedoc publishes the docs for the re-exported types again.

Fixes #4153
2023-12-14 13:16:00 +01:00
Tobias Hunger
2bdcbc8e9f
core: Add a double-click callback to the TouchArea (#4060)
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2023-12-08 12:12:41 +01:00
Florian Blasius
5af7095fc9
move mapmodel to private_api (#4015)
Moved MapModel to private api because it is not ready now until the notify mechanism for node models is improved.
2023-11-27 13:11:31 +01:00
Florian Blasius
b19cbba7ad
node: added MapModel (#3946)
---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2023-11-23 12:20:06 +01:00
FliPPeDround
2920e15f4a feat: export loadSource api 2023-11-22 08:11:53 +01:00
Simon Hausmann
84fd6dc08c Clean up Node.js port build system
- Instead of building index.js with esbuild and generating types with
  tsc, use tsc to build index.js and index.d.ts.
- Use ts-node instead of swc for typescript based tests, as that
  works with es modules.
- Remove "syntax_check" target from package.json as that's now
  implied with "compile".
- Sadly this requires one "as any" cast as tsc somehow fails to
  determine the right type info for node-fetch.

Unfortunately index.js can't be an ES module without breaking
compatiblity. It would imply that the Node.js port can't be used with
require() anymore. So even thought that would simplify things further,
it's not part of this PR.
2023-11-21 07:20:21 +01:00
Florian Blasius
80bcdee646
added requestRedraw to node window (#3940) 2023-11-16 06:49:49 +01:00
Florian Blasius
440f1a5a1d
Added more documentation to the node port (#3938)
* Added more documentation to the node port

* Update api/node/index.ts

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

* Update api/node/index.ts

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

* Update api/node/index.ts

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

* code review feedback

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2023-11-16 06:49:16 +01:00
Florian Blasius
1d30ff9352
node: code cleanup (#3894) 2023-11-09 18:43:09 +01:00
Florian Blasius
bb9ba91255
moved slint classed to private_api (#3893) 2023-11-09 16:03:08 +01:00
Florian Blasius
9e393a6f74
Florian/node model notify (#3892) 2023-11-09 14:19:15 +01:00
Simon Hausmann
ad95dc3ad7 Various changes to the Node.js docs
- Make the walkthrough actually work
- Fix incorrect file paths
- Link between loadFile and the component instantiation section, as well as ComponentHandle
- Declare that loadFile may throw an exception
2023-11-08 19:52:50 +01:00
Simon Hausmann
432103d38f Node.js: Seal modules and component instances 2023-11-06 18:32:01 +01:00
Simon Hausmann
7b61e455eb Initial implementation of a Slint event loop sitting on top of Node.js
At the moment this is implemented using polling.

cc #2477
2023-11-06 11:37:45 +01:00
Florian Blasius
e3dbefafa5
node: implement access for globals (#3815) 2023-11-02 11:01:40 +01:00
Florian Blasius
88a814c234 Revert "Implement globals for node"
This reverts commit 8412a971af.
2023-10-31 11:40:39 +01:00
Florian Blasius
8412a971af Implement globals for node 2023-10-31 11:36:25 +01:00
Florian Blasius
62a30a0e2e
node: export classes use interfaces for setters (#3804) 2023-10-31 10:36:00 +01:00
Simon Hausmann
55085d43af
Fix Node.js version of memory game not working properly (#3789)
The rules require comparing if tiles are equal, which used to be a string comparison as we just
converted the image to a path. With ImageData this doesn't
work anymore, so this patch proposes an optional path
property that makes the code also a tad bit more readable.
2023-10-31 08:50:32 +01:00
Florian Blasius
52a0cd5c13
Show warning on duplciatedd properties (#3805) 2023-10-31 07:08:40 +01:00
Simon Hausmann
ce0f8ddf7c janitor: reformat these files with vscode
This matches the existing formatting in the files present.
2023-10-27 16:41:06 +02:00
Florian Blasius
0045787e1c
node: api review adjustements part I (#3766)
* Update api/node/src/types/brush.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update tests/cases/callbacks/handler_with_arg.slint

Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2023-10-26 10:02:49 +02:00
Simon Hausmann
2fc418251b node: remove workaround for font imports with relative paths
Commit a76c3ec789 fixes the underlying issue.
2023-10-25 15:04:55 +02:00
Florian Blasius
bf77b064ab
Replace neon node port (#3744)
* Update api/node/README.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-10-24 15:07:59 +02:00
Renamed from api/napi/index.ts (Browse further)