mirror of
https://github.com/hanzoai/mobile.git
synced 2026-10-30 14:53:17 +00:00
30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
const { withEntitlementsPlist } = require('expo/config-plugins')
|
|
|
|
// App side of the home-screen widget pact. The widget target itself is
|
|
// generated by @bacons/apple-targets from targets/widget/expo-target.config.js;
|
|
// here the APP joins the same App Group so state written by modules/widget is
|
|
// readable across the process boundary. The targets plugin is composed here
|
|
// too, so registering this one plugin turns the whole widget on.
|
|
|
|
const group = 'group.ai.hanzo.mobile'
|
|
|
|
module.exports = function widget(config) {
|
|
config = withEntitlementsPlist(config, (config) => {
|
|
const groups = config.modResults['com.apple.security.application-groups'] ?? []
|
|
if (!groups.includes(group)) groups.push(group)
|
|
config.modResults['com.apple.security.application-groups'] = groups
|
|
return config
|
|
})
|
|
try {
|
|
config = require('@bacons/apple-targets/app.plugin')(config)
|
|
} catch (error) {
|
|
// Without the targets plugin the app still builds; the widget target is
|
|
// simply not generated. Say what restores it instead of failing prebuild.
|
|
console.warn(
|
|
`[widget] @bacons/apple-targets unavailable (${error.message}); ` +
|
|
'install it and re-run prebuild to generate the HanzoWidget target.'
|
|
)
|
|
}
|
|
return config
|
|
}
|