rn-remove-image-bg 0.0.24 → 0.0.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-remove-image-bg",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "rn-remove-image-bg",
5
5
  "homepage": "https://github.com/a-eid/rn-remove-image-bg",
6
6
  "main": "lib/index",
@@ -33,10 +33,11 @@
33
33
  "app.plugin.js",
34
34
  "nitro.json",
35
35
  "*.podspec",
36
- "README.md"
36
+ "README.md",
37
+ "scripts"
37
38
  ],
38
39
  "scripts": {
39
- "postinstall": "tsc || exit 0;",
40
+ "postinstall": "node scripts/patch-onnxruntime-web.js && tsc || exit 0;",
40
41
  "typecheck": "tsc --noEmit",
41
42
  "clean": "rm -rf android/build node_modules/**/android/build lib",
42
43
  "lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ // Patch script for onnxruntime-web Metro bundler compatibility
3
+ // Removes webpack-specific comments that break Metro bundler
4
+ // Usage: node scripts/patch-onnxruntime-web.js
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+
9
+ const filesToPatch = [
10
+ 'node_modules/onnxruntime-web/dist/ort.bundle.min.mjs',
11
+ 'node_modules/onnxruntime-web/dist/ort.webgpu.bundle.min.mjs',
12
+ 'node_modules/onnxruntime-web/dist/ort.all.bundle.min.mjs',
13
+ ];
14
+
15
+ let patchedCount = 0;
16
+ let skippedCount = 0;
17
+
18
+ for (const relativePath of filesToPatch) {
19
+ const absolutePath = path.join(__dirname, '..', relativePath);
20
+
21
+ if (!fs.existsSync(absolutePath)) {
22
+ // File doesn't exist, skip silently (not all bundles may be present)
23
+ continue;
24
+ }
25
+
26
+ try {
27
+ const content = fs.readFileSync(absolutePath, 'utf-8');
28
+
29
+ // Remove webpack-specific comments that break Metro
30
+ // Pattern: /*webpackIgnore:true*/ or /*webpackChunkName:...*/
31
+ const patched = content
32
+ .replace(/\/\*webpackIgnore:true\*\//g, '')
33
+ .replace(/\/\*webpackChunkName:[^*]+\*\//g, '');
34
+
35
+ if (content === patched) {
36
+ console.log(`✅ ${relativePath} - already patched`);
37
+ skippedCount++;
38
+ } else {
39
+ fs.writeFileSync(absolutePath, patched);
40
+ console.log(`✅ ${relativePath} - patched successfully`);
41
+ patchedCount++;
42
+ }
43
+ } catch (error) {
44
+ console.error(`❌ ${relativePath} - failed to patch: ${error.message}`);
45
+ }
46
+ }
47
+
48
+ if (patchedCount === 0 && skippedCount === 0) {
49
+ console.log('⚠️ No onnxruntime-web files found to patch (library may not be installed yet)');
50
+ } else {
51
+ console.log(`\n📦 Patch complete: ${patchedCount} patched, ${skippedCount} already patched`);
52
+ }