rn-remove-image-bg 0.0.10 → 0.0.11

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.
@@ -4,7 +4,6 @@
4
4
  * Provides real background removal on web using WebAssembly and ML models.
5
5
  * Falls back to no-op if the library fails to load.
6
6
  */
7
- import { removeBackground as imglyRemoveBackground } from '@imgly/background-removal';
8
7
  // Web cache configuration
9
8
  const webCacheConfig = {
10
9
  maxEntries: 50,
@@ -134,6 +133,8 @@ export async function removeBgImage(uri, options = {}) {
134
133
  }
135
134
  onProgress?.(5);
136
135
  try {
136
+ // Dynamically import the library to prevent Metro from parsing onnxruntime-web at build time
137
+ const { removeBackground: imglyRemoveBackground } = await import('@imgly/background-removal');
137
138
  // Call @imgly/background-removal
138
139
  const blob = await imglyRemoveBackground(uri, {
139
140
  progress: (key, current, total) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-remove-image-bg",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "rn-remove-image-bg",
5
5
  "homepage": "https://github.com/a-eid/rn-remove-image-bg",
6
6
  "main": "lib/index",
@@ -5,7 +5,8 @@
5
5
  * Falls back to no-op if the library fails to load.
6
6
  */
7
7
 
8
- import { removeBackground as imglyRemoveBackground } from '@imgly/background-removal';
8
+ // @imgly/background-removal is dynamically imported at runtime in removeBgImage()
9
+ // to prevent Metro from parsing onnxruntime-web at build time
9
10
 
10
11
  /**
11
12
  * Output format for processed images
@@ -207,6 +208,9 @@ export async function removeBgImage(
207
208
  onProgress?.(5);
208
209
 
209
210
  try {
211
+ // Dynamically import the library to prevent Metro from parsing onnxruntime-web at build time
212
+ const { removeBackground: imglyRemoveBackground } = await import('@imgly/background-removal');
213
+
210
214
  // Call @imgly/background-removal
211
215
  const blob = await imglyRemoveBackground(uri, {
212
216
  progress: (key: string, current: number, total: number) => {