From f61ba6898ddd20ce37813d7c10df66a395ef568b Mon Sep 17 00:00:00 2001
From: feedmeapples <aksenov.ro@outlook.com>
Date: Sun, 31 Mar 2024 15:36:25 -0400
Subject: [PATCH] Replace lodash with lodash-es

---
 packages/web/ThirdPartyLicenses.json |  2 +-
 packages/web/package-lock.json       | 98 ++++++++++++++++------------
 packages/web/package.json            |  4 +-
 packages/web/src/index.ts            |  3 +-
 4 files changed, 61 insertions(+), 46 deletions(-)

diff --git a/packages/web/ThirdPartyLicenses.json b/packages/web/ThirdPartyLicenses.json
index 6dab1df..aa57d16 100644
--- a/packages/web/ThirdPartyLicenses.json
+++ b/packages/web/ThirdPartyLicenses.json
@@ -9,7 +9,7 @@
         "type": "model",
         "license": "MIT"
     },
-    "lodash": {
+    "lodash-es": {
         "source": "https://lodash.com/",
         "type": "code",
         "license": "MIT"
diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json
index f45b610..d914050 100644
--- a/packages/web/package-lock.json
+++ b/packages/web/package-lock.json
@@ -1,33 +1,34 @@
 {
   "name": "@imgly/background-removal",
-  "version": "1.2.1",
+  "version": "1.4.5",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "@imgly/background-removal",
-      "version": "1.2.1",
+      "version": "1.4.5",
       "license": "SEE LICENSE IN LICENSE.md",
       "dependencies": {
-        "@types/lodash": "^4.14.195",
-        "@types/node": "^20.3.1",
-        "lodash": "^4.17.21",
-        "ndarray": "^1.0.19",
-        "onnxruntime-web": "^1.16.3",
-        "zod": "^3.21.4"
+        "@types/ndarray": "~1.0.14",
+        "@types/node": "~20.3.0",
+        "lodash-es": "^4.17.21",
+        "ndarray": "~1.0.0",
+        "onnxruntime-web": "~1.17.0",
+        "zod": "~3.21.0"
       },
       "devDependencies": {
-        "assert": "^2.0.0",
-        "esbuild": "^0.18.18",
-        "glob": "^10.3.3",
-        "npm-dts": "^1.3.12",
-        "process": "^0.11.10",
-        "ts-loader": "^9.4.3",
-        "tslib": "^2.5.3",
-        "typescript": "^5.1.3",
-        "util": "^0.12.5",
-        "webpack": "^5.85.1",
-        "webpack-cli": "^5.1.4"
+        "@types/lodash-es": "^4.17.12",
+        "assert": "~2.0.0",
+        "esbuild": "~0.18.0",
+        "glob": "~10.3.0",
+        "npm-dts": "~1.3.0",
+        "process": "~0.11.0",
+        "ts-loader": "~9.4.0",
+        "tslib": "~2.5.0",
+        "typescript": "~5.1.0",
+        "util": "~0.12.0",
+        "webpack": "~5.85.0",
+        "webpack-cli": "~5.1.0"
       }
     },
     "node_modules/@colors/colors": {
@@ -585,12 +586,27 @@
     "node_modules/@types/lodash": {
       "version": "4.14.196",
       "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.196.tgz",
-      "integrity": "sha512-22y3o88f4a94mKljsZcanlNWPzO0uBsBdzLAngf2tp533LzZcQzb6+eZPJ+vCTt+bqF2XnvT9gejTLsAcJAJyQ=="
+      "integrity": "sha512-22y3o88f4a94mKljsZcanlNWPzO0uBsBdzLAngf2tp533LzZcQzb6+eZPJ+vCTt+bqF2XnvT9gejTLsAcJAJyQ==",
+      "dev": true
+    },
+    "node_modules/@types/lodash-es": {
+      "version": "4.17.12",
+      "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz",
+      "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==",
+      "dev": true,
+      "dependencies": {
+        "@types/lodash": "*"
+      }
+    },
+    "node_modules/@types/ndarray": {
+      "version": "1.0.14",
+      "resolved": "https://registry.npmjs.org/@types/ndarray/-/ndarray-1.0.14.tgz",
+      "integrity": "sha512-oANmFZMnFQvb219SSBIhI1Ih/r4CvHDOzkWyJS/XRqkMrGH5/kaPSA1hQhdIBzouaE+5KpE/f5ylI9cujmckQg=="
     },
     "node_modules/@types/node": {
-      "version": "20.4.8",
-      "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.8.tgz",
-      "integrity": "sha512-0mHckf6D2DiIAzh8fM8f3HQCvMKDpK94YQ0DSVkfWTG9BZleYIWudw9cJxX8oCk9bM+vAkDyujDV6dmKHbvQpg=="
+      "version": "20.3.3",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.3.tgz",
+      "integrity": "sha512-wheIYdr4NYML61AjC8MKj/2jrR/kDQri/CIpVoZwldwhnIrD/j9jIU5bJ8yBKuB2VhpFV7Ab6G2XkBjv9r9Zzw=="
     },
     "node_modules/@types/triple-beam": {
       "version": "1.3.2",
@@ -2086,10 +2102,10 @@
         "node": ">=8"
       }
     },
-    "node_modules/lodash": {
+    "node_modules/lodash-es": {
       "version": "4.17.21",
-      "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
-      "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
+      "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz",
+      "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="
     },
     "node_modules/logform": {
       "version": "2.5.1",
@@ -2382,19 +2398,19 @@
       }
     },
     "node_modules/onnxruntime-common": {
-      "version": "1.16.3",
-      "resolved": "https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.16.3.tgz",
-      "integrity": "sha512-ZZfFzEqBf6YIGwB9PtBLESHI53jMXA+/hn+ACVUbEfPuK2xI5vMGpLPn+idpwCmHsKJNRzRwqV12K+6TQj6tug=="
+      "version": "1.17.1",
+      "resolved": "https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.17.1.tgz",
+      "integrity": "sha512-6wLNhpn+1hnsKN+jq6ulqUEJ61TdRmyFkGCvtRNnZkAupH8Yfr805UeNxjl9jtiX9B1q48pq6Q/67fEFpxT7Dw=="
     },
     "node_modules/onnxruntime-web": {
-      "version": "1.16.3",
-      "resolved": "https://registry.npmjs.org/onnxruntime-web/-/onnxruntime-web-1.16.3.tgz",
-      "integrity": "sha512-8O1xCG/RcNQNYYWvdiQJSNpncVg78OVOFeV6MYs/jx++/b12oje8gYUzKqz9wR/sXiX/8TCvdyHgEjj5gQGKUg==",
+      "version": "1.17.1",
+      "resolved": "https://registry.npmjs.org/onnxruntime-web/-/onnxruntime-web-1.17.1.tgz",
+      "integrity": "sha512-EotY9uJU4xFY/ZVZ2Zrl2OZmBcbTVTWn/2OOh4cCWODPwtsYN2xeJYgoz8LfCgZSrhenGg0q4ceYUWATXqEsYQ==",
       "dependencies": {
         "flatbuffers": "^1.12.0",
         "guid-typescript": "^1.0.9",
         "long": "^5.2.3",
-        "onnxruntime-common": "~1.16.3",
+        "onnxruntime-common": "1.17.1",
         "platform": "^1.3.6",
         "protobufjs": "^7.2.4"
       }
@@ -3141,9 +3157,9 @@
       }
     },
     "node_modules/tslib": {
-      "version": "2.6.1",
-      "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.1.tgz",
-      "integrity": "sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==",
+      "version": "2.5.3",
+      "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz",
+      "integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==",
       "dev": true
     },
     "node_modules/typescript": {
@@ -3231,9 +3247,9 @@
       }
     },
     "node_modules/webpack": {
-      "version": "5.88.2",
-      "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.88.2.tgz",
-      "integrity": "sha512-JmcgNZ1iKj+aiR0OvTYtWQqJwq37Pf683dY9bVORwVbUrDhLhdn/PlO2sHsFHPkj7sHNQF3JwaAkp49V+Sq1tQ==",
+      "version": "5.85.1",
+      "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.85.1.tgz",
+      "integrity": "sha512-xTb7MRf4LY8Z5rzn7aIx4TDrwYJrjcHnIfU1TqtyZOoObyuGSpAUwIvVuqq5wPnv7WEgQr8UvO1q/dgoGG4HjA==",
       "dev": true,
       "dependencies": {
         "@types/eslint-scope": "^3.7.3",
@@ -3245,7 +3261,7 @@
         "acorn-import-assertions": "^1.9.0",
         "browserslist": "^4.14.5",
         "chrome-trace-event": "^1.0.2",
-        "enhanced-resolve": "^5.15.0",
+        "enhanced-resolve": "^5.14.1",
         "es-module-lexer": "^1.2.1",
         "eslint-scope": "5.1.1",
         "events": "^3.2.0",
@@ -3255,7 +3271,7 @@
         "loader-runner": "^4.2.0",
         "mime-types": "^2.1.27",
         "neo-async": "^2.6.2",
-        "schema-utils": "^3.2.0",
+        "schema-utils": "^3.1.2",
         "tapable": "^2.1.1",
         "terser-webpack-plugin": "^5.3.7",
         "watchpack": "^2.4.0",
diff --git a/packages/web/package.json b/packages/web/package.json
index a5a6fe6..d84dcd9 100644
--- a/packages/web/package.json
+++ b/packages/web/package.json
@@ -60,15 +60,15 @@
   },
   "bundledDependencies": [],
   "dependencies": {
-    "@types/lodash": "~4.14.0",
     "@types/node": "~20.3.0",
     "@types/ndarray": "~1.0.14",
-    "lodash": "~4.17.0",
+    "lodash-es": "^4.17.21",
     "ndarray": "~1.0.0",
     "onnxruntime-web": "~1.17.0",
     "zod": "~3.21.0"
   },
   "devDependencies": {
+    "@types/lodash-es": "^4.17.12",
     "assert": "~2.0.0",
     "esbuild": "~0.18.0",
     "glob": "~10.3.0",
diff --git a/packages/web/src/index.ts b/packages/web/src/index.ts
index b97b3b8..251210f 100644
--- a/packages/web/src/index.ts
+++ b/packages/web/src/index.ts
@@ -8,7 +8,7 @@ export {
 };
 export type { Config, ImageSource };
 
-import lodash from 'lodash';
+import { memoize } from 'lodash-es';
 import ndarray from 'ndarray';
 import { initInference, runInference } from './inference';
 import { preload as preloadResources } from './resource';
@@ -16,7 +16,6 @@ import { Config, validateConfig } from './schema';
 import * as utils from './utils';
 import { ImageSource } from './utils';
 
-const { memoize } = lodash;
 const init = memoize(initInference, (config) => JSON.stringify(config));
 
 async function preload(configuration?: Config): Promise<void> {