slint-ui 1.9.0-nightly.2024102609 → 1.9.0-nightly.2024102814
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Cargo.toml
CHANGED
|
@@ -41,10 +41,10 @@ accessibility = ["slint-interpreter/accessibility"]
|
|
|
41
41
|
[dependencies]
|
|
42
42
|
napi = { version = "2.14.0", default-features = false, features = ["napi8"] }
|
|
43
43
|
napi-derive = "2.14.0"
|
|
44
|
-
i-slint-compiler = { features = ["default"] , git = "https://github.com/slint-ui/slint", rev = "
|
|
45
|
-
i-slint-core = { features = ["default", "gettext-rs"] , git = "https://github.com/slint-ui/slint", rev = "
|
|
46
|
-
i-slint-backend-selector = { git = "https://github.com/slint-ui/slint", rev = "
|
|
47
|
-
slint-interpreter = { default-features = false , features = ["display-diagnostics", "internal", "compat-1-2"] , git = "https://github.com/slint-ui/slint", rev = "
|
|
44
|
+
i-slint-compiler = { features = ["default"] , git = "https://github.com/slint-ui/slint", rev = "1340a4902e4d01ce28880bd996ad25fc2601c947", version = "=1.9.0", default-features = false }
|
|
45
|
+
i-slint-core = { features = ["default", "gettext-rs"] , git = "https://github.com/slint-ui/slint", rev = "1340a4902e4d01ce28880bd996ad25fc2601c947", version = "=1.9.0", default-features = false }
|
|
46
|
+
i-slint-backend-selector = { git = "https://github.com/slint-ui/slint", rev = "1340a4902e4d01ce28880bd996ad25fc2601c947", version = "=1.9.0", default-features = false }
|
|
47
|
+
slint-interpreter = { default-features = false , features = ["display-diagnostics", "internal", "compat-1-2"] , git = "https://github.com/slint-ui/slint", rev = "1340a4902e4d01ce28880bd996ad25fc2601c947", version = "=1.9.0"}
|
|
48
48
|
spin_on = { version = "0.1" }
|
|
49
49
|
css-color-parser2 = { version = "1.0.1" }
|
|
50
50
|
itertools = { version = "0.13" }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slint-ui",
|
|
3
|
-
"version": "1.9.0-nightly.
|
|
3
|
+
"version": "1.9.0-nightly.2024102814",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"homepage": "https://github.com/slint-ui/slint",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"@napi-rs/cli": "2.16.5"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
|
-
"@slint-ui/slint-ui-binary-linux-x64-gnu": "1.9.0-nightly.
|
|
71
|
-
"@slint-ui/slint-ui-binary-darwin-x64": "1.9.0-nightly.
|
|
72
|
-
"@slint-ui/slint-ui-binary-darwin-arm64": "1.9.0-nightly.
|
|
73
|
-
"@slint-ui/slint-ui-binary-win32-x64-msvc": "1.9.0-nightly.
|
|
74
|
-
"@slint-ui/slint-ui-binary-win32-ia32-msvc": "1.9.0-nightly.
|
|
70
|
+
"@slint-ui/slint-ui-binary-linux-x64-gnu": "1.9.0-nightly.2024102814",
|
|
71
|
+
"@slint-ui/slint-ui-binary-darwin-x64": "1.9.0-nightly.2024102814",
|
|
72
|
+
"@slint-ui/slint-ui-binary-darwin-arm64": "1.9.0-nightly.2024102814",
|
|
73
|
+
"@slint-ui/slint-ui-binary-win32-x64-msvc": "1.9.0-nightly.2024102814",
|
|
74
|
+
"@slint-ui/slint-ui-binary-win32-ia32-msvc": "1.9.0-nightly.2024102814"
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -114,10 +114,11 @@ impl JsComponentCompiler {
|
|
|
114
114
|
pub fn structs(&self, env: Env) -> HashMap<String, JsUnknown> {
|
|
115
115
|
fn convert_type(env: &Env, ty: &Type) -> Option<(String, JsUnknown)> {
|
|
116
116
|
match ty {
|
|
117
|
-
Type::Struct
|
|
117
|
+
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
|
|
118
|
+
let name = s.name.as_ref().unwrap();
|
|
118
119
|
let struct_instance = to_js_unknown(
|
|
119
120
|
env,
|
|
120
|
-
&Value::Struct(slint_interpreter::Struct::from_iter(fields.iter().map(
|
|
121
|
+
&Value::Struct(slint_interpreter::Struct::from_iter(s.fields.iter().map(
|
|
121
122
|
|(name, field_type)| {
|
|
122
123
|
(
|
|
123
124
|
name.to_string(),
|
|
@@ -133,10 +133,10 @@ impl JsComponentInstance {
|
|
|
133
133
|
))
|
|
134
134
|
})?;
|
|
135
135
|
|
|
136
|
-
if let Type::Callback
|
|
136
|
+
if let Type::Callback(callback) = ty {
|
|
137
137
|
self.inner
|
|
138
138
|
.set_callback(callback_name.as_str(), {
|
|
139
|
-
let return_type = return_type.clone();
|
|
139
|
+
let return_type = callback.return_type.clone();
|
|
140
140
|
let callback_name = callback_name.clone();
|
|
141
141
|
|
|
142
142
|
move |args| {
|
|
@@ -160,18 +160,13 @@ impl JsComponentInstance {
|
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
if
|
|
164
|
-
if let Ok(value) = super::to_value(&env, result, return_type) {
|
|
165
|
-
return value;
|
|
166
|
-
} else {
|
|
167
|
-
eprintln!(
|
|
168
|
-
"Node.js: cannot convert return type of callback {}",
|
|
169
|
-
callback_name
|
|
170
|
-
);
|
|
171
|
-
return slint_interpreter::default_value_for_type(return_type);
|
|
172
|
-
}
|
|
173
|
-
} else {
|
|
163
|
+
if matches!(return_type, Type::Void) {
|
|
174
164
|
Value::Void
|
|
165
|
+
} else if let Ok(value) = super::to_value(&env, result, &return_type) {
|
|
166
|
+
return value;
|
|
167
|
+
} else {
|
|
168
|
+
eprintln!("Node.js: cannot convert return type of callback {callback_name}");
|
|
169
|
+
return slint_interpreter::default_value_for_type(&return_type);
|
|
175
170
|
}
|
|
176
171
|
}
|
|
177
172
|
})
|
|
@@ -206,10 +201,10 @@ impl JsComponentInstance {
|
|
|
206
201
|
))
|
|
207
202
|
})?;
|
|
208
203
|
|
|
209
|
-
if let Type::Callback
|
|
204
|
+
if let Type::Callback(callback) = ty {
|
|
210
205
|
self.inner
|
|
211
206
|
.set_global_callback(global_name.as_str(), callback_name.as_str(), {
|
|
212
|
-
let return_type = return_type.clone();
|
|
207
|
+
let return_type = callback.return_type.clone();
|
|
213
208
|
let global_name = global_name.clone();
|
|
214
209
|
let callback_name = callback_name.clone();
|
|
215
210
|
|
|
@@ -237,18 +232,13 @@ impl JsComponentInstance {
|
|
|
237
232
|
}
|
|
238
233
|
};
|
|
239
234
|
|
|
240
|
-
if
|
|
241
|
-
if let Ok(value) = super::to_value(&env, result, return_type) {
|
|
242
|
-
return value;
|
|
243
|
-
} else {
|
|
244
|
-
eprintln!(
|
|
245
|
-
"Node.js: cannot convert return type of callback {}",
|
|
246
|
-
callback_name
|
|
247
|
-
);
|
|
248
|
-
return slint_interpreter::default_value_for_type(return_type);
|
|
249
|
-
}
|
|
250
|
-
} else {
|
|
235
|
+
if matches!(return_type, Type::Void) {
|
|
251
236
|
Value::Void
|
|
237
|
+
} else if let Ok(value) = super::to_value(&env, result, &return_type) {
|
|
238
|
+
return value;
|
|
239
|
+
} else {
|
|
240
|
+
eprintln!("Node.js: cannot convert return type of callback {callback_name}");
|
|
241
|
+
return slint_interpreter::default_value_for_type(&return_type);
|
|
252
242
|
}
|
|
253
243
|
}
|
|
254
244
|
})
|
|
@@ -260,6 +250,32 @@ impl JsComponentInstance {
|
|
|
260
250
|
Err(napi::Error::from_reason(format!("{} is not a callback", callback_name).as_str()))
|
|
261
251
|
}
|
|
262
252
|
|
|
253
|
+
fn invoke_args(
|
|
254
|
+
env: Env,
|
|
255
|
+
callback_name: &String,
|
|
256
|
+
arguments: Vec<JsUnknown>,
|
|
257
|
+
args: &Vec<Type>,
|
|
258
|
+
) -> Result<Vec<Value>> {
|
|
259
|
+
let count = args.len();
|
|
260
|
+
let args = arguments
|
|
261
|
+
.into_iter()
|
|
262
|
+
.zip(args.into_iter())
|
|
263
|
+
.map(|(a, ty)| super::value::to_value(&env, a, &ty))
|
|
264
|
+
.collect::<Result<Vec<_>, _>>()?;
|
|
265
|
+
if args.len() != count {
|
|
266
|
+
return Err(napi::Error::from_reason(
|
|
267
|
+
format!(
|
|
268
|
+
"{} expect {} arguments, but {} where provided",
|
|
269
|
+
callback_name,
|
|
270
|
+
count,
|
|
271
|
+
args.len()
|
|
272
|
+
)
|
|
273
|
+
.as_str(),
|
|
274
|
+
));
|
|
275
|
+
}
|
|
276
|
+
Ok(args)
|
|
277
|
+
}
|
|
278
|
+
|
|
263
279
|
#[napi]
|
|
264
280
|
pub fn invoke(
|
|
265
281
|
&self,
|
|
@@ -280,25 +296,8 @@ impl JsComponentInstance {
|
|
|
280
296
|
})?;
|
|
281
297
|
|
|
282
298
|
let args = match ty {
|
|
283
|
-
Type::Callback
|
|
284
|
-
|
|
285
|
-
let args = arguments
|
|
286
|
-
.into_iter()
|
|
287
|
-
.zip(args.into_iter())
|
|
288
|
-
.map(|(a, ty)| super::value::to_value(&env, a, &ty))
|
|
289
|
-
.collect::<Result<Vec<_>, _>>()?;
|
|
290
|
-
if args.len() != count {
|
|
291
|
-
return Err(napi::Error::from_reason(
|
|
292
|
-
format!(
|
|
293
|
-
"{} expect {} arguments, but {} where provided",
|
|
294
|
-
callback_name,
|
|
295
|
-
count,
|
|
296
|
-
args.len()
|
|
297
|
-
)
|
|
298
|
-
.as_str(),
|
|
299
|
-
));
|
|
300
|
-
}
|
|
301
|
-
args
|
|
299
|
+
Type::Callback(function) | Type::Function(function) => {
|
|
300
|
+
Self::invoke_args(env, &callback_name, arguments, &function.args)?
|
|
302
301
|
}
|
|
303
302
|
_ => {
|
|
304
303
|
return Err(napi::Error::from_reason(
|
|
@@ -340,25 +339,8 @@ impl JsComponentInstance {
|
|
|
340
339
|
})?;
|
|
341
340
|
|
|
342
341
|
let args = match ty {
|
|
343
|
-
Type::Callback
|
|
344
|
-
|
|
345
|
-
let args = arguments
|
|
346
|
-
.into_iter()
|
|
347
|
-
.zip(args.into_iter())
|
|
348
|
-
.map(|(a, ty)| super::value::to_value(&env, a, &ty))
|
|
349
|
-
.collect::<Result<Vec<_>, _>>()?;
|
|
350
|
-
if args.len() != count {
|
|
351
|
-
return Err(napi::Error::from_reason(
|
|
352
|
-
format!(
|
|
353
|
-
"{} expect {} arguments, but {} where provided",
|
|
354
|
-
callback_name,
|
|
355
|
-
count,
|
|
356
|
-
args.len()
|
|
357
|
-
)
|
|
358
|
-
.as_str(),
|
|
359
|
-
));
|
|
360
|
-
}
|
|
361
|
-
args
|
|
342
|
+
Type::Callback(function) | Type::Function(function) => {
|
|
343
|
+
Self::invoke_args(env, &callback_name, arguments, &function.args)?
|
|
362
344
|
}
|
|
363
345
|
_ => {
|
|
364
346
|
return Err(napi::Error::from_reason(
|
|
@@ -216,11 +216,11 @@ pub fn to_value(env: &Env, unknown: JsUnknown, typ: &Type) -> Result<Value> {
|
|
|
216
216
|
Ok(Value::Image(Image::from_rgba8(pixel_buffer)))
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
Type::Struct
|
|
219
|
+
Type::Struct(s) => {
|
|
220
220
|
let js_object = unknown.coerce_to_object()?;
|
|
221
221
|
|
|
222
222
|
Ok(Value::Struct(
|
|
223
|
-
fields
|
|
223
|
+
s.fields
|
|
224
224
|
.iter()
|
|
225
225
|
.map(|(pro_name, pro_ty)| {
|
|
226
226
|
let prop: JsUnknown = js_object
|