From 493372668dc89caeaf88303ebe94250fb2731e2d Mon Sep 17 00:00:00 2001 From: Beatrice Guerra Date: Fri, 27 Jan 2023 16:42:14 +0100 Subject: [PATCH] fix: use DS local fonts instead of downloading them from third-party source * style: update carbonio configs package * fix: move out implementations from d.ts files * chore: ignore carbonio tgz packages * fix: us DS local fonts instead of downloading them from google refs: IRIS-3443 (#184) --- .gitignore | 3 +- package-lock.json | 16 +- package.json | 3 +- src/boot/theme-provider.tsx | 2 +- src/custom-hooks/useDarkReaderResultValue.ts | 23 +- src/index.template.html | 6 - src/index.tsx | 4 - src/reporting/store.ts | 3 +- .../dark-theme-settings-section.tsx | 7 +- src/shell/shell-view.tsx | 10 +- src/store/integrations/store.ts | 3 +- src/utility-bar/bar.tsx | 3 +- types/account/index.d.ts | 11 +- types/exports/index.d.ts | 274 +++++++++--------- types/misc/index.d.ts | 9 - 15 files changed, 181 insertions(+), 196 deletions(-) diff --git a/.gitignore b/.gitignore index e4798da6..58d71f84 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ /coverage/cobertura-coverage.xml /.vscode/ /.idea/ -.dev.json \ No newline at end of file +.dev.json +zextras-carbonio-*.tgz diff --git a/package-lock.json b/package-lock.json index 781e6c59..1f092a38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "hasInstallScript": true, "license": "AGPL-3.0-only", "dependencies": { - "@fontsource/roboto": "^4.5.7", "@sentry/browser": "^6.17.7", "@tinymce/tinymce-react": "^3.13.0", "@zextras/carbonio-design-system": "^1.0.1", @@ -2310,11 +2309,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@fontsource/roboto": { - "version": "4.5.7", - "resolved": "https://registry.npmjs.org/@fontsource/roboto/-/roboto-4.5.7.tgz", - "integrity": "sha512-m57UMER23Mk6Drg9OjtHW1Y+0KPGyZfE5XJoPTOsLARLar6013kJj4X2HICt+iFLJqIgTahA/QAvSn9lwF1EEw==" - }, "node_modules/@humanwhocodes/config-array": { "version": "0.5.0", "dev": true, @@ -3941,8 +3935,9 @@ }, "node_modules/@zextras/carbonio-ui-configs": { "version": "0.1.11", + "resolved": "https://registry.npmjs.org/@zextras/carbonio-ui-configs/-/carbonio-ui-configs-0.1.11.tgz", + "integrity": "sha512-JwE7YwNaH7jEbpEnv1amDMtnekj7UsCeprxyPCpNNpx9r+rfVU965ac0W32I4DZHu4rir8U6JTYXRuI+kJKaJg==", "dev": true, - "license": "AGPL-3.0-only", "dependencies": { "@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/parser": "^5.4.0", @@ -16592,11 +16587,6 @@ } } }, - "@fontsource/roboto": { - "version": "4.5.7", - "resolved": "https://registry.npmjs.org/@fontsource/roboto/-/roboto-4.5.7.tgz", - "integrity": "sha512-m57UMER23Mk6Drg9OjtHW1Y+0KPGyZfE5XJoPTOsLARLar6013kJj4X2HICt+iFLJqIgTahA/QAvSn9lwF1EEw==" - }, "@humanwhocodes/config-array": { "version": "0.5.0", "dev": true, @@ -17689,6 +17679,8 @@ }, "@zextras/carbonio-ui-configs": { "version": "0.1.11", + "resolved": "https://registry.npmjs.org/@zextras/carbonio-ui-configs/-/carbonio-ui-configs-0.1.11.tgz", + "integrity": "sha512-JwE7YwNaH7jEbpEnv1amDMtnekj7UsCeprxyPCpNNpx9r+rfVU965ac0W32I4DZHu4rir8U6JTYXRuI+kJKaJg==", "dev": true, "requires": { "@typescript-eslint/eslint-plugin": "^5.4.0", diff --git a/package.json b/package.json index 7a6c22f9..724c4cc1 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "postpublish": "pinst --enable && rm -rf lib", "type-check": "tsc --noEmit", "type-check:watch": "npm run type-check -- --watch", - "lint": "eslint --ext .js,.jsx,.ts,.tsx --resolve-plugins-relative-to node_modules/@zextras/zapp-config src", + "lint": "eslint --ext .js,.jsx,.ts,.tsx --resolve-plugins-relative-to node_modules/@zextras/carbonio-ui-configs src", "build": "sdk build", "deploy": "sdk deploy", "start": "sdk watch", @@ -97,7 +97,6 @@ "webpack-merge": "5.8.0" }, "dependencies": { - "@fontsource/roboto": "^4.5.7", "@sentry/browser": "^6.17.7", "@tinymce/tinymce-react": "^3.13.0", "@zextras/carbonio-design-system": "^1.0.1", diff --git a/src/boot/theme-provider.tsx b/src/boot/theme-provider.tsx index c7ff771d..5cb46afc 100644 --- a/src/boot/theme-provider.tsx +++ b/src/boot/theme-provider.tsx @@ -145,7 +145,7 @@ export const ThemeProvider: FC = ({ children }) => { }, [localStorageSettings]); return ( - + {children} diff --git a/src/custom-hooks/useDarkReaderResultValue.ts b/src/custom-hooks/useDarkReaderResultValue.ts index d78b6b03..22b1bc62 100644 --- a/src/custom-hooks/useDarkReaderResultValue.ts +++ b/src/custom-hooks/useDarkReaderResultValue.ts @@ -8,12 +8,23 @@ import { useMemo } from 'react'; import { find, size } from 'lodash'; import { useUserSettings } from '../store/account'; import { useLoginConfigStore } from '../store/login/store'; -import { - DarkReaderPropValues, - isZappDarkreaderModeZimletProp, - ZappDarkreaderModeZimletProp, - ZimletProp -} from '../../types'; +import type { DarkReaderPropValues, ZappDarkreaderModeZimletProp, ZimletProp } from '../../types'; +import { DARK_READER_PROP_KEY, DARK_READER_VALUES, SHELL_APP_ID } from '../constants'; + +export function isZappDarkreaderModeZimletProp( + prop: ZimletProp +): prop is ZappDarkreaderModeZimletProp { + return prop.name === DARK_READER_PROP_KEY && prop.zimlet === SHELL_APP_ID; +} + +export function isDarkReaderPropValues( + maybeDarkReaderPropValue: unknown +): maybeDarkReaderPropValue is DarkReaderPropValues { + return ( + typeof maybeDarkReaderPropValue === 'string' && + DARK_READER_VALUES.includes(maybeDarkReaderPropValue as DarkReaderPropValues) + ); +} // return the final calculated value between ZappDarkreaderModeZimletProp value and carbonioWebUiDarkMode config export function useDarkReaderResultValue(): undefined | DarkReaderPropValues { diff --git a/src/index.template.html b/src/index.template.html index d4812b45..da88f966 100644 --- a/src/index.template.html +++ b/src/index.template.html @@ -16,12 +16,6 @@ - - - - - - diff --git a/src/index.tsx b/src/index.tsx index aee6ca75..7e43512e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -10,10 +10,6 @@ import './index.css'; import React, { lazy, Suspense } from 'react'; import { render } from 'react-dom'; import LoadingView from './boot/splash'; -import '@fontsource/roboto/300.css'; -import '@fontsource/roboto/400.css'; -import '@fontsource/roboto/500.css'; -import '@fontsource/roboto/700.css'; window.addEventListener('contextmenu', (ev) => { if ( diff --git a/src/reporting/store.ts b/src/reporting/store.ts index 27916ee8..92e7245b 100644 --- a/src/reporting/store.ts +++ b/src/reporting/store.ts @@ -7,7 +7,8 @@ import create, { StoreApi, UseBoundStore } from 'zustand'; import { BrowserClient, Hub } from '@sentry/browser'; import { reduce } from 'lodash'; -import { CarbonioModule, SHELL_APP_ID } from '../../types'; +import type { CarbonioModule } from '../../types'; +import { SHELL_APP_ID } from '../constants'; type ReporterState = { clients: Record; diff --git a/src/settings/components/general-settings/dark-theme-settings-section.tsx b/src/settings/components/general-settings/dark-theme-settings-section.tsx index 5aaca6f9..6213e5d9 100644 --- a/src/settings/components/general-settings/dark-theme-settings-section.tsx +++ b/src/settings/components/general-settings/dark-theme-settings-section.tsx @@ -7,11 +7,14 @@ import { Select, SelectItem, SingleSelectionOnChange, Text } from '@zextras/carbonio-design-system'; import { find } from 'lodash'; import React, { FC, useCallback, useContext, useEffect, useMemo, useState } from 'react'; -import { AddMod, DarkReaderPropValues, isDarkReaderPropValues, RemoveMod } from '../../../../types'; +import type { AddMod, DarkReaderPropValues, RemoveMod } from '../../../../types'; import { ThemeCallbacksContext } from '../../../boot/theme-provider'; import { DARK_READER_PROP_KEY, SHELL_APP_ID } from '../../../constants'; import { getT } from '../../../store/i18n'; -import { useDarkReaderResultValue } from '../../../custom-hooks/useDarkReaderResultValue'; +import { + isDarkReaderPropValues, + useDarkReaderResultValue +} from '../../../custom-hooks/useDarkReaderResultValue'; const DarkThemeSettingSection: FC<{ addMod: AddMod; diff --git a/src/shell/shell-view.tsx b/src/shell/shell-view.tsx index a5347dd6..77732500 100644 --- a/src/shell/shell-view.tsx +++ b/src/shell/shell-view.tsx @@ -6,15 +6,9 @@ import { Responsive, Row } from '@zextras/carbonio-design-system'; import { PreviewManager } from '@zextras/carbonio-ui-preview'; -import { find, size } from 'lodash'; -import React, { FC, useContext, useEffect, useMemo, useState } from 'react'; +import React, { FC, useContext, useEffect, useState } from 'react'; import styled from 'styled-components'; -import { - AppRoute, - isZappDarkreaderModeZimletProp, - ZappDarkreaderModeZimletProp, - ZimletProp -} from '../../types'; +import type { AppRoute } from '../../types'; import { ThemeCallbacksContext } from '../boot/theme-provider'; import { IS_STANDALONE } from '../constants'; import { useCurrentRoute } from '../history/hooks'; diff --git a/src/store/integrations/store.ts b/src/store/integrations/store.ts index 5fc037d8..9213e3f7 100644 --- a/src/store/integrations/store.ts +++ b/src/store/integrations/store.ts @@ -8,8 +8,9 @@ import produce from 'immer'; import create from 'zustand'; import { forEach, omit, reduce } from 'lodash'; import { ComponentType } from 'react'; -import { ActionFactory, AnyFunction, IntegrationsState, SHELL_APP_ID } from '../../../types'; +import type { ActionFactory, AnyFunction, IntegrationsState } from '../../../types'; import Composer from './composer'; +import { SHELL_APP_ID } from '../../constants'; export const useIntegrationsStore = create((set) => ({ actions: {}, diff --git a/src/utility-bar/bar.tsx b/src/utility-bar/bar.tsx index c3c6695e..9249965b 100644 --- a/src/utility-bar/bar.tsx +++ b/src/utility-bar/bar.tsx @@ -12,7 +12,7 @@ import { } from '@zextras/carbonio-design-system'; import { map, noop } from 'lodash'; import React, { FC, useCallback, useMemo } from 'react'; -import { SHELL_APP_ID, UtilityView } from '../../types'; +import type { UtilityView } from '../../types'; import { noOp } from '../network/fetch'; import { logout } from '../network/logout'; import { useUserAccount } from '../store/account'; @@ -20,6 +20,7 @@ import { addBoard } from '../store/boards'; import { getT } from '../store/i18n'; import { useUtilityBarStore } from './store'; import { useUtilityViews } from './utils'; +import { SHELL_APP_ID } from '../constants'; const UtilityBarItem: FC<{ view: UtilityView }> = ({ view }) => { const { mode, setMode, current, setCurrent } = useUtilityBarStore(); diff --git a/types/account/index.d.ts b/types/account/index.d.ts index 413bb721..e5aae2ef 100644 --- a/types/account/index.d.ts +++ b/types/account/index.d.ts @@ -4,8 +4,9 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { DARK_READER_PROP_KEY, SHELL_APP_ID } from '../../src/constants'; -import { DarkReaderPropValues } from '../misc'; +import type { DarkReaderPropValues } from '../misc'; +import { DARK_READER_PROP_KEY } from '../../src/constants'; +import type { SHELL_APP_ID } from '../exports'; export interface ZimletProp { name: string; @@ -19,12 +20,6 @@ export interface ZappDarkreaderModeZimletProp extends ZimletProp { _content: DarkReaderPropValues; } -export function isZappDarkreaderModeZimletProp( - prop: ZimletProp -): ZimletProp is ZappDarkreaderModeZimletProp { - return prop.name === DARK_READER_PROP_KEY && prop.zimlet === SHELL_APP_ID; -} - export type SoapFetch = ( api: string, body: Request, diff --git a/types/exports/index.d.ts b/types/exports/index.d.ts index b6a4a1e1..efde6ad2 100644 --- a/types/exports/index.d.ts +++ b/types/exports/index.d.ts @@ -3,7 +3,6 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -/* eslint-disable @typescript-eslint/ban-types */ import { i18n } from 'i18next'; import { ComponentType, Dispatch, FC, SetStateAction } from 'react'; @@ -38,204 +37,211 @@ import { INotificationManager } from '../notification'; import { QueryChip } from '../search'; import { Tag, Tags } from '../tags'; -export const getBridgedFunctions: () => { +declare const getBridgedFunctions: () => { createModal: (...params: any[]) => void; createSnackbar: (...params: any[]) => void; getHistory: () => History; }; -export const editSettings: (mods: Mods) => Promise; -export const ZIMBRA_STANDARD_COLORS: Array<{ zValue: number; hex: string; zLabel: string }>; -export const FOLDERS: { +declare const editSettings: (mods: Mods) => Promise; +declare const ZIMBRA_STANDARD_COLORS: Array<{ zValue: number; hex: string; zLabel: string }>; +declare const FOLDERS: { [name: string]: string; }; -export const SHELL_APP_ID = 'carbonio-shell-ui'; -export const SETTINGS_APP_ID = 'settings'; -export const SEARCH_APP_ID = 'search'; -export const ACTION_TYPES: { +declare const SHELL_APP_ID = 'carbonio-shell-ui'; +declare const SETTINGS_APP_ID = 'settings'; +declare const SEARCH_APP_ID = 'search'; +declare const ACTION_TYPES: { [name: string]: string; }; -export const ROOT_NAME: string; -export const SHELL_MODES: Record; -export const BASENAME: string; - -export const IS_STANDALONE: boolean; - -export const getIntegratedHook: (id: string) => [Function, boolean]; -export const getIntegratedFunction: (id: string) => [Function, boolean]; -export const getIntegratedComponent: (id: string) => [ComponentType, boolean]; -export const getActions: (target: T, type: string) => Array; -export const getActionsFactory: (type: string) => (target: T) => Array; -export const getAction: (type: string, id: string, target?: T) => [Action | undefined, boolean]; -export const getActionFactory: ( +declare const ROOT_NAME: string; +declare const SHELL_MODES: Record; +declare const BASENAME: string; + +declare const IS_STANDALONE: boolean; + +// eslint-disable-next-line @typescript-eslint/ban-types +declare const getIntegratedHook: (id: string) => [Function, boolean]; +// eslint-disable-next-line @typescript-eslint/ban-types +declare const getIntegratedFunction: (id: string) => [Function, boolean]; +declare const getIntegratedComponent: (id: string) => [ComponentType, boolean]; +declare const getActions: (target: T, type: string) => Array; +declare const getActionsFactory: (type: string) => (target: T) => Array; +declare const getAction: (type: string, id: string, target?: T) => [Action | undefined, boolean]; +declare const getActionFactory: ( type: string, id: string ) => [ActionFactory | undefined, boolean]; -export const useIntegratedHook: (id: string) => [Function, boolean]; -export const useIntegratedFunction: (id: string) => [Function, boolean]; -export const useIntegratedComponent: (id: string) => [ComponentType, boolean]; -export const useActions: (target: T, type: string) => Array; -export const useActionsFactory: (type: string) => CombinedActionFactory; -export const useAction: (type: string, id: string, target?: T) => [Action | undefined, boolean]; -export const useActionFactory: ( +// eslint-disable-next-line @typescript-eslint/ban-types +declare const useIntegratedHook: (id: string) => [Function, boolean]; +// eslint-disable-next-line @typescript-eslint/ban-types +declare const useIntegratedFunction: (id: string) => [Function, boolean]; +declare const useIntegratedComponent: (id: string) => [ComponentType, boolean]; +declare const useActions: (target: T, type: string) => Array; +declare const useActionsFactory: (type: string) => CombinedActionFactory; +declare const useAction: (type: string, id: string, target?: T) => [Action | undefined, boolean]; +declare const useActionFactory: ( type: string, id: string ) => [ActionFactory | undefined, boolean]; -export const useApp: () => CarbonioModule; -export const getApp: () => CarbonioModule; -export const useAppContext: () => T; -export const getAppContext: () => T; -export const useUserAccount: () => Account; -export const useUserAccounts: () => Array; -export const useUserRights: () => AccountRights; -export const useUserRight: (right: AccountRightName) => Array; -export const getUserAccount: () => Account; -export const getUserAccounts: () => Array; -export const getUserRights: () => AccountRights; -export const getUserRight: (right: AccountRightName) => Array; -export const useTags: () => Tags; -export const getTags: () => Tags; -export const useTag: (id: string) => Tag; -export const getTag: (id: string) => Tag; -export const useFolder: (id: string) => BaseFolder | Folder | LinkFolder; -export const getFolder: (id: string) => BaseFolder | Folder | LinkFolder; -export const useFolders: () => Folders; -export const getFolders: () => Folders; -export const useRoot: (name: string) => Folder; -export const getRoot: (name: string) => Folder; -export const useRoots: () => Roots; -export const getRoots: () => Roots; -export const useRootByView: (view: string) => Folder; -export const getRootByView: (view: string) => Folder; -export const createTag: (tag: Omit) => Promise; -export const renameTag: (id: string, name: string) => Promise; -export const deleteTag: (id: string) => Promise; -export const changeTagColor: (id: string, color: number | string) => Promise; -export const useUserSettings: () => AccountSettings; -export const useUserSetting: (...path: Array) => string | T; -export const getUserSettings: () => AccountSettings; -export const getUserSetting: (...path: Array) => string | T; -export const useNotify: () => Array; -export const useRefresh: () => SoapRefresh; -export const AppLink: FC; -export const Spinner: FC; - -export const useIsMobile: () => boolean; -export const soapFetch: SoapFetch; -export const xmlSoapFetch: SoapFetch; -export const report: (error: Error, hint?: unknown) => void; -export const setAppContext: (obj: T) => void; - -export const removeActions: (...ids: Array) => void; -export const registerActions: ( +declare const useApp: () => CarbonioModule; +declare const getApp: () => CarbonioModule; +declare const useAppContext: () => T; +declare const getAppContext: () => T; +declare const useUserAccount: () => Account; +declare const useUserAccounts: () => Array; +declare const useUserRights: () => AccountRights; +declare const useUserRight: (right: AccountRightName) => Array; +declare const getUserAccount: () => Account; +declare const getUserAccounts: () => Array; +declare const getUserRights: () => AccountRights; +declare const getUserRight: (right: AccountRightName) => Array; +declare const useTags: () => Tags; +declare const getTags: () => Tags; +declare const useTag: (id: string) => Tag; +declare const getTag: (id: string) => Tag; +declare const useFolder: (id: string) => BaseFolder | Folder | LinkFolder; +declare const getFolder: (id: string) => BaseFolder | Folder | LinkFolder; +declare const useFolders: () => Folders; +declare const getFolders: () => Folders; +declare const useRoot: (name: string) => Folder; +declare const getRoot: (name: string) => Folder; +declare const useRoots: () => Roots; +declare const getRoots: () => Roots; +declare const useRootByView: (view: string) => Folder; +declare const getRootByView: (view: string) => Folder; +declare const createTag: (tag: Omit) => Promise; +declare const renameTag: (id: string, name: string) => Promise; +declare const deleteTag: (id: string) => Promise; +declare const changeTagColor: (id: string, color: number | string) => Promise; +declare const useUserSettings: () => AccountSettings; +declare const useUserSetting: (...path: Array) => string | T; +declare const getUserSettings: () => AccountSettings; +declare const getUserSetting: (...path: Array) => string | T; +declare const useNotify: () => Array; +declare const useRefresh: () => SoapRefresh; +declare const AppLink: FC; +declare const Spinner: FC; + +declare const useIsMobile: () => boolean; +declare const soapFetch: SoapFetch; +declare const xmlSoapFetch: SoapFetch; +declare const report: (error: Error, hint?: unknown) => void; +declare const setAppContext: (obj: T) => void; + +declare const removeActions: (...ids: Array) => void; +declare const registerActions: ( ...items: Array<{ id: string; action: ActionFactory; type: string }> ) => void; -export const removeComponents: (...ids: Array) => void; -export const registerComponents: ( +declare const removeComponents: (...ids: Array) => void; +declare const registerComponents: ( ...items: Array<{ id: string; component: ComponentType }> ) => void; -export const removeHooks: (...ids: Array) => void; -export const registerHooks: (...items: Array<{ id: string; hook: AnyFunction }>) => void; -export const removeFunctions: (...ids: Array) => void; -export const registerFunctions: (...items: Array<{ id: string; fn: AnyFunction }>) => void; +declare const removeHooks: (...ids: Array) => void; +declare const registerHooks: (...items: Array<{ id: string; hook: AnyFunction }>) => void; +declare const removeFunctions: (...ids: Array) => void; +declare const registerFunctions: (...items: Array<{ id: string; fn: AnyFunction }>) => void; // add route (id route primaryBar secondaryBar app) -export const addRoute: (routeData: Partial) => string; -export const setRouteVisibility: (id: string, visible: boolean) => void; +declare const addRoute: (routeData: Partial) => string; +declare const setRouteVisibility: (id: string, visible: boolean) => void; // remove route (id | route) -export const removeRoute: (id: string) => void; +declare const removeRoute: (id: string) => void; // // update primaryBar -export const updatePrimaryBadge: (badge: Partial, id: string) => void; -export const updateUtilityBadge: (badge: Partial, id: string) => void; +declare const updatePrimaryBadge: (badge: Partial, id: string) => void; +declare const updateUtilityBadge: (badge: Partial, id: string) => void; // // add board -export const addBoardView: (data: Object & Partial) => string; +declare const addBoardView: (data: Record & Partial) => string; // remove board -export const removeBoardView: (id: string) => void; +declare const removeBoardView: (id: string) => void; // // add settings -export const addSettingsView: (data: Partial) => string; +declare const addSettingsView: (data: Partial) => string; // remove settings -export const removeSettingsView: (id: string) => void; +declare const removeSettingsView: (id: string) => void; // // add search -export const addSearchView: (data: Partial) => string; +declare const addSearchView: (data: Partial) => string; // remove search -export const removeSearchView: (id: string) => void; +declare const removeSearchView: (id: string) => void; // // add utility -export const addUtilityView: (data: Partial) => string; +declare const addUtilityView: (data: Partial) => string; // remove utility -export const removeUtilityView: (id: string) => void; +declare const removeUtilityView: (id: string) => void; // // add primaryAccessory -export const addPrimaryAccessoryView: (data: Partial) => string; +declare const addPrimaryAccessoryView: (data: Partial) => string; // remove primaryAccessory -export const removePrimaryAccessoryView: (id: string) => void; +declare const removePrimaryAccessoryView: (id: string) => void; // // add secondaryAccessory -export const addSecondaryAccessoryView: (data: Partial) => string; +declare const addSecondaryAccessoryView: (data: Partial) => string; // remove secondaryAccessory -export const removeSecondaryAccessoryView: (id: string) => void; -export const usePushHistoryCallback: () => (params: HistoryParams) => void; -export const useReplaceHistoryCallback: () => (params: HistoryParams) => void; -export const useGoBackHistoryCallback: () => () => void; -export const pushHistory: (params: HistoryParams) => void; -export const replaceHistory: (params: HistoryParams) => void; -export const goBackHistory: () => void; -export const useCurrentRoute: () => AppRoute | undefined; -export const getCurrentRoute: () => AppRoute | undefined; +declare const removeSecondaryAccessoryView: (id: string) => void; +declare const usePushHistoryCallback: () => (params: HistoryParams) => void; +declare const useReplaceHistoryCallback: () => (params: HistoryParams) => void; +declare const useGoBackHistoryCallback: () => () => void; +declare const pushHistory: (params: HistoryParams) => void; +declare const replaceHistory: (params: HistoryParams) => void; +declare const goBackHistory: () => void; +declare const useCurrentRoute: () => AppRoute | undefined; +declare const getCurrentRoute: () => AppRoute | undefined; // FOLDERS // ROOTS // ROOTS BY USER -export const useRootByUser: (userId: string) => Folder | SearchFolder | Record; -export const getRootByUser: (userId: string) => Folder | SearchFolder | Record; +declare const useRootByUser: (userId: string) => Folder | SearchFolder | Record; +declare const getRootByUser: (userId: string) => Folder | SearchFolder | Record; // SEARCHES -export const useSearchFolder: (id: string) => SearchFolder | undefined; -export const useSearchFolders: (id: string) => SearchFolder | undefined; -export const getSearchFolder: () => Searches; -export const getSearchFolders: () => Searches; +declare const useSearchFolder: (id: string) => SearchFolder | undefined; +declare const useSearchFolders: (id: string) => SearchFolder | undefined; +declare const getSearchFolder: () => Searches; +declare const getSearchFolders: () => Searches; // Accordion-ize -export const useFoldersByView: (view: string) => Array; +declare const useFoldersByView: (view: string) => Array; -export const useFoldersAccordionByView: ( +declare const useFoldersAccordionByView: ( view: string, CustomComponent: ComponentType<{ folder: Folder }>, itemProps?: (item: AccordionFolder) => Record ) => Array; // NOTIFICATION -export const getNotificationManager: () => INotificationManager; +declare const getNotificationManager: () => INotificationManager; // Run Search -export const runSearch: (query: Array, module: string) => void; +declare const runSearch: (query: Array, module: string) => void; -export const useLocalStorage: (key: string, initialValue: T) => [T, Dispatch>]; +declare const useLocalStorage: ( + key: string, + initialValue: T +) => [T, Dispatch>]; // TRANSLATIONS -export const getI18n: () => i18n; -export const useI18n: () => i18n; -export const t: TFunction; +declare const getI18n: () => i18n; +declare const useI18n: () => i18n; +declare const t: TFunction; -export const addBoard: ( +declare const addBoard: ( board: Omit, 'app' | 'icon' | 'id'> & { id?: string; icon?: string }, expanded?: boolean ) => Board; -export const closeBoard: (id: string) => void; -export const updateBoard: (id: string, board: Partial>) => void; -export const updateBoardContext: (id: string, context: T) => void; -export const getBoardById: (id: string) => Board; -export const getBoardContextById: (id: string) => T; -export const useBoardContextById: (id: string) => T; -export const useBoardById: (id: string) => Board; -export const minimizeBoards: () => void; -export const reopenBoards: () => void; -export const setCurrentBoard: (id: string) => void; -export const useBoardHooks: () => BoardHooksContext; -export const useBoard: () => Board; +declare const closeBoard: (id: string) => void; +declare const updateBoard: (id: string, board: Partial>) => void; +declare const updateBoardContext: (id: string, context: T) => void; +declare const getBoardById: (id: string) => Board; +declare const getBoardContextById: (id: string) => T; +declare const useBoardContextById: (id: string) => T; +declare const useBoardById: (id: string) => Board; +declare const minimizeBoards: () => void; +declare const reopenBoards: () => void; +declare const setCurrentBoard: (id: string) => void; +declare const useBoardHooks: () => BoardHooksContext; +declare const useBoard: () => Board; diff --git a/types/misc/index.d.ts b/types/misc/index.d.ts index 42b30e12..55432f8f 100644 --- a/types/misc/index.d.ts +++ b/types/misc/index.d.ts @@ -21,15 +21,6 @@ export enum JSNS { export type DarkReaderPropValues = typeof DARK_READER_VALUES[number]; -export function isDarkReaderPropValues( - maybeDarkReaderPropValue: unknown -): maybeDarkReaderPropValue is DarkReaderPropValues { - return ( - typeof maybeDarkReaderPropValue === 'string' && - DARK_READER_VALUES.includes(maybeDarkReaderPropValue) - ); -} - // eslint-disable-next-line @typescript-eslint/ban-types export type PackageDependentFunction = (app: string) => Function; // eslint-disable-next-line @typescript-eslint/ban-types