@imgly/editor-react-native 1.40.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.
Files changed (48) hide show
  1. package/IMGLYEditorModule.podspec +21 -0
  2. package/LICENSE.md +137 -0
  3. package/README.md +31 -0
  4. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  5. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  6. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  7. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  8. package/android/.gradle/8.9/gc.properties +0 -0
  9. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  10. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  11. package/android/.gradle/vcs-1/gc.properties +0 -0
  12. package/android/build.gradle +65 -0
  13. package/android/src/main/AndroidManifest.xml +8 -0
  14. package/android/src/main/assets/photo-ui-empty.png +0 -0
  15. package/android/src/main/kotlin/ly/img/editor/reactnative/module/IMGLYEditorModule.kt +252 -0
  16. package/android/src/main/kotlin/ly/img/editor/reactnative/module/IMGLYEditorPackage.kt +35 -0
  17. package/android/src/main/kotlin/ly/img/editor/reactnative/module/activity/EditorActivity.kt +112 -0
  18. package/android/src/main/kotlin/ly/img/editor/reactnative/module/builder/EditorBuilder.kt +478 -0
  19. package/android/src/main/kotlin/ly/img/editor/reactnative/module/helper/AssetHelper.kt +18 -0
  20. package/android/src/main/kotlin/ly/img/editor/reactnative/module/helper/IntentHelper.kt +61 -0
  21. package/android/src/main/kotlin/ly/img/editor/reactnative/module/model/EditorPreset.kt +47 -0
  22. package/android/src/main/kotlin/ly/img/editor/reactnative/module/model/EditorResult.kt +73 -0
  23. package/android/src/main/kotlin/ly/img/editor/reactnative/module/model/EditorSettings.kt +63 -0
  24. package/android/src/main/kotlin/ly/img/editor/reactnative/module/model/EditorSourceType.kt +39 -0
  25. package/android/src/main/kotlin/ly/img/editor/reactnative/module/model/Source.kt +44 -0
  26. package/android/src/newarch/IMGLYEditorModuleSpec.kt +7 -0
  27. package/android/src/oldarch/IMGLYEditorModuleSpec.kt +18 -0
  28. package/index.d.ts +3 -0
  29. package/index.js +3 -0
  30. package/ios/Constants/IMGLYConstants.h +13 -0
  31. package/ios/Constants/IMGLYConstants.m +13 -0
  32. package/ios/Extensions/OnCreate+.swift +75 -0
  33. package/ios/Extensions/OnExport+.swift +64 -0
  34. package/ios/Extensions/String+.swift +7 -0
  35. package/ios/Helper/ExportHelper.swift +67 -0
  36. package/ios/IMGLYEditorModule-Bridging-Header.h +3 -0
  37. package/ios/IMGLYEditorModule.h +11 -0
  38. package/ios/IMGLYEditorModule.mm +86 -0
  39. package/ios/IMGLYEditorModule.swift +110 -0
  40. package/ios/Model/EditorBuilder.swift +293 -0
  41. package/ios/Model/EditorPreset.swift +52 -0
  42. package/ios/Model/EditorResult.swift +27 -0
  43. package/ios/Model/EditorSettings.swift +33 -0
  44. package/ios/Model/EditorSourceType.swift +11 -0
  45. package/ios/Model/Source.swift +8 -0
  46. package/ios/View/ModalEditor.swift +55 -0
  47. package/package.json +46 -0
  48. package/src/NativeIMGLYEditor.ts +195 -0
@@ -0,0 +1,195 @@
1
+ import { Image, TurboModule, TurboModuleRegistry } from 'react-native';
2
+
3
+ /** An editor preset for an existing UI configuration. */
4
+ export enum EditorPreset {
5
+ /** Design editor. */
6
+ DESIGN = 'design',
7
+
8
+ /** Photo editor. */
9
+ PHOTO = 'photo',
10
+
11
+ /** Postcard editor. */
12
+ POSTCARD = 'postcard',
13
+
14
+ /** Apparel editor. */
15
+ APPAREL = 'apparel',
16
+
17
+ /** Video editor. */
18
+ VIDEO = 'video'
19
+ }
20
+
21
+ /**
22
+ * An editor result is returned from a successful
23
+ * editor export and contains the relevant export
24
+ * information.
25
+ */
26
+ export interface EditorResult {
27
+ /** The scene. */
28
+ scene?: string;
29
+
30
+ /** The path of the exported image/video/pdf. */
31
+ artifact?: string;
32
+
33
+ /** The path of the thumbnail of the artifact. */
34
+ thumbnail?: string;
35
+
36
+ /**
37
+ * Metadata associated with the export.
38
+ * Should be customizable by the customer
39
+ * using the onExport interface.
40
+ */
41
+ metadata: { [key: string]: unknown };
42
+ }
43
+
44
+ /**
45
+ * The EditorSettings are used to provide the
46
+ * information needed by the editor to operate.
47
+ */
48
+ export interface EditorSettings {
49
+ /** The license of the editor. */
50
+ license: string;
51
+
52
+ /**
53
+ * The base URI to the assets included in
54
+ * the scene of which the sources are specified
55
+ * as relative paths.
56
+ */
57
+ sceneBaseUri: string;
58
+
59
+ /** The base URI to the default assets of the asset library. */
60
+ assetBaseUri?: string;
61
+
62
+ /**
63
+ * Unique ID tied to your application's user.
64
+ * This helps us accurately calculate monthly
65
+ * active users (MAU).
66
+ */
67
+ userId?: string;
68
+ }
69
+
70
+ /**
71
+ * Default implementation of the `EditorSettings`.
72
+ *
73
+ * The EditorSettings are used to provide the
74
+ * information needed by the editor to operate.
75
+ */
76
+ export class EditorSettingsModel implements EditorSettings {
77
+ /** The license of the editor. */
78
+ license: string;
79
+
80
+ /**
81
+ * The base URI to the assets included in
82
+ * the scene of which the sources are specified
83
+ * as relative paths.
84
+ */
85
+ sceneBaseUri: string =
86
+ 'https://cdn.img.ly/packages/imgly/cesdk-engine/1.35.0/assets';
87
+
88
+ /** The base URI to the default assets of the asset library. */
89
+ assetBaseUri?: string;
90
+
91
+ /**
92
+ * Unique ID tied to your application's user.
93
+ * This helps us accurately calculate monthly
94
+ * active users (MAU).
95
+ */
96
+ userId?: string;
97
+
98
+ constructor(settings: Partial<EditorSettings> = {}) {
99
+ Object.assign(this, settings);
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Defines all available types of source that can be
105
+ * loaded into the editor.
106
+ */
107
+ export enum SourceType {
108
+ /** A `.scene` file. */
109
+ SCENE = 'scene',
110
+
111
+ /** An image, e.g. `.png`. */
112
+ IMAGE = 'image',
113
+
114
+ /** A video, e.g. `.mp4`. */
115
+ VIDEO = 'video'
116
+ }
117
+
118
+ /** A source for the editor. */
119
+ export interface Source {
120
+ /**
121
+ * The source location.
122
+ * The source should be pointing to a valid file based
123
+ * on the selected `type`.
124
+ */
125
+ source: string;
126
+
127
+ /** The type of the source. */
128
+ type: SourceType;
129
+ }
130
+
131
+ /** TurboModule Spec. */
132
+ interface Spec extends TurboModule {
133
+ /**
134
+ * Open the Creative Editor.
135
+ * @param settings The `EditorSettings`.
136
+ * @param source The `Source` to open.
137
+ * @param preset The editor variant to open.
138
+ * @param metadata The metadata to pass to the native module.
139
+ */
140
+ openEditor(
141
+ settings: EditorSettings,
142
+ source?: Source,
143
+ preset?: EditorPreset,
144
+ metadata?: { [key: string]: unknown }
145
+ ): Promise<EditorResult | null>;
146
+ }
147
+
148
+ /** The native module. */
149
+ const NativeModule = TurboModuleRegistry.get<Spec>(
150
+ 'IMGLYEditor'
151
+ ) as Spec | null;
152
+
153
+ /**
154
+ * Resolves assets that are imported via `require`.
155
+ * @param assetSource The asset source, e.g. require('my-asset')
156
+ * @returns The resolved URI.
157
+ */
158
+ function resolveStaticAsset(assetSource: any): string {
159
+ const resolvedSource = Image.resolveAssetSource(assetSource);
160
+ if (resolvedSource) {
161
+ return resolvedSource.uri;
162
+ }
163
+ return assetSource;
164
+ }
165
+
166
+ /** The IMG.LY Creative Editor. */
167
+ class IMGLYEditor {
168
+ /**
169
+ * Open the Creative Editor.
170
+ * @param settings The `EditorSettings`.
171
+ * @param source The `Source` to open.
172
+ * @param preset The editor variant to open.
173
+ * @param metadata The metadata to pass to the native module.
174
+ */
175
+ static async openEditor(
176
+ settings: EditorSettings,
177
+ source?: Source,
178
+ preset?: EditorPreset,
179
+ metadata?: { [key: string]: unknown }
180
+ ): Promise<EditorResult | null> {
181
+ if (NativeModule == null) return null;
182
+
183
+ const modifiedSource =
184
+ source?.source != null
185
+ ? {
186
+ ...source,
187
+ source: resolveStaticAsset(source.source)
188
+ }
189
+ : source;
190
+
191
+ return NativeModule.openEditor(settings, modifiedSource, preset, metadata);
192
+ }
193
+ }
194
+
195
+ export default IMGLYEditor;