diff --git a/code/client/dev-dist/sw.js b/code/client/dev-dist/sw.js index 1b41745f..f586b4bc 100644 --- a/code/client/dev-dist/sw.js +++ b/code/client/dev-dist/sw.js @@ -67,7 +67,7 @@ if (!self.define) { }); }; } -define(['./workbox-fda11f75'], (function (workbox) { 'use strict'; +define(['./workbox-a0f72815'], (function (workbox) { 'use strict'; self.skipWaiting(); workbox.clientsClaim(); @@ -82,7 +82,7 @@ define(['./workbox-fda11f75'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "index.html", - "revision": "0.m5gr4j769k" + "revision": "0.3hobnoep3ho" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { diff --git a/code/client/jest.config.js b/code/client/jest.config.js deleted file mode 100644 index a9fe07b3..00000000 --- a/code/client/jest.config.js +++ /dev/null @@ -1,12 +0,0 @@ -export default { - globals: { - 'ts-jest': { - tsConfig: 'tsconfig.json', - }, - }, - moduleDirectories: ['node_modules', 'src'], - paths: { - '@src/*': ['./src/*'], - '@editor/*': ['./src/editor/*'], - }, -}; diff --git a/code/client/package.json b/code/client/package.json index e384631c..16ac4088 100644 --- a/code/client/package.json +++ b/code/client/package.json @@ -31,11 +31,11 @@ "devDependencies": { "@types/lodash": "^4.17.0", "@types/node": "^20.11.30", - "@types/react": "^18.2.67", + "@types/react": "^18.2.70", "@types/react-dom": "^18.2.22", "@types/react-router-dom": "^5.3.3", - "@typescript-eslint/eslint-plugin": "^7.3.1", - "@typescript-eslint/parser": "^7.3.1", + "@typescript-eslint/eslint-plugin": "^7.4.0", + "@typescript-eslint/parser": "^7.4.0", "@vite-pwa/assets-generator": "^0.2.4", "@vitejs/plugin-react": "^4.2.1", "@vitest/coverage-v8": "^1.4.0", @@ -47,12 +47,12 @@ "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.6", "jsdom": "^24.0.0", - "knip": "^5.2.2", + "knip": "^5.5.0", "prettier": "^3.2.5", "sass": "^1.72.0", "typescript": "^5.4.3", - "vite": "^5.2.3", - "vite-plugin-pwa": "^0.19.6", + "vite": "^5.2.6", + "vite-plugin-pwa": "^0.19.7", "vite-tsconfig-paths": "^4.3.2", "vitest": "^1.4.0" }, diff --git a/code/client/src/editor/crdt/fugue.ts b/code/client/src/editor/crdt/fugue.ts index 6816d2c8..78ab2807 100644 --- a/code/client/src/editor/crdt/fugue.ts +++ b/code/client/src/editor/crdt/fugue.ts @@ -7,9 +7,9 @@ import { type Node, type Id } from '@notespace/shared/crdt/types/nodes'; import { type Style } from '@notespace/shared/crdt/types/styles'; import { FugueTree } from '@notespace/shared/crdt/FugueTree'; import { generateReplicaId } from './utils'; -import { socket } from '@src/socket/socket'; +import { socket } from '@src/socket.io/socket'; import { type InsertNode } from '@editor/crdt/types'; -import { Cursor, Selection } from '@editor/slate/model/cursor'; +import { Cursor, Selection } from '@editor/slate.js/model/cursor'; import { isEmpty, isEqual } from 'lodash'; /** diff --git a/code/client/src/editor/slate/SlateEditor.scss b/code/client/src/editor/slate.js/SlateEditor.scss similarity index 100% rename from code/client/src/editor/slate/SlateEditor.scss rename to code/client/src/editor/slate.js/SlateEditor.scss diff --git a/code/client/src/editor/slate/SlateEditor.tsx b/code/client/src/editor/slate.js/SlateEditor.tsx similarity index 100% rename from code/client/src/editor/slate/SlateEditor.tsx rename to code/client/src/editor/slate.js/SlateEditor.tsx diff --git a/code/client/src/editor/slate/hooks/useEditor.ts b/code/client/src/editor/slate.js/hooks/useEditor.ts similarity index 100% rename from code/client/src/editor/slate/hooks/useEditor.ts rename to code/client/src/editor/slate.js/hooks/useEditor.ts diff --git a/code/client/src/editor/slate/hooks/useInputHandlers.ts b/code/client/src/editor/slate.js/hooks/useInputHandlers.ts similarity index 100% rename from code/client/src/editor/slate/hooks/useInputHandlers.ts rename to code/client/src/editor/slate.js/hooks/useInputHandlers.ts diff --git a/code/client/src/editor/slate/hooks/useRenderers.tsx b/code/client/src/editor/slate.js/hooks/useRenderers.tsx similarity index 100% rename from code/client/src/editor/slate/hooks/useRenderers.tsx rename to code/client/src/editor/slate.js/hooks/useRenderers.tsx diff --git a/code/client/src/editor/slate/model/CustomEditor.ts b/code/client/src/editor/slate.js/model/CustomEditor.ts similarity index 100% rename from code/client/src/editor/slate/model/CustomEditor.ts rename to code/client/src/editor/slate.js/model/CustomEditor.ts diff --git a/code/client/src/editor/slate/model/cursor.ts b/code/client/src/editor/slate.js/model/cursor.ts similarity index 100% rename from code/client/src/editor/slate/model/cursor.ts rename to code/client/src/editor/slate.js/model/cursor.ts diff --git a/code/client/src/editor/slate/model/types.ts b/code/client/src/editor/slate.js/model/types.ts similarity index 100% rename from code/client/src/editor/slate/model/types.ts rename to code/client/src/editor/slate.js/model/types.ts diff --git a/code/client/src/editor/slate/model/utils.ts b/code/client/src/editor/slate.js/model/utils.ts similarity index 100% rename from code/client/src/editor/slate/model/utils.ts rename to code/client/src/editor/slate.js/model/utils.ts diff --git a/code/client/src/editor/slate/plugins/markdown/operations.ts b/code/client/src/editor/slate.js/plugins/markdown/operations.ts similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/operations.ts rename to code/client/src/editor/slate.js/plugins/markdown/operations.ts diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/components.ts b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/components.ts similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/components.ts rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/components.ts diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Blockquote.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Blockquote.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Blockquote.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Blockquote.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Code.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Code.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Code.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Code.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading1.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading1.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading1.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading1.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading2.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading2.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading2.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading2.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading3.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading3.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading3.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading3.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading4.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading4.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading4.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading4.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading5.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading5.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading5.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading5.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading6.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading6.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Heading6.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Heading6.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/LineBreak.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/LineBreak.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/LineBreak.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/LineBreak.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/ListItem.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/ListItem.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/ListItem.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/ListItem.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/NumberedListItem.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/NumberedListItem.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/NumberedListItem.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/NumberedListItem.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Paragraph.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Paragraph.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/components/elements/Paragraph.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/components/elements/Paragraph.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/elements.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/elements.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/elements.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/elements.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/rendering/renderers.tsx b/code/client/src/editor/slate.js/plugins/markdown/rendering/renderers.tsx similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/rendering/renderers.tsx rename to code/client/src/editor/slate.js/plugins/markdown/rendering/renderers.tsx diff --git a/code/client/src/editor/slate/plugins/markdown/shortcuts.ts b/code/client/src/editor/slate.js/plugins/markdown/shortcuts.ts similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/shortcuts.ts rename to code/client/src/editor/slate.js/plugins/markdown/shortcuts.ts diff --git a/code/client/src/editor/slate/plugins/markdown/withMarkdown.ts b/code/client/src/editor/slate.js/plugins/markdown/withMarkdown.ts similarity index 100% rename from code/client/src/editor/slate/plugins/markdown/withMarkdown.ts rename to code/client/src/editor/slate.js/plugins/markdown/withMarkdown.ts diff --git a/code/client/src/editor/slate/plugins/normalize/withNormalize.ts b/code/client/src/editor/slate.js/plugins/normalize/withNormalize.ts similarity index 100% rename from code/client/src/editor/slate/plugins/normalize/withNormalize.ts rename to code/client/src/editor/slate.js/plugins/normalize/withNormalize.ts diff --git a/code/client/src/editor/slate/toolbar/Toolbar.tsx b/code/client/src/editor/slate.js/toolbar/Toolbar.tsx similarity index 100% rename from code/client/src/editor/slate/toolbar/Toolbar.tsx rename to code/client/src/editor/slate.js/toolbar/Toolbar.tsx diff --git a/code/client/src/editor/slate/utils/selection.ts b/code/client/src/editor/slate.js/utils/selection.ts similarity index 100% rename from code/client/src/editor/slate/utils/selection.ts rename to code/client/src/editor/slate.js/utils/selection.ts diff --git a/code/client/src/editor/slate/utils/toSlate.ts b/code/client/src/editor/slate.js/utils/toSlate.ts similarity index 100% rename from code/client/src/editor/slate/utils/toSlate.ts rename to code/client/src/editor/slate.js/utils/toSlate.ts diff --git a/code/client/src/socket/socket.ts b/code/client/src/socket.io/socket.ts similarity index 100% rename from code/client/src/socket/socket.ts rename to code/client/src/socket.io/socket.ts diff --git a/code/client/src/socket/useSocketListeners.ts b/code/client/src/socket.io/useSocketListeners.ts similarity index 100% rename from code/client/src/socket/useSocketListeners.ts rename to code/client/src/socket.io/useSocketListeners.ts diff --git a/code/client/tests/editor/crdt/fugue.test.ts b/code/client/tests/editor/crdt/fugue.test.ts index b2849ce3..afcac485 100644 --- a/code/client/tests/editor/crdt/fugue.test.ts +++ b/code/client/tests/editor/crdt/fugue.test.ts @@ -1,6 +1,6 @@ import { Fugue } from '@editor/crdt/fugue'; import { InsertOperation, DeleteOperation } from '@notespace/shared/crdt/types'; -import { Selection, Cursor } from '@editor/slate/model/cursor'; +import { Selection, Cursor } from '@editor/slate.js/model/cursor'; import { InsertNode } from '@editor/crdt/types'; import { describe, it, expect, beforeEach } from 'vitest'; diff --git a/code/server/jest.config.js b/code/server/jest.config.js index d89c26af..deed6882 100644 --- a/code/server/jest.config.js +++ b/code/server/jest.config.js @@ -5,6 +5,15 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', transform: {}, - moduleNameMapper: pathsToModuleNameMapper({ '@src/*': ['./src/*'] }, { prefix: '/' }), + moduleNameMapper: pathsToModuleNameMapper({ + /*Controllers*/ + "@controllers/*": ["./src/controllers/*"], + /*Databases*/ + "@database/*": ["./src/database/*"], + /*Others*/ + '@src/*': ['./src/*'], + "@domain/*": ["./src/domain/*"], + "@services/*": ["./src/services/*"], + }, { prefix: '/' }), transformIgnorePatterns: ['/node_modules/(?!@notespace/shared).+\\.js$'], }; diff --git a/code/server/package.json b/code/server/package.json index 892595e7..bde8d4a0 100644 --- a/code/server/package.json +++ b/code/server/package.json @@ -16,7 +16,7 @@ "@notespace/shared": "file:..\\shared", "cors": "^2.8.5", "dotenv": "^16.4.5", - "express": "^4.19.1", + "express": "^4.19.2", "firebase-admin": "^12.0.0", "lodash": "^4.17.21", "socket.io": "^4.7.5", @@ -31,12 +31,12 @@ "@types/lodash": "^4.17.0", "@types/node": "^20.11.30", "@types/supertest": "^6.0.2", - "@typescript-eslint/eslint-plugin": "^7.3.1", - "@typescript-eslint/parser": "^7.3.1", + "@typescript-eslint/eslint-plugin": "^7.4.0", + "@typescript-eslint/parser": "^7.4.0", "babel-jest": "^29.7.0", "eslint": "^8.57.0", "jest": "^29.7.0", - "knip": "^5.2.2", + "knip": "^5.5.0", "prettier": "^3.2.5", "socket.io-client": "^4.7.5", "test-jest": "^1.0.1", diff --git a/code/server/src/controllers/http/router.ts b/code/server/src/controllers/http/router.ts index 30e48d31..6294508e 100644 --- a/code/server/src/controllers/http/router.ts +++ b/code/server/src/controllers/http/router.ts @@ -1,7 +1,7 @@ import express from 'express'; import { DocumentService } from '@src/types'; -import getDocument from '@src/controllers/http/document/getDocument'; -import deleteDocument from '@src/controllers/http/document/deleteDocument'; +import getDocument from '@controllers/http/document/getDocument'; +import deleteDocument from '@controllers/http/document/deleteDocument'; export default function (service: DocumentService) { if (!service) { diff --git a/code/server/src/controllers/socket/document/onCursorChange.ts b/code/server/src/controllers/socket.io/document/onCursorChange.ts similarity index 100% rename from code/server/src/controllers/socket/document/onCursorChange.ts rename to code/server/src/controllers/socket.io/document/onCursorChange.ts diff --git a/code/server/src/controllers/socket/document/onOperation.ts b/code/server/src/controllers/socket.io/document/onOperation.ts similarity index 91% rename from code/server/src/controllers/socket/document/onOperation.ts rename to code/server/src/controllers/socket.io/document/onOperation.ts index a7b628b8..9789c81d 100644 --- a/code/server/src/controllers/socket/document/onOperation.ts +++ b/code/server/src/controllers/socket.io/document/onOperation.ts @@ -1,6 +1,6 @@ import { Socket } from 'socket.io'; import { DocumentService } from '@src/types'; -import { Operation } from 'shared/crdt/types/operations'; +import { Operation } from '@notespace/shared/crdt/types/operations'; function onOperation(service: DocumentService) { return (socket: Socket, operation: Operation) => { diff --git a/code/server/src/controllers/socket/events.ts b/code/server/src/controllers/socket.io/events.ts similarity index 67% rename from code/server/src/controllers/socket/events.ts rename to code/server/src/controllers/socket.io/events.ts index 8db92fb6..adf5d2c2 100644 --- a/code/server/src/controllers/socket/events.ts +++ b/code/server/src/controllers/socket.io/events.ts @@ -1,5 +1,5 @@ -import onOperation from '@src/controllers/socket/document/onOperation'; -import onCursorChange from '@src/controllers/socket/document/onCursorChange'; +import onOperation from '@controllers/socket.io/document/onOperation'; +import onCursorChange from '@controllers/socket.io/document/onCursorChange'; import { DocumentService, SocketHandler } from '@src/types'; export default function events(service: DocumentService): Record { diff --git a/code/server/src/controllers/socket/onConnection.ts b/code/server/src/controllers/socket.io/onConnection.ts similarity index 89% rename from code/server/src/controllers/socket/onConnection.ts rename to code/server/src/controllers/socket.io/onConnection.ts index 3fdeedc6..a434c788 100644 --- a/code/server/src/controllers/socket/onConnection.ts +++ b/code/server/src/controllers/socket.io/onConnection.ts @@ -1,6 +1,11 @@ import { Socket } from 'socket.io'; import { DocumentService, SocketHandler } from '@src/types'; +/** + * Returns a connection handler for socket.io + * @param service + * @param events + */ function onConnection(service: DocumentService, events: Record) { return async (socket: Socket) => { console.log('a client connected'); diff --git a/code/server/src/database/firestore/operations.ts b/code/server/src/database/firestore/operations.ts index bde00794..4b11d1d4 100644 --- a/code/server/src/database/firestore/operations.ts +++ b/code/server/src/database/firestore/operations.ts @@ -1,5 +1,5 @@ import { InsertOperation, DeleteOperation, StyleOperation } from '@notespace/shared/crdt/types/operations'; -import { getTreeInstance, setDocument, updateTree } from '@src/database/firestore/firestore'; +import { getTreeInstance, setDocument, updateTree } from '@databases/firestore/firestore'; async function getTree() { const tree = await getTreeInstance(); diff --git a/code/server/src/server.ts b/code/server/src/server.ts index 9d09a491..253f430a 100644 --- a/code/server/src/server.ts +++ b/code/server/src/server.ts @@ -3,11 +3,11 @@ import http from 'http'; import { Server } from 'socket.io'; import { config } from 'dotenv'; import cors from 'cors'; -import serviceInit from './services/documentService'; -import eventsInit from './controllers/socket/events'; -import database from './database/memory/operations'; +import serviceInit from '@services/documentService'; +import eventsInit from '@controllers/socket.io/events'; +import database from '@database/memory/operations'; import router from '@src/controllers/http/router'; -import onConnection from '@src/controllers/socket/onConnection'; +import onConnection from '@controllers/socket.io/onConnection'; config(); const PORT = process.env.PORT || 8080; diff --git a/code/server/tsconfig.json b/code/server/tsconfig.json index 44c8453d..7a87a690 100644 --- a/code/server/tsconfig.json +++ b/code/server/tsconfig.json @@ -12,7 +12,14 @@ "downlevelIteration": true, "baseUrl": "../", "paths": { - "@src/*": ["./server/src/*"] + /*Controllers*/ + "@controllers/*": ["./server/src/controllers/*"], + /*Databases*/ + "@database/*": ["./server/src/database/*"], + /*Others*/ + "@src/*": ["./server/src/*"], + "@domain/*": ["./server/src/domain/*"], + "@services/*": ["./server/src/services/*"], } }, "include": ["src/**/*"], diff --git a/code/shared/package.json b/code/shared/package.json index 82be6da9..4af39779 100644 --- a/code/shared/package.json +++ b/code/shared/package.json @@ -13,10 +13,10 @@ "devDependencies": { "@types/lodash": "^4.17.0", "@types/node": "^20.11.30", - "@typescript-eslint/eslint-plugin": "^7.3.1", - "@typescript-eslint/parser": "^7.3.1", + "@typescript-eslint/eslint-plugin": "^7.4.0", + "@typescript-eslint/parser": "^7.4.0", "eslint": "^8.57.0", - "knip": "^5.2.2", + "knip": "^5.5.0", "prettier": "^3.2.5", "typescript": "^5.4.3" },