expo-widgets 58.0.15 → 58.0.16

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.0.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [Android] Fix `generateExpoWidgetsLayoutRegistry` failing on Windows with `RangeError: Maximum call stack size exceeded` when a widget sets `initialLayout`. Absolute Windows paths (`D:\...`) are now resolved as files instead of being stubbed as empty modules. ([#51028](https://github.com/expo/expo/pull/51028) by [@Cedric921](https://github.com/Cedric921))
8
+ - [Android] Fix minified release builds crashing on launch with `Failed to create an instance of class androidx.work.impl.WorkDatabase.canonicalName`. R8 stripped the no-arg constructor of WorkManager's Room database, which WorkManager creates by reflection; `expo-widgets` now ships consumer keep rules for it and for WorkManager's input mergers. ([#51349](https://github.com/expo/expo/pull/51349) by [@expo-bot](https://github.com/expo-bot))
9
+ - [iOS] Show an empty widget, instead of an error, before the app has been launched. The widget layout is stored when the app first runs `createWidget()`, so a freshly installed or updated app that hasn't been opened yet has no layout. Widgets in this state, including previews in the widget gallery, rendered the "No layout found" red box. Because that view has no container background, iOS 17+ replaced it with the system's "Please adopt containerBackground API" placeholder. They now render an empty view with the system's tertiary fill until the app runs. ([#51350](https://github.com/expo/expo/pull/51350) by [@jsg2021](https://github.com/jsg2021))
10
+ - [iOS] Fix widget layout errors being hidden behind the system's "Please adopt containerBackground API" placeholder on iOS 17+. The red box shown when a widget's layout fails to evaluate now declares a container background, so its error message is visible. ([#51350](https://github.com/expo/expo/pull/51350) by [@jsg2021](https://github.com/jsg2021))
11
+ - [Android] Fix a release build failing `checkReleaseDuplicateClasses` when another dependency brings WorkManager 2.8 or newer, by pinning `work-runtime-ktx` forward from the 2.7.1 that Glance requests. ([#50010](https://github.com/expo/expo/pull/50010) by [@LizunovSergey](https://github.com/LizunovSergey))
12
+ - Updated dependencies. ([#51368](https://github.com/expo/expo/pull/51368), [#51319](https://github.com/expo/expo/pull/51319), [#51237](https://github.com/expo/expo/pull/51237), [#50715](https://github.com/expo/expo/pull/50715), [#50727](https://github.com/expo/expo/pull/50727), [#51412](https://github.com/expo/expo/pull/51412), [#51322](https://github.com/expo/expo/pull/51322), [#51351](https://github.com/expo/expo/pull/51351))
13
+ - @expo/ui@58.0.16
14
+
3
15
  ## 58.0.15
4
16
 
5
17
  ### Patch Changes
@@ -6,7 +6,7 @@ plugins {
6
6
  }
7
7
 
8
8
  group = 'expo.modules.widgets'
9
- version = '58.0.15'
9
+ version = '58.0.16'
10
10
 
11
11
  def expoWidgetsPackageDirFile = project.projectDir.parentFile
12
12
  def expoWidgetsPackageDir = expoWidgetsPackageDirFile.absolutePath
@@ -39,7 +39,8 @@ android {
39
39
  namespace "expo.modules.widgets"
40
40
  defaultConfig {
41
41
  versionCode 1
42
- versionName '58.0.15'
42
+ versionName '58.0.16'
43
+ consumerProguardFiles("proguard-rules.pro")
43
44
 
44
45
  externalNativeBuild {
45
46
  cmake {
@@ -145,4 +146,8 @@ dependencies {
145
146
  implementation expoModule.getExpoDependency("expo-ui")
146
147
  api 'io.github.expo.peek:peek-emittables:0.3.2'
147
148
  implementation "androidx.glance:glance:1.2.0"
149
+ // Glance requests work-runtime-ktx 2.7.1, which still bundles the Kotlin extensions WorkManager 2.8+
150
+ // moved into work-runtime, so any 2.8+ in the graph duplicates those classes in release builds.
151
+ // 2.9.1, the version expo-background-task and expo-observe use, is the empty shim.
152
+ implementation 'androidx.work:work-runtime-ktx:2.9.1'
148
153
  }
@@ -0,0 +1,7 @@
1
+ # expo-widgets brings in WorkManager through Glance. WorkManager creates its Room database
2
+ # (`androidx.work.impl.WorkDatabase_Impl`) and its input mergers by reflection, so R8 sees no
3
+ # caller for their no-arg constructors and strips them. Minified release builds then crash on
4
+ # launch in WorkManager's startup initializer:
5
+ # java.lang.RuntimeException: Failed to create an instance of class androidx.work.impl.WorkDatabase.canonicalName
6
+ -keep class * extends androidx.room.RoomDatabase { <init>(); }
7
+ -keep class * extends androidx.work.InputMerger { <init>(); }
@@ -29,7 +29,23 @@ public struct WidgetsEntryView: View {
29
29
  let node = evaluateLayout(layout: layout, props: entry.props, environment: widgetEnvironment)
30
30
  WidgetsDynamicView(name: entry.name, kind: .widget, node: node, entryIndex: entry.entryIndex, environmentString: widgetEnvironmentString)
31
31
  } else {
32
- WidgetsDynamicView(name: entry.name, kind: .widget, node: createRedBox(message: "No layout found for \(WidgetsStorage.appGroupIdentifier ?? "")::\(entry.name)"), entryIndex: entry.entryIndex, environmentString: widgetEnvironmentString)
32
+ // No layout is stored until the app has run once after install or
33
+ // update. That's an expected state, not an error, so show a neutral,
34
+ // system-themed empty widget instead of the red box.
35
+ EmptyWidgetView()
36
+ }
37
+ }
38
+ }
39
+
40
+ // Also used by the generated configurable widgets (withWidgetSourceFiles).
41
+ public struct EmptyWidgetView: View {
42
+ public init() {}
43
+
44
+ public var body: some View {
45
+ if #available(iOS 17.0, *) {
46
+ Color.clear.containerBackground(.fill.tertiary, for: .widget)
47
+ } else {
48
+ Color.clear
33
49
  }
34
50
  }
35
51
  }
@@ -49,6 +49,22 @@ public struct RedBoxView: ExpoSwiftUI.View {
49
49
  .padding(12)
50
50
  .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
51
51
  }
52
+ .modifier(RedBoxContainerBackground(kind: props.kind))
53
+ }
54
+ }
55
+
56
+ // On iOS 17+, WidgetKit replaces any widget without a container background with
57
+ // its "Please adopt containerBackground API" placeholder, which would hide the error.
58
+ private struct RedBoxContainerBackground: ViewModifier {
59
+ let kind: WidgetsKind
60
+
61
+ @ViewBuilder
62
+ func body(content: Content) -> some View {
63
+ if #available(iOS 17.0, *), kind == .widget {
64
+ content.containerBackground(Color.red, for: .widget)
65
+ } else {
66
+ content
67
+ }
52
68
  }
53
69
  }
54
70
 
@@ -5,12 +5,19 @@ const baseResolveRequest = config.resolver.resolveRequest;
5
5
  const expoWidgetsStubPath = path.join(__dirname, 'bundle/layout-registry-stub.ts');
6
6
  const asyncRequireStubPath = path.join(__dirname, 'bundle/async-require-stub.ts');
7
7
  // const emptyModuleStubPath = path.join(__dirname, 'bundle/empty-module-stub.js');
8
- const fileSpecifierRe = /^[\\/]|^\.\.?(?:$|[\\/])/i;
8
+ const relativeFileSpecifierRe = /^\.\.?(?:$|[\\/])/;
9
+
10
+ // Metro also resolves its own absolute paths (e.g. the empty module) through `resolveRequest`.
11
+ // `path.win32.isAbsolute` covers POSIX paths as well as Windows drive letter (`D:\`) and UNC paths,
12
+ // which would otherwise be stubbed as empty modules and make Metro recurse until the stack overflows.
13
+ function isFileSpecifier(moduleName) {
14
+ return path.win32.isAbsolute(moduleName) || relativeFileSpecifierRe.test(moduleName);
15
+ }
9
16
 
10
17
  config.resolver = {
11
18
  ...config.resolver,
12
19
  resolveRequest(context, moduleName, platform) {
13
- if (fileSpecifierRe.test(moduleName)) {
20
+ if (isFileSpecifier(moduleName)) {
14
21
  return baseResolveRequest(context, moduleName, platform);
15
22
  }
16
23
  if (moduleName === 'expo-widgets') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-widgets",
3
- "version": "58.0.15",
3
+ "version": "58.0.16",
4
4
  "description": "Widgets.",
5
5
  "keywords": [
6
6
  "expo",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@expo/plist": "^0.10.1",
31
- "@expo/ui": "~58.0.15"
31
+ "@expo/ui": "~58.0.16"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@expo/internal-scripts": "58.0.1",
@@ -36,7 +36,7 @@
36
36
  "@types/jest": "^30.0.0",
37
37
  "@types/node": "^22.14.0",
38
38
  "@types/react": "~19.3.0",
39
- "expo": "58.0.7",
39
+ "expo": "58.0.8",
40
40
  "react-native": "0.88.0-rc.4",
41
41
  "resolve-workspace-root": "^2.0.0"
42
42
  },
@@ -437,7 +437,7 @@ struct ${widget.name}EntryView: View {
437
437
  let node = evaluateLayout(layout: layout, props: entry.props, environment: widgetEnvironment)
438
438
  WidgetsDynamicView(name: entry.name, kind: .widget, node: node, entryIndex: entry.entryIndex, environmentString: widgetEnvironmentString)
439
439
  } else {
440
- WidgetsDynamicView(name: entry.name, kind: .widget, node: createRedBox(message: "No layout found for \\(WidgetsStorage.appGroupIdentifier ?? "")::\\(entry.name)"), entryIndex: entry.entryIndex, environmentString: widgetEnvironmentString)
440
+ EmptyWidgetView()
441
441
  }
442
442
  }
443
443
  }
@@ -473,7 +473,7 @@ struct ${widget.name}EntryView: View {
473
473
  let node = evaluateLayout(layout: layout, props: entry.props, environment: widgetEnvironment)
474
474
  WidgetsDynamicView(name: entry.name, kind: .widget, node: node, entryIndex: entry.entryIndex, environmentString: widgetEnvironmentString)
475
475
  } else {
476
- WidgetsDynamicView(name: entry.name, kind: .widget, node: createRedBox(message: "No layout found for \\(WidgetsStorage.appGroupIdentifier ?? "")::\\(entry.name)"), entryIndex: entry.entryIndex, environmentString: widgetEnvironmentString)
476
+ EmptyWidgetView()
477
477
  }
478
478
  }
479
479
  }