diff --git a/app/features/art/routes/art.new.tsx b/app/features/art/routes/art.new.tsx index 9e0801577..d79648b74 100644 --- a/app/features/art/routes/art.new.tsx +++ b/app/features/art/routes/art.new.tsx @@ -11,7 +11,6 @@ import { } from "@remix-run/node"; import { Form, useLoaderData } from "@remix-run/react"; import Compressor from "compressorjs"; -import clone from "just-clone"; import { nanoid } from "nanoid"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -474,7 +473,7 @@ function LinkedUsers() { { - const newUsers = clone(users); + const newUsers = structuredClone(users); newUsers[i] = { ...newUsers[i], userId: newUser.id }; setUsers(newUsers); diff --git a/app/features/builds/routes/builds.$slug.tsx b/app/features/builds/routes/builds.$slug.tsx index 39ddf75a0..70c543228 100644 --- a/app/features/builds/routes/builds.$slug.tsx +++ b/app/features/builds/routes/builds.$slug.tsx @@ -4,7 +4,6 @@ import { useLoaderData, useSearchParams, } from "@remix-run/react"; -import clone from "just-clone"; import { nanoid } from "nanoid"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -240,7 +239,7 @@ export default function WeaponsBuildsPage() { }; const handleFilterChange = (i: number, newFilter: Partial) => { - const newFilters = clone(filters); + const newFilters = structuredClone(filters); newFilters[i] = { ...(filters[i] as AbilityBuildFilter), diff --git a/app/features/map-list-generator/core/map-pool.ts b/app/features/map-list-generator/core/map-pool.ts index cc30752a6..7324767dd 100644 --- a/app/features/map-list-generator/core/map-pool.ts +++ b/app/features/map-list-generator/core/map-pool.ts @@ -1,4 +1,3 @@ -import clone from "just-clone"; import type { MapPoolMap } from "~/db/types"; import { type ModeShort, @@ -108,8 +107,8 @@ export class MapPool { return this.stageModePairs.length; } - getClonedObject(): MapPoolObject { - return clone(this.parsed) as MapPoolObject; + getClonedObject() { + return structuredClone(this.parsed) as MapPoolObject; } toString() { diff --git a/app/features/sendouq/core/groups.server.ts b/app/features/sendouq/core/groups.server.ts index c5a74fd01..afd4a390b 100644 --- a/app/features/sendouq/core/groups.server.ts +++ b/app/features/sendouq/core/groups.server.ts @@ -1,4 +1,3 @@ -import clone from "just-clone"; import type { Tables } from "~/db/tables"; import type { Group } from "~/db/types"; import { TIERS } from "~/features/mmr/mmr-constants"; @@ -524,7 +523,7 @@ export function tierDifferenceToRangeOrExact({ tier: TieredSkill["tier"] | [TieredSkill["tier"], TieredSkill["tier"]]; } { if (ourTier.name === theirTier.name && ourTier.isPlus === theirTier.isPlus) { - return { diff: 0, tier: clone(ourTier) }; + return { diff: 0, tier: structuredClone(ourTier) }; } const tiers = hasLeviathan @@ -546,11 +545,14 @@ export function tierDifferenceToRangeOrExact({ const upperBound = tier1Idx + idxDiff; if (lowerBound < 0 || upperBound >= tiers.length) { - return { diff: idxDiff, tier: clone(theirTier) }; + return { diff: idxDiff, tier: structuredClone(theirTier) }; } const lowerTier = tiers[lowerBound]; const upperTier = tiers[upperBound]; - return { diff: idxDiff, tier: [clone(lowerTier), clone(upperTier)] }; + return { + diff: idxDiff, + tier: [structuredClone(lowerTier), structuredClone(upperTier)], + }; } diff --git a/app/features/tournament-bracket/components/TeamRosterInputs.tsx b/app/features/tournament-bracket/components/TeamRosterInputs.tsx index de2cee2fe..d67b3c989 100644 --- a/app/features/tournament-bracket/components/TeamRosterInputs.tsx +++ b/app/features/tournament-bracket/components/TeamRosterInputs.tsx @@ -1,6 +1,5 @@ import { Link, useFetcher, useLoaderData } from "@remix-run/react"; import clsx from "clsx"; -import clone from "just-clone"; import * as React from "react"; import { Avatar } from "~/components/Avatar"; import { Button } from "~/components/Button"; @@ -140,7 +139,7 @@ function _TeamRoster({ const didCancel = !editing; if (didCancel) { setCheckedPlayers?.((oldPlayers) => { - const newPlayers = clone(oldPlayers); + const newPlayers = structuredClone(oldPlayers); newPlayers[idx] = activeRoster ?? []; return newPlayers; }); @@ -157,7 +156,7 @@ function _TeamRoster({ const onPointsChange = React.useCallback( (newPoint: number) => { setPoints((points) => { - const newPoints = clone(points); + const newPoints = structuredClone(points); newPoints[idx] = newPoint; return newPoints; }); @@ -218,7 +217,7 @@ function _TeamRoster({ if (!setCheckedPlayers) return; setCheckedPlayers((oldPlayers) => { - const newPlayers = clone(oldPlayers); + const newPlayers = structuredClone(oldPlayers); if (oldPlayers[idx].includes(playerId)) { newPlayers[idx] = newPlayers[idx].filter((id) => id !== playerId); } else { diff --git a/app/features/tournament-bracket/core/toMapList.ts b/app/features/tournament-bracket/core/toMapList.ts index 7f96a2e9f..a176c78cd 100644 --- a/app/features/tournament-bracket/core/toMapList.ts +++ b/app/features/tournament-bracket/core/toMapList.ts @@ -1,6 +1,5 @@ /** Map list generation logic for "TO pick" as in the map list is defined beforehand by TO and teams don't pick */ -import clone from "just-clone"; import shuffle from "just-shuffle"; import type { Tables, TournamentRoundMaps } from "~/db/tables"; import type { Round } from "~/modules/brackets-model"; @@ -199,7 +198,7 @@ function modesWithSZBiased({ } if (flavor === "SZ_FIRST" && modes.includes("SZ")) { - const result: ModeShort[] = clone(modes); + const result: ModeShort[] = structuredClone(modes); const szIndex = result.indexOf("SZ"); result.splice(szIndex, 1); result.unshift("SZ"); diff --git a/app/features/tournament/routes/to.$id.seeds.tsx b/app/features/tournament/routes/to.$id.seeds.tsx index 38e086aa0..f52d8e954 100644 --- a/app/features/tournament/routes/to.$id.seeds.tsx +++ b/app/features/tournament/routes/to.$id.seeds.tsx @@ -17,7 +17,6 @@ import type { ActionFunction, LoaderFunctionArgs } from "@remix-run/node"; import { redirect } from "@remix-run/node"; import { Link, useFetcher, useNavigation } from "@remix-run/react"; import clsx from "clsx"; -import clone from "just-clone"; import * as React from "react"; import { Alert } from "~/components/Alert"; import { Button } from "~/components/Button"; @@ -161,7 +160,7 @@ export default function TournamentSeedsPage() { type="button" onClick={() => { setTeamOrder( - clone(tournament.ctx.teams) + structuredClone(tournament.ctx.teams) .sort( (a, b) => (b.avgSeedingSkillOrdinal ?? Number.NEGATIVE_INFINITY) - diff --git a/app/features/user-page/routes/u.$identifier.builds.new.tsx b/app/features/user-page/routes/u.$identifier.builds.new.tsx index 244c618a2..f29f02e37 100644 --- a/app/features/user-page/routes/u.$identifier.builds.new.tsx +++ b/app/features/user-page/routes/u.$identifier.builds.new.tsx @@ -4,7 +4,6 @@ import { useMatches, useSearchParams, } from "@remix-run/react"; -import clone from "just-clone"; import * as React from "react"; import { useTranslation } from "react-i18next"; import { AbilitiesSelector } from "~/components/AbilitiesSelector"; @@ -319,7 +318,7 @@ function GearSelector({ // let's not overwrite current selections if (!currentAbilities.every((a) => a === "UNKNOWN")) return; - const newAbilities = clone(abilities); + const newAbilities = structuredClone(abilities); newAbilities[gearIndex] = abilitiesFromExistingGear; setAbilities(newAbilities); diff --git a/app/modules/brackets-memory-db/index.ts b/app/modules/brackets-memory-db/index.ts index d5529e288..03020455e 100644 --- a/app/modules/brackets-memory-db/index.ts +++ b/app/modules/brackets-memory-db/index.ts @@ -1,4 +1,3 @@ -import clone from "just-clone"; import type { CrudInterface, Database, @@ -130,16 +129,18 @@ export class InMemoryDatabase implements CrudInterface { try { if (arg === undefined) { // @ts-expect-error imported - return this.data[table].map(clone); + return this.data[table].map((val) => structuredClone(val)); } if (typeof arg === "number") { // @ts-expect-error imported - return clone(this.data[table].find((d) => d?.id === arg)); + return structuredClone(this.data[table].find((d) => d?.id === arg)); } // @ts-expect-error imported - return this.data[table].filter(this.makeFilter(arg)).map(clone); + return this.data[table] + .filter(this.makeFilter(arg)) + .map((val) => structuredClone(val)); } catch (error) { return null; } diff --git a/app/utils/arrays.ts b/app/utils/arrays.ts index 40703d666..554a4a920 100644 --- a/app/utils/arrays.ts +++ b/app/utils/arrays.ts @@ -1,7 +1,6 @@ // TODO: when more examples of permissions profile difference between // this implementation and one that takes arrays -import clone from "just-clone"; import shuffle from "just-shuffle"; import invariant from "~/utils/invariant"; @@ -89,7 +88,7 @@ export function nullFilledArray(size: number): null[] { export function pickRandomItem(array: T[]): T { invariant(array.length > 0, "Can't pick from empty array"); - const shuffled = shuffle(clone(array)); + const shuffled = shuffle(structuredClone(array)); return shuffled[0]; } diff --git a/package-lock.json b/package-lock.json index 43534d5a4..35cbccdf6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,9 +33,7 @@ "i18next-browser-languagedetector": "^8.0.4", "i18next-http-backend": "^2.6.2", "isbot": "^5.1.23", - "just-camel-case": "^6.2.0", "just-capitalize": "^3.2.0", - "just-clone": "^6.2.0", "just-compare": "^2.3.0", "just-random-integer": "^4.2.0", "just-shuffle": "^4.2.0", @@ -55,7 +53,6 @@ "react-flip-toolkit": "7.2.4", "react-hook-form": "^7.54.2", "react-i18next": "^15.4.1", - "react-responsive-masonry": "2.2.0", "react-use": "^17.6.0", "react-use-draggable-scroll": "^0.4.7", "reconnecting-websocket": "^4.4.0", @@ -78,7 +75,6 @@ "@types/nprogress": "^0.2.3", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", - "@types/react-responsive-masonry": "^2.1.3", "@types/web-push": "^3.6.4", "cross-env": "^7.0.3", "ley": "^0.8.1", @@ -6732,16 +6728,6 @@ "@types/react": "^18.0.0" } }, - "node_modules/@types/react-responsive-masonry": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/@types/react-responsive-masonry/-/react-responsive-masonry-2.6.0.tgz", - "integrity": "sha512-MF2ql1CjzOoL9fLWp6L3ABoyzBUP/YV71wyb3Fx+cViYNj7+tq3gDCllZHbLg1LQfGOQOEGbV2P7TOcUeGiR6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/react": "*" - } - }, "node_modules/@types/scheduler": { "version": "0.16.8", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz", @@ -10667,24 +10653,12 @@ "graceful-fs": "^4.1.6" } }, - "node_modules/just-camel-case": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/just-camel-case/-/just-camel-case-6.2.0.tgz", - "integrity": "sha512-ICenRLXwkQYLk3UyvLQZ+uKuwFVJ3JHFYFn7F2782G2Mv2hW8WPePqgdhpnjGaqkYtSVWnyCESZhGXUmY3/bEg==", - "license": "MIT" - }, "node_modules/just-capitalize": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/just-capitalize/-/just-capitalize-3.2.0.tgz", "integrity": "sha512-FK8U9A5AHCIGxlEXg3RFJkb9Nz/fS9luJlrfRf0bFBZU6xnIQ6tbwl+HitMJLwCFszZqVaXQcyeoy8/PYABS6A==", "license": "MIT" }, - "node_modules/just-clone": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/just-clone/-/just-clone-6.2.0.tgz", - "integrity": "sha512-1IynUYEc/HAwxhi3WDpIpxJbZpMCvvrrmZVqvj9EhpvbH8lls7HhdhiByjL7DkAaWlLIzpC0Xc/VPvy/UxLNjA==", - "license": "MIT" - }, "node_modules/just-compare": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/just-compare/-/just-compare-2.3.0.tgz", @@ -13692,12 +13666,6 @@ } } }, - "node_modules/react-responsive-masonry": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/react-responsive-masonry/-/react-responsive-masonry-2.2.0.tgz", - "integrity": "sha512-IYbnfe2tWCZ3pvyTLyBWPj7uv5ZmNOULYMcAZi5a47ZLhSotOck1vkkISq6gP2qiyWdMvPfeMhjvYzUYGw9BOQ==", - "license": "MIT" - }, "node_modules/react-router": { "version": "6.30.0", "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.30.0.tgz", diff --git a/package.json b/package.json index 87b01cc71..ee6b60b39 100644 --- a/package.json +++ b/package.json @@ -49,9 +49,7 @@ "i18next-browser-languagedetector": "^8.0.4", "i18next-http-backend": "^2.6.2", "isbot": "^5.1.23", - "just-camel-case": "^6.2.0", "just-capitalize": "^3.2.0", - "just-clone": "^6.2.0", "just-compare": "^2.3.0", "just-random-integer": "^4.2.0", "just-shuffle": "^4.2.0", @@ -71,7 +69,6 @@ "react-flip-toolkit": "7.2.4", "react-hook-form": "^7.54.2", "react-i18next": "^15.4.1", - "react-responsive-masonry": "2.2.0", "react-use": "^17.6.0", "react-use-draggable-scroll": "^0.4.7", "reconnecting-websocket": "^4.4.0", @@ -94,7 +91,6 @@ "@types/nprogress": "^0.2.3", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", - "@types/react-responsive-masonry": "^2.1.3", "@types/web-push": "^3.6.4", "cross-env": "^7.0.3", "ley": "^0.8.1",