Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
* Set client production ready
* Removed unused dependencies and exports
* Fixed CheckedListItem import path
  • Loading branch information
GuilhermeF03 committed Jun 28, 2024
1 parent aefb129 commit eda1fb9
Show file tree
Hide file tree
Showing 26 changed files with 32 additions and 178 deletions.
14 changes: 2 additions & 12 deletions code/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@
"@emotion/styled": "^11.11.5",
"@mui/material": "^5.15.18",
"@notespace/shared": "file:..\\shared",
"@testing-library/jest-dom": "^6.4.5",
"dotenv": "^16.4.5",
"eslint-plugin-playwright": "^1.6.0",
"firebase": "^10.12.2",
"js-cookie": "^3.0.5",
"lodash": "^4.17.21",
"msw": "^2.2.14",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.2.1",
Expand All @@ -39,18 +36,12 @@
"socket.io-client": "^4.7.5"
},
"devDependencies": {
"@testing-library/dom": "^10.1.0",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.5.2",
"@types/firebase": "^3.2.1",
"@types/jest": "^29.5.12",
"@types/js-cookie": "^3.0.6",
"@types/lodash": "^4.17.1",
"@types/node": "^20.12.10",
"@types/node": "^20.14.9",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@types/react-router-dom": "^5.3.3",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@vite-pwa/assets-generator": "^0.2.4",
Expand All @@ -68,9 +59,8 @@
"knip": "^5.12.3",
"prettier": "^3.2.5",
"sass": "^1.77.0",
"typescript": "^5.4.5",
"typescript": "^5.5.2",
"vite": "^5.2.11",
"vite-plugin-pwa": "^0.20.0",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
}
Expand Down
2 changes: 1 addition & 1 deletion code/client/src/contexts/auth/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type AuthProviderProps = {
children: ReactNode;
};

export function AuthProvider({ children }: AuthProviderProps) {
function AuthProvider({ children }: AuthProviderProps) {
const [currentUser, setCurrentUser] = useState<User | null>(null);
const [loading, setLoading] = useState(true);
const { publishError } = useError();
Expand Down
2 changes: 1 addition & 1 deletion code/client/src/contexts/error/ErrorContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const ERROR_TIMEOUT = 5000;

export type ErrorHandler = <T>(fn: () => T) => Promise<T>;

export type ErrorContextType = {
type ErrorContextType = {
publishError: (error: Error) => void;
errorHandler: ErrorHandler;
};
Expand Down
2 changes: 1 addition & 1 deletion code/client/src/contexts/workspace/WorkspaceContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type WorkspaceOperations = {
moveResource: (id: string, parent: string) => Promise<void>;
};

export type WorkspaceContextType = {
type WorkspaceContextType = {
workspace?: WorkspaceMeta;
resources?: Resources;
operations?: WorkspaceOperations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Selection from '@ui/pages/document/components/cursor/Selection';
import Cursor from '@ui/pages/document/components/cursor/Cursor';
import { Range } from 'slate';
import { type BlockStyle, BlockStyles } from '@notespace/shared/src/document/types/styles';
import CheckListItem from '@domain/editor/slate/plugins/markdown/rendering/components/elements/CheckListItem';
import { CheckListItem } from '@domain/editor/slate/plugins/markdown/rendering/components/components';
import { isStatefulBlock } from '@domain/editor/slate/utils/slate';

/**
Expand Down
4 changes: 2 additions & 2 deletions code/client/src/domain/editor/slate/plugins/markdown/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export enum RuleType {
Inline = 'inline',
}

export type Rule = {
type Rule = {
type: RuleType;
triggers: RegExp[];
apply: ApplyFunction;
};

export type ApplyFunction = (handler: ApplyBlockStyle | ApplyInlineStyle) => (editor: Editor, range: Range) => void;
type ApplyFunction = (handler: ApplyBlockStyle | ApplyInlineStyle) => (editor: Editor, range: Range) => void;

export function blockRules(style: BlockStyle, ...triggerCharacters: string[]): Rule {
const triggers = triggerCharacters.map(trigger => new RegExp(`^(${escapeRegExp(trigger)})$`));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MarkdownConnector } from '@domain/editor/connectors/markdown/types';
* @param editor
* @param connector
*/
export function withMarkdown(editor: Editor, connector: MarkdownConnector) {
function withMarkdown(editor: Editor, connector: MarkdownConnector) {
const { deleteBackward, insertText, isInline, delete: deleteOperation } = editor;
const editorOperations = operations(editor, connector);

Expand Down
4 changes: 2 additions & 2 deletions code/client/src/domain/editor/slate/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type ReactEditor } from 'slate-react';
import { type BlockStyle, InlineStyle } from '@notespace/shared/src/document/types/styles';
import { CursorData } from '@ui/pages/document/components/editor/hooks/useCursors';

export interface CustomFormat {
interface CustomFormat {
bold?: boolean;
italic?: boolean;
underline?: boolean;
Expand All @@ -16,7 +16,7 @@ export interface CustomText extends CustomFormat {
cursor?: CursorData;
}

export interface CustomElement {
interface CustomElement {
type: BlockStyle | InlineStyle;
children: Descendant[];
}
Expand Down
16 changes: 3 additions & 13 deletions code/client/src/domain/editor/slate/utils/selection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Editor, Node, Path, Point, Range, Text } from 'slate';
import { Cursor, emptyCursor, emptySelection, Selection } from '@domain/editor/cursor';
import { first, isEqual } from 'lodash';
import { Cursor, emptySelection, Selection } from '@domain/editor/cursor';
import { first } from 'lodash';

/**
* Checks if the current selection is active
Expand Down Expand Up @@ -39,7 +39,7 @@ const pointsToSelection = (editor: Editor, start: Point, end: Point): Selection
* @param editor
* @param point
*/
export function pointToCursor(editor: Editor, point: Point): Cursor {
function pointToCursor(editor: Editor, point: Point): Cursor {
const line = point.path[0];
const cursor: Cursor = { line, column: point.offset };
if (point.path[1] === 0) return cursor;
Expand Down Expand Up @@ -72,13 +72,3 @@ export function getSelectionByRange(editor: Editor, range: Range, offset: number
selection.end.column += offset;
return selection;
}

/**
* Checks if the selection is empty
* @param selection
*/
export function isSelectionEmpty(selection: Selection): boolean {
const { start, end } = selection;
const startCursor = emptyCursor();
return isEqual(startCursor, start) && isEqual(start, end);
}
6 changes: 0 additions & 6 deletions code/client/src/pwa/inject-config.ts

This file was deleted.

35 changes: 0 additions & 35 deletions code/client/src/pwa/manifest-config.ts

This file was deleted.

9 changes: 0 additions & 9 deletions code/client/src/pwa/pwa-assets.config.ts

This file was deleted.

13 changes: 0 additions & 13 deletions code/client/src/pwa/pwa-config.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type CursorData = {
styles: InlineStyle[];
};

export function useCursors(connector: ServiceConnector) {
function useCursors(connector: ServiceConnector) {
const [cursors, setCursors] = useState<CursorData[]>([]);

const onCursorChange = (cursor: CursorData) => {
Expand Down
14 changes: 0 additions & 14 deletions code/client/src/utils/logging.ts

This file was deleted.

2 changes: 1 addition & 1 deletion code/client/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function formatDate(isoString: string) {
});
}

export function formatTime(time: number, unit: string) {
function formatTime(time: number, unit: string) {
return `${time} ${unit}${time === 1 ? '' : 's'} ago`;
}

Expand Down
12 changes: 0 additions & 12 deletions code/client/tests/mocks/global-mocks.ts

This file was deleted.

1 change: 0 additions & 1 deletion code/client/tests/mocks/mock-handlers.ts

This file was deleted.

4 changes: 0 additions & 4 deletions code/client/tests/mocks/mock-server.ts

This file was deleted.

24 changes: 0 additions & 24 deletions code/client/tests/test-utils.ts

This file was deleted.

8 changes: 4 additions & 4 deletions code/client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext", "WebWorker"],
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ES2022",
"moduleResolution": "Bundler",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
Expand All @@ -32,5 +32,5 @@
}
},
"include": ["src", "tests"],
"exclude": ["vite.config.ts"]
"exclude": ["node_modules", "vite.config.ts"]
}
14 changes: 9 additions & 5 deletions code/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
import { config } from 'dotenv';

// Load environment variables from .env file
config();

export default defineConfig({
publicDir: './public',
server: {
port: Number.parseInt(process.env.VITE_PORT) || 5173,
},
plugins: [tsconfigPaths(), react() /*VitePWA(pwaConfig)*/],
plugins: [tsconfigPaths(), react()],
build: {
//sourcemap: true,
// Enable sourcemaps if needed
// sourcemap: true,
rollupOptions: {
output: {
manualChunks: (id: string) => {
//if(id.includes('node_modules')) return 'vendor';
if (id.includes('node_modules')) {
if (id.includes('react')) return 'react';
if (id.includes('slate')) return 'slate';
return 'vendor';
}
if (id.includes('src')) return 'app';
if (id.includes('slate')) return 'slate';
if (id.includes('react')) return 'react';
},
entryFileNames: 'assets/[name].js',
chunkFileNames: 'assets/[name].js',
Expand Down
9 changes: 0 additions & 9 deletions code/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
},
"dependencies": {
"@notespace/shared": "file:..\\shared",
"@types/cookie": "^0.6.0",
"@types/socket.io": "^3.0.2",
"cookie": "^0.6.0",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
Expand All @@ -26,7 +24,6 @@
"lodash": "^4.17.21",
"postgres": "^3.4.4",
"socket.io": "^4.7.5",
"supertest": "^6.3.4",
"uuid": "^9.0.1"
},
"devDependencies": {
Expand All @@ -35,11 +32,8 @@
"@types/cookie-parser": "^1.4.7",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.17.1",
"@types/node": "^20.14.8",
"@types/pg": "^8.11.6",
"@types/supertest": "^6.0.2",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
Expand All @@ -49,9 +43,6 @@
"jest": "^29.7.0",
"knip": "^5.12.3",
"prettier": "^3.2.5",
"socket.io-client": "^4.7.5",
"superagent": "^9.0.0",
"test-jest": "^1.0.1",
"ts-jest": "^29.1.2",
"tsconfig-paths": "^4.2.0",
"tsx": "^4.9.3",
Expand Down
Loading

0 comments on commit eda1fb9

Please sign in to comment.