slint-ui 1.7.0-nightly.2024070208 → 1.7.0-nightly.2024070318
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 +4 -4
- package/README.md +32 -1
- package/index.d.ts +21 -23
- package/index.js +160 -159
- package/index.ts +326 -326
- package/package.json +6 -6
- package/rust-module.d.ts +2 -2
- package/src/interpreter/component_compiler.rs +17 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slint-ui",
|
|
3
|
-
"version": "1.7.0-nightly.
|
|
3
|
+
"version": "1.7.0-nightly.2024070318",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"homepage": "https://github.com/slint-ui/slint",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"@napi-rs/cli": "^2.16.5"
|
|
60
60
|
},
|
|
61
61
|
"optionalDependencies": {
|
|
62
|
-
"@slint-ui/slint-ui-binary-linux-x64-gnu": "1.7.0-nightly.
|
|
63
|
-
"@slint-ui/slint-ui-binary-darwin-x64": "1.7.0-nightly.
|
|
64
|
-
"@slint-ui/slint-ui-binary-darwin-arm64": "1.7.0-nightly.
|
|
65
|
-
"@slint-ui/slint-ui-binary-win32-x64-msvc": "1.7.0-nightly.
|
|
66
|
-
"@slint-ui/slint-ui-binary-win32-ia32-msvc": "1.7.0-nightly.
|
|
62
|
+
"@slint-ui/slint-ui-binary-linux-x64-gnu": "1.7.0-nightly.2024070318",
|
|
63
|
+
"@slint-ui/slint-ui-binary-darwin-x64": "1.7.0-nightly.2024070318",
|
|
64
|
+
"@slint-ui/slint-ui-binary-darwin-arm64": "1.7.0-nightly.2024070318",
|
|
65
|
+
"@slint-ui/slint-ui-binary-win32-x64-msvc": "1.7.0-nightly.2024070318",
|
|
66
|
+
"@slint-ui/slint-ui-binary-win32-ia32-msvc": "1.7.0-nightly.2024070318"
|
|
67
67
|
}
|
|
68
68
|
}
|
package/rust-module.d.ts
CHANGED
|
@@ -103,9 +103,9 @@ export declare class ComponentCompiler {
|
|
|
103
103
|
*
|
|
104
104
|
* Returns the compiled `ComponentDefinition` if there were no errors.
|
|
105
105
|
*/
|
|
106
|
-
buildFromPath(path: string): JsComponentDefinition
|
|
106
|
+
buildFromPath(path: string): Record<string, JsComponentDefinition>
|
|
107
107
|
/** Compile some .slint code into a ComponentDefinition */
|
|
108
|
-
buildFromSource(sourceCode: string, path: string): JsComponentDefinition
|
|
108
|
+
buildFromSource(sourceCode: string, path: string): Record<string, JsComponentDefinition>
|
|
109
109
|
}
|
|
110
110
|
export type JsComponentDefinition = ComponentDefinition
|
|
111
111
|
export declare class ComponentDefinition {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
2
2
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
|
3
3
|
|
|
4
|
-
use std::collections::HashMap;
|
|
5
|
-
use std::path::PathBuf;
|
|
6
|
-
|
|
7
4
|
use super::JsComponentDefinition;
|
|
8
5
|
use super::JsDiagnostic;
|
|
9
6
|
use itertools::Itertools;
|
|
10
|
-
use slint_interpreter::
|
|
7
|
+
use slint_interpreter::Compiler;
|
|
8
|
+
use std::collections::HashMap;
|
|
9
|
+
use std::path::PathBuf;
|
|
11
10
|
|
|
12
11
|
/// ComponentCompiler is the entry point to the Slint interpreter that can be used
|
|
13
12
|
/// to load .slint files or compile them on-the-fly from a string.
|
|
14
13
|
#[napi(js_name = "ComponentCompiler")]
|
|
15
14
|
pub struct JsComponentCompiler {
|
|
16
|
-
internal:
|
|
15
|
+
internal: Compiler,
|
|
16
|
+
diagnostics: Vec<slint_interpreter::Diagnostic>,
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
#[napi]
|
|
@@ -21,7 +21,7 @@ impl JsComponentCompiler {
|
|
|
21
21
|
/// Returns a new ComponentCompiler.
|
|
22
22
|
#[napi(constructor)]
|
|
23
23
|
pub fn new() -> Self {
|
|
24
|
-
let mut compiler =
|
|
24
|
+
let mut compiler = Compiler::default();
|
|
25
25
|
let include_paths = match std::env::var_os("SLINT_INCLUDE_PATH") {
|
|
26
26
|
Some(paths) => {
|
|
27
27
|
std::env::split_paths(&paths).filter(|path| !path.as_os_str().is_empty()).collect()
|
|
@@ -39,12 +39,12 @@ impl JsComponentCompiler {
|
|
|
39
39
|
.map(|(k, v)| (k.into(), v.into()))
|
|
40
40
|
})
|
|
41
41
|
.collect(),
|
|
42
|
-
None =>
|
|
42
|
+
None => HashMap::new(),
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
compiler.set_include_paths(include_paths);
|
|
46
46
|
compiler.set_library_paths(library_paths);
|
|
47
|
-
Self { internal: compiler }
|
|
47
|
+
Self { internal: compiler, diagnostics: vec![] }
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
#[napi(setter)]
|
|
@@ -96,15 +96,17 @@ impl JsComponentCompiler {
|
|
|
96
96
|
|
|
97
97
|
#[napi(getter)]
|
|
98
98
|
pub fn diagnostics(&self) -> Vec<JsDiagnostic> {
|
|
99
|
-
self.
|
|
99
|
+
self.diagnostics.iter().map(|d| JsDiagnostic::from(d.clone())).collect()
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/// Compile a .slint file into a ComponentDefinition
|
|
103
103
|
///
|
|
104
104
|
/// Returns the compiled `ComponentDefinition` if there were no errors.
|
|
105
105
|
#[napi]
|
|
106
|
-
pub fn build_from_path(&mut self, path: String) ->
|
|
107
|
-
spin_on::spin_on(self.internal.build_from_path(PathBuf::from(path)))
|
|
106
|
+
pub fn build_from_path(&mut self, path: String) -> HashMap<String, JsComponentDefinition> {
|
|
107
|
+
let r = spin_on::spin_on(self.internal.build_from_path(PathBuf::from(path)));
|
|
108
|
+
self.diagnostics = r.diagnostics().collect();
|
|
109
|
+
r.component_names().filter_map(|n| Some((n.to_owned(), r.component(n)?.into()))).collect()
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
/// Compile some .slint code into a ComponentDefinition
|
|
@@ -113,8 +115,9 @@ impl JsComponentCompiler {
|
|
|
113
115
|
&mut self,
|
|
114
116
|
source_code: String,
|
|
115
117
|
path: String,
|
|
116
|
-
) ->
|
|
117
|
-
spin_on::spin_on(self.internal.build_from_source(source_code, PathBuf::from(path)))
|
|
118
|
-
|
|
118
|
+
) -> HashMap<String, JsComponentDefinition> {
|
|
119
|
+
let r = spin_on::spin_on(self.internal.build_from_source(source_code, PathBuf::from(path)));
|
|
120
|
+
self.diagnostics = r.diagnostics().collect();
|
|
121
|
+
r.component_names().filter_map(|n| Some((n.to_owned(), r.component(n)?.into()))).collect()
|
|
119
122
|
}
|
|
120
123
|
}
|