diff --git a/commons/jest.config.json b/commons/jest.config.json index af756215c..d60dfbf18 100644 --- a/commons/jest.config.json +++ b/commons/jest.config.json @@ -1,26 +1,29 @@ { - "testRegex" : "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "testPathIgnorePatterns" : [ + "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", + "testPathIgnorePatterns": [ "/dist/" ], - "moduleFileExtensions" : [ + "moduleFileExtensions": [ "ts", "tsx", "js" ], - "extensionsToTreatAsEsm" : [ + "extensionsToTreatAsEsm": [ ".ts" ], - "moduleNameMapper" : { - "^(\\.{1,2}/.*)\\.js$" : "$1" + "moduleNameMapper": { + "^(\\.{1,2}/.*)\\.js$": "$1" }, - "transformIgnorePatterns": ["/node_modules/"], - "transform" : { - "^.+\\.tsx?$" : [ + "testEnvironment": "jsdom", + "transformIgnorePatterns": [ + "/node_modules/" + ], + "transform": { + "^.+\\.tsx?$": [ "ts-jest", { - "tsconfig" : "tsconfig.test.json", - "useESM" : true + "tsconfig": "tsconfig.test.json", + "useESM": true } ] } diff --git a/commons/src/utils/index.ts b/commons/src/utils/index.ts index fa097d089..12a056e10 100644 --- a/commons/src/utils/index.ts +++ b/commons/src/utils/index.ts @@ -7,3 +7,4 @@ export * from './wait-for-other-promises-to-finish.js' export type { DeepPartial } from './deep-partial.js' export * from './test-modes.js' +export * from './logger.js' diff --git a/frontend/src/utils/logger.spec.ts b/commons/src/utils/logger.spec.ts similarity index 90% rename from frontend/src/utils/logger.spec.ts rename to commons/src/utils/logger.spec.ts index 961984dc1..7bbc459ec 100644 --- a/frontend/src/utils/logger.spec.ts +++ b/commons/src/utils/logger.spec.ts @@ -3,13 +3,22 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from './logger' +import { Logger } from './logger.js' import { Settings } from 'luxon' import { Mock } from 'ts-mockery' +import { + jest, + describe, + beforeEach, + expect, + it, + afterEach +} from '@jest/globals' +import type { SpyInstance } from 'jest-mock' let testMode = false let devMode = false -jest.mock('@hedgedoc/commons', () => ({ +jest.mock('../utils/test-modes.js', () => ({ get isTestMode() { return testMode }, @@ -22,11 +31,11 @@ describe('Logger', () => { let originalNow: () => number let dateShift = 0 - let infoLogMock: jest.SpyInstance - let warnLogMock: jest.SpyInstance - let errorLogMock: jest.SpyInstance - let debugLogMock: jest.SpyInstance - let defaultLogMock: jest.SpyInstance + let infoLogMock: SpyInstance + let warnLogMock: SpyInstance + let errorLogMock: SpyInstance + let debugLogMock: SpyInstance + let defaultLogMock: SpyInstance let isLocalStorageAccessDenied = false const mockLocalStorage = () => { @@ -63,7 +72,16 @@ describe('Logger', () => { defaultLogMock = jest.spyOn(console, 'log').mockReturnValue() originalNow = Settings.now - Settings.now = () => new Date(2021, 9, 25, dateShift, 1 + dateShift, 2 + dateShift, 3 + dateShift).valueOf() + Settings.now = () => + new Date( + 2021, + 9, + 25, + dateShift, + 1 + dateShift, + 2 + dateShift, + 3 + dateShift + ).valueOf() }) afterEach(() => { diff --git a/frontend/src/utils/logger.ts b/commons/src/utils/logger.ts similarity index 82% rename from frontend/src/utils/logger.ts rename to commons/src/utils/logger.ts index 2a548a5cd..7134faf0a 100644 --- a/frontend/src/utils/logger.ts +++ b/commons/src/utils/logger.ts @@ -1,9 +1,9 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ -import { isDevMode, isTestMode } from '@hedgedoc/commons' +import { isDevMode, isTestMode } from './test-modes.js' import { DateTime } from 'luxon' import pico from 'picocolors' @@ -16,7 +16,8 @@ export class Logger { constructor(scope: string) { this.scope = scope - this.debugLoggingEnabled = isDevMode || isTestMode || this.isDebugLoggingEnabled() + this.debugLoggingEnabled = + isDevMode || isTestMode || this.isDebugLoggingEnabled() } private isDebugLoggingEnabled() { @@ -75,7 +76,11 @@ export class Logger { if (typeof window === 'undefined') { return [pico.yellow(`[${timestamp}]`), pico.green(`(${this.scope})`)] } else { - return [`%c[${timestamp}] %c(${this.scope})`, 'color: yellow', 'color: green'] + return [ + `%c[${timestamp}] %c(${this.scope})`, + 'color: yellow', + 'color: green' + ] } } } diff --git a/frontend/next.config.js b/frontend/next.config.js index f30894f38..d0ed388b8 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -3,17 +3,19 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -const { isMockMode, isTestMode, isProfilingMode, isBuildTime } = require('@hedgedoc/commons') +const { isMockMode, isTestMode, isProfilingMode, isBuildTime, Logger } = require('@hedgedoc/commons') const path = require('path') const CopyWebpackPlugin = require('copy-webpack-plugin') const withBundleAnalyzer = require('@next/bundle-analyzer')({ enabled: isProfilingMode }) -console.log('Node environment is', process.env.NODE_ENV) +const logger = new Logger('Bootstrap') + +logger.info('Node environment is', process.env.NODE_ENV) if (isTestMode) { - console.warn(`This build runs in test mode. This means: + logger.warn(`This build runs in test mode. This means: - No sandboxed iframe - Additional data-attributes for e2e tests added to DOM - Editor and renderer are running on the same origin @@ -22,7 +24,7 @@ if (isTestMode) { } if (isMockMode) { - console.warn(`This build runs in mock mode. This means: + logger.warn(`This build runs in mock mode. This means: - No real data. All API responses are mocked - No persistent data - No realtime editing @@ -30,14 +32,14 @@ if (isMockMode) { } if (isBuildTime) { - console.warn(`This process runs in build mode. During build time this means: + logger.warn(`This process runs in build mode. During build time this means: - Editor and Renderer base urls are https://example.org - No frontend config will be fetched `) } if (isProfilingMode) { - console.info('This build contains the bundle analyzer and profiling metrics.') + logger.info('This build contains the bundle analyzer and profiling metrics.') } /** @type {import('@svgr/webpack').LoaderOptions} */ diff --git a/frontend/src/components/application-loader/application-loader.tsx b/frontend/src/components/application-loader/application-loader.tsx index 3c0062e0c..909f439c5 100644 --- a/frontend/src/components/application-loader/application-loader.tsx +++ b/frontend/src/components/application-loader/application-loader.tsx @@ -4,7 +4,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { ApplicationLoaderError } from './application-loader-error' import { createSetUpTaskList } from './initializers' import { LoadingScreen } from './loading-screen/loading-screen' diff --git a/frontend/src/components/application-loader/initializers/index.ts b/frontend/src/components/application-loader/initializers/index.ts index 646cdae9e..4a494286b 100644 --- a/frontend/src/components/application-loader/initializers/index.ts +++ b/frontend/src/components/application-loader/initializers/index.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { refreshHistoryState } from '../../../redux/history/methods' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { isDevMode, isTestMode } from '@hedgedoc/commons' import { fetchAndSetUser } from '../../login-page/auth/utils' import { loadDarkMode } from './load-dark-mode' diff --git a/frontend/src/components/application-loader/initializers/load-dark-mode.ts b/frontend/src/components/application-loader/initializers/load-dark-mode.ts index e055031b4..0720e109e 100644 --- a/frontend/src/components/application-loader/initializers/load-dark-mode.ts +++ b/frontend/src/components/application-loader/initializers/load-dark-mode.ts @@ -6,7 +6,7 @@ import { DARK_MODE_LOCAL_STORAGE_KEY } from '../../../hooks/dark-mode/use-save-dark-mode-preference-to-local-storage' import { setDarkModePreference } from '../../../redux/dark-mode/methods' import { DarkModePreference } from '../../../redux/dark-mode/types' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' const logger = new Logger('Dark mode initializer') diff --git a/frontend/src/components/common/copyable/copyable-field/copyable-field.tsx b/frontend/src/components/common/copyable/copyable-field/copyable-field.tsx index f458b29e0..2ab1e634c 100644 --- a/frontend/src/components/common/copyable/copyable-field/copyable-field.tsx +++ b/frontend/src/components/common/copyable/copyable-field/copyable-field.tsx @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { UiIcon } from '../../icons/ui-icon' import { ShowIf } from '../../show-if/show-if' import { CopyToClipboardButton } from '../copy-to-clipboard-button/copy-to-clipboard-button' diff --git a/frontend/src/components/common/copyable/hooks/use-copy-overlay.tsx b/frontend/src/components/common/copyable/hooks/use-copy-overlay.tsx index 9a22fd812..ed68b64b2 100644 --- a/frontend/src/components/common/copyable/hooks/use-copy-overlay.tsx +++ b/frontend/src/components/common/copyable/hooks/use-copy-overlay.tsx @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { ShowIf } from '../../show-if/show-if' import type { ReactElement, RefObject } from 'react' import React, { useCallback, useEffect, useMemo, useState } from 'react' diff --git a/frontend/src/components/common/highlighted-code/hooks/use-async-highlight-js-import.tsx b/frontend/src/components/common/highlighted-code/hooks/use-async-highlight-js-import.tsx index 98744d431..27a4345d9 100644 --- a/frontend/src/components/common/highlighted-code/hooks/use-async-highlight-js-import.tsx +++ b/frontend/src/components/common/highlighted-code/hooks/use-async-highlight-js-import.tsx @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import type { HLJSApi } from 'highlight.js' import { useAsync } from 'react-use' import type { AsyncState } from 'react-use/lib/useAsyncFn' diff --git a/frontend/src/components/common/note-loading-boundary/note-loading-boundary.tsx b/frontend/src/components/common/note-loading-boundary/note-loading-boundary.tsx index 37891660f..36206449c 100644 --- a/frontend/src/components/common/note-loading-boundary/note-loading-boundary.tsx +++ b/frontend/src/components/common/note-loading-boundary/note-loading-boundary.tsx @@ -6,7 +6,7 @@ */ import { ApiError } from '../../../api/common/api-error' import { ErrorToI18nKeyMapper } from '../../../api/common/error-to-i18n-key-mapper' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { LoadingScreen } from '../../application-loader/loading-screen/loading-screen' import { CommonErrorPage } from '../../error-pages/common-error-page' import { CustomAsyncLoadingBoundary } from '../async-loading-boundary/custom-async-loading-boundary' diff --git a/frontend/src/components/common/renderer-iframe/hooks/use-force-render-page-url-on-iframe-load-callback.ts b/frontend/src/components/common/renderer-iframe/hooks/use-force-render-page-url-on-iframe-load-callback.ts index 644670aad..55dbb82de 100644 --- a/frontend/src/components/common/renderer-iframe/hooks/use-force-render-page-url-on-iframe-load-callback.ts +++ b/frontend/src/components/common/renderer-iframe/hooks/use-force-render-page-url-on-iframe-load-callback.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { ORIGIN, useBaseUrl } from '../../../../hooks/common/use-base-url' -import { Logger } from '../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { useEditorToRendererCommunicator } from '../../../editor-page/render-context/editor-to-renderer-communicator-context-provider' import type { RefObject } from 'react' import { useCallback, useEffect, useMemo, useRef } from 'react' diff --git a/frontend/src/components/common/renderer-iframe/renderer-iframe.tsx b/frontend/src/components/common/renderer-iframe/renderer-iframe.tsx index a921634ce..845e96341 100644 --- a/frontend/src/components/common/renderer-iframe/renderer-iframe.tsx +++ b/frontend/src/components/common/renderer-iframe/renderer-iframe.tsx @@ -5,7 +5,7 @@ */ import { concatCssClasses } from '../../../utils/concat-css-classes' import { cypressAttribute, cypressId } from '../../../utils/cypress-attribute' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { isTestMode } from '@hedgedoc/commons' import { useEditorToRendererCommunicator } from '../../editor-page/render-context/editor-to-renderer-communicator-context-provider' import type { ScrollProps } from '../../editor-page/synced-scroll/scroll-props' diff --git a/frontend/src/components/common/upload-input.tsx b/frontend/src/components/common/upload-input.tsx index 7486dd148..e5c13da65 100644 --- a/frontend/src/components/common/upload-input.tsx +++ b/frontend/src/components/common/upload-input.tsx @@ -5,7 +5,7 @@ */ import type { PropsWithDataCypressId } from '../../utils/cypress-attribute' import { cypressId } from '../../utils/cypress-attribute' -import { Logger } from '../../utils/logger' +import { Logger } from '@hedgedoc/commons' import type { MutableRefObject } from 'react' import React, { useCallback, useEffect, useRef } from 'react' diff --git a/frontend/src/components/editor-page/editor-pane/hooks/image-upload-from-renderer/use-on-image-upload-from-renderer.ts b/frontend/src/components/editor-page/editor-pane/hooks/image-upload-from-renderer/use-on-image-upload-from-renderer.ts index 124acbd02..8bf476974 100644 --- a/frontend/src/components/editor-page/editor-pane/hooks/image-upload-from-renderer/use-on-image-upload-from-renderer.ts +++ b/frontend/src/components/editor-page/editor-pane/hooks/image-upload-from-renderer/use-on-image-upload-from-renderer.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { getGlobalState } from '../../../../../redux' -import { Logger } from '../../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { useEditorReceiveHandler } from '../../../../render-page/window-post-message-communicator/hooks/use-editor-receive-handler' import type { ImageUploadMessage } from '../../../../render-page/window-post-message-communicator/rendering-message' import { CommunicationMessageType } from '../../../../render-page/window-post-message-communicator/rendering-message' diff --git a/frontend/src/components/editor-page/editor-pane/hooks/use-apply-scroll-state.ts b/frontend/src/components/editor-page/editor-pane/hooks/use-apply-scroll-state.ts index d36f646d2..65c7bdb25 100644 --- a/frontend/src/components/editor-page/editor-pane/hooks/use-apply-scroll-state.ts +++ b/frontend/src/components/editor-page/editor-pane/hooks/use-apply-scroll-state.ts @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { useCodemirrorReferenceContext } from '../../change-content-context/codemirror-reference-context' import type { ScrollState } from '../../synced-scroll/scroll-props' import { EditorView } from '@codemirror/view' diff --git a/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-y-doc-sync-client-adapter.ts b/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-y-doc-sync-client-adapter.ts index ba7647797..bfda454fa 100644 --- a/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-y-doc-sync-client-adapter.ts +++ b/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-y-doc-sync-client-adapter.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { setRealtimeSyncedState } from '../../../../../redux/realtime/methods' -import { Logger } from '../../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import type { MessageTransporter, RealtimeDoc } from '@hedgedoc/commons' import { YDocSyncClientAdapter } from '@hedgedoc/commons' import type { Listener } from 'eventemitter2' diff --git a/frontend/src/components/editor-page/editor-pane/tool-bar/upload-image-button/upload-image-button.tsx b/frontend/src/components/editor-page/editor-pane/tool-bar/upload-image-button/upload-image-button.tsx index afe1a4936..790f455ae 100644 --- a/frontend/src/components/editor-page/editor-pane/tool-bar/upload-image-button/upload-image-button.tsx +++ b/frontend/src/components/editor-page/editor-pane/tool-bar/upload-image-button/upload-image-button.tsx @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { cypressId } from '../../../../../utils/cypress-attribute' -import { Logger } from '../../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { ShowIf } from '../../../../common/show-if/show-if' import { acceptedMimeTypes } from '../../../../common/upload-image-mimetypes' import { UploadInput } from '../../../../common/upload-input' diff --git a/frontend/src/components/editor-page/hooks/use-scroll-state.ts b/frontend/src/components/editor-page/hooks/use-scroll-state.ts index b88d959c7..3315d72f2 100644 --- a/frontend/src/components/editor-page/hooks/use-scroll-state.ts +++ b/frontend/src/components/editor-page/hooks/use-scroll-state.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { useApplicationState } from '../../../hooks/common/use-application-state' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import type { ScrollSource } from '../editor-page-content' import type { ScrollState } from '../synced-scroll/scroll-props' import type { RefObject } from 'react' diff --git a/frontend/src/components/editor-page/hooks/use-set-scroll-source.ts b/frontend/src/components/editor-page/hooks/use-set-scroll-source.ts index f0c9e3d77..d25382f56 100644 --- a/frontend/src/components/editor-page/hooks/use-set-scroll-source.ts +++ b/frontend/src/components/editor-page/hooks/use-set-scroll-source.ts @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import type { ScrollSource } from '../editor-page-content' import type { MutableRefObject } from 'react' import { useCallback } from 'react' diff --git a/frontend/src/components/global-dialogs/motd-modal/fetch-motd.ts b/frontend/src/components/global-dialogs/motd-modal/fetch-motd.ts index 6c2f6f018..3a30dbfae 100644 --- a/frontend/src/components/global-dialogs/motd-modal/fetch-motd.ts +++ b/frontend/src/components/global-dialogs/motd-modal/fetch-motd.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { defaultConfig } from '../../../api/common/default-config' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' export const MOTD_LOCAL_STORAGE_KEY = 'motd.lastModified' const log = new Logger('Motd') diff --git a/frontend/src/components/global-dialogs/motd-modal/motd-modal.tsx b/frontend/src/components/global-dialogs/motd-modal/motd-modal.tsx index 872b9bfb5..c09913d5f 100644 --- a/frontend/src/components/global-dialogs/motd-modal/motd-modal.tsx +++ b/frontend/src/components/global-dialogs/motd-modal/motd-modal.tsx @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { cypressId } from '../../../utils/cypress-attribute' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { testId } from '../../../utils/test-id' import { CommonModal } from '../../common/modals/common-modal' import { RendererIframe } from '../../common/renderer-iframe/renderer-iframe' diff --git a/frontend/src/components/global-dialogs/settings-dialog/global/language-picker.tsx b/frontend/src/components/global-dialogs/settings-dialog/global/language-picker.tsx index e5f424fe1..32b999838 100644 --- a/frontend/src/components/global-dialogs/settings-dialog/global/language-picker.tsx +++ b/frontend/src/components/global-dialogs/settings-dialog/global/language-picker.tsx @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { cypressId } from '../../../../utils/cypress-attribute' -import { Logger } from '../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { testId } from '../../../../utils/test-id' import { availableLanguages } from './available-languages' import { LanguageOption } from './language-option' diff --git a/frontend/src/components/intro-page/intro-custom-content.tsx b/frontend/src/components/intro-page/intro-custom-content.tsx index 13229b674..ad49f8792 100644 --- a/frontend/src/components/intro-page/intro-custom-content.tsx +++ b/frontend/src/components/intro-page/intro-custom-content.tsx @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { AsyncLoadingBoundary } from '../common/async-loading-boundary/async-loading-boundary' import { RendererIframe } from '../common/renderer-iframe/renderer-iframe' import { RendererType } from '../render-page/window-post-message-communicator/rendering-message' diff --git a/frontend/src/components/login-page/auth/utils/get-one-click-provider-metadata.ts b/frontend/src/components/login-page/auth/utils/get-one-click-provider-metadata.ts index 08335f3c8..32f65b51d 100644 --- a/frontend/src/components/login-page/auth/utils/get-one-click-provider-metadata.ts +++ b/frontend/src/components/login-page/auth/utils/get-one-click-provider-metadata.ts @@ -5,7 +5,7 @@ */ import type { AuthProvider } from '../../../../api/config/types' import { AuthProviderType } from '../../../../api/config/types' -import { Logger } from '../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { IconGitlab } from '../../../common/icons/additional/icon-gitlab' import styles from '../via-one-click.module.scss' import type { Icon } from 'react-bootstrap-icons' diff --git a/frontend/src/components/markdown-renderer/extensions/image/proxy-image-frame.tsx b/frontend/src/components/markdown-renderer/extensions/image/proxy-image-frame.tsx index 37b6ed1bd..e3cc6dca6 100644 --- a/frontend/src/components/markdown-renderer/extensions/image/proxy-image-frame.tsx +++ b/frontend/src/components/markdown-renderer/extensions/image/proxy-image-frame.tsx @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { getProxiedUrl } from '../../../../api/media' -import { Logger } from '../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { useFrontendConfig } from '../../../common/frontend-config-context/use-frontend-config' import React, { useEffect, useState } from 'react' diff --git a/frontend/src/components/markdown-renderer/extensions/reveal/process-reveal-comment-nodes.ts b/frontend/src/components/markdown-renderer/extensions/reveal/process-reveal-comment-nodes.ts index 6c6de85f6..bd854dfa5 100644 --- a/frontend/src/components/markdown-renderer/extensions/reveal/process-reveal-comment-nodes.ts +++ b/frontend/src/components/markdown-renderer/extensions/reveal/process-reveal-comment-nodes.ts @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { TravelerNodeProcessor } from '../../node-preprocessors/traveler-node-processor' import type { DataNode, Element, Node } from 'domhandler' import { isComment, isTag } from 'domhandler' diff --git a/frontend/src/components/markdown-renderer/hooks/use-reveal.ts b/frontend/src/components/markdown-renderer/hooks/use-reveal.ts index 9c2290856..3f63f31ef 100644 --- a/frontend/src/components/markdown-renderer/hooks/use-reveal.ts +++ b/frontend/src/components/markdown-renderer/hooks/use-reveal.ts @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import type { SlideOptions } from '@hedgedoc/commons' import { useEffect, useRef, useState } from 'react' import type Reveal from 'reveal.js' diff --git a/frontend/src/components/markdown-renderer/replace-components/click-shield/click-shield.tsx b/frontend/src/components/markdown-renderer/replace-components/click-shield/click-shield.tsx index 92bddd98a..1fd0bacf7 100644 --- a/frontend/src/components/markdown-renderer/replace-components/click-shield/click-shield.tsx +++ b/frontend/src/components/markdown-renderer/replace-components/click-shield/click-shield.tsx @@ -5,7 +5,7 @@ */ import type { PropsWithDataCypressId } from '../../../../utils/cypress-attribute' import { cypressId } from '../../../../utils/cypress-attribute' -import { Logger } from '../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { ShowIf } from '../../../common/show-if/show-if' import { ProxyImageFrame } from '../../extensions/image/proxy-image-frame' import styles from './click-shield.module.scss' diff --git a/frontend/src/components/notifications/ui-notification-boundary.tsx b/frontend/src/components/notifications/ui-notification-boundary.tsx index 90896abff..4f147c466 100644 --- a/frontend/src/components/notifications/ui-notification-boundary.tsx +++ b/frontend/src/components/notifications/ui-notification-boundary.tsx @@ -4,7 +4,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../utils/logger' +import { Logger } from '@hedgedoc/commons' import type { DispatchOptions, UiNotification } from './types' import { UiNotifications } from './ui-notifications' import type { TOptions } from 'i18next' diff --git a/frontend/src/components/notifications/ui-notification-toast.tsx b/frontend/src/components/notifications/ui-notification-toast.tsx index 7a16726f0..26ba6dc19 100644 --- a/frontend/src/components/notifications/ui-notification-toast.tsx +++ b/frontend/src/components/notifications/ui-notification-toast.tsx @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { cypressId } from '../../utils/cypress-attribute' -import { Logger } from '../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { UiIcon } from '../common/icons/ui-icon' import { ShowIf } from '../common/show-if/show-if' import styles from './notifications.module.scss' diff --git a/frontend/src/components/render-page/window-post-message-communicator/editor-to-renderer-communicator.ts b/frontend/src/components/render-page/window-post-message-communicator/editor-to-renderer-communicator.ts index 39644d438..2240c7875 100644 --- a/frontend/src/components/render-page/window-post-message-communicator/editor-to-renderer-communicator.ts +++ b/frontend/src/components/render-page/window-post-message-communicator/editor-to-renderer-communicator.ts @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import type { CommunicationMessages, EditorToRendererMessageType, diff --git a/frontend/src/components/render-page/window-post-message-communicator/renderer-to-editor-communicator.ts b/frontend/src/components/render-page/window-post-message-communicator/renderer-to-editor-communicator.ts index ee04f0694..54945633a 100644 --- a/frontend/src/components/render-page/window-post-message-communicator/renderer-to-editor-communicator.ts +++ b/frontend/src/components/render-page/window-post-message-communicator/renderer-to-editor-communicator.ts @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import type { CommunicationMessages, EditorToRendererMessageType, diff --git a/frontend/src/components/render-page/window-post-message-communicator/window-post-message-communicator.ts b/frontend/src/components/render-page/window-post-message-communicator/window-post-message-communicator.ts index 70004abfa..d377d6802 100644 --- a/frontend/src/components/render-page/window-post-message-communicator/window-post-message-communicator.ts +++ b/frontend/src/components/render-page/window-post-message-communicator/window-post-message-communicator.ts @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import type { Logger } from '../../../utils/logger' +import type { Logger } from '@hedgedoc/commons' import { Optional } from '@mrdrogdrog/optional' import { EventEmitter2 } from 'eventemitter2' diff --git a/frontend/src/extensions/essential-app-extensions/image-placeholder/hooks/use-on-image-upload.ts b/frontend/src/extensions/essential-app-extensions/image-placeholder/hooks/use-on-image-upload.ts index 19eabaa61..7df3c590d 100644 --- a/frontend/src/extensions/essential-app-extensions/image-placeholder/hooks/use-on-image-upload.ts +++ b/frontend/src/extensions/essential-app-extensions/image-placeholder/hooks/use-on-image-upload.ts @@ -5,7 +5,7 @@ */ import { useRendererToEditorCommunicator } from '../../../../components/editor-page/render-context/renderer-to-editor-communicator-context-provider' import { CommunicationMessageType } from '../../../../components/render-page/window-post-message-communicator/rendering-message' -import { Logger } from '../../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { FileContentFormat, readFile } from '../../../../utils/read-file' import { useCallback } from 'react' diff --git a/frontend/src/extensions/external-lib-app-extensions/abcjs/abc-frame.tsx b/frontend/src/extensions/external-lib-app-extensions/abcjs/abc-frame.tsx index 89cc0a8ad..3543a9d9d 100644 --- a/frontend/src/extensions/external-lib-app-extensions/abcjs/abc-frame.tsx +++ b/frontend/src/extensions/external-lib-app-extensions/abcjs/abc-frame.tsx @@ -9,7 +9,7 @@ import { WaitSpinner } from '../../../components/common/wait-spinner/wait-spinne import type { CodeProps } from '../../../components/markdown-renderer/replace-components/code-block-component-replacer' import { useEffectWithCatch } from '../../../hooks/common/use-effect-with-catch' import { cypressId } from '../../../utils/cypress-attribute' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import styles from './abc.module.scss' import React, { useRef } from 'react' import { useAsync } from 'react-use' diff --git a/frontend/src/extensions/external-lib-app-extensions/flowchart/flowchart.tsx b/frontend/src/extensions/external-lib-app-extensions/flowchart/flowchart.tsx index a08b7c085..784bcdd32 100644 --- a/frontend/src/extensions/external-lib-app-extensions/flowchart/flowchart.tsx +++ b/frontend/src/extensions/external-lib-app-extensions/flowchart/flowchart.tsx @@ -8,7 +8,7 @@ import { AsyncLoadingBoundary } from '../../../components/common/async-loading-b import { ShowIf } from '../../../components/common/show-if/show-if' import type { CodeProps } from '../../../components/markdown-renderer/replace-components/code-block-component-replacer' import { useDarkModeState } from '../../../hooks/dark-mode/use-dark-mode-state' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { testId } from '../../../utils/test-id' import React, { useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' diff --git a/frontend/src/extensions/external-lib-app-extensions/graphviz/graphviz-frame.tsx b/frontend/src/extensions/external-lib-app-extensions/graphviz/graphviz-frame.tsx index 9544da45f..bdc85cca1 100644 --- a/frontend/src/extensions/external-lib-app-extensions/graphviz/graphviz-frame.tsx +++ b/frontend/src/extensions/external-lib-app-extensions/graphviz/graphviz-frame.tsx @@ -7,7 +7,7 @@ import { AsyncLoadingBoundary } from '../../../components/common/async-loading-b import { ShowIf } from '../../../components/common/show-if/show-if' import type { CodeProps } from '../../../components/markdown-renderer/replace-components/code-block-component-replacer' import { cypressId } from '../../../utils/cypress-attribute' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import React, { useCallback, useEffect, useRef, useState } from 'react' import { useAsync } from 'react-use' import { ApplicationErrorAlert } from '../../../components/common/application-error-alert/application-error-alert' diff --git a/frontend/src/extensions/external-lib-app-extensions/mermaid/mermaid-chart.tsx b/frontend/src/extensions/external-lib-app-extensions/mermaid/mermaid-chart.tsx index df229050d..05284a1d3 100644 --- a/frontend/src/extensions/external-lib-app-extensions/mermaid/mermaid-chart.tsx +++ b/frontend/src/extensions/external-lib-app-extensions/mermaid/mermaid-chart.tsx @@ -6,7 +6,7 @@ import { ShowIf } from '../../../components/common/show-if/show-if' import type { CodeProps } from '../../../components/markdown-renderer/replace-components/code-block-component-replacer' import { cypressId } from '../../../utils/cypress-attribute' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import styles from './mermaid.module.scss' import React, { Fragment, useRef } from 'react' import { useTranslation } from 'react-i18next' diff --git a/frontend/src/extensions/external-lib-app-extensions/vega-lite/vega-lite-chart.tsx b/frontend/src/extensions/external-lib-app-extensions/vega-lite/vega-lite-chart.tsx index 0bce2588e..f6bab0ad6 100644 --- a/frontend/src/extensions/external-lib-app-extensions/vega-lite/vega-lite-chart.tsx +++ b/frontend/src/extensions/external-lib-app-extensions/vega-lite/vega-lite-chart.tsx @@ -6,7 +6,7 @@ import { AsyncLoadingBoundary } from '../../../components/common/async-loading-boundary/async-loading-boundary' import { ShowIf } from '../../../components/common/show-if/show-if' import type { CodeProps } from '../../../components/markdown-renderer/replace-components/code-block-component-replacer' -import { Logger } from '../../../utils/logger' +import { Logger } from '@hedgedoc/commons' import React, { useEffect, useRef } from 'react' import { useTranslation } from 'react-i18next' import { useAsync } from 'react-use' diff --git a/frontend/src/hooks/dark-mode/use-save-dark-mode-preference-to-local-storage.ts b/frontend/src/hooks/dark-mode/use-save-dark-mode-preference-to-local-storage.ts index a647c78d3..84d90522f 100644 --- a/frontend/src/hooks/dark-mode/use-save-dark-mode-preference-to-local-storage.ts +++ b/frontend/src/hooks/dark-mode/use-save-dark-mode-preference-to-local-storage.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { DarkModePreference } from '../../redux/dark-mode/types' -import { Logger } from '../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { useApplicationState } from '../common/use-application-state' import { useEffect } from 'react' diff --git a/frontend/src/redux/editor/reducers.ts b/frontend/src/redux/editor/reducers.ts index e8bfa598f..be3e4b6f4 100644 --- a/frontend/src/redux/editor/reducers.ts +++ b/frontend/src/redux/editor/reducers.ts @@ -6,7 +6,7 @@ import type { EditorConfig, EditorConfigActions } from './types' import { EditorConfigActionType } from './types' import type { Reducer } from 'redux' -import { Logger } from '../../utils/logger' +import { Logger } from '@hedgedoc/commons' const logger = new Logger('EditorConfig Local Storage') diff --git a/frontend/src/redux/history/methods.ts b/frontend/src/redux/history/methods.ts index 5052458eb..f467f7a3c 100644 --- a/frontend/src/redux/history/methods.ts +++ b/frontend/src/redux/history/methods.ts @@ -14,7 +14,7 @@ import { addRemoteOriginToHistoryEntry, historyEntryToHistoryEntryPutDto } from import type { HistoryEntry, HistoryEntryWithOrigin } from '../../api/history/types' import { HistoryEntryOrigin } from '../../api/history/types' import { download } from '../../components/common/download/download' -import { Logger } from '../../utils/logger' +import { Logger } from '@hedgedoc/commons' import { getGlobalState, store } from '../index' import type { HistoryExportJson, RemoveEntryAction, SetEntriesAction, UpdateEntryAction, V1HistoryEntry } from './types' import { HistoryActionType } from './types' diff --git a/frontend/src/utils/base-url-from-env-extractor.ts b/frontend/src/utils/base-url-from-env-extractor.ts index 3970e57a0..858c5ed2e 100644 --- a/frontend/src/utils/base-url-from-env-extractor.ts +++ b/frontend/src/utils/base-url-from-env-extractor.ts @@ -4,9 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import type { BaseUrls } from '../components/common/base-url/base-url-context-provider' -import { Logger } from './logger' -import { isTestMode, isBuildTime } from '@hedgedoc/commons' -import { NoSubdirectoryAllowedError, parseUrl } from '@hedgedoc/commons' +import { NoSubdirectoryAllowedError, parseUrl, Logger, isTestMode, isBuildTime } from '@hedgedoc/commons' import { Optional } from '@mrdrogdrog/optional' /**