-
Notifications
You must be signed in to change notification settings - Fork 0
feat(cli): UTExportedTypeDeclarations support for file associations #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: coderabbit_combined_20260121_augment_sentry_coderabbit_1_base_featcli_utexportedtypedeclarations_support_for_file_associations_pr166
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "tauri-cli": minor:feat | ||
| "@tauri-apps/cli": minor:feat | ||
| --- | ||
|
|
||
| Added support to defining the content type of the declared file association on macOS (maps to LSItemContentTypes property). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "tauri-cli": minor:feat | ||
| "@tauri-apps/cli": minor:feat | ||
| --- | ||
|
|
||
| Added support to defining the metadata for custom types declared in `tauri.conf.json > bundle > fileAssociations > exportedType` via the `UTExportedTypeDeclarations` Info.plist property. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "tauri-utils": minor:feat | ||
| --- | ||
|
|
||
| Added `FileAssociation::exported_type` and `FileAssociation::content_types` for better support to defining custom types on macOS. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -268,29 +268,89 @@ fn create_info_plist( | |||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(associations) = settings.file_associations() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| let exported_associations = associations | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .filter_map(|association| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| association.exported_type.as_ref().map(|exported_type| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| let mut dict = plist::Dictionary::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "UTTypeIdentifier".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| exported_type.identifier.clone().into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(description) = &association.description { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert("UTTypeDescription".into(), description.clone().into()); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(content_types) = &association.content_types { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "UTTypeConformsTo".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array(content_types.iter().map(|s| s.clone().into()).collect()), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| let mut specification = plist::Dictionary::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| specification.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "public.filename-extension".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| association | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .ext | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(|s| s.to_string().into()) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .collect(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(mime_type) = &association.mime_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| specification.insert("public.mime-type".into(), mime_type.clone().into()); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert("UTTypeTagSpecification".into(), specification.into()); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Dictionary(dict) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .collect::<Vec<_>>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if !exported_associations.is_empty() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "UTExportedTypeDeclarations".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array(exported_associations), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| plist.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "CFBundleDocumentTypes".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| associations | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(|association| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| let mut dict = plist::Dictionary::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "CFBundleTypeExtensions".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| association | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .ext | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(|ext| ext.to_string().into()) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .collect(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if association.ext.is_empty() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "CFBundleTypeExtensions".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| association | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .ext | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(|ext| ext.to_string().into()) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .collect(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+328
to
+339
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Inverted condition inserts empty array instead of actual extensions. The condition 🐛 Proposed fix- if association.ext.is_empty() {
+ if !association.ext.is_empty() {
dict.insert(
"CFBundleTypeExtensions".into(),
plist::Value::Array(
association
.ext
.iter()
.map(|ext| ext.to_string().into())
.collect(),
),
);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(content_types) = &association.content_types { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "LSItemContentTypes".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array(content_types.iter().map(|s| s.to_string().into()).collect()), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "CFBundleTypeName".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| association | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .as_ref() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .unwrap_or(&association.ext[0].0) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .expect("File association must have a name") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .to_string() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Wrong field used for
UTTypeConformsTo.association.content_typesis meant forLSItemContentTypesinCFBundleDocumentTypes, not forUTTypeConformsToinUTExportedTypeDeclarations. TheExportedFileAssociationstruct has its ownconforms_tofield that should be used here.🐛 Proposed fix
🤖 Prompt for AI Agents