@imgly/editor-react-native 1.65.0 → 1.66.0

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.
@@ -83,7 +83,7 @@ repositories {
83
83
  }
84
84
 
85
85
  dependencies {
86
- implementation findProject(":editor") ?: "ly.img:editor:1.65.0"
86
+ implementation findProject(":editor") ?: "ly.img:editor:1.66.0"
87
87
  implementation platform("androidx.compose:compose-bom:2023.05.01")
88
88
  implementation "androidx.activity:activity-compose:1.6.1"
89
89
  implementation "androidx.activity:activity:1.7.0"
@@ -14,9 +14,11 @@ RCT_EXPORT_MODULE(IMGLYEditor)
14
14
  resolve:(RCTPromiseResolveBlock)resolve
15
15
  reject:(RCTPromiseRejectBlock)reject {
16
16
  NSMutableDictionary* mergedSettings = [@{
17
- @"license" : settings.license(),
18
17
  @"sceneBaseUri" : settings.sceneBaseUri(),
19
18
  } mutableCopy];
19
+ if (settings.license() != nil) {
20
+ mergedSettings[@"license"] = settings.license();
21
+ }
20
22
  if (settings.assetBaseUri() != nil) {
21
23
  mergedSettings[@"assetBaseUri"] = settings.assetBaseUri();
22
24
  }
@@ -24,9 +26,10 @@ RCT_EXPORT_MODULE(IMGLYEditor)
24
26
  mergedSettings[@"userId"] = settings.userId();
25
27
  }
26
28
 
27
- JS::NativeIMGLYEditor::Source* sourcePtr = &source;
28
- if (sourcePtr != nullptr) {
29
- mergedSettings[@"source"] = @{@"source" : source.source(), @"type" : source.type()};
29
+ NSString* sourceValue = source.source();
30
+ NSString* typeValue = source.type();
31
+ if (sourceValue != nil && typeValue != nil) {
32
+ mergedSettings[@"source"] = @{@"source" : sourceValue, @"type" : typeValue};
30
33
  }
31
34
 
32
35
  [self open:mergedSettings preset:preset metadata:metadata resolve:resolve reject:reject];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imgly/editor-react-native",
3
- "version": "1.65.0",
3
+ "version": "1.66.0",
4
4
  "description": "CreativeEditor SDK for React Native - enable photo, video and design editing for your users on iOS and Android.",
5
5
  "react-native": "index.js",
6
6
  "source": "index.js",
@@ -159,6 +159,17 @@ const NativeModule = TurboModuleRegistry.get<Spec>(
159
159
  'IMGLYEditor'
160
160
  ) as Spec | null;
161
161
 
162
+ /**
163
+ * Checks if the app is using the New Architecture (TurboModules or Bridgeless).
164
+ * @returns true if New Architecture is enabled, false for Bridge.
165
+ */
166
+ function isNewArchitectureEnabled(): boolean {
167
+ const g = global as any;
168
+ // Check for TurboModules (Expo 51-52 / RN 0.74-0.76)
169
+ // Check for Bridgeless mode (Expo 53+ / RN 0.79+)
170
+ return g.__turboModuleProxy != null || g.RN$Bridgeless === true;
171
+ }
172
+
162
173
  /**
163
174
  * Resolves assets that are imported via `require`.
164
175
  * @param assetSource The asset source, e.g. require('my-asset')
@@ -189,15 +200,27 @@ class IMGLYEditor {
189
200
  ): Promise<EditorResult | null> {
190
201
  if (NativeModule == null) return null;
191
202
 
192
- const modifiedSource =
193
- source?.source != null
194
- ? {
195
- ...source,
196
- source: resolveStaticAsset(source.source)
197
- }
198
- : source;
199
-
200
- return NativeModule.openEditor(settings, modifiedSource, preset, metadata);
203
+ let modifiedSource: Source | undefined;
204
+ if (source?.source != null) {
205
+ modifiedSource = {
206
+ ...source,
207
+ source: resolveStaticAsset(source.source)
208
+ };
209
+ } else if (isNewArchitectureEnabled()) {
210
+ // iOS New Architecture: Pass empty object to ensure struct conversion is triggered.
211
+ // Passing undefined leaves the C++ struct with garbage memory in release builds.
212
+ // See: https://github.com/facebook/react-native/issues/49920
213
+ modifiedSource = {} as unknown as Source;
214
+ }
215
+ // iOS Bridge (Old Architecture): Pass undefined, which the bridge handles
216
+ // gracefully. Passing {} causes decoding errors.
217
+
218
+ return NativeModule.openEditor(
219
+ settings,
220
+ modifiedSource,
221
+ preset,
222
+ metadata
223
+ );
201
224
  }
202
225
  }
203
226