Commit graph

42 commits

Author SHA1 Message Date
dependabot[bot]
9226051e17
build(deps): bump jimp from 0.22.8 to 1.6.0 (#6860)
* build(deps): bump jimp from 0.22.8 to 1.6.0

Bumps [jimp](https://github.com/jimp-dev/jimp) from 0.22.8 to 1.6.0.
- [Release notes](https://github.com/jimp-dev/jimp/releases)
- [Changelog](https://github.com/jimp-dev/jimp/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jimp-dev/jimp/compare/v0.22.8...v1.6.0)

---
updated-dependencies:
- dependency-name: jimp
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix import

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nigel Breslaw <nigel.breslaw@slint.dev>
2024-11-21 11:58:24 +02:00
FloVanGH
181739d624
node: add tests for color set (#6646) 2024-10-24 17:45:27 +00:00
FloVanGH
fe596179da
node: added fileloader to LoadData. (#6530) 2024-10-14 07:33: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
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
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
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
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
Simon Hausmann
8cf9256338 Fix failing Node.js test expectations
Adjust line numbers.

Amends 0cfeec1a31
2024-04-15 16:16:09 +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
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
841cb25565 Node.js: Always map Slint arrays to Model<T> in JavaScript
This gives a consistent interface - there's no more need to check the result of a property read on whether it's an array or a model.
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
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
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
Simon Hausmann
e4cc80aeea
Fix typescript errors shown in VS code when editing node test files (#3999)
The nodenext module resolution was only passed to ts-node, but vscode didn't see it.
Use a dedicated tsconfig.json for vscode as well as ts-node.
2023-11-24 17:22:38 +08: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
1d643dd6c2 fix: use loadSource in loadSource api test 2023-11-22 08:11:53 +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
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
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
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
Simon Hausmann
2310015315 janitor: Reformat JS types to match formatting of other files
(Just saved in VS code)
2023-10-27 16:42:54 +02: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
Simon Hausmann
80bb7af08c node: Fix typescript setup for tests
Share tsconfig.json so that ava runs the typescript compiler also on the tests.
Similary, the syntax check now also covers the tests.

Sadly, the exception that the Slint compiler throws is not type declared,
so we have to use any.
Similarly, the object share returned by loadFile() is unknown
in terms of properties, callbacks, etc.
2023-10-27 11:39:44 +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
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