1use super::*;
2use serde::Serialize;
3
4pub type OmenaQueryTsconfigPathMappingV0 = omena_resolver::OmenaResolverTsconfigPathMappingV0;
5pub type OmenaQueryBundlerPathAliasMappingV0 =
6 omena_resolver::OmenaResolverBundlerPathAliasMappingV0;
7
8#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize)]
9#[serde(rename_all = "camelCase")]
10pub struct OmenaQueryStyleResolutionInputsV0 {
11 pub package_manifests: Vec<OmenaQueryStylePackageManifestV0>,
12 pub tsconfig_path_mappings: Vec<OmenaQueryTsconfigPathMappingV0>,
13 pub bundler_path_mappings: Vec<OmenaQueryBundlerPathAliasMappingV0>,
14}
15
16pub fn summarize_omena_query_source_import_declarations(
17 source: &str,
18) -> OmenaQuerySourceImportDeclarationSummaryV0 {
19 omena_bridge::summarize_omena_bridge_source_import_declarations(source)
20}
21
22pub fn summarize_omena_query_source_import_declarations_for_source_language(
23 source_path: &str,
24 source: &str,
25 source_language: Option<&str>,
26) -> OmenaQuerySourceImportDeclarationSummaryV0 {
27 omena_bridge::summarize_omena_bridge_source_import_declarations_for_source_language(
28 source_path,
29 source,
30 source_language,
31 )
32}
33
34pub fn resolve_omena_query_style_uri_for_specifier(
35 base_document_uri: &str,
36 workspace_folder_uri: Option<&str>,
37 specifier: &str,
38) -> Option<String> {
39 omena_bridge::resolve_omena_bridge_style_uri_for_specifier(
40 base_document_uri,
41 workspace_folder_uri,
42 specifier,
43 )
44}
45
46pub fn resolve_omena_query_style_uri_for_specifier_with_package_manifests(
47 base_document_uri: &str,
48 workspace_folder_uri: Option<&str>,
49 specifier: &str,
50 package_manifests: &[OmenaQueryStylePackageManifestV0],
51) -> Option<String> {
52 let resolver_package_manifests = package_manifests
53 .iter()
54 .map(|manifest| OmenaResolverStylePackageManifestV0 {
55 package_json_path: manifest.package_json_path.clone(),
56 package_json_source: manifest.package_json_source.clone(),
57 })
58 .collect::<Vec<_>>();
59 omena_bridge::resolve_omena_bridge_style_uri_for_specifier_with_package_manifests(
60 base_document_uri,
61 workspace_folder_uri,
62 specifier,
63 resolver_package_manifests.as_slice(),
64 )
65}
66
67pub fn resolve_omena_query_style_uri_for_specifier_with_resolution_inputs(
68 base_document_uri: &str,
69 workspace_folder_uri: Option<&str>,
70 specifier: &str,
71 resolution_inputs: &OmenaQueryStyleResolutionInputsV0,
72) -> Option<String> {
73 let bridge_inputs = omena_bridge::OmenaBridgeStyleResolutionInputsV0 {
74 package_manifests: resolution_inputs
75 .package_manifests
76 .iter()
77 .map(|manifest| OmenaResolverStylePackageManifestV0 {
78 package_json_path: manifest.package_json_path.clone(),
79 package_json_source: manifest.package_json_source.clone(),
80 })
81 .collect(),
82 tsconfig_path_mappings: resolution_inputs.tsconfig_path_mappings.clone(),
83 bundler_path_mappings: resolution_inputs.bundler_path_mappings.clone(),
84 };
85 omena_bridge::resolve_omena_bridge_style_uri_for_specifier_with_resolution_inputs(
86 base_document_uri,
87 workspace_folder_uri,
88 specifier,
89 &bridge_inputs,
90 )
91}
92
93pub fn load_omena_query_workspace_style_resolution_inputs(
94 workspace_folder_uri: Option<&str>,
95 configured_package_manifests: &[OmenaQueryStylePackageManifestV0],
96) -> OmenaQueryStyleResolutionInputsV0 {
97 let resolver_package_manifests = configured_package_manifests
98 .iter()
99 .map(|manifest| OmenaResolverStylePackageManifestV0 {
100 package_json_path: manifest.package_json_path.clone(),
101 package_json_source: manifest.package_json_source.clone(),
102 })
103 .collect::<Vec<_>>();
104 let bridge_inputs = omena_bridge::load_omena_bridge_workspace_style_resolution_inputs(
105 workspace_folder_uri,
106 resolver_package_manifests.as_slice(),
107 );
108 OmenaQueryStyleResolutionInputsV0 {
109 package_manifests: bridge_inputs
110 .package_manifests
111 .into_iter()
112 .map(|manifest| OmenaQueryStylePackageManifestV0 {
113 package_json_path: manifest.package_json_path,
114 package_json_source: manifest.package_json_source,
115 })
116 .collect(),
117 tsconfig_path_mappings: bridge_inputs.tsconfig_path_mappings,
118 bundler_path_mappings: bridge_inputs.bundler_path_mappings,
119 }
120}
121
122pub fn summarize_omena_query_source_syntax_index(
123 source: &str,
124 imported_style_bindings: Vec<OmenaQuerySourceImportedStyleBindingV0>,
125 classnames_bind_bindings: Vec<String>,
126) -> OmenaQuerySourceSyntaxIndexV0 {
127 omena_bridge::summarize_omena_bridge_source_syntax_index(
128 source,
129 imported_style_bindings,
130 classnames_bind_bindings,
131 )
132}
133
134pub fn summarize_omena_query_source_syntax_index_for_source_language(
135 source_path: &str,
136 source: &str,
137 source_language: Option<&str>,
138 imported_style_bindings: Vec<OmenaQuerySourceImportedStyleBindingV0>,
139 classnames_bind_bindings: Vec<String>,
140) -> OmenaQuerySourceSyntaxIndexV0 {
141 omena_bridge::summarize_omena_bridge_source_syntax_index_for_source_language(
142 source_path,
143 source,
144 source_language,
145 imported_style_bindings,
146 classnames_bind_bindings,
147 )
148}
149
150pub fn collect_omena_query_vue_style_module_bindings(
151 source_path: &str,
152 source: &str,
153 source_language: Option<&str>,
154) -> Vec<String> {
155 omena_bridge::collect_omena_bridge_vue_style_module_bindings(
156 source_path,
157 source,
158 source_language,
159 )
160}
161
162pub fn canonicalize_omena_query_source_selector_references(
163 references: &mut Vec<OmenaQuerySourceSelectorReferenceFactV0>,
164) {
165 omena_bridge::canonicalize_source_selector_references(references);
166}