9.0 KiB
Dependencies
Dev
These are some global dev dependencies in the root package.json
. These set the
baseline for how our code be in all the workspaces in this (yarn) monorepo.
-
prettier - Formatter
-
eslint - Linter
-
typescript - Type checker
They also need some support packages, which come from the leaf @/build-config
package:
-
@eslint/js provides JavaScript ESLint functionality, and provides the configuration recommended the by ESLint team.
-
typescript-eslint - provides TypeScript ESLint functionality and provides a set of recommended configurations (
typescript-eslint
is the new entry point, our yet-unmigrated packages use the older method of separately including @typescript-eslint/parser - which tells ESLint how to read TypeScript syntax - and @typescript-eslint/eslint-plugin - which provides the TypeScript rules and presets). -
eslint-plugin-react, eslint-plugin-react-hooks - Some React specific ESLint rules and configurations that are used by the workspaces that have React code.
-
eslint-plugin-react-refresh - A plugin to ensure that React components are exported in a way that they can be HMR-ed.
-
prettier-plugin-organize-imports - A Prettier plugin to sort imports.
-
prettier-plugin-packagejson - A Prettier plugin to also prettify
package.json
.
The root package.json
also has a convenience dev dependency:
- concurrently for spawning parallel tasks when we invoke various yarn scripts.
Cryptography
We use libsodium for our cryptography primitives. We use its WebAssembly target, accessible via JavaScript wrappers maintained by the original authors of libsodium themselves - libsodium-wrappers.
More precisely, we use the sumo variant, "libsodium-wrappers-sumo", since the
standard variant does not provide the crypto_pwhash_*
functions.
Meta frameworks
Next.js
Next.js (package: next) provides the meta framework for both the photos and the auth app, and also for some of the sidecar apps like accounts and cast.
We use a limited subset of Next.js. The main thing we get out of it is a reasonable set of defaults for bundling our app into a static export which we can then deploy to our webserver. In addition, the Next.js page router is convenient. Overall our apps can be described as regular React SPAs, and are not particularly tied to Next.js.
Vite
For some of our newer code, we have started to use Vite. It is likely the future (both generally, and for our code) since Next.js is becoming less suitable for SPAs and static SSR with their push towards RSC and dynamic SSR.
UI
React
React (package: react) is our core framework. We also import its a sibling react-dom package that renders JSX to the DOM.
MUI and Material Icons
We use MUI's @mui/material as our base React component library.
MUI uses Emotion as its preferred CSS-in-JS library, for
which we need to install install two Emotion packages (@emotion/react
and
@emotion/styled
) as peer dependencies.
We need to pin the emotion version (using the "resolutions" field in
package.json
) to those used by MUI since react-select (another package we use)
specify a different emotion version directly instead of as a peer dependency,
and we end up with two emotions at runtime otherwise.
We also use MUI's
@mui/material-icons package,
which provides Material icons exported as React components (a SvgIcon
).
Date pickers
@mui/x-date-pickers is used to get a date/time picker component. This is the community version of the DateTimePicker component provided by MUI.
dayjs is used as the date library that that
@mui/x-date-pickers
will internally use to manipulate dates.
Translations
For showing the app's UI in multiple languages, we use the i18next, specifically its three components
- i18next: The core
i18next
library. - react-i18next: React specific
support in
i18next
. - i18next-http-backend:
Adds support for initializing
i18next
with JSON file containing the translation in a particular language, fetched at runtime.
Note that inspite of the "next" in the name of the library, it has nothing to do with Next.js.
For more details, see translations.md.
Others
-
formik provides an easier to use abstraction for dealing with form state, validation and submission states when using React.
-
react-select is used for search dropdowns.
Utilities
-
comlink provides a minimal layer on top of web workers to make them more easier to use.
-
idb provides a promise API over the browser-native IndexedDB APIs.
For more details about IDB and its role, see storage.md.
-
zod is used for runtime typechecking (e.g. verifying that API responses match the expected TypeScript shape).
-
nanoid is used for generating unique identifiers.
-
debounce and its promise-supporting sibling pDebounce are used for debouncing operations (See also:
[Note: Throttle and debounce]
).
Media
-
ExifReader is used for Exif parsing. piexifjs is used for writing back Exif (only supports JPEG).
-
jszip is used for reading zip files in the web code (Live photos are zip files under the hood). Note that the desktop app uses also has a ZIP parser (that one supports streaming).
-
file-type is used for MIME type detection. We are at an old version 16.5.4 because v17 onwards the package became ESM only - for our limited use case, the custom Webpack configuration that it'd entail is not worth the upgrade.
-
heic-convert is used for converting HEIC files (which browsers don't natively support) into JPEG.
Photos app specific
General
-
react-dropzone is a React hook to create a drag-and-drop input zone.
-
sanitize-filename is for converting arbitrary strings into strings that are suitable for being used as filenames.
-
chrono-node is used for parsing natural language queries into dates for showing search results.
Face search
-
transformation-matrix is used for performing 2D affine transformations using transformation matrices. It is used during face detection.
-
matrix is mathematical matrix abstraction. It is used alongwith similarity-transformation during face alignment.
Note that while both
transformation-matrix
andmatrix
are "matrix" libraries, they have different foci and purposes:transformation-matrix
provides affine transforms, whilematrix
is for performing computations on matrices, say inverting them or performing their decomposition. -
hdbscan is used for face clustering.
Auth app specific
-
otpauth is used for the generation of the actual OTP from the user's TOTP/HOTP secret.
-
However, otpauth doesn't support steam OTPs. For these, we need to compute the SHA-1, and we use the same library,
jssha
thatotpauth
uses since it is already part of our bundle (transitively).