expo-image-manipulator 13.0.0 → 13.0.2

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
@@ -10,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 13.0.2 — 2024-10-24
14
+
15
+ ### 💡 Others
16
+
17
+ - Exported missing types, removed unnecessary fallback and properly registered the module on Web. ([#32302](https://github.com/expo/expo/pull/32302) by [@tsapeta](https://github.com/tsapeta))
18
+
19
+ ## 13.0.1 — 2024-10-22
20
+
21
+ _This version does not introduce any user-facing changes._
22
+
13
23
  ## 13.0.0 — 2024-10-22
14
24
 
15
25
  ### 🛠 Breaking changes
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'host.exp.exponent'
4
- version = '13.0.0'
4
+ version = '13.0.2'
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
7
  apply from: expoModulesCorePlugin
@@ -14,7 +14,7 @@ android {
14
14
  namespace "expo.modules.imagemanipulator"
15
15
  defaultConfig {
16
16
  versionCode 23
17
- versionName "13.0.0"
17
+ versionName "13.0.2"
18
18
  }
19
19
  }
20
20
 
@@ -10,7 +10,7 @@ internal object FileUtils {
10
10
  fun generateRandomOutputPath(context: Context, imageFormat: ImageFormat): String {
11
11
  val directory = File("${context.cacheDir}${File.separator}ImageManipulator")
12
12
  ensureDirExists(directory)
13
- return "${directory}${File.separator}${UUID.randomUUID()}${imageFormat.fileExtension})}"
13
+ return "${directory}${File.separator}${UUID.randomUUID()}${imageFormat.fileExtension}"
14
14
  }
15
15
 
16
16
  @Throws(IOException::class)
@@ -19,7 +19,6 @@ import kotlinx.coroutines.suspendCancellableCoroutine
19
19
  import java.io.ByteArrayOutputStream
20
20
  import java.io.File
21
21
  import java.io.FileOutputStream
22
- import java.net.URL
23
22
  import kotlin.coroutines.resume
24
23
  import kotlin.coroutines.resumeWithException
25
24
 
@@ -27,7 +26,7 @@ class ImageManipulatorModule : Module() {
27
26
  private val context: Context
28
27
  get() = appContext.reactContext ?: throw Exceptions.ReactContextLost()
29
28
 
30
- private fun createManipulatorContext(url: URL): ImageManipulatorContext {
29
+ private fun createManipulatorContext(url: Uri): ImageManipulatorContext {
31
30
  val loader = suspend {
32
31
  val imageLoader = appContext.imageLoader
33
32
  ?: throw ImageLoaderNotFoundException()
@@ -55,12 +54,12 @@ class ImageManipulatorModule : Module() {
55
54
  override fun definition() = ModuleDefinition {
56
55
  Name("ExpoImageManipulator")
57
56
 
58
- Function("manipulate") { url: URL ->
57
+ Function("manipulate") { url: Uri ->
59
58
  createManipulatorContext(url)
60
59
  }
61
60
 
62
61
  Class<ImageManipulatorContext>("Context") {
63
- Constructor { url: URL ->
62
+ Constructor { url: Uri ->
64
63
  createManipulatorContext(url)
65
64
  }
66
65
 
@@ -94,7 +93,8 @@ class ImageManipulatorModule : Module() {
94
93
  Property("width") { image: ImageRef -> image.ref.width }
95
94
  Property("height") { image: ImageRef -> image.ref.height }
96
95
 
97
- AsyncFunction("saveAsync") Coroutine { image: ImageRef, options: ManipulateOptions ->
96
+ AsyncFunction("saveAsync") Coroutine { image: ImageRef, options: ManipulateOptions? ->
97
+ val options = options ?: ManipulateOptions()
98
98
  val path = FileUtils.generateRandomOutputPath(context, options.format)
99
99
  val compression = (options.compress * 100).toInt()
100
100
  val resultBitmap = image.ref
@@ -1,5 +1,6 @@
1
- import ExpoImageManipulator from './ExpoImageManipulator';
2
- import { Action, Context, ImageResult, SaveOptions } from './ImageManipulator.types';
1
+ import { Action, ImageResult, SaveOptions } from './ImageManipulator.types';
2
+ import { ImageManipulatorContext } from './ImageManipulatorContext';
3
+ import ExpoImageManipulator from './NativeImageManipulatorModule';
3
4
  /**
4
5
  * Manipulate the image provided via `uri`. Available modifications are rotating, flipping (mirroring),
5
6
  * resizing and cropping. Each invocation results in a new file. With one invocation you can provide
@@ -14,6 +15,6 @@ import { Action, Context, ImageResult, SaveOptions } from './ImageManipulator.ty
14
15
  * Use [`ImageManipulator.manipulate`](#manipulateuri) or [`useImageManipulator`](#useimagemanipulatoruri) instead.
15
16
  */
16
17
  export declare function manipulateAsync(uri: string, actions?: Action[], saveOptions?: SaveOptions): Promise<ImageResult>;
17
- export declare function useImageManipulator(uri: string): Context;
18
+ export declare function useImageManipulator(uri: string): ImageManipulatorContext;
18
19
  export { ExpoImageManipulator as ImageManipulator };
19
20
  //# sourceMappingURL=ImageManipulator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImageManipulator.d.ts","sourceRoot":"","sources":["../src/ImageManipulator.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAc,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIjG;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,MAAM,EAAO,EACtB,WAAW,GAAE,WAAgB,GAC5B,OAAO,CAAC,WAAW,CAAC,CAiCtB;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,OAAO,EAAE,oBAAoB,IAAI,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"ImageManipulator.d.ts","sourceRoot":"","sources":["../src/ImageManipulator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAc,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,oBAAoB,MAAM,gCAAgC,CAAC;AAIlE;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,MAAM,EAAO,EACtB,WAAW,GAAE,WAAgB,GAC5B,OAAO,CAAC,WAAW,CAAC,CA2BtB;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAExE;AAED,OAAO,EAAE,oBAAoB,IAAI,gBAAgB,EAAE,CAAC"}
@@ -1,4 +1,6 @@
1
- import type { NativeModule, SharedObject, SharedRef } from 'expo';
1
+ import type { NativeModule } from 'expo';
2
+ import type { ImageManipulatorContext } from './ImageManipulatorContext';
3
+ import ImageRef from './ImageRef';
2
4
  export type ImageResult = {
3
5
  /**
4
6
  * An URI to the modified image (usable as the source for an `Image` or `Video` element).
@@ -101,82 +103,17 @@ export type SaveOptions = {
101
103
  format?: SaveFormat;
102
104
  };
103
105
  export declare class ImageManipulator extends NativeModule {
104
- Context: typeof Context;
105
- Image: typeof ImageRef;
106
106
  /**
107
- * Loads an image from the given URI and creates a new image manipulation context.
107
+ * @hidden
108
108
  */
109
- manipulate(uri: string): Context;
110
- /**
111
- * @hidden This was removed from the native code on iOS and Web. See `ImageManipulator.ts`
112
- * for the JS implementation that uses the new API under the hood.
113
- * @platform android
114
- */
115
- manipulateAsync(uri: string, actions: Action[], saveOptions: SaveOptions): any;
116
- }
117
- /**
118
- * A context for an image manipulation. It provides synchronous, chainable functions that schedule transformations on the original image to the background thread.
119
- * Use an asynchronous [`renderAsync`](#contextrenderasync) to await for all transformations to finish and access the final image.
120
- */
121
- export declare class Context extends SharedObject {
109
+ Context: typeof ImageManipulatorContext;
122
110
  /**
123
- * Resizes the image to the given size.
124
- * @param size Values correspond to the result image dimensions. If you specify only one value, the other will
125
- * be calculated automatically to preserve image ratio.
111
+ * @hidden
126
112
  */
127
- resize(size: {
128
- width?: number | null;
129
- height?: number | null;
130
- }): Context;
131
- /**
132
- * Rotates the image by the given number of degrees.
133
- * @param degrees Degrees to rotate the image. Rotation is clockwise when the value is positive and
134
- * counter-clockwise when negative.
135
- */
136
- rotate(degrees: number): Context;
137
- /**
138
- * Flips the image vertically or horizontally.
139
- * @param flipType An axis on which image will be flipped. Only one flip per transformation is available. If you
140
- * want to flip according to both axes then provide two separate transformations.
141
- */
142
- flip(flipType: 'vertical' | 'horizontal'): Context;
143
- /**
144
- * Crops the image to the given rectangle's origin and size.
145
- * @param rect Fields specify top-left corner and dimensions of a crop rectangle.
146
- */
147
- crop(rect: ActionCrop['crop']): Context;
148
- /**
149
- * Set the image size and offset. If the image is enlarged, unfilled areas are set to the `backgroundColor`.
150
- * To position the image, use `originX` and `originY`.
151
- *
152
- * @platform web
153
- */
154
- extent(options: ActionExtent['extent']): Context;
155
- /**
156
- * Resets the manipulator context to the originally loaded image.
157
- */
158
- reset(): Context;
159
- /**
160
- * Awaits for all manipulation tasks to finish and resolves with a reference to the resulted native image.
161
- */
162
- renderAsync(): Promise<ImageRef>;
163
- }
164
- /**
165
- * A reference to a native instance of the image.
166
- */
167
- export declare class ImageRef extends SharedRef<'image'> {
168
- /**
169
- * Width of the image.
170
- */
171
- width: number;
172
- /**
173
- * Height of the image.
174
- */
175
- height: number;
113
+ Image: typeof ImageRef;
176
114
  /**
177
- * Saves the image to the file system in the cache directory.
178
- * @param options A map defining how modified image should be saved.
115
+ * Loads an image from the given URI and creates a new image manipulation context.
179
116
  */
180
- saveAsync(options?: SaveOptions): Promise<ImageResult>;
117
+ manipulate(uri: string): ImageManipulatorContext;
181
118
  }
182
119
  //# sourceMappingURL=ImageManipulator.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImageManipulator.types.d.ts","sourceRoot":"","sources":["../src/ImageManipulator.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAGlE,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,C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M,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CAAC;AAG1F,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAGD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,YAAY;IACxD;;OAEG;IACH,OAAO,EAAE,OAAO,uBAAuB,CAAC;IAExC;;OAEG;IACH,KAAK,EAAE,OAAO,QAAQ,CAAC;IAEvB;;OAEG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB;CACjD"}
@@ -0,0 +1,53 @@
1
+ import { SharedObject } from 'expo';
2
+ import type { ActionCrop, ActionExtent } from './ImageManipulator.types';
3
+ import type { ImageRef } from './ImageRef';
4
+ /**
5
+ * A context for an image manipulation. It provides synchronous, chainable functions that schedule transformations on the original image to the background thread.
6
+ * Use an asynchronous [`renderAsync`](#contextrenderasync) to await for all transformations to finish and access the final image.
7
+ */
8
+ export declare class ImageManipulatorContext extends SharedObject {
9
+ /**
10
+ * Resizes the image to the given size.
11
+ * @param size Values correspond to the result image dimensions. If you specify only one value, the other will
12
+ * be calculated automatically to preserve image ratio.
13
+ */
14
+ resize(size: {
15
+ width?: number | null;
16
+ height?: number | null;
17
+ }): ImageManipulatorContext;
18
+ /**
19
+ * Rotates the image by the given number of degrees.
20
+ * @param degrees Degrees to rotate the image. Rotation is clockwise when the value is positive and
21
+ * counter-clockwise when negative.
22
+ */
23
+ rotate(degrees: number): ImageManipulatorContext;
24
+ /**
25
+ * Flips the image vertically or horizontally.
26
+ * @param flipType An axis on which image will be flipped. Only one flip per transformation is available. If you
27
+ * want to flip according to both axes then provide two separate transformations.
28
+ */
29
+ flip(flipType: 'vertical' | 'horizontal'): ImageManipulatorContext;
30
+ /**
31
+ * Crops the image to the given rectangle's origin and size.
32
+ * @param rect Fields specify top-left corner and dimensions of a crop rectangle.
33
+ */
34
+ crop(rect: ActionCrop['crop']): ImageManipulatorContext;
35
+ /**
36
+ * Set the image size and offset. If the image is enlarged, unfilled areas are set to the `backgroundColor`.
37
+ * To position the image, use `originX` and `originY`.
38
+ *
39
+ * @platform web
40
+ */
41
+ extent(options: ActionExtent['extent']): ImageManipulatorContext;
42
+ /**
43
+ * Resets the manipulator context to the originally loaded image.
44
+ */
45
+ reset(): ImageManipulatorContext;
46
+ /**
47
+ * Awaits for all manipulation tasks to finish and resolves with a reference to the resulted native image.
48
+ */
49
+ renderAsync(): Promise<ImageRef>;
50
+ }
51
+ declare const _default: typeof ImageManipulatorContext;
52
+ export default _default;
53
+ //# sourceMappingURL=ImageManipulatorContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageManipulatorContext.d.ts","sourceRoot":"","sources":["../src/ImageManipulatorContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,YAAY;IAC/D;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,uBAAuB;IAExF;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB;IAEhD;;;;OAIG;IACH,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,YAAY,GAAG,uBAAuB;IAElE;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,uBAAuB;IAEvD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,uBAAuB;IAEhE;;OAEG;IACH,KAAK,IAAI,uBAAuB;IAEhC;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;CACjC;;AAED,wBAA8E"}
@@ -0,0 +1,23 @@
1
+ import { SharedRef } from 'expo';
2
+ import type { ImageResult, SaveOptions } from './ImageManipulator.types';
3
+ /**
4
+ * A reference to a native instance of the image.
5
+ */
6
+ export declare class ImageRef extends SharedRef<'image'> {
7
+ /**
8
+ * Width of the image.
9
+ */
10
+ width: number;
11
+ /**
12
+ * Height of the image.
13
+ */
14
+ height: number;
15
+ /**
16
+ * Saves the image to the file system in the cache directory.
17
+ * @param options A map defining how modified image should be saved.
18
+ */
19
+ saveAsync(options?: SaveOptions): Promise<ImageResult>;
20
+ }
21
+ declare const _default: typeof ImageRef;
22
+ export default _default;
23
+ //# sourceMappingURL=ImageRef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageRef.d.ts","sourceRoot":"","sources":["../src/ImageRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGzE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,SAAS,CAAC,OAAO,CAAC;IACtD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CACvD;;AAED,wBAAgE"}
@@ -1,4 +1,4 @@
1
1
  import { ImageManipulator } from './ImageManipulator.types';
2
2
  declare const _default: ImageManipulator;
3
3
  export default _default;
4
- //# sourceMappingURL=ExpoImageManipulator.d.ts.map
4
+ //# sourceMappingURL=NativeImageManipulatorModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeImageManipulatorModule.d.ts","sourceRoot":"","sources":["../src/NativeImageManipulatorModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;;AAE5D,wBAA6E"}
@@ -6,6 +6,6 @@ declare class ImageManipulator extends NativeModule {
6
6
  Image: typeof ImageManipulatorImageRef;
7
7
  manipulate(uri: string): ImageManipulatorContext;
8
8
  }
9
- declare const _default: ImageManipulator;
9
+ declare const _default: typeof ImageManipulator;
10
10
  export default _default;
11
- //# sourceMappingURL=ExpoImageManipulator.web.d.ts.map
11
+ //# sourceMappingURL=NativeImageManipulatorModule.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeImageManipulatorModule.web.d.ts","sourceRoot":"","sources":["../src/NativeImageManipulatorModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,uBAAuB,MAAM,mCAAmC,CAAC;AACxE,OAAO,wBAAwB,MAAM,oCAAoC,CAAC;AAG1E,cAAM,gBAAiB,SAAQ,YAAY;IACzC,OAAO,iCAA2B;IAClC,KAAK,kCAA4B;IAEjC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB;CAGjD;;AAED,wBAAmD"}
package/build/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { ImageManipulator, manipulateAsync, useImageManipulator } from './ImageManipulator';
2
2
  export { SaveOptions, SaveFormat, ImageResult } from './ImageManipulator.types';
3
3
  export { ActionResize, ActionRotate, FlipType, ActionFlip, ActionCrop, ActionExtent, Action, } from './ImageManipulator.types';
4
+ export type { ImageRef } from './ImageRef';
5
+ export type { ImageManipulatorContext } from './ImageManipulatorContext';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGhF,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,YAAY,EACZ,MAAM,GACP,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGhF,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,YAAY,EACZ,MAAM,GACP,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-image-manipulator",
3
- "version": "13.0.0",
3
+ "version": "13.0.2",
4
4
  "description": "Provides functions that let you manipulation images on the local file system, eg: resize, crop.",
5
5
  "main": "src/index.ts",
6
6
  "types": "build/index.d.ts",
@@ -39,5 +39,5 @@
39
39
  "peerDependencies": {
40
40
  "expo": "*"
41
41
  },
42
- "gitHead": "7c7d2362fff23bec26cd145ed34edd9c403551bd"
42
+ "gitHead": "2e4f18d41da033c5ced0a4a045d91cf5250016b7"
43
43
  }
@@ -1,7 +1,8 @@
1
1
  import { useReleasingSharedObject } from 'expo-modules-core';
2
2
 
3
- import ExpoImageManipulator from './ExpoImageManipulator';
4
- import { Action, Context, ImageResult, SaveFormat, SaveOptions } from './ImageManipulator.types';
3
+ import { Action, ImageResult, SaveFormat, SaveOptions } from './ImageManipulator.types';
4
+ import { ImageManipulatorContext } from './ImageManipulatorContext';
5
+ import ExpoImageManipulator from './NativeImageManipulatorModule';
5
6
  import { validateArguments } from './validators';
6
7
 
7
8
  // @needsAudit
@@ -26,12 +27,6 @@ export async function manipulateAsync(
26
27
  validateArguments(uri, actions, saveOptions);
27
28
 
28
29
  const { format = SaveFormat.JPEG, ...rest } = saveOptions;
29
-
30
- if (ExpoImageManipulator.manipulateAsync) {
31
- // Fall back to the module on Android and web where the new API is not available yet.
32
- return ExpoImageManipulator.manipulateAsync(uri, actions, { format, ...rest });
33
- }
34
-
35
30
  const context = ExpoImageManipulator.manipulate(uri);
36
31
 
37
32
  for (const action of actions) {
@@ -57,7 +52,7 @@ export async function manipulateAsync(
57
52
  return result;
58
53
  }
59
54
 
60
- export function useImageManipulator(uri: string): Context {
55
+ export function useImageManipulator(uri: string): ImageManipulatorContext {
61
56
  return useReleasingSharedObject(() => ExpoImageManipulator.manipulate(uri), [uri]);
62
57
  }
63
58
 
@@ -1,4 +1,7 @@
1
- import type { NativeModule, SharedObject, SharedRef } from 'expo';
1
+ import type { NativeModule } from 'expo';
2
+
3
+ import type { ImageManipulatorContext } from './ImageManipulatorContext';
4
+ import ImageRef from './ImageRef';
2
5
 
3
6
  // @needsAudit
4
7
  export type ImageResult = {
@@ -122,90 +125,18 @@ export type SaveOptions = {
122
125
  };
123
126
 
124
127
  export declare class ImageManipulator extends NativeModule {
125
- Context: typeof Context;
126
- Image: typeof ImageRef;
127
-
128
- /**
129
- * Loads an image from the given URI and creates a new image manipulation context.
130
- */
131
- manipulate(uri: string): Context;
132
-
133
- /**
134
- * @hidden This was removed from the native code on iOS and Web. See `ImageManipulator.ts`
135
- * for the JS implementation that uses the new API under the hood.
136
- * @platform android
137
- */
138
- manipulateAsync(uri: string, actions: Action[], saveOptions: SaveOptions);
139
- }
140
-
141
- /**
142
- * A context for an image manipulation. It provides synchronous, chainable functions that schedule transformations on the original image to the background thread.
143
- * Use an asynchronous [`renderAsync`](#contextrenderasync) to await for all transformations to finish and access the final image.
144
- */
145
- export declare class Context extends SharedObject {
146
- /**
147
- * Resizes the image to the given size.
148
- * @param size Values correspond to the result image dimensions. If you specify only one value, the other will
149
- * be calculated automatically to preserve image ratio.
150
- */
151
- resize(size: { width?: number | null; height?: number | null }): Context;
152
-
153
- /**
154
- * Rotates the image by the given number of degrees.
155
- * @param degrees Degrees to rotate the image. Rotation is clockwise when the value is positive and
156
- * counter-clockwise when negative.
157
- */
158
- rotate(degrees: number): Context;
159
-
160
- /**
161
- * Flips the image vertically or horizontally.
162
- * @param flipType An axis on which image will be flipped. Only one flip per transformation is available. If you
163
- * want to flip according to both axes then provide two separate transformations.
164
- */
165
- flip(flipType: 'vertical' | 'horizontal'): Context;
166
-
167
- /**
168
- * Crops the image to the given rectangle's origin and size.
169
- * @param rect Fields specify top-left corner and dimensions of a crop rectangle.
170
- */
171
- crop(rect: ActionCrop['crop']): Context;
172
-
173
- /**
174
- * Set the image size and offset. If the image is enlarged, unfilled areas are set to the `backgroundColor`.
175
- * To position the image, use `originX` and `originY`.
176
- *
177
- * @platform web
178
- */
179
- extent(options: ActionExtent['extent']): Context;
180
-
181
- /**
182
- * Resets the manipulator context to the originally loaded image.
183
- */
184
- reset(): Context;
185
-
186
- /**
187
- * Awaits for all manipulation tasks to finish and resolves with a reference to the resulted native image.
188
- */
189
- renderAsync(): Promise<ImageRef>;
190
- }
191
-
192
- /**
193
- * A reference to a native instance of the image.
194
- */
195
- export declare class ImageRef extends SharedRef<'image'> {
196
128
  /**
197
- * Width of the image.
129
+ * @hidden
198
130
  */
199
- width: number;
131
+ Context: typeof ImageManipulatorContext;
200
132
 
201
133
  /**
202
- * Height of the image.
134
+ * @hidden
203
135
  */
204
- height: number;
136
+ Image: typeof ImageRef;
205
137
 
206
138
  /**
207
- * Saves the image to the file system in the cache directory.
208
- * @param options A map defining how modified image should be saved.
139
+ * Loads an image from the given URI and creates a new image manipulation context.
209
140
  */
210
- saveAsync(options?: SaveOptions): Promise<ImageResult>;
141
+ manipulate(uri: string): ImageManipulatorContext;
211
142
  }
@@ -0,0 +1,58 @@
1
+ import { SharedObject } from 'expo';
2
+
3
+ import type { ActionCrop, ActionExtent } from './ImageManipulator.types';
4
+ import type { ImageRef } from './ImageRef';
5
+ import ExpoImageManipulator from './NativeImageManipulatorModule';
6
+
7
+ /**
8
+ * A context for an image manipulation. It provides synchronous, chainable functions that schedule transformations on the original image to the background thread.
9
+ * Use an asynchronous [`renderAsync`](#contextrenderasync) to await for all transformations to finish and access the final image.
10
+ */
11
+ export declare class ImageManipulatorContext extends SharedObject {
12
+ /**
13
+ * Resizes the image to the given size.
14
+ * @param size Values correspond to the result image dimensions. If you specify only one value, the other will
15
+ * be calculated automatically to preserve image ratio.
16
+ */
17
+ resize(size: { width?: number | null; height?: number | null }): ImageManipulatorContext;
18
+
19
+ /**
20
+ * Rotates the image by the given number of degrees.
21
+ * @param degrees Degrees to rotate the image. Rotation is clockwise when the value is positive and
22
+ * counter-clockwise when negative.
23
+ */
24
+ rotate(degrees: number): ImageManipulatorContext;
25
+
26
+ /**
27
+ * Flips the image vertically or horizontally.
28
+ * @param flipType An axis on which image will be flipped. Only one flip per transformation is available. If you
29
+ * want to flip according to both axes then provide two separate transformations.
30
+ */
31
+ flip(flipType: 'vertical' | 'horizontal'): ImageManipulatorContext;
32
+
33
+ /**
34
+ * Crops the image to the given rectangle's origin and size.
35
+ * @param rect Fields specify top-left corner and dimensions of a crop rectangle.
36
+ */
37
+ crop(rect: ActionCrop['crop']): ImageManipulatorContext;
38
+
39
+ /**
40
+ * Set the image size and offset. If the image is enlarged, unfilled areas are set to the `backgroundColor`.
41
+ * To position the image, use `originX` and `originY`.
42
+ *
43
+ * @platform web
44
+ */
45
+ extent(options: ActionExtent['extent']): ImageManipulatorContext;
46
+
47
+ /**
48
+ * Resets the manipulator context to the originally loaded image.
49
+ */
50
+ reset(): ImageManipulatorContext;
51
+
52
+ /**
53
+ * Awaits for all manipulation tasks to finish and resolves with a reference to the resulted native image.
54
+ */
55
+ renderAsync(): Promise<ImageRef>;
56
+ }
57
+
58
+ export default ExpoImageManipulator.Context as typeof ImageManipulatorContext;
@@ -0,0 +1,27 @@
1
+ import { SharedRef } from 'expo';
2
+
3
+ import type { ImageResult, SaveOptions } from './ImageManipulator.types';
4
+ import ExpoImageManipulator from './NativeImageManipulatorModule';
5
+
6
+ /**
7
+ * A reference to a native instance of the image.
8
+ */
9
+ export declare class ImageRef extends SharedRef<'image'> {
10
+ /**
11
+ * Width of the image.
12
+ */
13
+ width: number;
14
+
15
+ /**
16
+ * Height of the image.
17
+ */
18
+ height: number;
19
+
20
+ /**
21
+ * Saves the image to the file system in the cache directory.
22
+ * @param options A map defining how modified image should be saved.
23
+ */
24
+ saveAsync(options?: SaveOptions): Promise<ImageResult>;
25
+ }
26
+
27
+ export default ExpoImageManipulator.ImageRef as typeof ImageRef;
@@ -1,4 +1,4 @@
1
- import { requireNativeModule } from 'expo-modules-core';
1
+ import { requireNativeModule } from 'expo';
2
2
 
3
3
  import { ImageManipulator } from './ImageManipulator.types';
4
4
 
@@ -1,4 +1,5 @@
1
1
  import { NativeModule } from 'expo';
2
+ import { registerWebModule } from 'expo-modules-core';
2
3
 
3
4
  import ImageManipulatorContext from './web/ImageManipulatorContext.web';
4
5
  import ImageManipulatorImageRef from './web/ImageManipulatorImageRef.web';
@@ -13,4 +14,4 @@ class ImageManipulator extends NativeModule {
13
14
  }
14
15
  }
15
16
 
16
- export default new ImageManipulator();
17
+ export default registerWebModule(ImageManipulator);
package/src/index.ts CHANGED
@@ -12,3 +12,6 @@ export {
12
12
  ActionExtent,
13
13
  Action,
14
14
  } from './ImageManipulator.types';
15
+
16
+ export type { ImageRef } from './ImageRef';
17
+ export type { ImageManipulatorContext } from './ImageManipulatorContext';
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoImageManipulator.d.ts","sourceRoot":"","sources":["../src/ExpoImageManipulator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;;AAE5D,wBAA6E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoImageManipulator.web.d.ts","sourceRoot":"","sources":["../src/ExpoImageManipulator.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,uBAAuB,MAAM,mCAAmC,CAAC;AACxE,OAAO,wBAAwB,MAAM,oCAAoC,CAAC;AAG1E,cAAM,gBAAiB,SAAQ,YAAY;IACzC,OAAO,iCAA2B;IAClC,KAAK,kCAA4B;IAEjC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB;CAGjD;;AAED,wBAAsC"}