Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Bump shallow-equal (#853)

Bogdan Chadkin2e10e164f587
diff --git a/apps/designer/app/shared/store-utils.ts b/apps/designer/app/shared/store-utils.ts
index 61af20f03c..b6ac845e38 100644
--- a/apps/designer/app/shared/store-utils.ts
+++ b/apps/designer/app/shared/store-utils.ts
@@ -1,30 +1,5 @@
import { type AnyStore, type StoreValue, computed } from "nanostores";
-// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore soon will have definitions
-import { shallowEqualArrays, shallowEqualObjects } from "shallow-equal";
-
-type Comparable<Item> = Record<string, Item> | Item[] | null | undefined;
-
-type ValidArrayValue<Item> = Item[] | null | undefined;
-
-type ValidObjectValue<Item> = Record<string, Item> | null | undefined;
-
-const shallowEqual = <Item extends Comparable<Item>>(
- a: Item,
- b: Item
-): boolean => {
- if (Array.isArray(a) || Array.isArray(b)) {
- return shallowEqualArrays(
- a as ValidArrayValue<Item>,
- b as ValidArrayValue<Item>
- );
- }
-
- return shallowEqualObjects(
- a as ValidObjectValue<Item>,
- b as ValidObjectValue<Item>
- );
-};
+import { shallowEqual } from "shallow-equal";
// https://github.com/nanostores/nanostores/blob/0d27b0d18d0f471ca0ac5439137d3dac71d01f08/computed/index.d.ts
@@ -32,15 +7,20 @@ type StoreValues<Stores extends AnyStore[]> = {
[Index in keyof Stores]: StoreValue<Stores[Index]>;
};
-export const shallowComputed = <Value, OriginStores extends AnyStore[]>(
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+type Comparable = Record<string, any> | any[] | null | undefined;
+
+export const shallowComputed = <
+ Value extends Comparable,
+ OriginStores extends AnyStore[]
+>(
stores: [...OriginStores],
cb: (...values: StoreValues<OriginStores>) => Value
) => {
let prevComputed: Value;
return computed<Value, OriginStores>(stores, (...values) => {
const nextComputed = cb(...values);
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- if (shallowEqual<any>(prevComputed, nextComputed)) {
+ if (shallowEqual(prevComputed, nextComputed)) {
return prevComputed;
} else {
prevComputed = nextComputed;
diff --git a/apps/designer/package.json b/apps/designer/package.json
index 075327e8ff..d39ca41094 100644
--- a/apps/designer/package.json
+++ b/apps/designer/package.json
@@ -34,11 +34,13 @@
"@remix-run/vercel": "1.9.0",
"@sentry/remix": "^7.5.0",
"@sentry/types": "7.5.0",
+ "@trpc/server": "^10.9.0",
"@vercel/node": "^2.4.1",
"@webstudio-is/asset-uploader": "workspace:^",
"@webstudio-is/css-data": "workspace:^",
"@webstudio-is/css-engine": "workspace:^",
"@webstudio-is/css-vars": "workspace:^",
+ "@webstudio-is/dashboard": "workspace:^",
"@webstudio-is/design-system": "workspace:^",
"@webstudio-is/design-tokens": "workspace:^",
"@webstudio-is/feature-flags": "workspace:^",
@@ -49,8 +51,6 @@
"@webstudio-is/project": "workspace:^",
"@webstudio-is/react-sdk": "workspace:^",
"@webstudio-is/trpc-interface": "workspace:^",
- "@webstudio-is/dashboard": "workspace:^",
- "@trpc/server": "^10.9.0",
"bson-objectid": "^2.0.4",
"camelcase": "^6.3.0",
"colord": "^2.9.3",
@@ -88,7 +88,7 @@
"remix-auth-github": "^1.1.1",
"remix-auth-google": "^1.1.0",
"remix-utils": "^4.1.0",
- "shallow-equal": "^1.2.1",
+ "shallow-equal": "^3.0.0",
"slugify": "^1.6.5",
"use-debounce": "^9.0.2",
"uuid": "^9.0.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 7121adc6b1..0c434ee931 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -146,7 +146,7 @@ importers:
remix-auth-github: ^1.1.1
remix-auth-google: ^1.1.0
remix-utils: ^4.1.0
- shallow-equal: ^1.2.1
+ shallow-equal: ^3.0.0
slugify: ^1.6.5
typescript: 4.7.4
use-debounce: ^9.0.2
@@ -225,7 +225,7 @@ importers:
remix-auth-github: 1.1.1_xwzgzw5pppjvklzjkjpfcyhkre
remix-auth-google: 1.1.0_vfjkmpgf2kafw3snxw2uyzxrma
remix-utils: 4.1.0_p7gsab2odbjrdioff2iqwg35mm
- shallow-equal: 1.2.1
+ shallow-equal: 3.0.0
slugify: 1.6.5
use-debounce: [email protected]
uuid: 9.0.0
@@ -19947,8 +19947,8 @@ packages:
dependencies:
kind-of: 6.0.3
- /shallow-equal/1.2.1:
- resolution: {integrity: sha512-S4vJDjHHMBaiZuT9NPb616CSmLf618jawtv3sufLl6ivK8WocjAo58cXwbRV1cgqxH0Qbv+iUt6m05eqEa2IRA==}
+ /shallow-equal/3.0.0:
+ resolution: {integrity: sha512-RQCWw09DuoLI8FSuACf3Pba1MJWCXMVXOuGQlZ5pmhxwq1KawCOIwggrIlUTtFyHkyc9aJMBb7nA4X19Tmv8qw==}
dev: false
/sharp/0.30.7: