From fb34a8bf4ac20f2eb6a0bf7e95f4fde0601490db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Thu, 17 Oct 2024 23:55:52 +0200 Subject: [PATCH] pl-hooks: Work on making this an actual library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- packages/pl-fe/src/actions/accounts.ts | 2 +- packages/pl-fe/src/actions/admin.ts | 2 +- packages/pl-fe/src/actions/aliases.ts | 2 +- packages/pl-fe/src/actions/auth.ts | 2 +- packages/pl-fe/src/actions/bookmarks.ts | 2 +- packages/pl-fe/src/actions/compose.ts | 2 +- packages/pl-fe/src/actions/conversations.ts | 2 +- packages/pl-fe/src/actions/directory.ts | 2 +- packages/pl-fe/src/actions/emoji-reacts.ts | 2 +- packages/pl-fe/src/actions/events.ts | 2 +- .../pl-fe/src/actions/familiar-followers.ts | 2 +- packages/pl-fe/src/actions/favourites.ts | 2 +- packages/pl-fe/src/actions/groups.ts | 2 +- packages/pl-fe/src/actions/history.ts | 2 +- packages/pl-fe/src/actions/interactions.ts | 2 +- packages/pl-fe/src/actions/lists.ts | 2 +- packages/pl-fe/src/actions/me.ts | 2 +- packages/pl-fe/src/actions/notifications.ts | 2 +- packages/pl-fe/src/actions/pin-statuses.ts | 2 +- packages/pl-fe/src/actions/polls.ts | 2 +- packages/pl-fe/src/actions/preload.ts | 2 +- packages/pl-fe/src/actions/search.ts | 2 +- packages/pl-fe/src/actions/settings.ts | 2 +- packages/pl-fe/src/actions/status-quotes.ts | 2 +- packages/pl-fe/src/actions/statuses.ts | 2 +- packages/pl-fe/src/actions/suggestions.ts | 2 +- packages/pl-fe/src/actions/timelines.ts | 2 +- .../pl-fe/src/actions/trending-statuses.ts | 2 +- .../components/quoted-status-indicator.tsx | 2 +- packages/pl-fe/src/components/status.tsx | 2 +- .../pl-fe/src/containers/status-container.tsx | 2 +- .../components/reply-group-indicator.tsx | 2 +- .../compose/components/reply-mentions.tsx | 2 +- .../containers/quoted-status-container.tsx | 2 +- .../containers/reply-indicator-container.tsx | 2 +- .../src/features/embedded-status/index.tsx | 2 +- .../src/features/event/event-discussion.tsx | 2 +- .../src/features/event/event-information.tsx | 2 +- .../events/components/event-carousel.tsx | 2 +- .../notifications/components/notification.tsx | 2 +- .../src/features/notifications/index.tsx | 4 +--- .../containers/quoted-status-container.tsx | 2 +- packages/pl-fe/src/features/status/index.tsx | 2 +- .../src/features/test-timeline/index.tsx | 2 +- .../ui/components/modals/boost-modal.tsx | 2 +- .../ui/components/modals/event-map-modal.tsx | 2 +- .../ui/components/modals/media-modal.tsx | 2 +- .../ui/components/modals/mentions-modal.tsx | 2 +- .../modals/reply-mentions-modal.tsx | 2 +- .../modals/select-bookmark-folder-modal.tsx | 2 +- .../ui/components/modals/video-modal.tsx | 2 +- packages/pl-fe/src/features/ui/index.tsx | 3 +-- packages/pl-fe/src/layouts/event-layout.tsx | 2 +- packages/pl-fe/src/queries/chats.ts | 2 +- packages/pl-fe/src/queries/suggestions.ts | 2 +- packages/pl-hooks/lib/main.ts | 12 +++++++++++ .../lib/normalizers/normalizeStatus.ts | 8 ++------ packages/pl-hooks/package.json | 5 +++-- packages/pl-hooks/yarn.lock | 20 +++++++++---------- 59 files changed, 82 insertions(+), 76 deletions(-) diff --git a/packages/pl-fe/src/actions/accounts.ts b/packages/pl-fe/src/actions/accounts.ts index bea1397b1..09344c31a 100644 --- a/packages/pl-fe/src/actions/accounts.ts +++ b/packages/pl-fe/src/actions/accounts.ts @@ -1,5 +1,5 @@ import { PLEROMA, type UpdateNotificationSettingsParams, type Account, type CreateAccountParams, type PaginatedResponse, type Relationship } from 'pl-api'; -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient, type PlfeResponse } from 'pl-fe/api'; import { Entities } from 'pl-fe/entity-store/entities'; diff --git a/packages/pl-fe/src/actions/admin.ts b/packages/pl-fe/src/actions/admin.ts index 2ea917a98..3458f9772 100644 --- a/packages/pl-fe/src/actions/admin.ts +++ b/packages/pl-fe/src/actions/admin.ts @@ -1,5 +1,5 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { fetchRelationships } from 'pl-fe/actions/accounts'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/aliases.ts b/packages/pl-fe/src/actions/aliases.ts index 3b914eb01..98f9791db 100644 --- a/packages/pl-fe/src/actions/aliases.ts +++ b/packages/pl-fe/src/actions/aliases.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { defineMessages } from 'react-intl'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/auth.ts b/packages/pl-fe/src/actions/auth.ts index 958e4d813..e5d202d14 100644 --- a/packages/pl-fe/src/actions/auth.ts +++ b/packages/pl-fe/src/actions/auth.ts @@ -7,7 +7,7 @@ * @see module:pl-fe/actions/security */ import { credentialAccountSchema, PlApiClient, type CreateAccountParams, type Token } from 'pl-api'; -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { defineMessages } from 'react-intl'; import * as v from 'valibot'; diff --git a/packages/pl-fe/src/actions/bookmarks.ts b/packages/pl-fe/src/actions/bookmarks.ts index 84e625e78..f4962de35 100644 --- a/packages/pl-fe/src/actions/bookmarks.ts +++ b/packages/pl-fe/src/actions/bookmarks.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/compose.ts b/packages/pl-fe/src/actions/compose.ts index 775f915b6..506dee075 100644 --- a/packages/pl-fe/src/actions/compose.ts +++ b/packages/pl-fe/src/actions/compose.ts @@ -1,5 +1,5 @@ import throttle from 'lodash/throttle'; -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { defineMessages, IntlShape } from 'react-intl'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/conversations.ts b/packages/pl-fe/src/actions/conversations.ts index c74bd11c0..f44956e1a 100644 --- a/packages/pl-fe/src/actions/conversations.ts +++ b/packages/pl-fe/src/actions/conversations.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; import { isLoggedIn } from 'pl-fe/utils/auth'; diff --git a/packages/pl-fe/src/actions/directory.ts b/packages/pl-fe/src/actions/directory.ts index fdc0557d1..8371808c3 100644 --- a/packages/pl-fe/src/actions/directory.ts +++ b/packages/pl-fe/src/actions/directory.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/emoji-reacts.ts b/packages/pl-fe/src/actions/emoji-reacts.ts index 01beefc25..7545d593d 100644 --- a/packages/pl-fe/src/actions/emoji-reacts.ts +++ b/packages/pl-fe/src/actions/emoji-reacts.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; import { isLoggedIn } from 'pl-fe/utils/auth'; diff --git a/packages/pl-fe/src/actions/events.ts b/packages/pl-fe/src/actions/events.ts index 13f4a07ba..6bb890aa0 100644 --- a/packages/pl-fe/src/actions/events.ts +++ b/packages/pl-fe/src/actions/events.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { defineMessages } from 'react-intl'; import { STATUS_FETCH_SOURCE_FAIL, STATUS_FETCH_SOURCE_REQUEST, STATUS_FETCH_SOURCE_SUCCESS } from 'pl-fe/actions/statuses'; diff --git a/packages/pl-fe/src/actions/familiar-followers.ts b/packages/pl-fe/src/actions/familiar-followers.ts index bf28b7a30..43d262ccd 100644 --- a/packages/pl-fe/src/actions/familiar-followers.ts +++ b/packages/pl-fe/src/actions/familiar-followers.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; import { AppDispatch, RootState } from 'pl-fe/store'; diff --git a/packages/pl-fe/src/actions/favourites.ts b/packages/pl-fe/src/actions/favourites.ts index 0edef7438..8fcc3658a 100644 --- a/packages/pl-fe/src/actions/favourites.ts +++ b/packages/pl-fe/src/actions/favourites.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; import { isLoggedIn } from 'pl-fe/utils/auth'; diff --git a/packages/pl-fe/src/actions/groups.ts b/packages/pl-fe/src/actions/groups.ts index 68c7f200b..580a3e8cb 100644 --- a/packages/pl-fe/src/actions/groups.ts +++ b/packages/pl-fe/src/actions/groups.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/history.ts b/packages/pl-fe/src/actions/history.ts index d12167a43..8727f2b43 100644 --- a/packages/pl-fe/src/actions/history.ts +++ b/packages/pl-fe/src/actions/history.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/interactions.ts b/packages/pl-fe/src/actions/interactions.ts index c5010096b..a4ffc1b31 100644 --- a/packages/pl-fe/src/actions/interactions.ts +++ b/packages/pl-fe/src/actions/interactions.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { defineMessages } from 'react-intl'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/lists.ts b/packages/pl-fe/src/actions/lists.ts index 2ec70deb3..a8dab04e7 100644 --- a/packages/pl-fe/src/actions/lists.ts +++ b/packages/pl-fe/src/actions/lists.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; import { selectAccount } from 'pl-fe/selectors'; diff --git a/packages/pl-fe/src/actions/me.ts b/packages/pl-fe/src/actions/me.ts index 462004e8c..31ae41515 100644 --- a/packages/pl-fe/src/actions/me.ts +++ b/packages/pl-fe/src/actions/me.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; import { selectAccount } from 'pl-fe/selectors'; diff --git a/packages/pl-fe/src/actions/notifications.ts b/packages/pl-fe/src/actions/notifications.ts index df82c8508..b4590e8e9 100644 --- a/packages/pl-fe/src/actions/notifications.ts +++ b/packages/pl-fe/src/actions/notifications.ts @@ -1,6 +1,6 @@ import IntlMessageFormat from 'intl-messageformat'; import 'intl-pluralrules'; -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { defineMessages } from 'react-intl'; import { FILTER_TYPES, type FilterType } from 'pl-fe/features/notifications'; diff --git a/packages/pl-fe/src/actions/pin-statuses.ts b/packages/pl-fe/src/actions/pin-statuses.ts index 9ee169a10..5cbf59bac 100644 --- a/packages/pl-fe/src/actions/pin-statuses.ts +++ b/packages/pl-fe/src/actions/pin-statuses.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; import { isLoggedIn } from 'pl-fe/utils/auth'; diff --git a/packages/pl-fe/src/actions/polls.ts b/packages/pl-fe/src/actions/polls.ts index d804828b0..0eeaeeeda 100644 --- a/packages/pl-fe/src/actions/polls.ts +++ b/packages/pl-fe/src/actions/polls.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/preload.ts b/packages/pl-fe/src/actions/preload.ts index 3fbab4a6e..72e8813cf 100644 --- a/packages/pl-fe/src/actions/preload.ts +++ b/packages/pl-fe/src/actions/preload.ts @@ -1,5 +1,5 @@ import mapValues from 'lodash/mapValues'; -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { verifyCredentials } from './auth'; diff --git a/packages/pl-fe/src/actions/search.ts b/packages/pl-fe/src/actions/search.ts index 49d933c1b..d6b5b1833 100644 --- a/packages/pl-fe/src/actions/search.ts +++ b/packages/pl-fe/src/actions/search.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; import { useSettingsStore } from 'pl-fe/stores'; diff --git a/packages/pl-fe/src/actions/settings.ts b/packages/pl-fe/src/actions/settings.ts index 61003930c..4728b33d3 100644 --- a/packages/pl-fe/src/actions/settings.ts +++ b/packages/pl-fe/src/actions/settings.ts @@ -1,4 +1,3 @@ -import { Account } from 'pl-hooks/normalizers/normalizeAccount'; import { defineMessage } from 'react-intl'; import { patchMe } from 'pl-fe/actions/me'; @@ -11,6 +10,7 @@ import toast from 'pl-fe/toast'; import { isLoggedIn } from 'pl-fe/utils/auth'; import type { AppDispatch, RootState } from 'pl-fe/store'; +import type { Account } from 'pl-hooks/normalizers/normalizeAccount'; const FE_NAME = 'pl_fe'; diff --git a/packages/pl-fe/src/actions/status-quotes.ts b/packages/pl-fe/src/actions/status-quotes.ts index 5b285c0fd..d1cd6375a 100644 --- a/packages/pl-fe/src/actions/status-quotes.ts +++ b/packages/pl-fe/src/actions/status-quotes.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/statuses.ts b/packages/pl-fe/src/actions/statuses.ts index cec4f6927..92399a447 100644 --- a/packages/pl-fe/src/actions/statuses.ts +++ b/packages/pl-fe/src/actions/statuses.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; import { useModalsStore, useSettingsStore } from 'pl-fe/stores'; diff --git a/packages/pl-fe/src/actions/suggestions.ts b/packages/pl-fe/src/actions/suggestions.ts index 68121589a..7ca7eb40a 100644 --- a/packages/pl-fe/src/actions/suggestions.ts +++ b/packages/pl-fe/src/actions/suggestions.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/timelines.ts b/packages/pl-fe/src/actions/timelines.ts index 8f0af94fc..511d16fd7 100644 --- a/packages/pl-fe/src/actions/timelines.ts +++ b/packages/pl-fe/src/actions/timelines.ts @@ -1,5 +1,5 @@ import { Map as ImmutableMap } from 'immutable'; -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getLocale } from 'pl-fe/actions/settings'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/actions/trending-statuses.ts b/packages/pl-fe/src/actions/trending-statuses.ts index aff18d35b..806182bbf 100644 --- a/packages/pl-fe/src/actions/trending-statuses.ts +++ b/packages/pl-fe/src/actions/trending-statuses.ts @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { getClient } from 'pl-fe/api'; diff --git a/packages/pl-fe/src/components/quoted-status-indicator.tsx b/packages/pl-fe/src/components/quoted-status-indicator.tsx index 34f3e7f7f..630aa479d 100644 --- a/packages/pl-fe/src/components/quoted-status-indicator.tsx +++ b/packages/pl-fe/src/components/quoted-status-indicator.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React from 'react'; import { HStack, Icon, Text } from 'pl-fe/components/ui'; diff --git a/packages/pl-fe/src/components/status.tsx b/packages/pl-fe/src/components/status.tsx index c3a1529be..0a9c5fa7c 100644 --- a/packages/pl-fe/src/components/status.tsx +++ b/packages/pl-fe/src/components/status.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx'; -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React, { useEffect, useRef } from 'react'; import { defineMessages, useIntl, FormattedList, FormattedMessage } from 'react-intl'; import { Link, useHistory } from 'react-router-dom'; diff --git a/packages/pl-fe/src/containers/status-container.tsx b/packages/pl-fe/src/containers/status-container.tsx index cc1ae14df..c436cf207 100644 --- a/packages/pl-fe/src/containers/status-container.tsx +++ b/packages/pl-fe/src/containers/status-container.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React from 'react'; import Status, { IStatus } from 'pl-fe/components/status'; diff --git a/packages/pl-fe/src/features/compose/components/reply-group-indicator.tsx b/packages/pl-fe/src/features/compose/components/reply-group-indicator.tsx index d3d900a80..dd1fea2f8 100644 --- a/packages/pl-fe/src/features/compose/components/reply-group-indicator.tsx +++ b/packages/pl-fe/src/features/compose/components/reply-group-indicator.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React from 'react'; import { FormattedMessage } from 'react-intl'; diff --git a/packages/pl-fe/src/features/compose/components/reply-mentions.tsx b/packages/pl-fe/src/features/compose/components/reply-mentions.tsx index 1d08a899b..c251d8c26 100644 --- a/packages/pl-fe/src/features/compose/components/reply-mentions.tsx +++ b/packages/pl-fe/src/features/compose/components/reply-mentions.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React from 'react'; import { FormattedList, FormattedMessage } from 'react-intl'; diff --git a/packages/pl-fe/src/features/compose/containers/quoted-status-container.tsx b/packages/pl-fe/src/features/compose/containers/quoted-status-container.tsx index bbcff3515..066e5e4bc 100644 --- a/packages/pl-fe/src/features/compose/containers/quoted-status-container.tsx +++ b/packages/pl-fe/src/features/compose/containers/quoted-status-container.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React from 'react'; import { cancelQuoteCompose } from 'pl-fe/actions/compose'; diff --git a/packages/pl-fe/src/features/compose/containers/reply-indicator-container.tsx b/packages/pl-fe/src/features/compose/containers/reply-indicator-container.tsx index 338ca170f..b4dbb052c 100644 --- a/packages/pl-fe/src/features/compose/containers/reply-indicator-container.tsx +++ b/packages/pl-fe/src/features/compose/containers/reply-indicator-container.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React from 'react'; import { cancelReplyCompose } from 'pl-fe/actions/compose'; diff --git a/packages/pl-fe/src/features/embedded-status/index.tsx b/packages/pl-fe/src/features/embedded-status/index.tsx index 6d310fb78..227dc7b8e 100644 --- a/packages/pl-fe/src/features/embedded-status/index.tsx +++ b/packages/pl-fe/src/features/embedded-status/index.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React, { useEffect } from 'react'; import { useHistory } from 'react-router-dom'; diff --git a/packages/pl-fe/src/features/event/event-discussion.tsx b/packages/pl-fe/src/features/event/event-discussion.tsx index fc1d243cd..f3a16753c 100644 --- a/packages/pl-fe/src/features/event/event-discussion.tsx +++ b/packages/pl-fe/src/features/event/event-discussion.tsx @@ -1,5 +1,5 @@ import { List as ImmutableList, OrderedSet as ImmutableOrderedSet } from 'immutable'; -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React, { useEffect, useRef, useState } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; diff --git a/packages/pl-fe/src/features/event/event-information.tsx b/packages/pl-fe/src/features/event/event-information.tsx index c90b1c48e..29d612b0a 100644 --- a/packages/pl-fe/src/features/event/event-information.tsx +++ b/packages/pl-fe/src/features/event/event-information.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React, { useCallback } from 'react'; import { FormattedDate, FormattedMessage } from 'react-intl'; diff --git a/packages/pl-fe/src/features/events/components/event-carousel.tsx b/packages/pl-fe/src/features/events/components/event-carousel.tsx index a8c9910e8..7996b90f5 100644 --- a/packages/pl-fe/src/features/events/components/event-carousel.tsx +++ b/packages/pl-fe/src/features/events/components/event-carousel.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React, { useState } from 'react'; import { Link } from 'react-router-dom'; import ReactSwipeableViews from 'react-swipeable-views'; diff --git a/packages/pl-fe/src/features/notifications/components/notification.tsx b/packages/pl-fe/src/features/notifications/components/notification.tsx index 47cdefd27..0a3abb67a 100644 --- a/packages/pl-fe/src/features/notifications/components/notification.tsx +++ b/packages/pl-fe/src/features/notifications/components/notification.tsx @@ -1,4 +1,4 @@ -import { useNotification } from 'pl-hooks/hooks/notifications/useNotification'; +import { useNotification } from 'pl-hooks'; import React, { useCallback } from 'react'; import { defineMessages, useIntl, FormattedList, FormattedMessage, IntlShape, MessageDescriptor } from 'react-intl'; import { Link, useHistory } from 'react-router-dom'; diff --git a/packages/pl-fe/src/features/notifications/index.tsx b/packages/pl-fe/src/features/notifications/index.tsx index 6526ea704..591f5743d 100644 --- a/packages/pl-fe/src/features/notifications/index.tsx +++ b/packages/pl-fe/src/features/notifications/index.tsx @@ -1,8 +1,6 @@ import clsx from 'clsx'; import debounce from 'lodash/debounce'; -import { useMarker } from 'pl-hooks/hooks/markers/useMarkers'; -import { useUpdateMarkerMutation } from 'pl-hooks/hooks/markers/useUpdateMarkerMutation'; -import { useNotificationList } from 'pl-hooks/hooks/notifications/useNotificationList'; +import { useMarker, useNotificationList, useUpdateMarkerMutation } from 'pl-hooks'; import React, { useCallback, useEffect, useRef } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; diff --git a/packages/pl-fe/src/features/status/containers/quoted-status-container.tsx b/packages/pl-fe/src/features/status/containers/quoted-status-container.tsx index 6c28326a5..63a1b5f23 100644 --- a/packages/pl-fe/src/features/status/containers/quoted-status-container.tsx +++ b/packages/pl-fe/src/features/status/containers/quoted-status-container.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React from 'react'; import QuotedStatus from 'pl-fe/components/quoted-status'; diff --git a/packages/pl-fe/src/features/status/index.tsx b/packages/pl-fe/src/features/status/index.tsx index 00f0c0cb0..0290c12a3 100644 --- a/packages/pl-fe/src/features/status/index.tsx +++ b/packages/pl-fe/src/features/status/index.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React, { useEffect } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { Redirect } from 'react-router-dom'; diff --git a/packages/pl-fe/src/features/test-timeline/index.tsx b/packages/pl-fe/src/features/test-timeline/index.tsx index c81c2c692..2a3434a62 100644 --- a/packages/pl-fe/src/features/test-timeline/index.tsx +++ b/packages/pl-fe/src/features/test-timeline/index.tsx @@ -1,4 +1,4 @@ -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import React from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; diff --git a/packages/pl-fe/src/features/ui/components/modals/boost-modal.tsx b/packages/pl-fe/src/features/ui/components/modals/boost-modal.tsx index 5f1a798b0..f8488fb51 100644 --- a/packages/pl-fe/src/features/ui/components/modals/boost-modal.tsx +++ b/packages/pl-fe/src/features/ui/components/modals/boost-modal.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; diff --git a/packages/pl-fe/src/features/ui/components/modals/event-map-modal.tsx b/packages/pl-fe/src/features/ui/components/modals/event-map-modal.tsx index 8f651218e..b80537f2f 100644 --- a/packages/pl-fe/src/features/ui/components/modals/event-map-modal.tsx +++ b/packages/pl-fe/src/features/ui/components/modals/event-map-modal.tsx @@ -1,5 +1,5 @@ import L from 'leaflet'; -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React, { useEffect, useRef } from 'react'; import { FormattedMessage } from 'react-intl'; diff --git a/packages/pl-fe/src/features/ui/components/modals/media-modal.tsx b/packages/pl-fe/src/features/ui/components/modals/media-modal.tsx index a18d82454..7dbf08279 100644 --- a/packages/pl-fe/src/features/ui/components/modals/media-modal.tsx +++ b/packages/pl-fe/src/features/ui/components/modals/media-modal.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx'; -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React, { useEffect, useState } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; diff --git a/packages/pl-fe/src/features/ui/components/modals/mentions-modal.tsx b/packages/pl-fe/src/features/ui/components/modals/mentions-modal.tsx index 4d97e1c22..5c9280425 100644 --- a/packages/pl-fe/src/features/ui/components/modals/mentions-modal.tsx +++ b/packages/pl-fe/src/features/ui/components/modals/mentions-modal.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React, { useEffect, useRef } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; diff --git a/packages/pl-fe/src/features/ui/components/modals/reply-mentions-modal.tsx b/packages/pl-fe/src/features/ui/components/modals/reply-mentions-modal.tsx index 0a8b78a0b..644189f09 100644 --- a/packages/pl-fe/src/features/ui/components/modals/reply-mentions-modal.tsx +++ b/packages/pl-fe/src/features/ui/components/modals/reply-mentions-modal.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React from 'react'; import { FormattedMessage } from 'react-intl'; diff --git a/packages/pl-fe/src/features/ui/components/modals/select-bookmark-folder-modal.tsx b/packages/pl-fe/src/features/ui/components/modals/select-bookmark-folder-modal.tsx index 76bd3b89e..86668e6f0 100644 --- a/packages/pl-fe/src/features/ui/components/modals/select-bookmark-folder-modal.tsx +++ b/packages/pl-fe/src/features/ui/components/modals/select-bookmark-folder-modal.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React, { useState } from 'react'; import { FormattedMessage } from 'react-intl'; diff --git a/packages/pl-fe/src/features/ui/components/modals/video-modal.tsx b/packages/pl-fe/src/features/ui/components/modals/video-modal.tsx index b8f052aac..685bed699 100644 --- a/packages/pl-fe/src/features/ui/components/modals/video-modal.tsx +++ b/packages/pl-fe/src/features/ui/components/modals/video-modal.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; diff --git a/packages/pl-fe/src/features/ui/index.tsx b/packages/pl-fe/src/features/ui/index.tsx index 12ea70c4c..124cdc1a8 100644 --- a/packages/pl-fe/src/features/ui/index.tsx +++ b/packages/pl-fe/src/features/ui/index.tsx @@ -1,6 +1,5 @@ import clsx from 'clsx'; -import { prefetchMarker } from 'pl-hooks/hooks/markers/useMarkers'; -import { prefetchNotifications } from 'pl-hooks/hooks/notifications/useNotificationList'; +import { prefetchMarker, prefetchNotifications } from 'pl-hooks'; import React, { Suspense, lazy, useEffect, useRef } from 'react'; import { Switch, useHistory, useLocation, Redirect } from 'react-router-dom'; diff --git a/packages/pl-fe/src/layouts/event-layout.tsx b/packages/pl-fe/src/layouts/event-layout.tsx index a7e3a9af6..e85d1d1c7 100644 --- a/packages/pl-fe/src/layouts/event-layout.tsx +++ b/packages/pl-fe/src/layouts/event-layout.tsx @@ -1,4 +1,4 @@ -import { useStatus } from 'pl-hooks/hooks/statuses/useStatus'; +import { useStatus } from 'pl-hooks'; import React from 'react'; import { Helmet } from 'react-helmet-async'; import { FormattedMessage } from 'react-intl'; diff --git a/packages/pl-fe/src/queries/chats.ts b/packages/pl-fe/src/queries/chats.ts index a2c7aab8c..88b52b041 100644 --- a/packages/pl-fe/src/queries/chats.ts +++ b/packages/pl-fe/src/queries/chats.ts @@ -1,7 +1,7 @@ import { InfiniteData, keepPreviousData, useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query'; import sumBy from 'lodash/sumBy'; import { type Chat, type ChatMessage as BaseChatMessage, type PaginatedResponse, chatMessageSchema, type Relationship } from 'pl-api'; -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import * as v from 'valibot'; import { ChatWidgetScreens, useChatContext } from 'pl-fe/contexts/chat-context'; diff --git a/packages/pl-fe/src/queries/suggestions.ts b/packages/pl-fe/src/queries/suggestions.ts index 096abcd98..028c5173e 100644 --- a/packages/pl-fe/src/queries/suggestions.ts +++ b/packages/pl-fe/src/queries/suggestions.ts @@ -1,5 +1,5 @@ import { useMutation, keepPreviousData, useQuery } from '@tanstack/react-query'; -import { importEntities } from 'pl-hooks/importer'; +import { importEntities } from 'pl-hooks'; import { fetchRelationships } from 'pl-fe/actions/accounts'; import { useAppDispatch, useClient } from 'pl-fe/hooks'; diff --git a/packages/pl-hooks/lib/main.ts b/packages/pl-hooks/lib/main.ts index e69de29bb..c35d0e772 100644 --- a/packages/pl-hooks/lib/main.ts +++ b/packages/pl-hooks/lib/main.ts @@ -0,0 +1,12 @@ +export * from './contexts/api-client'; +export * from './contexts/query-client'; + +export * from './hooks/accounts/useAccount'; +export * from './hooks/accounts/useAccountRelationship'; +export * from './hooks/markers/useMarkers'; +export * from './hooks/markers/useUpdateMarkerMutation'; +export * from './hooks/notifications/useNotification'; +export * from './hooks/notifications/useNotificationList'; +export * from './hooks/statuses/useStatus'; + +export * from './importer'; diff --git a/packages/pl-hooks/lib/normalizers/normalizeStatus.ts b/packages/pl-hooks/lib/normalizers/normalizeStatus.ts index aa5666483..3010ac232 100644 --- a/packages/pl-hooks/lib/normalizers/normalizeStatus.ts +++ b/packages/pl-hooks/lib/normalizers/normalizeStatus.ts @@ -1,9 +1,5 @@ -/** - * Status normalizer: - * Converts API statuses into our internal format. - * @see {@link https://docs.joinmastodon.org/entities/status/} - */ import { type Account as BaseAccount, type Status as BaseStatus, type MediaAttachment, mentionSchema } from 'pl-api'; +import * as v from 'valibot'; type StatusApprovalStatus = Exclude; type StatusVisibility = 'public' | 'unlisted' | 'private' | 'direct' | 'group' | 'mutuals_only' | 'local'; @@ -23,7 +19,7 @@ const normalizeStatus = ({ account, accounts, reblog, poll, group, quote, ...sta const hasSelfMention = status.mentions.some(mention => account.id === mention.id); if (isSelfReply && !hasSelfMention) { - const selfMention = mentionSchema.parse(account); + const selfMention = v.parse(mentionSchema, account); mentions = [selfMention, ...mentions]; } diff --git a/packages/pl-hooks/package.json b/packages/pl-hooks/package.json index 2639c640f..b0c3197bf 100644 --- a/packages/pl-hooks/package.json +++ b/packages/pl-hooks/package.json @@ -35,8 +35,9 @@ "dependencies": { "@tanstack/react-query": "^5.56.2", "lodash": "^4.17.21", - "pl-api": "^0.0.37", - "react": "^18.3.1" + "pl-api": "^0.1.1", + "react": "^18.3.1", + "valibot": "^0.42.1" }, "module": "./dist/main.es.js", "types": "dist/main.d.ts", diff --git a/packages/pl-hooks/yarn.lock b/packages/pl-hooks/yarn.lock index 7a12169dc..e11017c1a 100644 --- a/packages/pl-hooks/yarn.lock +++ b/packages/pl-hooks/yarn.lock @@ -2138,10 +2138,10 @@ pkg-types@^1.0.3, pkg-types@^1.1.1: mlly "^1.7.1" pathe "^1.1.2" -pl-api@^0.0.37: - version "0.0.37" - resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.0.37.tgz#1475be139a3733b8a60dc3dd5fdfb00f83743eea" - integrity sha512-oCeKkJtUYC5XwM5PIVt+VPdLrJT7rjvfXgiv+qrUydK++cHnO1ZiixCaBnYW3M5D1BLZ6/OS4T+mk5hlCt8+1g== +pl-api@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.1.1.tgz#e3465482697ea53e10bba510c5217c42b1d40ab0" + integrity sha512-JFao273dOG9XgrunqlfJn+e3DUr001MePCmJasQwaX3aPjM/L158hKfCnYPmoDKn1u5bfekMK6tVauBtbnkmqA== dependencies: blurhash "^2.0.5" http-link-header "^1.1.3" @@ -2149,7 +2149,7 @@ pl-api@^0.0.37: object-to-formdata "^4.5.1" query-string "^9.1.0" semver "^7.6.3" - zod "^3.23.8" + valibot "^0.42.1" possible-typed-array-names@^1.0.0: version "1.0.0" @@ -2586,6 +2586,11 @@ uri-js@^4.2.2, uri-js@^4.4.1: dependencies: punycode "^2.1.0" +valibot@^0.42.1: + version "0.42.1" + resolved "https://registry.yarnpkg.com/valibot/-/valibot-0.42.1.tgz#a31183d8e9d7552f98e22ca0977172cab8815188" + integrity sha512-3keXV29Ar5b//Hqi4MbSdV7lfVp6zuYLZuA9V1PvQUsXqogr+u5lvLPLk3A4f74VUXDnf/JfWMN6sB+koJ/FFw== + vite-plugin-dts@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/vite-plugin-dts/-/vite-plugin-dts-4.2.1.tgz#f8bee33b732929717ce13ef7a382696d51200c30" @@ -2665,8 +2670,3 @@ yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== - -zod@^3.23.8: - version "3.23.8" - resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" - integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==