voltra 1.1.1 → 1.2.0-rc.1
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/android/src/main/java/voltra/VoltraModule.kt +52 -0
- package/android/src/main/java/voltra/generated/ShortNames.kt +9 -1
- package/android/src/main/java/voltra/glance/renderers/TextAndImageRenderers.kt +18 -7
- package/android/src/main/java/voltra/models/VoltraPayload.kt +68 -0
- package/android/src/main/java/voltra/parsing/VoltraDecompressor.kt +103 -3
- package/build/VoltraModule.d.ts +4 -0
- package/build/VoltraModule.d.ts.map +1 -1
- package/build/VoltraModule.js.map +1 -1
- package/build/android/client.d.ts +2 -2
- package/build/android/client.d.ts.map +1 -1
- package/build/android/client.js +1 -1
- package/build/android/client.js.map +1 -1
- package/build/android/jsx/props/Image.d.ts +5 -0
- package/build/android/jsx/props/Image.d.ts.map +1 -1
- package/build/android/jsx/props/Image.js.map +1 -1
- package/build/android/widgets/api.d.ts +14 -2
- package/build/android/widgets/api.d.ts.map +1 -1
- package/build/android/widgets/api.js +14 -0
- package/build/android/widgets/api.js.map +1 -1
- package/build/android/widgets/index.d.ts +2 -2
- package/build/android/widgets/index.d.ts.map +1 -1
- package/build/android/widgets/index.js +1 -1
- package/build/android/widgets/index.js.map +1 -1
- package/build/android/widgets/types.d.ts +16 -0
- package/build/android/widgets/types.d.ts.map +1 -1
- package/build/android/widgets/types.js.map +1 -1
- package/build/client.d.ts +2 -2
- package/build/client.d.ts.map +1 -1
- package/build/client.js +1 -1
- package/build/client.js.map +1 -1
- package/build/components/VoltraView.d.ts +5 -1
- package/build/components/VoltraView.d.ts.map +1 -1
- package/build/components/VoltraView.js +8 -2
- package/build/components/VoltraView.js.map +1 -1
- package/build/jsx/View.d.ts +4 -0
- package/build/jsx/View.d.ts.map +1 -0
- package/build/jsx/View.js +3 -0
- package/build/jsx/View.js.map +1 -0
- package/build/jsx/primitives.d.ts +1 -0
- package/build/jsx/primitives.d.ts.map +1 -1
- package/build/jsx/primitives.js +1 -0
- package/build/jsx/primitives.js.map +1 -1
- package/build/jsx/props/AndroidImage.d.ts +3 -0
- package/build/jsx/props/AndroidImage.d.ts.map +1 -1
- package/build/jsx/props/AndroidImage.js.map +1 -1
- package/build/jsx/props/Box.d.ts +6 -0
- package/build/jsx/props/Box.d.ts.map +1 -0
- package/build/jsx/props/Box.js +5 -0
- package/build/jsx/props/Box.js.map +1 -0
- package/build/jsx/props/CircularProgressView.d.ts +5 -0
- package/build/jsx/props/CircularProgressView.d.ts.map +1 -1
- package/build/jsx/props/CircularProgressView.js.map +1 -1
- package/build/jsx/props/HStack.d.ts +4 -2
- package/build/jsx/props/HStack.d.ts.map +1 -1
- package/build/jsx/props/HStack.js.map +1 -1
- package/build/jsx/props/Image.d.ts +3 -0
- package/build/jsx/props/Image.d.ts.map +1 -1
- package/build/jsx/props/Image.js.map +1 -1
- package/build/jsx/props/LinearProgressView.d.ts +4 -0
- package/build/jsx/props/LinearProgressView.d.ts.map +1 -1
- package/build/jsx/props/LinearProgressView.js.map +1 -1
- package/build/jsx/props/Timer.d.ts +0 -2
- package/build/jsx/props/Timer.d.ts.map +1 -1
- package/build/jsx/props/Timer.js.map +1 -1
- package/build/jsx/props/VStack.d.ts +4 -2
- package/build/jsx/props/VStack.d.ts.map +1 -1
- package/build/jsx/props/VStack.js.map +1 -1
- package/build/jsx/props/View.d.ts +3 -0
- package/build/jsx/props/View.d.ts.map +1 -0
- package/build/jsx/props/View.js +5 -0
- package/build/jsx/props/View.js.map +1 -0
- package/build/payload/component-ids.d.ts.map +1 -1
- package/build/payload/component-ids.js +16 -14
- package/build/payload/component-ids.js.map +1 -1
- package/build/payload/short-names.d.ts.map +1 -1
- package/build/payload/short-names.js +18 -2
- package/build/payload/short-names.js.map +1 -1
- package/build/styles/types.d.ts +2 -2
- package/build/styles/types.d.ts.map +1 -1
- package/build/styles/types.js.map +1 -1
- package/build/widgets/types.d.ts +11 -0
- package/build/widgets/types.d.ts.map +1 -1
- package/build/widgets/types.js.map +1 -1
- package/build/widgets/widget-api.d.ts +14 -2
- package/build/widgets/widget-api.d.ts.map +1 -1
- package/build/widgets/widget-api.js +16 -0
- package/build/widgets/widget-api.js.map +1 -1
- package/docs/FLEXBOX.md +366 -0
- package/ios/app/VoltraModule.swift +4 -0
- package/ios/app/VoltraModuleImpl.swift +38 -0
- package/ios/shared/ComponentTypeID.swift +11 -7
- package/ios/shared/ShortNames.swift +9 -1
- package/ios/shared/VoltraNode.swift +3 -0
- package/ios/target/VoltraHomeWidget.swift +13 -3
- package/ios/ui/Generated/Parameters/BoxParameters.swift +24 -0
- package/ios/ui/Generated/Parameters/GaugeParameters.swift +0 -15
- package/ios/ui/Generated/Parameters/GroupBoxParameters.swift +1 -4
- package/ios/ui/Generated/Parameters/HStackParameters.swift +10 -5
- package/ios/ui/Generated/Parameters/LinearProgressViewParameters.swift +0 -5
- package/ios/ui/Generated/Parameters/MaskParameters.swift +1 -4
- package/ios/ui/Generated/Parameters/TimerParameters.swift +0 -5
- package/ios/ui/Generated/Parameters/VStackParameters.swift +10 -5
- package/ios/ui/Generated/Parameters/ViewParameters.swift +12 -0
- package/ios/ui/Layout/FlexContainerHelper.swift +114 -0
- package/ios/ui/Layout/VoltraFlexStackLayout.swift +400 -0
- package/ios/ui/Style/CompositeStyle.swift +68 -15
- package/ios/ui/Style/FlexEnvironment.swift +35 -0
- package/ios/ui/Style/JSStyleParser.swift +15 -0
- package/ios/ui/Style/LayoutStyle.swift +132 -21
- package/ios/ui/Style/StyleConverter.swift +71 -20
- package/ios/ui/Style/View+applyStyle.swift +22 -4
- package/ios/ui/Views/VoltraCircularProgressView.swift +52 -44
- package/ios/ui/Views/VoltraFlexView.swift +33 -0
- package/ios/ui/Views/VoltraHStack.swift +44 -4
- package/ios/ui/Views/VoltraImage.swift +57 -50
- package/ios/ui/Views/VoltraLinearProgressView.swift +78 -95
- package/ios/ui/Views/VoltraText.swift +9 -1
- package/ios/ui/Views/VoltraTimer.swift +62 -123
- package/ios/ui/Views/VoltraVStack.swift +46 -5
- package/package.json +5 -3
- package/plugin/build/{features/android/files/assets/index.d.ts → android/files/assets.d.ts} +7 -3
- package/plugin/build/{features/android/files/assets/images.js → android/files/assets.js} +99 -6
- package/plugin/build/{features/android → android}/files/index.d.ts +1 -1
- package/plugin/build/{features/android → android}/files/index.js +18 -5
- package/plugin/build/{features/android → android}/files/initialStates.d.ts +2 -2
- package/plugin/build/{features/android → android}/files/initialStates.js +6 -6
- package/plugin/build/{features/android/files/kotlin/index.d.ts → android/files/kotlin.d.ts} +2 -2
- package/plugin/build/{features/android/files/kotlin/index.js → android/files/kotlin.js} +33 -4
- package/plugin/build/android/files/xml.d.ts +24 -0
- package/plugin/build/android/files/xml.js +246 -0
- package/plugin/build/{features/android → android}/index.d.ts +1 -1
- package/plugin/build/{features/android → android}/index.js +5 -2
- package/plugin/build/{features/android/manifest/index.d.ts → android/manifest.d.ts} +1 -1
- package/plugin/build/constants.d.ts +28 -0
- package/plugin/build/constants.js +47 -0
- package/plugin/build/index.js +29 -34
- package/plugin/build/ios/eas.d.ts +11 -0
- package/plugin/build/ios/eas.js +27 -0
- package/plugin/build/ios/entitlements.d.ts +11 -0
- package/plugin/build/ios/entitlements.js +25 -0
- package/plugin/build/ios/index.d.ts +15 -0
- package/plugin/build/ios/index.js +34 -0
- package/plugin/build/ios/infoPlist.d.ts +14 -0
- package/plugin/build/ios/infoPlist.js +28 -0
- package/plugin/build/{features/ios/eas/index.js → ios-widget/eas.js} +3 -2
- package/plugin/build/ios-widget/files/assets.js +198 -0
- package/plugin/build/{features/ios → ios-widget}/files/entitlements.d.ts +0 -4
- package/plugin/build/{features/ios → ios-widget}/files/entitlements.js +4 -12
- package/plugin/build/{features/ios → ios-widget}/files/index.d.ts +1 -1
- package/plugin/build/{features/ios → ios-widget}/files/index.js +5 -2
- package/plugin/build/{features/ios/files/plist.js → ios-widget/files/infoPlist.js} +2 -2
- package/plugin/build/{features/ios/files/swift/index.d.ts → ios-widget/files/swift.d.ts} +1 -1
- package/plugin/build/ios-widget/files/swift.js +254 -0
- package/plugin/build/{features/ios → ios-widget}/fonts.js +35 -26
- package/plugin/build/{features/ios → ios-widget}/index.d.ts +7 -7
- package/plugin/build/{features/ios → ios-widget}/index.js +15 -15
- package/plugin/build/ios-widget/podfile.js +79 -0
- package/plugin/build/{features/ios/plist/index.d.ts → ios-widget/widgetPlist.d.ts} +1 -1
- package/plugin/build/ios-widget/widgetPlist.js +67 -0
- package/plugin/build/{features/ios/xcode/build/phases.d.ts → ios-widget/xcode/buildPhases.d.ts} +9 -2
- package/plugin/build/ios-widget/xcode/buildPhases.js +245 -0
- package/plugin/build/{features/ios/xcode/build → ios-widget/xcode}/configurationList.d.ts +6 -0
- package/plugin/build/{features/ios/xcode/build → ios-widget/xcode}/configurationList.js +47 -6
- package/plugin/build/{features/ios → ios-widget}/xcode/groups.d.ts +5 -1
- package/plugin/build/ios-widget/xcode/groups.js +65 -0
- package/plugin/build/{features/ios → ios-widget}/xcode/index.js +56 -21
- package/plugin/build/{features/ios → ios-widget}/xcode/productFile.d.ts +4 -0
- package/plugin/build/ios-widget/xcode/productFile.js +73 -0
- package/plugin/build/{features/ios/xcode/target/index.d.ts → ios-widget/xcode/target.d.ts} +8 -0
- package/plugin/build/ios-widget/xcode/target.js +112 -0
- package/plugin/build/{types/plugin.d.ts → types.d.ts} +46 -1
- package/plugin/build/utils/entitlements.d.ts +8 -0
- package/plugin/build/utils/entitlements.js +20 -0
- package/plugin/build/validation.d.ts +16 -0
- package/plugin/build/{validation/validateAndroidWidget.js → validation.js} +107 -0
- package/plugin/build/constants/index.d.ts +0 -6
- package/plugin/build/constants/index.js +0 -17
- package/plugin/build/constants/ios.d.ts +0 -13
- package/plugin/build/constants/ios.js +0 -16
- package/plugin/build/constants/paths.d.ts +0 -7
- package/plugin/build/constants/paths.js +0 -10
- package/plugin/build/constants/widgets.d.ts +0 -14
- package/plugin/build/constants/widgets.js +0 -24
- package/plugin/build/features/android/files/assets/images.d.ts +0 -20
- package/plugin/build/features/android/files/assets/index.js +0 -95
- package/plugin/build/features/android/files/assets/preview.d.ts +0 -6
- package/plugin/build/features/android/files/assets/preview.js +0 -73
- package/plugin/build/features/android/files/kotlin/widgetReceiver.d.ts +0 -5
- package/plugin/build/features/android/files/kotlin/widgetReceiver.js +0 -27
- package/plugin/build/features/android/files/xml/index.d.ts +0 -11
- package/plugin/build/features/android/files/xml/index.js +0 -76
- package/plugin/build/features/android/files/xml/placeholderLayout.d.ts +0 -5
- package/plugin/build/features/android/files/xml/placeholderLayout.js +0 -27
- package/plugin/build/features/android/files/xml/previewLayout.d.ts +0 -11
- package/plugin/build/features/android/files/xml/previewLayout.js +0 -106
- package/plugin/build/features/android/files/xml/stringResources.d.ts +0 -5
- package/plugin/build/features/android/files/xml/stringResources.js +0 -22
- package/plugin/build/features/android/files/xml/widgetInfo.d.ts +0 -5
- package/plugin/build/features/android/files/xml/widgetInfo.js +0 -43
- package/plugin/build/features/ios/files/assets/catalog.d.ts +0 -22
- package/plugin/build/features/ios/files/assets/catalog.js +0 -107
- package/plugin/build/features/ios/files/assets/images.d.ts +0 -23
- package/plugin/build/features/ios/files/assets/images.js +0 -108
- package/plugin/build/features/ios/files/assets/index.js +0 -57
- package/plugin/build/features/ios/files/swift/index.js +0 -67
- package/plugin/build/features/ios/files/swift/initialStates.d.ts +0 -4
- package/plugin/build/features/ios/files/swift/initialStates.js +0 -88
- package/plugin/build/features/ios/files/swift/widgetBundle.d.ts +0 -10
- package/plugin/build/features/ios/files/swift/widgetBundle.js +0 -103
- package/plugin/build/features/ios/plist/index.js +0 -46
- package/plugin/build/features/ios/podfile/index.js +0 -47
- package/plugin/build/features/ios/xcode/build/index.d.ts +0 -29
- package/plugin/build/features/ios/xcode/build/index.js +0 -32
- package/plugin/build/features/ios/xcode/build/phases.js +0 -59
- package/plugin/build/features/ios/xcode/groups.js +0 -21
- package/plugin/build/features/ios/xcode/productFile.js +0 -22
- package/plugin/build/features/ios/xcode/target/dependency.d.ts +0 -7
- package/plugin/build/features/ios/xcode/target/dependency.js +0 -15
- package/plugin/build/features/ios/xcode/target/index.js +0 -20
- package/plugin/build/features/ios/xcode/target/nativeTarget.d.ts +0 -28
- package/plugin/build/features/ios/xcode/target/nativeTarget.js +0 -25
- package/plugin/build/features/ios/xcode/target/projectSection.d.ts +0 -7
- package/plugin/build/features/ios/xcode/target/projectSection.js +0 -19
- package/plugin/build/types/index.d.ts +0 -5
- package/plugin/build/types/index.js +0 -5
- package/plugin/build/types/widget.d.ts +0 -46
- package/plugin/build/types/widget.js +0 -5
- package/plugin/build/utils/index.d.ts +0 -6
- package/plugin/build/utils/index.js +0 -12
- package/plugin/build/validation/index.d.ts +0 -5
- package/plugin/build/validation/index.js +0 -10
- package/plugin/build/validation/validateAndroidWidget.d.ts +0 -6
- package/plugin/build/validation/validateProps.d.ts +0 -6
- package/plugin/build/validation/validateProps.js +0 -55
- package/plugin/build/validation/validateWidget.d.ts +0 -6
- package/plugin/build/validation/validateWidget.js +0 -46
- /package/plugin/build/{features/android/manifest/index.js → android/manifest.js} +0 -0
- /package/plugin/build/{features/pushNotifications/index.d.ts → ios/pushNotifications.d.ts} +0 -0
- /package/plugin/build/{features/pushNotifications/index.js → ios/pushNotifications.js} +0 -0
- /package/plugin/build/{features/ios/eas/index.d.ts → ios-widget/eas.d.ts} +0 -0
- /package/plugin/build/{features/ios/files/assets/index.d.ts → ios-widget/files/assets.d.ts} +0 -0
- /package/plugin/build/{features/ios/files/plist.d.ts → ios-widget/files/infoPlist.d.ts} +0 -0
- /package/plugin/build/{features/ios → ios-widget}/fonts.d.ts +0 -0
- /package/plugin/build/{features/ios/podfile/index.d.ts → ios-widget/podfile.d.ts} +0 -0
- /package/plugin/build/{features/ios → ios-widget}/xcode/index.d.ts +0 -0
- /package/plugin/build/{features/ios/xcode/utils/getMainAppTargetSettings.d.ts → ios-widget/xcode/mainAppSettings.d.ts} +0 -0
- /package/plugin/build/{features/ios/xcode/utils/getMainAppTargetSettings.js → ios-widget/xcode/mainAppSettings.js} +0 -0
- /package/plugin/build/{types/plugin.js → types.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package voltra
|
|
2
2
|
|
|
3
|
+
import android.appwidget.AppWidgetManager
|
|
3
4
|
import android.util.Log
|
|
4
5
|
import androidx.compose.ui.unit.DpSize
|
|
5
6
|
import androidx.compose.ui.unit.dp
|
|
@@ -171,6 +172,57 @@ class VoltraModule : Module() {
|
|
|
171
172
|
Log.d(TAG, "clearAllAndroidWidgets completed")
|
|
172
173
|
}
|
|
173
174
|
|
|
175
|
+
AsyncFunction("getActiveWidgets") {
|
|
176
|
+
val context = appContext.reactContext ?: return@AsyncFunction emptyList<Map<String, Any>>()
|
|
177
|
+
val manager = AppWidgetManager.getInstance(context)
|
|
178
|
+
val packageName = context.packageName
|
|
179
|
+
|
|
180
|
+
// 1. Get all providers defined in this app
|
|
181
|
+
val installedProviders =
|
|
182
|
+
manager.installedProviders.filter {
|
|
183
|
+
it.provider.packageName == packageName
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
val activeWidgets = mutableListOf<Map<String, Any>>()
|
|
187
|
+
|
|
188
|
+
// 2. Iterate over every provider
|
|
189
|
+
for (providerInfo in installedProviders) {
|
|
190
|
+
val ids = manager.getAppWidgetIds(providerInfo.provider)
|
|
191
|
+
|
|
192
|
+
// 3. Iterate over every instance of that widget
|
|
193
|
+
for (id in ids) {
|
|
194
|
+
val options = manager.getAppWidgetOptions(id)
|
|
195
|
+
val minWidth = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH)
|
|
196
|
+
val minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT)
|
|
197
|
+
|
|
198
|
+
// Get short class name (e.g. ".widget.VoltraWidget_weatherReceiver")
|
|
199
|
+
val shortClassName = providerInfo.provider.shortClassName
|
|
200
|
+
|
|
201
|
+
val prefix = ".widget.VoltraWidget_"
|
|
202
|
+
val suffix = "Receiver"
|
|
203
|
+
val name =
|
|
204
|
+
if (shortClassName.startsWith(prefix) && shortClassName.endsWith(suffix)) {
|
|
205
|
+
shortClassName.substring(prefix.length, shortClassName.length - suffix.length)
|
|
206
|
+
} else {
|
|
207
|
+
shortClassName
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
activeWidgets.add(
|
|
211
|
+
mapOf(
|
|
212
|
+
"name" to name,
|
|
213
|
+
"widgetId" to id,
|
|
214
|
+
"providerClassName" to shortClassName,
|
|
215
|
+
"label" to providerInfo.loadLabel(context.packageManager).toString(),
|
|
216
|
+
"width" to minWidth,
|
|
217
|
+
"height" to minHeight,
|
|
218
|
+
),
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
activeWidgets
|
|
224
|
+
}
|
|
225
|
+
|
|
174
226
|
AsyncFunction("requestPinGlanceAppWidget") {
|
|
175
227
|
widgetId: String,
|
|
176
228
|
options: Map<String, Any?>?,
|
|
@@ -16,10 +16,11 @@ object ShortNames {
|
|
|
16
16
|
private val shortToName: Map<String, String> =
|
|
17
17
|
mapOf(
|
|
18
18
|
"ap" to "absolutePosition",
|
|
19
|
+
"ai" to "alignItems",
|
|
19
20
|
"al" to "alignment",
|
|
21
|
+
"as" to "alignSelf",
|
|
20
22
|
"ar" to "aspectRatio",
|
|
21
23
|
"an" to "assetName",
|
|
22
|
-
"ahe" to "autoHideOnEnd",
|
|
23
24
|
"bkg" to "background",
|
|
24
25
|
"bg" to "backgroundColor",
|
|
25
26
|
"bgs" to "backgroundStyle",
|
|
@@ -49,13 +50,17 @@ object ShortNames {
|
|
|
49
50
|
"en" to "enabled",
|
|
50
51
|
"end" to "endAtMs",
|
|
51
52
|
"ep" to "endPoint",
|
|
53
|
+
"flb" to "fallback",
|
|
52
54
|
"fmh" to "fillMaxHeight",
|
|
53
55
|
"fmw" to "fillMaxWidth",
|
|
54
56
|
"fsh" to "fixedSizeHorizontal",
|
|
55
57
|
"fsv" to "fixedSizeVertical",
|
|
56
58
|
"fl" to "flex",
|
|
59
|
+
"fb" to "flexBasis",
|
|
60
|
+
"fdir" to "flexDirection",
|
|
57
61
|
"fg" to "flexGrow",
|
|
58
62
|
"fgw" to "flexGrowWidth",
|
|
63
|
+
"fk" to "flexShrink",
|
|
59
64
|
"fnt" to "font",
|
|
60
65
|
"ff" to "fontFamily",
|
|
61
66
|
"fs" to "fontSize",
|
|
@@ -63,6 +68,7 @@ object ShortNames {
|
|
|
63
68
|
"fw" to "fontWeight",
|
|
64
69
|
"fgs" to "foregroundStyle",
|
|
65
70
|
"f" to "frame",
|
|
71
|
+
"g" to "gap",
|
|
66
72
|
"gs" to "gaugeStyle",
|
|
67
73
|
"ge" to "glassEffect",
|
|
68
74
|
"h" to "height",
|
|
@@ -71,8 +77,10 @@ object ShortNames {
|
|
|
71
77
|
"ic" to "icon",
|
|
72
78
|
"id" to "id",
|
|
73
79
|
"it" to "italic",
|
|
80
|
+
"jc" to "justifyContent",
|
|
74
81
|
"kern" to "kerning",
|
|
75
82
|
"lbl" to "label",
|
|
83
|
+
"ly" to "layout",
|
|
76
84
|
"lp" to "layoutPriority",
|
|
77
85
|
"l" to "left",
|
|
78
86
|
"ls" to "letterSpacing",
|
|
@@ -3,20 +3,18 @@ package voltra.glance.renderers
|
|
|
3
3
|
import androidx.compose.runtime.Composable
|
|
4
4
|
import androidx.glance.GlanceModifier
|
|
5
5
|
import androidx.glance.Image
|
|
6
|
-
import androidx.glance.
|
|
6
|
+
import androidx.glance.background
|
|
7
7
|
import androidx.glance.text.Text
|
|
8
|
-
import
|
|
8
|
+
import androidx.glance.unit.ColorProvider
|
|
9
9
|
import voltra.glance.LocalVoltraRenderContext
|
|
10
|
-
import voltra.glance.ResolvedStyle
|
|
11
10
|
import voltra.glance.applyClickableIfNeeded
|
|
12
11
|
import voltra.glance.resolveAndApplyStyle
|
|
13
12
|
import voltra.models.VoltraElement
|
|
14
13
|
import voltra.models.VoltraNode
|
|
14
|
+
import voltra.models.componentProp
|
|
15
|
+
import voltra.styling.JSColorParser
|
|
15
16
|
import voltra.styling.toGlanceTextStyle
|
|
16
17
|
|
|
17
|
-
private const val TAG = "TextAndImageRenderers"
|
|
18
|
-
private val gson = Gson()
|
|
19
|
-
|
|
20
18
|
@Composable
|
|
21
19
|
fun RenderText(
|
|
22
20
|
element: VoltraElement,
|
|
@@ -94,7 +92,20 @@ fun RenderImage(
|
|
|
94
92
|
alpha = alpha,
|
|
95
93
|
)
|
|
96
94
|
} else {
|
|
97
|
-
|
|
95
|
+
val fallbackNode =
|
|
96
|
+
element.componentProp(
|
|
97
|
+
"fallback",
|
|
98
|
+
renderContext.sharedStyles,
|
|
99
|
+
renderContext.sharedElements,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
if (fallbackNode != null) {
|
|
103
|
+
androidx.glance.layout.Box(modifier = finalModifier) {
|
|
104
|
+
RenderNode(fallbackNode)
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
androidx.glance.layout.Box(modifier = finalModifier) {}
|
|
108
|
+
}
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
111
|
|
|
@@ -51,3 +51,71 @@ sealed class VoltraNode {
|
|
|
51
51
|
val text: String,
|
|
52
52
|
) : VoltraNode()
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Resolve a raw prop value into a VoltraNode with shared context.
|
|
57
|
+
* Unlike parseVoltraNode, this eagerly resolves $r references (matching iOS behavior).
|
|
58
|
+
*/
|
|
59
|
+
@Suppress("UNCHECKED_CAST")
|
|
60
|
+
fun resolveToVoltraNode(
|
|
61
|
+
value: Any?,
|
|
62
|
+
sharedStyles: List<Map<String, Any>>?,
|
|
63
|
+
sharedElements: List<VoltraNode>?,
|
|
64
|
+
): VoltraNode? {
|
|
65
|
+
return when (value) {
|
|
66
|
+
null -> {
|
|
67
|
+
null
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
is VoltraNode -> {
|
|
71
|
+
value
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
is String -> {
|
|
75
|
+
VoltraNode.Text(value)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
is Number -> {
|
|
79
|
+
VoltraNode.Text(value.toString())
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
is Boolean -> {
|
|
83
|
+
VoltraNode.Text(value.toString())
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
is List<*> -> {
|
|
87
|
+
val elements = value.mapNotNull { resolveToVoltraNode(it, sharedStyles, sharedElements) }
|
|
88
|
+
if (elements.isEmpty()) null else VoltraNode.Array(elements)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
is Map<*, *> -> {
|
|
92
|
+
val map = value as Map<String, Any>
|
|
93
|
+
val ref = map["\$r"] as? Number
|
|
94
|
+
if (ref != null) {
|
|
95
|
+
return sharedElements?.getOrNull(ref.toInt())
|
|
96
|
+
}
|
|
97
|
+
val typeId = map["t"] as? Number ?: return null
|
|
98
|
+
val id = map["i"] as? String
|
|
99
|
+
val child = resolveToVoltraNode(map["c"], sharedStyles, sharedElements)
|
|
100
|
+
val props = map["p"] as? Map<String, Any>
|
|
101
|
+
VoltraNode.Element(VoltraElement(t = typeId.toInt(), i = id, c = child, p = props))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
else -> {
|
|
105
|
+
null
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Extract a ReactNode-typed prop from this element, resolving it with shared context.
|
|
112
|
+
* Mirrors iOS's VoltraElement.componentProp(_:).
|
|
113
|
+
*/
|
|
114
|
+
fun VoltraElement.componentProp(
|
|
115
|
+
propName: String,
|
|
116
|
+
sharedStyles: List<Map<String, Any>>?,
|
|
117
|
+
sharedElements: List<VoltraNode>?,
|
|
118
|
+
): VoltraNode? {
|
|
119
|
+
val value = p?.get(propName) ?: return null
|
|
120
|
+
return resolveToVoltraNode(value, sharedStyles, sharedElements)
|
|
121
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package voltra.parsing
|
|
2
2
|
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import com.google.gson.Gson
|
|
3
5
|
import voltra.generated.ShortNames
|
|
4
6
|
import voltra.models.*
|
|
5
7
|
|
|
@@ -8,6 +10,9 @@ import voltra.models.*
|
|
|
8
10
|
* This should be run as the first step after JSON parsing.
|
|
9
11
|
*/
|
|
10
12
|
object VoltraDecompressor {
|
|
13
|
+
private const val TAG = "VoltraDecompressor"
|
|
14
|
+
private val gson = Gson()
|
|
15
|
+
|
|
11
16
|
/**
|
|
12
17
|
* Decompress the entire payload recursively.
|
|
13
18
|
*/
|
|
@@ -44,13 +49,108 @@ object VoltraDecompressor {
|
|
|
44
49
|
val expandedKey = ShortNames.expand(key)
|
|
45
50
|
val expandedValue =
|
|
46
51
|
when (value) {
|
|
47
|
-
is Map<*, *> ->
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
is Map<*, *> -> {
|
|
53
|
+
val mapValue = value as Map<String, Any>
|
|
54
|
+
// Detect if this is a VoltraElement structure
|
|
55
|
+
if (mapValue["t"] is Number) {
|
|
56
|
+
Log.d(
|
|
57
|
+
TAG,
|
|
58
|
+
"decompressMap: Detected element structure in prop '$key' (expanded: '$expandedKey')",
|
|
59
|
+
)
|
|
60
|
+
decompressElementStructure(mapValue)
|
|
61
|
+
} else {
|
|
62
|
+
decompressMap(mapValue)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
is List<*> -> {
|
|
67
|
+
value.map {
|
|
68
|
+
when (it) {
|
|
69
|
+
is Map<*, *> -> {
|
|
70
|
+
val mapItem = it as Map<String, Any>
|
|
71
|
+
// Detect elements in lists too
|
|
72
|
+
if (mapItem["t"] is Number) {
|
|
73
|
+
decompressElementStructure(mapItem)
|
|
74
|
+
} else {
|
|
75
|
+
decompressMap(mapItem)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
else -> {
|
|
80
|
+
it
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
else -> {
|
|
87
|
+
value
|
|
88
|
+
}
|
|
50
89
|
}
|
|
51
90
|
result[expandedKey] = expandedValue
|
|
52
91
|
}
|
|
53
92
|
|
|
54
93
|
return result
|
|
55
94
|
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Decompress a VoltraElement structure within props without expanding its structure field keys.
|
|
98
|
+
* Structure keys like "t", "i", "c" are preserved, but nested props and children are processed.
|
|
99
|
+
*/
|
|
100
|
+
@Suppress("UNCHECKED_CAST")
|
|
101
|
+
private fun decompressElementStructure(map: Map<String, Any>): Map<String, Any> {
|
|
102
|
+
Log.d(TAG, "decompressElementStructure: Processing element with type=${map["t"]}")
|
|
103
|
+
val result = map.toMutableMap()
|
|
104
|
+
|
|
105
|
+
// Decompress the "p" (props) field - expand prop keys
|
|
106
|
+
if (map["p"] is Map<*, *>) {
|
|
107
|
+
val originalProps = map["p"] as Map<String, Any>
|
|
108
|
+
Log.d(TAG, "decompressElementStructure: Original props keys: ${originalProps.keys}")
|
|
109
|
+
val decompressedProps = decompressMap(originalProps)
|
|
110
|
+
Log.d(TAG, "decompressElementStructure: Decompressed props keys: ${decompressedProps.keys}")
|
|
111
|
+
result["p"] = decompressedProps
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Decompress the "c" (children) field recursively
|
|
115
|
+
val childValue = map["c"]
|
|
116
|
+
if (childValue != null) {
|
|
117
|
+
result["c"] = decompressNodeValue(childValue)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return result
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Decompress a value that represents a VoltraNode (element, array, text, or ref).
|
|
125
|
+
*/
|
|
126
|
+
@Suppress("UNCHECKED_CAST")
|
|
127
|
+
private fun decompressNodeValue(value: Any): Any =
|
|
128
|
+
when (value) {
|
|
129
|
+
is Map<*, *> -> {
|
|
130
|
+
val mapValue = value as Map<String, Any>
|
|
131
|
+
// Check if it's an element structure
|
|
132
|
+
if (mapValue["t"] is Number) {
|
|
133
|
+
decompressElementStructure(mapValue)
|
|
134
|
+
} else {
|
|
135
|
+
// Could be a ref ($r) or other map - don't expand keys for refs
|
|
136
|
+
mapValue
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
is List<*> -> {
|
|
141
|
+
// Array of nodes - recursively decompress each item
|
|
142
|
+
value.map { item ->
|
|
143
|
+
if (item != null) {
|
|
144
|
+
decompressNodeValue(item)
|
|
145
|
+
} else {
|
|
146
|
+
item
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
else -> {
|
|
152
|
+
// Text nodes (strings, numbers) or null - pass through
|
|
153
|
+
value
|
|
154
|
+
}
|
|
155
|
+
}
|
|
56
156
|
}
|
package/build/VoltraModule.d.ts
CHANGED
|
@@ -171,6 +171,10 @@ export interface VoltraModuleSpec {
|
|
|
171
171
|
* Clear all widgets' stored data
|
|
172
172
|
*/
|
|
173
173
|
clearAllWidgets(): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Fetches all active widget configurations/instances
|
|
176
|
+
*/
|
|
177
|
+
getActiveWidgets<T = any>(): Promise<T[]>;
|
|
174
178
|
/**
|
|
175
179
|
* Add an event listener
|
|
176
180
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoltraModule.d.ts","sourceRoot":"","sources":["../src/VoltraModule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAElH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;O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AE,mBAAmB,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"VoltraModule.js","sourceRoot":"","sources":["../src/VoltraModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAmN1C,MAAM,YAAY,GAAG,mBAAmB,CAAmB,cAAc,CAAC,CAAA;AAE1E,eAAe,YAAY,CAAA","sourcesContent":["import { requireNativeModule } from 'expo'\n\nimport type { EventSubscription, PreloadImageOptions, PreloadImagesResult, UpdateWidgetOptions } from './types.js'\n\n/**\n * Options for starting a Live Activity\n */\nexport type StartVoltraOptions = {\n /**\n * Target type for the activity (used internally)\n */\n target?: string\n /**\n * URL to open when the Live Activity is tapped.\n */\n deepLinkUrl?: string\n /**\n * The ID/name of the Live Activity.\n * Allows you to rebind to the same activity on app restart.\n */\n activityId?: string\n /**\n * Unix timestamp in milliseconds\n */\n staleDate?: number\n /**\n * Double value between 0.0 and 1.0, defaults to 0.0\n */\n relevanceScore?: number\n}\n\n/**\n * Options for updating a Live Activity\n */\nexport type UpdateVoltraOptions = {\n /**\n * Unix timestamp in milliseconds\n */\n staleDate?: number\n /**\n * Double value between 0.0 and 1.0, defaults to 0.0\n */\n relevanceScore?: number\n}\n\n/**\n * Options for ending a Live Activity\n */\nexport type EndVoltraOptions = {\n dismissalPolicy?: {\n type: 'immediate' | 'after'\n date?: number\n }\n}\n\n/**\n * VoltraModule native module interface\n */\nexport interface VoltraModuleSpec {\n /**\n * Start a new Live Activity\n */\n startLiveActivity(jsonString: string, options?: StartVoltraOptions): Promise<string>\n\n /**\n * Update an existing Live Activity\n */\n updateLiveActivity(activityId: string, jsonString: string, options?: UpdateVoltraOptions): Promise<void>\n\n /**\n * End a Live Activity\n */\n endLiveActivity(activityId: string, options?: EndVoltraOptions): Promise<void>\n\n /**\n * End all active Live Activities\n */\n endAllLiveActivities(): Promise<void>\n\n /**\n * Get the latest (most recently created) Voltra Live Activity ID, if any\n */\n getLatestVoltraActivityId(): Promise<string | null>\n\n /**\n * List all running Voltra Live Activity IDs\n */\n listVoltraActivityIds(): Promise<string[]>\n\n /**\n * Check if a Live Activity with the given name is currently active\n */\n isLiveActivityActive(activityName: string): boolean\n\n /**\n * Check if the app was launched in the background (headless)\n */\n isHeadless(): boolean\n\n /**\n * Android Live Update: Start a new live update notification\n */\n startAndroidLiveUpdate(payload: string, options: { updateName?: string; channelId?: string }): Promise<string>\n\n /**\n * Android Live Update: Update an existing live update notification\n */\n updateAndroidLiveUpdate(notificationId: string, payload: string): Promise<void>\n\n /**\n * Android Live Update: Stop a live update notification\n */\n stopAndroidLiveUpdate(notificationId: string): Promise<void>\n\n /**\n * Android Live Update: Check if a live update is active\n */\n isAndroidLiveUpdateActive(updateName: string): boolean\n\n /**\n * Android Live Update: End all active live updates\n */\n endAllAndroidLiveUpdates(): Promise<void>\n\n /**\n * Android Widget: Update a widget with new content\n */\n updateAndroidWidget(widgetId: string, jsonString: string, options?: { deepLinkUrl?: string }): Promise<void>\n\n /**\n * Android Widget: Reload widget timelines to refresh their content\n */\n reloadAndroidWidgets(widgetIds?: string[] | null): Promise<void>\n\n /**\n * Android Widget: Clear a widget's stored data\n */\n clearAndroidWidget(widgetId: string): Promise<void>\n\n /**\n * Android Widget: Clear all widgets' stored data\n */\n clearAllAndroidWidgets(): Promise<void>\n\n /**\n * Android Widget: Request to pin a widget to the home screen\n *\n * See: https://developer.android.com/develop/ui/compose/glance/pin-in-app\n *\n * @param widgetId - The widget identifier to pin\n * @param options - Optional settings for the pin request\n * @param options.previewWidth - Optional preview width in dp (default: 245)\n * @param options.previewHeight - Optional preview height in dp (default: 115)\n * @returns Promise that resolves to true if the pin request was successful\n */\n requestPinGlanceAppWidget(\n widgetId: string,\n options?: { previewWidth?: number; previewHeight?: number }\n ): Promise<boolean>\n\n /**\n * Preload images to App Group storage for use in Live Activities\n */\n preloadImages(images: PreloadImageOptions[]): Promise<PreloadImagesResult>\n\n /**\n * Reload Live Activities to pick up preloaded images\n */\n reloadLiveActivities(activityNames?: string[] | null): Promise<void>\n\n /**\n * Clear preloaded images from App Group storage\n */\n clearPreloadedImages(keys?: string[] | null): Promise<void>\n\n /**\n * Update a home screen widget with new content\n */\n updateWidget(widgetId: string, jsonString: string, options?: UpdateWidgetOptions): Promise<void>\n\n /**\n * Schedule a widget timeline with multiple entries to be displayed at future times\n */\n scheduleWidget(widgetId: string, timelineJson: string): Promise<void>\n\n /**\n * Reload widget timelines to refresh their content\n */\n reloadWidgets(widgetIds?: string[] | null): Promise<void>\n\n /**\n * Clear a widget's stored data\n */\n clearWidget(widgetId: string): Promise<void>\n\n /**\n * Clear all widgets' stored data\n */\n clearAllWidgets(): Promise<void>\n\n /**\n * Fetches all active widget configurations/instances\n */\n getActiveWidgets<T = any>(): Promise<T[]>\n\n /**\n * Add an event listener\n */\n addListener(event: string, listener: (event: any) => void): EventSubscription\n}\n\nconst VoltraModule = requireNativeModule<VoltraModuleSpec>('VoltraModule')\n\nexport default VoltraModule\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { endAllAndroidLiveUpdates, isAndroidLiveUpdateActive, startAndroidLiveUpdate, stopAndroidLiveUpdate, updateAndroidLiveUpdate, useAndroidLiveUpdate, } from './live-update/api.js';
|
|
2
2
|
export type { AndroidLiveUpdateJson, AndroidLiveUpdateVariants, AndroidLiveUpdateVariantsJson, StartAndroidLiveUpdateOptions, UpdateAndroidLiveUpdateOptions, UseAndroidLiveUpdateOptions, UseAndroidLiveUpdateResult, } from './live-update/types.js';
|
|
3
|
-
export { clearAllAndroidWidgets, clearAndroidWidget, reloadAndroidWidgets, requestPinAndroidWidget, updateAndroidWidget, } from './widgets/api.js';
|
|
4
|
-
export type { AndroidWidgetSize, AndroidWidgetSizeVariant, AndroidWidgetVariants, UpdateAndroidWidgetOptions, } from './widgets/types.js';
|
|
3
|
+
export { clearAllAndroidWidgets, clearAndroidWidget, getActiveWidgets, reloadAndroidWidgets, requestPinAndroidWidget, updateAndroidWidget, } from './widgets/api.js';
|
|
4
|
+
export type { AndroidWidgetSize, AndroidWidgetSizeVariant, AndroidWidgetVariants, UpdateAndroidWidgetOptions, WidgetInfo, } from './widgets/types.js';
|
|
5
5
|
export { clearPreloadedImages, preloadImages, reloadWidgets } from './preload.js';
|
|
6
6
|
export { VoltraView, type VoltraViewProps } from './components/VoltraView.js';
|
|
7
7
|
export { type AndroidWidgetFamily, VoltraWidgetPreview, type VoltraWidgetPreviewProps, } from './components/VoltraWidgetPreview.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/android/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,wBAAwB,CAAA;AAG/B,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/android/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,wBAAwB,CAAA;AAG/B,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,EAC1B,UAAU,GACX,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGjF,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,EACL,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,KAAK,wBAAwB,GAC9B,MAAM,qCAAqC,CAAA"}
|
package/build/android/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Android Live Update API and types
|
|
2
2
|
export { endAllAndroidLiveUpdates, isAndroidLiveUpdateActive, startAndroidLiveUpdate, stopAndroidLiveUpdate, updateAndroidLiveUpdate, useAndroidLiveUpdate, } from './live-update/api.js';
|
|
3
3
|
// Android Widget API and types
|
|
4
|
-
export { clearAllAndroidWidgets, clearAndroidWidget, reloadAndroidWidgets, requestPinAndroidWidget, updateAndroidWidget, } from './widgets/api.js';
|
|
4
|
+
export { clearAllAndroidWidgets, clearAndroidWidget, getActiveWidgets, reloadAndroidWidgets, requestPinAndroidWidget, updateAndroidWidget, } from './widgets/api.js';
|
|
5
5
|
// Preload API
|
|
6
6
|
export { clearPreloadedImages, preloadImages, reloadWidgets } from './preload.js';
|
|
7
7
|
// Android Preview Components
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/android/client.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAW7B,+BAA+B;AAC/B,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/android/client.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAW7B,+BAA+B;AAC/B,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,kBAAkB,CAAA;AASzB,cAAc;AACd,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjF,6BAA6B;AAC7B,OAAO,EAAE,UAAU,EAAwB,MAAM,4BAA4B,CAAA;AAC7E,OAAO,EAEL,mBAAmB,GAEpB,MAAM,qCAAqC,CAAA","sourcesContent":["// Android Live Update API and types\nexport {\n endAllAndroidLiveUpdates,\n isAndroidLiveUpdateActive,\n startAndroidLiveUpdate,\n stopAndroidLiveUpdate,\n updateAndroidLiveUpdate,\n useAndroidLiveUpdate,\n} from './live-update/api.js'\nexport type {\n AndroidLiveUpdateJson,\n AndroidLiveUpdateVariants,\n AndroidLiveUpdateVariantsJson,\n StartAndroidLiveUpdateOptions,\n UpdateAndroidLiveUpdateOptions,\n UseAndroidLiveUpdateOptions,\n UseAndroidLiveUpdateResult,\n} from './live-update/types.js'\n\n// Android Widget API and types\nexport {\n clearAllAndroidWidgets,\n clearAndroidWidget,\n getActiveWidgets,\n reloadAndroidWidgets,\n requestPinAndroidWidget,\n updateAndroidWidget,\n} from './widgets/api.js'\nexport type {\n AndroidWidgetSize,\n AndroidWidgetSizeVariant,\n AndroidWidgetVariants,\n UpdateAndroidWidgetOptions,\n WidgetInfo,\n} from './widgets/types.js'\n\n// Preload API\nexport { clearPreloadedImages, preloadImages, reloadWidgets } from './preload.js'\n\n// Android Preview Components\nexport { VoltraView, type VoltraViewProps } from './components/VoltraView.js'\nexport {\n type AndroidWidgetFamily,\n VoltraWidgetPreview,\n type VoltraWidgetPreviewProps,\n} from './components/VoltraWidgetPreview.js'\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import type { VoltraAndroidBaseProps } from '../baseProps.js';
|
|
2
3
|
export type ImageProps = VoltraAndroidBaseProps & {
|
|
3
4
|
/** Image source - { assetName: string } for Android drawable resources or preloaded assets */
|
|
@@ -12,5 +13,9 @@ export type ImageProps = VoltraAndroidBaseProps & {
|
|
|
12
13
|
alpha?: number;
|
|
13
14
|
/** Tint color */
|
|
14
15
|
tintColor?: string;
|
|
16
|
+
/** Background color used when the image is missing */
|
|
17
|
+
fallbackColor?: string;
|
|
18
|
+
/** Custom fallback content rendered when the image is missing */
|
|
19
|
+
fallback?: ReactNode;
|
|
15
20
|
};
|
|
16
21
|
//# sourceMappingURL=Image.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../src/android/jsx/props/Image.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAE7D,MAAM,MAAM,UAAU,GAAG,sBAAsB,GAAG;IAChD,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,2DAA2D;IAC3D,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;IAClE,8CAA8C;IAC9C,YAAY,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,aAAa,CAAA;IAC7C,4CAA4C;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../src/android/jsx/props/Image.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAE7D,MAAM,MAAM,UAAU,GAAG,sBAAsB,GAAG;IAChD,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,2DAA2D;IAC3D,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;IAClE,8CAA8C;IAC9C,YAAY,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,aAAa,CAAA;IAC7C,4CAA4C;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../../src/android/jsx/props/Image.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,qDAAqD;AACrD,wBAAwB","sourcesContent":["// 🤖 AUTO-GENERATED from data/components.json\n// DO NOT EDIT MANUALLY - Changes will be overwritten\n// Schema version: 1.0.0\n\nimport type { VoltraAndroidBaseProps } from '../baseProps.js'\n\nexport type ImageProps = VoltraAndroidBaseProps & {\n /** Image source - { assetName: string } for Android drawable resources or preloaded assets */\n source: Record<string, any>\n /** How the image should be resized to fit its container */\n resizeMode?: 'cover' | 'contain' | 'stretch' | 'repeat' | 'center'\n /** Content scale mode (Glance terminology) */\n contentScale?: 'crop' | 'fit' | 'fill-bounds'\n /** Content description for accessibility */\n contentDescription?: string\n /** Opacity (0.0 to 1.0) */\n alpha?: number\n /** Tint color */\n tintColor?: string\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../../src/android/jsx/props/Image.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,qDAAqD;AACrD,wBAAwB","sourcesContent":["// 🤖 AUTO-GENERATED from data/components.json\n// DO NOT EDIT MANUALLY - Changes will be overwritten\n// Schema version: 1.0.0\n\nimport type { ReactNode } from 'react'\n\nimport type { VoltraAndroidBaseProps } from '../baseProps.js'\n\nexport type ImageProps = VoltraAndroidBaseProps & {\n /** Image source - { assetName: string } for Android drawable resources or preloaded assets */\n source: Record<string, any>\n /** How the image should be resized to fit its container */\n resizeMode?: 'cover' | 'contain' | 'stretch' | 'repeat' | 'center'\n /** Content scale mode (Glance terminology) */\n contentScale?: 'crop' | 'fit' | 'fill-bounds'\n /** Content description for accessibility */\n contentDescription?: string\n /** Opacity (0.0 to 1.0) */\n alpha?: number\n /** Tint color */\n tintColor?: string\n /** Background color used when the image is missing */\n fallbackColor?: string\n /** Custom fallback content rendered when the image is missing */\n fallback?: ReactNode\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AndroidWidgetVariants, UpdateAndroidWidgetOptions } from './types.js';
|
|
2
|
-
export type { AndroidWidgetSize, AndroidWidgetSizeVariant, AndroidWidgetVariants, UpdateAndroidWidgetOptions, } from './types.js';
|
|
1
|
+
import type { AndroidWidgetVariants, UpdateAndroidWidgetOptions, WidgetInfo } from './types.js';
|
|
2
|
+
export type { AndroidWidgetSize, AndroidWidgetSizeVariant, AndroidWidgetVariants, UpdateAndroidWidgetOptions, WidgetInfo, } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Update an Android home screen widget with new content.
|
|
5
5
|
*
|
|
@@ -116,4 +116,16 @@ export declare const requestPinAndroidWidget: (widgetId: string, options?: {
|
|
|
116
116
|
previewWidth?: number;
|
|
117
117
|
previewHeight?: number;
|
|
118
118
|
}) => Promise<boolean>;
|
|
119
|
+
/**
|
|
120
|
+
* Fetches all active widget instances for the containing app on Android.
|
|
121
|
+
*
|
|
122
|
+
* @returns A promise that resolves to an array of active widget instances.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const widgets = await getActiveWidgets()
|
|
127
|
+
* console.log('Active widgets:', widgets)
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare const getActiveWidgets: () => Promise<WidgetInfo[]>;
|
|
119
131
|
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/android/widgets/api.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/android/widgets/api.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG/F,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,EAC1B,UAAU,GACX,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,EAChB,UAAU,qBAAqB,EAC/B,UAAU,0BAA0B,KACnC,OAAO,CAAC,IAAI,CAMd,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,GAAU,YAAY,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAE7E,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,IAAI,CAEvE,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,QAAa,OAAO,CAAC,IAAI,CAE3D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAU,MAAM,EAChB,UAAU;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,KAC1D,OAAO,CAAC,OAAO,CAEjB,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,QAAa,OAAO,CAAC,UAAU,EAAE,CAE7D,CAAA"}
|
|
@@ -126,4 +126,18 @@ export const clearAllAndroidWidgets = async () => {
|
|
|
126
126
|
export const requestPinAndroidWidget = async (widgetId, options) => {
|
|
127
127
|
return VoltraModule.requestPinGlanceAppWidget(widgetId, options);
|
|
128
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Fetches all active widget instances for the containing app on Android.
|
|
131
|
+
*
|
|
132
|
+
* @returns A promise that resolves to an array of active widget instances.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const widgets = await getActiveWidgets()
|
|
137
|
+
* console.log('Active widgets:', widgets)
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export const getActiveWidgets = async () => {
|
|
141
|
+
return VoltraModule.getActiveWidgets();
|
|
142
|
+
};
|
|
129
143
|
//# sourceMappingURL=api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/android/widgets/api.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAA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A;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,IAA2B,EAAE;IAChE,OAAO,YAAY,CAAC,gBAAgB,EAAE,CAAA;AACxC,CAAC,CAAA","sourcesContent":["import VoltraModule from '../../VoltraModule.js'\nimport { renderAndroidWidgetToString } from './renderer.js'\nimport type { AndroidWidgetVariants, UpdateAndroidWidgetOptions, WidgetInfo } from './types.js'\n\n// Re-export types for public API\nexport type {\n AndroidWidgetSize,\n AndroidWidgetSizeVariant,\n AndroidWidgetVariants,\n UpdateAndroidWidgetOptions,\n WidgetInfo,\n} from './types.js'\n\n/**\n * Update an Android home screen widget with new content.\n *\n * The content will be stored in SharedPreferences and the widget\n * will be updated to display the new content.\n *\n * @param widgetId - The widget identifier\n * @param variants - An array of size variants with their breakpoints and content.\n * Android will automatically select the best matching variant based on the\n * actual widget dimensions.\n * @param options - Optional settings like deep link URL\n *\n * @example Different content per size\n * ```tsx\n * import { VoltraAndroid, updateAndroidWidget } from 'voltra'\n *\n * await updateAndroidWidget('weather', [\n * {\n * size: { width: 150, height: 100 },\n * content: <VoltraAndroid.Text fontSize={32}>72°F</VoltraAndroid.Text>\n * },\n * {\n * size: { width: 250, height: 150 },\n * content: (\n * <VoltraAndroid.Row>\n * <VoltraAndroid.Text fontSize={32}>72°F</VoltraAndroid.Text>\n * <VoltraAndroid.Column>\n * <VoltraAndroid.Text>Sunny</VoltraAndroid.Text>\n * <VoltraAndroid.Text>High: 78° Low: 65°</VoltraAndroid.Text>\n * </VoltraAndroid.Column>\n * </VoltraAndroid.Row>\n * )\n * }\n * ], { deepLinkUrl: '/weather' })\n * ```\n */\nexport const updateAndroidWidget = async (\n widgetId: string,\n variants: AndroidWidgetVariants,\n options?: UpdateAndroidWidgetOptions\n): Promise<void> => {\n const payload = renderAndroidWidgetToString(variants)\n\n return VoltraModule.updateAndroidWidget(widgetId, payload, {\n deepLinkUrl: options?.deepLinkUrl,\n })\n}\n\n/**\n * Reload widget timelines to refresh their content.\n *\n * Use this after updating data that widgets depend on (e.g., after preloading\n * new images) to force them to re-render.\n *\n * @param widgetIds - Optional array of widget IDs to reload. If omitted, reloads all widgets.\n *\n * @example\n * ```typescript\n * // Reload specific widgets\n * await reloadAndroidWidgets(['weather', 'calendar'])\n *\n * // Reload all widgets\n * await reloadAndroidWidgets()\n * ```\n */\nexport const reloadAndroidWidgets = async (widgetIds?: string[]): Promise<void> => {\n return VoltraModule.reloadAndroidWidgets(widgetIds ?? null)\n}\n\n/**\n * Clear a widget's stored data.\n *\n * This removes the JSON content and deep link URL for the specified widget,\n * causing it to show its placeholder state.\n *\n * @param widgetId - The widget identifier to clear\n *\n * @example\n * ```typescript\n * await clearAndroidWidget('weather')\n * ```\n */\nexport const clearAndroidWidget = async (widgetId: string): Promise<void> => {\n return VoltraModule.clearAndroidWidget(widgetId)\n}\n\n/**\n * Clear all widgets' stored data.\n *\n * This removes the JSON content and deep link URLs for all configured widgets,\n * causing them to show their placeholder states.\n *\n * @example\n * ```typescript\n * await clearAllAndroidWidgets()\n * ```\n */\nexport const clearAllAndroidWidgets = async (): Promise<void> => {\n return VoltraModule.clearAllAndroidWidgets()\n}\n\n/**\n * Request to pin a widget to the home screen.\n *\n * This will show the Android system pin widget dialog, allowing the user\n * to add the widget to their home screen. Optionally, you can provide\n * preview dimensions to show a preview of the widget in the pin dialog.\n *\n * See: https://developer.android.com/develop/ui/compose/glance/pin-in-app\n *\n * @param widgetId - The widget identifier to pin\n * @param options - Optional settings for the pin request\n * @param options.previewWidth - Optional preview width in dp (default: 245)\n * @param options.previewHeight - Optional preview height in dp (default: 115)\n * @returns Promise that resolves to true if the pin request was successful\n *\n * @example Basic usage\n * ```typescript\n * const success = await requestPinAndroidWidget('weather')\n * if (success) {\n * console.log('Widget pin request sent')\n * }\n * ```\n *\n * @example With preview dimensions\n * ```typescript\n * const success = await requestPinAndroidWidget('weather', {\n * previewWidth: 245,\n * previewHeight: 115\n * })\n * ```\n */\nexport const requestPinAndroidWidget = async (\n widgetId: string,\n options?: { previewWidth?: number; previewHeight?: number }\n): Promise<boolean> => {\n return VoltraModule.requestPinGlanceAppWidget(widgetId, options)\n}\n\n/**\n * Fetches all active widget instances for the containing app on Android.\n *\n * @returns A promise that resolves to an array of active widget instances.\n *\n * @example\n * ```typescript\n * const widgets = await getActiveWidgets()\n * console.log('Active widgets:', widgets)\n * ```\n */\nexport const getActiveWidgets = async (): Promise<WidgetInfo[]> => {\n return VoltraModule.getActiveWidgets()\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { clearAllAndroidWidgets, clearAndroidWidget, reloadAndroidWidgets, requestPinAndroidWidget, updateAndroidWidget, } from './api.js';
|
|
2
|
-
export type { AndroidWidgetSize, AndroidWidgetSizeVariant, AndroidWidgetVariants, UpdateAndroidWidgetOptions, } from './types.js';
|
|
1
|
+
export { clearAllAndroidWidgets, clearAndroidWidget, getActiveWidgets, reloadAndroidWidgets, requestPinAndroidWidget, updateAndroidWidget, } from './api.js';
|
|
2
|
+
export type { AndroidWidgetSize, AndroidWidgetSizeVariant, AndroidWidgetVariants, UpdateAndroidWidgetOptions, WidgetInfo, } from './types.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/android/widgets/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,UAAU,CAAA;AAGjB,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/android/widgets/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,UAAU,CAAA;AAGjB,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,EAC1B,UAAU,GACX,MAAM,YAAY,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Android Widget API
|
|
2
|
-
export { clearAllAndroidWidgets, clearAndroidWidget, reloadAndroidWidgets, requestPinAndroidWidget, updateAndroidWidget, } from './api.js';
|
|
2
|
+
export { clearAllAndroidWidgets, clearAndroidWidget, getActiveWidgets, reloadAndroidWidgets, requestPinAndroidWidget, updateAndroidWidget, } from './api.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/android/widgets/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,UAAU,CAAA","sourcesContent":["// Android Widget API\nexport {\n clearAllAndroidWidgets,\n clearAndroidWidget,\n reloadAndroidWidgets,\n requestPinAndroidWidget,\n updateAndroidWidget,\n} from './api.js'\n\n// Android Widget Types\nexport type {\n AndroidWidgetSize,\n AndroidWidgetSizeVariant,\n AndroidWidgetVariants,\n UpdateAndroidWidgetOptions,\n} from './types.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/android/widgets/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,UAAU,CAAA","sourcesContent":["// Android Widget API\nexport {\n clearAllAndroidWidgets,\n clearAndroidWidget,\n getActiveWidgets,\n reloadAndroidWidgets,\n requestPinAndroidWidget,\n updateAndroidWidget,\n} from './api.js'\n\n// Android Widget Types\nexport type {\n AndroidWidgetSize,\n AndroidWidgetSizeVariant,\n AndroidWidgetVariants,\n UpdateAndroidWidgetOptions,\n WidgetInfo,\n} from './types.js'\n"]}
|
|
@@ -14,6 +14,22 @@ export type AndroidWidgetSizeVariant = {
|
|
|
14
14
|
size: AndroidWidgetSize;
|
|
15
15
|
content: ReactNode;
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Information about an active widget instance on Android
|
|
19
|
+
*/
|
|
20
|
+
export type WidgetInfo = {
|
|
21
|
+
/** The name (ID) of the widget as defined in the config plugin */
|
|
22
|
+
name: string;
|
|
23
|
+
/** The unique ID for this widget instance (required for updates) */
|
|
24
|
+
widgetId: number;
|
|
25
|
+
/** The class name of the provider (e.g., ".WeatherWidget") */
|
|
26
|
+
providerClassName: string;
|
|
27
|
+
/** Current labeling associated with the widget */
|
|
28
|
+
label: string;
|
|
29
|
+
/** Dimensions in dp as reported by the system */
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
17
33
|
/**
|
|
18
34
|
* Widget variants using size-based breakpoints.
|
|
19
35
|
* Android picks the best matching variant based on widget dimensions.
|