update parcel

This commit is contained in:
2022-02-16 18:12:00 +00:00
committed by Stepan Usatiuk
parent e1096f6e28
commit 44da732a10
35 changed files with 617 additions and 12301 deletions

6
frontend/.parcelrc Normal file
View File

@@ -0,0 +1,6 @@
{
"extends": "@parcel/config-default",
"transformers": {
"*.{ts,tsx}": ["@parcel/transformer-typescript-tsc"]
}
}

12757
frontend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{ {
"name": "photos-frontend", "name": "photos-frontend",
"scripts": { "scripts": {
"start": "parcel serve src/index.html", "start": "parcel src/index.html",
"build": "parcel build src/index.html", "build": "parcel build src/index.html",
"lint": "eslint ./src/** --ext .js,.jsx,.ts,.tsx", "lint": "eslint ./src/** --ext .js,.jsx,.ts,.tsx",
"lint-fix": "eslint ./src/** --ext .js,.jsx,.ts,.tsx --fix", "lint-fix": "eslint ./src/** --ext .js,.jsx,.ts,.tsx --fix",
@@ -17,7 +17,6 @@
"@typescript-eslint/eslint-plugin": "^5.12.0", "@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0", "@typescript-eslint/parser": "^5.12.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0", "@wojtekmaj/enzyme-adapter-react-17": "^0",
"autoprefixer": "^9",
"enzyme": "^3.11.0", "enzyme": "^3.11.0",
"eslint": "^8.9.0", "eslint": "^8.9.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
@@ -31,11 +30,11 @@
"eslint-plugin-react-hooks": "^4.3.0", "eslint-plugin-react-hooks": "^4.3.0",
"flush-promises": "^1.0.2", "flush-promises": "^1.0.2",
"jest": "^27.5.1", "jest": "^27.5.1",
"parcel": "1.12.3", "parcel": "2.3.1",
"pluralize": "^8.0.0", "pluralize": "^8.0.0",
"postcss": "^8.4.6",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"prettier-eslint": "^13.0.0", "prettier-eslint": "^13.0.0",
"process": "^0.11.10",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-redux": "^7.2.6", "react-redux": "^7.2.6",
@@ -46,7 +45,6 @@
"redux-devtools-extension": "^2.13.9", "redux-devtools-extension": "^2.13.9",
"redux-persist": "^6.0.0", "redux-persist": "^6.0.0",
"redux-saga": "^1.1.3", "redux-saga": "^1.1.3",
"sass": "^1.49.7",
"spark-md5": "^3.0.2", "spark-md5": "^3.0.2",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"typescript": "^4.5.5" "typescript": "^4.5.5"
@@ -68,6 +66,8 @@
"@types/react-router": "^5.1.18", "@types/react-router": "^5.1.18",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",
"@types/sass": "^1.43.1", "@types/sass": "^1.43.1",
"@types/spark-md5": "^3.0.2" "@types/spark-md5": "^3.0.2",
"autoprefixer": "^10.4.2",
"postcss": "^8.4.6"
} }
} }

View File

@@ -2,8 +2,8 @@ import { Button, Card, FormGroup, H2, InputGroup } from "@blueprintjs/core";
import * as React from "react"; import * as React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Dispatch } from "redux"; import { Dispatch } from "redux";
import { IAppState } from "~redux/reducers"; import { IAppState } from "../redux/reducers";
import { userPassChange } from "~redux/user/actions"; import { userPassChange } from "../redux/user/actions";
export interface IAccountComponentProps { export interface IAccountComponentProps {
username: string | undefined; username: string | undefined;

View File

@@ -1,8 +1,8 @@
import * as React from "react"; import * as React from "react";
import { Route, RouteComponentProps, Switch, withRouter } from "react-router"; import { Route, RouteComponentProps, Switch, withRouter } from "react-router";
import { AuthScreen } from "~Auth/AuthScreen"; import { AuthScreen } from "./Auth/AuthScreen";
import { requireAuth } from "~Auth/AuthWrapper"; import { requireAuth } from "./Auth/AuthWrapper";
import { Home } from "~Home/Home"; import { Home } from "./Home/Home";
// Somehow, if we do it like this then App doesn't rerender every time // Somehow, if we do it like this then App doesn't rerender every time
// the route changes, and animations work // the route changes, and animations work

View File

@@ -1,6 +1,6 @@
import { Position, Toaster } from "@blueprintjs/core"; import { Position, Toaster } from "@blueprintjs/core";
import { isNumber } from "class-validator"; import { isNumber } from "class-validator";
import { IPhotoReqJSON } from "~../../src/entity/Photo"; import { IPhotoReqJSON } from "../../src/entity/Photo";
export const AppToaster = Toaster.create({ export const AppToaster = Toaster.create({
className: "recipe-toaster", className: "recipe-toaster",

View File

@@ -8,7 +8,7 @@ import {
withRouter, withRouter,
} from "react-router"; } from "react-router";
import { animated, Transition } from "react-spring/renderprops"; import { animated, Transition } from "react-spring/renderprops";
import { IAppState } from "~redux/reducers"; import { IAppState } from "../redux/reducers";
import { Login } from "./Login"; import { Login } from "./Login";
import { Signup } from "./Signup"; import { Signup } from "./Signup";

View File

@@ -1,8 +1,8 @@
import * as React from "react"; import * as React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Redirect } from "react-router"; import { Redirect } from "react-router";
import { webRoot } from "~env"; import { webRoot } from "../env";
import { IAppState } from "~redux/reducers"; import { IAppState } from "../redux/reducers";
interface IAuthWrapperComponentProps { interface IAuthWrapperComponentProps {
loggedIn: boolean; loggedIn: boolean;

View File

@@ -5,8 +5,8 @@ import * as React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { RouteComponentProps, withRouter } from "react-router-dom"; import { RouteComponentProps, withRouter } from "react-router-dom";
import { Dispatch } from "redux"; import { Dispatch } from "redux";
import { authStart } from "~redux/auth/actions"; import { authStart } from "../redux/auth/actions";
import { IAppState } from "~redux/reducers"; import { IAppState } from "../redux/reducers";
interface ILoginComponentProps extends RouteComponentProps { interface ILoginComponentProps extends RouteComponentProps {
inProgress: boolean; inProgress: boolean;

View File

@@ -5,8 +5,8 @@ import * as React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { RouteComponentProps, withRouter } from "react-router"; import { RouteComponentProps, withRouter } from "react-router";
import { Dispatch } from "redux"; import { Dispatch } from "redux";
import { signupStart } from "~redux/auth/actions"; import { signupStart } from "../redux/auth/actions";
import { IAppState } from "~redux/reducers"; import { IAppState } from "../redux/reducers";
interface ISignupComponentProps extends RouteComponentProps { interface ISignupComponentProps extends RouteComponentProps {
inProgress: boolean; inProgress: boolean;

View File

@@ -17,14 +17,14 @@ import { connect } from "react-redux";
import { Route, RouteComponentProps, Switch, withRouter } from "react-router"; import { Route, RouteComponentProps, Switch, withRouter } from "react-router";
import { animated, config, Transition } from "react-spring/renderprops"; import { animated, config, Transition } from "react-spring/renderprops";
import { Dispatch } from "redux"; import { Dispatch } from "redux";
import { IUserJSON } from "~../../src/entity/User"; import { IUserJSON } from "../../../src/entity/User";
import { Account } from "~Account/Account"; import { Account } from "../Account/Account";
import { Overview } from "~Photos/Overview"; import { Overview } from "../Photos/Overview";
import { toggleDarkMode } from "~redux/localSettings/actions"; import { toggleDarkMode } from "../redux/localSettings/actions";
import { IAppState } from "~redux/reducers"; import { IAppState } from "../redux/reducers";
import { logoutUser } from "~redux/user/actions"; import { logoutUser } from "../redux/user/actions";
import { Photo } from "~Photos/Photo"; import { Photo } from "../Photos/Photo";
import { PhotoRoute } from "~Photos/PhotoRoute"; import { PhotoRoute } from "../Photos/PhotoRoute";
import { UploadStatus } from "./UploadStatus"; import { UploadStatus } from "./UploadStatus";
export interface IHomeProps extends RouteComponentProps { export interface IHomeProps extends RouteComponentProps {

View File

@@ -1,7 +1,7 @@
import { Button, Icon, Popover, Spinner } from "@blueprintjs/core"; import { Button, Icon, Popover, Spinner } from "@blueprintjs/core";
import * as React from "react"; import * as React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { IAppState } from "~redux/reducers"; import { IAppState } from "../redux/reducers";
import pluralize from "pluralize"; import pluralize from "pluralize";
export interface IUploadStatusComponentProps { export interface IUploadStatusComponentProps {

View File

@@ -2,10 +2,10 @@ import "./Overview.scss";
import * as React from "react"; import * as React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Dispatch } from "redux"; import { Dispatch } from "redux";
import { IAppState } from "~redux/reducers"; import { IAppState } from "../redux/reducers";
import { photosLoadStart } from "~redux/photos/actions"; import { photosLoadStart } from "../redux/photos/actions";
import { IPhotoReqJSON } from "~../../src/entity/Photo"; import { IPhotoReqJSON } from "../../../src/entity/Photo";
import { LoadingStub } from "~LoadingStub"; import { LoadingStub } from "../LoadingStub";
import { PhotoCard } from "./PhotoCard"; import { PhotoCard } from "./PhotoCard";
import { import {
Button, Button,
@@ -18,7 +18,7 @@ import {
} from "@blueprintjs/core"; } from "@blueprintjs/core";
import { UploadButton } from "./UploadButton"; import { UploadButton } from "./UploadButton";
import { Photo } from "./Photo"; import { Photo } from "./Photo";
import { getPhotoThumbPath } from "~redux/api/photos"; import { getPhotoThumbPath } from "../redux/api/photos";
export interface IOverviewComponentProps { export interface IOverviewComponentProps {
photos: IPhotoReqJSON[]; photos: IPhotoReqJSON[];

View File

@@ -2,16 +2,16 @@ import "./Photo.scss";
import * as React from "react"; import * as React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Dispatch } from "redux"; import { Dispatch } from "redux";
import { IPhotoReqJSON } from "~../../src/entity/Photo"; import { IPhotoReqJSON } from "../../../src/entity/Photo";
import { LoadingStub } from "~LoadingStub"; import { LoadingStub } from "../LoadingStub";
import { import {
fetchPhoto, fetchPhoto,
getPhotoImgPath, getPhotoImgPath,
getPhotoThumbPath, getPhotoThumbPath,
} from "~redux/api/photos"; } from "../redux/api/photos";
import { photoLoadStart } from "~redux/photos/actions"; import { photoLoadStart } from "../redux/photos/actions";
import { IPhotoState } from "~redux/photos/reducer"; import { IPhotoState } from "../redux/photos/reducer";
import { IAppState } from "~redux/reducers"; import { IAppState } from "../redux/reducers";
import { LargeSize, PreviewSize } from "./helper"; import { LargeSize, PreviewSize } from "./helper";
export interface IPhotoComponentProps { export interface IPhotoComponentProps {

View File

@@ -8,13 +8,13 @@ import {
Spinner, Spinner,
} from "@blueprintjs/core"; } from "@blueprintjs/core";
import * as React from "react"; import * as React from "react";
import { IPhotoReqJSON } from "~../../src/entity/Photo"; import { IPhotoReqJSON } from "../../../src/entity/Photo";
import { getPhotoImgPath, getPhotoThumbPath } from "~redux/api/photos"; import { getPhotoImgPath, getPhotoThumbPath } from "../redux/api/photos";
import { showDeletionToast } from "~AppToaster"; import { showDeletionToast } from "../AppToaster";
import { Dispatch } from "redux"; import { Dispatch } from "redux";
import { photoDeleteCancel, photoDeleteStart } from "~redux/photos/actions"; import { photoDeleteCancel, photoDeleteStart } from "../redux/photos/actions";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { LoadingStub } from "~LoadingStub"; import { LoadingStub } from "../LoadingStub";
import { RouteComponentProps, withRouter } from "react-router"; import { RouteComponentProps, withRouter } from "react-router";
import { LargeSize, PreviewSize } from "./helper"; import { LargeSize, PreviewSize } from "./helper";

View File

@@ -2,7 +2,7 @@ import { Button } from "@blueprintjs/core";
import * as React from "react"; import * as React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Dispatch } from "redux"; import { Dispatch } from "redux";
import { photosUploadStart } from "~redux/photos/actions"; import { photosUploadStart } from "../redux/photos/actions";
export interface IUploadButtonComponentProps { export interface IUploadButtonComponentProps {
startUpload: (files: FileList) => void; startUpload: (files: FileList) => void;

View File

@@ -15,7 +15,7 @@
<body> <body>
<div id="body"></div> <div id="body"></div>
<script src="./index.tsx"></script> <script src="./index.tsx" type="module"></script>
</body> </body>
</html> </html>

View File

@@ -1,15 +1,15 @@
import "@blueprintjs/core/lib/css/blueprint.css"; import "@blueprintjs/core/lib/css/blueprint.css";
import "@blueprintjs/icons/lib/css/blueprint-icons.css"; import "@blueprintjs/icons/lib/css/blueprint-icons.css";
import "normalize.css/normalize.css"; import "normalize.css/normalize.css";
import "~App.scss"; import "./App.scss";
import * as React from "react"; import * as React from "react";
import { render } from "react-dom"; import { render } from "react-dom";
import { Provider } from "react-redux"; import { Provider } from "react-redux";
import { BrowserRouter } from "react-router-dom"; import { BrowserRouter } from "react-router-dom";
import { PersistGate } from "redux-persist/integration/react"; import { PersistGate } from "redux-persist/integration/react";
import { App } from "~App"; import { App } from "./App";
import { persistor, store } from "~redux/store"; import { persistor, store } from "./redux/store";
render( render(
<Provider store={store}> <Provider store={store}>

View File

@@ -1,7 +1,7 @@
import { import {
IUserLoginRespBody, IUserLoginRespBody,
IUserSignupRespBody, IUserSignupRespBody,
} from "~../../src/routes/users"; } from "../../../../../src/routes/users";
import { fetchJSON } from "../utils"; import { fetchJSON } from "../utils";
export async function login( export async function login(

View File

@@ -1,12 +1,12 @@
import { IPhotoReqJSON } from "~../../src/entity/Photo"; import { IPhotoReqJSON } from "../../../../src/entity/Photo";
import { import {
IPhotosByIDDeleteRespBody, IPhotosByIDDeleteRespBody,
IPhotosByIDGetRespBody, IPhotosByIDGetRespBody,
IPhotosListRespBody, IPhotosListRespBody,
IPhotosNewRespBody, IPhotosNewRespBody,
IPhotosUploadRespBody, IPhotosUploadRespBody,
} from "~../../src/routes/photos"; } from "../../../../src/routes/photos";
import { apiRoot } from "~env"; import { apiRoot } from "../../env";
import { fetchJSONAuth } from "./utils"; import { fetchJSONAuth } from "./utils";
export function getPhotoImgPath(photo: IPhotoReqJSON): string { export function getPhotoImgPath(photo: IPhotoReqJSON): string {

View File

@@ -1,5 +1,5 @@
import { fetchJSONAuth } from "../utils"; import { fetchJSONAuth } from "../utils";
import { IUserEditRespBody, IUserGetRespBody } from "~../../src/routes/users"; import { IUserEditRespBody, IUserGetRespBody } from "../../../../../src/routes/users";
export async function fetchUser(): Promise<IUserGetRespBody> { export async function fetchUser(): Promise<IUserGetRespBody> {
return (fetchJSONAuth("/users/user", "GET") as unknown) as Promise< return (fetchJSONAuth("/users/user", "GET") as unknown) as Promise<

View File

@@ -1,4 +1,4 @@
import { apiRoot } from "~env"; import { apiRoot } from "../../env";
let token: string | null; let token: string | null;

View File

@@ -1,5 +1,5 @@
import { Action } from "redux"; import { Action } from "redux";
import { IUserAuthJSON } from "~../../src/entity/User"; import { IUserAuthJSON } from "../../../../src/entity/User";
export enum AuthTypes { export enum AuthTypes {
AUTH_START = "AUTH_START", AUTH_START = "AUTH_START",

View File

@@ -1,7 +1,7 @@
import { Reducer } from "react"; import { Reducer } from "react";
import { setToken } from "~redux/api/utils"; import { setToken } from "../../redux/api/utils";
import { UserAction, UserTypes } from "~redux/user/actions"; import { UserAction, UserTypes } from "../../redux/user/actions";
import { AuthAction, AuthTypes } from "./actions"; import { AuthAction, AuthTypes } from "./actions";
export interface IAuthState { export interface IAuthState {

View File

@@ -8,7 +8,7 @@ import {
race, race,
takeLatest, takeLatest,
} from "redux-saga/effects"; } from "redux-saga/effects";
import { login, signup } from "~redux/api/auth"; import { login, signup } from "../../redux/api/auth";
import { import {
authFail, authFail,

View File

@@ -1,5 +1,5 @@
import { Reducer } from "react"; import { Reducer } from "react";
import { UserAction, UserTypes } from "~redux/user/actions"; import { UserAction, UserTypes } from "../../redux/user/actions";
import { LocalSettingsAction, LocalSettingsTypes } from "./actions"; import { LocalSettingsAction, LocalSettingsTypes } from "./actions";

View File

@@ -1,10 +1,10 @@
import { Action } from "redux"; import { Action } from "redux";
import { IPhotoReqJSON, Photo } from "~../../src/entity/Photo"; import { IPhotoReqJSON, Photo } from "../../../../src/entity/Photo";
import { import {
showPhotoCreateFailToast, showPhotoCreateFailToast,
showPhotoUploadFileFailToast, showPhotoUploadFileFailToast,
showPhotoUploadJSONFailToast, showPhotoUploadJSONFailToast,
} from "~AppToaster"; } from "../../AppToaster";
export enum PhotoTypes { export enum PhotoTypes {
PHOTOS_LOAD_START = "PHOTOS_LOAD", PHOTOS_LOAD_START = "PHOTOS_LOAD",

View File

@@ -1,6 +1,6 @@
import { Reducer } from "redux"; import { Reducer } from "redux";
import { IPhotoJSON, IPhotoReqJSON } from "~../../src/entity/Photo"; import { IPhotoJSON, IPhotoReqJSON } from "../../../../src/entity/Photo";
import { UserAction, UserTypes } from "~redux/user/actions"; import { UserAction, UserTypes } from "../../redux/user/actions";
import { PhotoAction, PhotoTypes } from "./actions"; import { PhotoAction, PhotoTypes } from "./actions";
export interface IPhotoState { export interface IPhotoState {

View File

@@ -18,7 +18,7 @@ import {
fetchPhoto, fetchPhoto,
fetchPhotosList, fetchPhotosList,
uploadPhoto, uploadPhoto,
} from "~redux/api/photos"; } from "../../redux/api/photos";
import { import {
IPhotoDeleteStartAction, IPhotoDeleteStartAction,
IPhotoLoadStartAction, IPhotoLoadStartAction,
@@ -41,8 +41,8 @@ import {
photoUploadStart, photoUploadStart,
photoUploadSuccess, photoUploadSuccess,
} from "./actions"; } from "./actions";
import { IPhotosNewRespBody } from "~../../src/routes/photos"; import { IPhotosNewRespBody } from "../../../../src/routes/photos";
import { IPhotosListPagination } from "~../../src/types"; import { IPhotosListPagination } from "../../../../src/types";
// Thanks, https://dev.to/qortex/compute-md5-checksum-for-a-file-in-typescript-59a4 // Thanks, https://dev.to/qortex/compute-md5-checksum-for-a-file-in-typescript-59a4
function computeChecksumMd5(file: File): Promise<string> { function computeChecksumMd5(file: File): Promise<string> {

View File

@@ -2,7 +2,7 @@ import { combineReducers } from "redux";
import { persistReducer } from "redux-persist"; import { persistReducer } from "redux-persist";
import { PersistPartial } from "redux-persist/es/persistReducer"; import { PersistPartial } from "redux-persist/es/persistReducer";
import storage from "redux-persist/lib/storage"; import storage from "redux-persist/lib/storage";
import { authReducer, IAuthState } from "~redux/auth/reducer"; import { authReducer, IAuthState } from "../redux/auth/reducer";
import { import {
ILocalSettingsState, ILocalSettingsState,
localSettingsReducer, localSettingsReducer,

View File

@@ -2,7 +2,7 @@ import { applyMiddleware, createStore } from "redux";
import { composeWithDevTools } from "redux-devtools-extension"; import { composeWithDevTools } from "redux-devtools-extension";
import { persistStore } from "redux-persist"; import { persistStore } from "redux-persist";
import createSagaMiddlware from "redux-saga"; import createSagaMiddlware from "redux-saga";
import { rootReducer } from "~redux/reducers"; import { rootReducer } from "../redux/reducers";
import { setToken } from "./api/utils"; import { setToken } from "./api/utils";
import { authSaga } from "./auth/sagas"; import { authSaga } from "./auth/sagas";

View File

@@ -1,6 +1,6 @@
import { Action } from "redux"; import { Action } from "redux";
import { IUserAuthJSON, IUserJSON } from "~../../src/entity/User"; import { IUserAuthJSON, IUserJSON } from "../../../../src/entity/User";
import { showPasswordNotSavedToast, showPasswordSavedToast } from "~AppToaster"; import { showPasswordNotSavedToast, showPasswordSavedToast } from "../../AppToaster";
export enum UserTypes { export enum UserTypes {
USER_GET = "USER_GET", USER_GET = "USER_GET",

View File

@@ -1,6 +1,6 @@
import { Reducer } from "react"; import { Reducer } from "react";
import { IUserJSON } from "~../../src/entity/User"; import { IUserJSON } from "../../../../src/entity/User";
import { AuthAction, AuthTypes } from "~redux/auth/actions"; import { AuthAction, AuthTypes } from "../../redux/auth/actions";
import { UserAction, UserTypes } from "./actions"; import { UserAction, UserTypes } from "./actions";
export interface IUserState { export interface IUserState {

View File

@@ -1,5 +1,5 @@
import { all, call, delay, put, race, takeLatest } from "redux-saga/effects"; import { all, call, delay, put, race, takeLatest } from "redux-saga/effects";
import { changeUserPassword, fetchUser } from "~redux/api/user"; import { changeUserPassword, fetchUser } from "../../redux/api/user";
import { import {
getUserFail, getUserFail,

View File

@@ -17,12 +17,7 @@
"strictFunctionTypes": true, "strictFunctionTypes": true,
"strictNullChecks": true, "strictNullChecks": true,
"skipLibCheck": true, "skipLibCheck": true,
"baseUrl": "./src", "isolatedModules": true,
"paths": {
"~*": [
"./*"
]
}
}, },
"include": [ "include": [
"./src/**/*.ts", "./src/**/*.ts",