diff --git a/source/scripts/common/enums/api/api-error-message.enum.js b/source/scripts/common/enums/api/api-error-message.enum.js deleted file mode 100644 index ff94bd55..00000000 --- a/source/scripts/common/enums/api/api-error-message.enum.js +++ /dev/null @@ -1,5 +0,0 @@ -let ApiErrorMessage = /** @type {const} */ ({ - NETWORK_ERROR: `Network Error`, -}) - -export { ApiErrorMessage } diff --git a/source/scripts/common/enums/api/api.js b/source/scripts/common/enums/api/api.js deleted file mode 100644 index 8a881278..00000000 --- a/source/scripts/common/enums/api/api.js +++ /dev/null @@ -1,3 +0,0 @@ -export { ApiErrorMessage } from './api-error-message.enum.js' -export { ApiPath } from './api-path.enum.js' -export { TimelineApiPath } from './timeline-api-path.enum.js' diff --git a/source/scripts/common/enums/app/app.js b/source/scripts/common/enums/app/app.js deleted file mode 100644 index 81b3bc92..00000000 --- a/source/scripts/common/enums/app/app.js +++ /dev/null @@ -1 +0,0 @@ -export { AppConfig } from './app-config.enum.js' diff --git a/source/scripts/common/enums/enums.js b/source/scripts/common/enums/enums.js deleted file mode 100644 index e2471a63..00000000 --- a/source/scripts/common/enums/enums.js +++ /dev/null @@ -1,9 +0,0 @@ -export { ApiErrorMessage, ApiPath, TimelineApiPath } from './api/api.js' -export { AppConfig } from './app/app.js' -export { KeyboardKey } from './event/event.js' -export { CustomExceptionName } from './exception/exception.js' -export { ContentType } from './file/file.js' -export { HttpCode, HttpHeader, HttpMethod } from './http/http.js' -export { NotificationMessage } from './notification/notification.js' -export { SettingButtonLabel, SettingName } from './setting/setting.js' -export { SkillType, TimelineType } from './timeline/timeline.js' diff --git a/source/scripts/common/enums/event/event.js b/source/scripts/common/enums/event/event.js deleted file mode 100644 index 5b0f6b34..00000000 --- a/source/scripts/common/enums/event/event.js +++ /dev/null @@ -1 +0,0 @@ -export { KeyboardKey } from './keyboard-key.enum.js' diff --git a/source/scripts/common/enums/exception/exception.js b/source/scripts/common/enums/exception/exception.js deleted file mode 100644 index 0b7b60b7..00000000 --- a/source/scripts/common/enums/exception/exception.js +++ /dev/null @@ -1 +0,0 @@ -export { CustomExceptionName } from './custom-exception-name.enum.js' diff --git a/source/scripts/common/enums/file/file.js b/source/scripts/common/enums/file/file.js deleted file mode 100644 index 853bb432..00000000 --- a/source/scripts/common/enums/file/file.js +++ /dev/null @@ -1 +0,0 @@ -export { ContentType } from './content-type.enum.js' diff --git a/source/scripts/common/enums/notification/notification.js b/source/scripts/common/enums/notification/notification.js deleted file mode 100644 index 2a4b576d..00000000 --- a/source/scripts/common/enums/notification/notification.js +++ /dev/null @@ -1 +0,0 @@ -export { NotificationMessage } from './notification-message.enum.js' diff --git a/source/scripts/common/enums/timeline/skill-type.enum.js b/source/scripts/common/enums/timeline/skill-type.enum.js deleted file mode 100644 index f73745d1..00000000 --- a/source/scripts/common/enums/timeline/skill-type.enum.js +++ /dev/null @@ -1,6 +0,0 @@ -let SkillType = /** @type {const} */ ({ - HARD_SKILL: `hardSkill`, - SOFT_SKILL: `softSkill`, -}) - -export { SkillType } diff --git a/source/scripts/common/enums/timeline/timeline.js b/source/scripts/common/enums/timeline/timeline.js deleted file mode 100644 index 4f6d6c80..00000000 --- a/source/scripts/common/enums/timeline/timeline.js +++ /dev/null @@ -1,2 +0,0 @@ -export { SkillType } from './skill-type.enum.js' -export { TimelineType } from './timeline-type.enum.js' diff --git a/source/scripts/common/maps/maps.js b/source/scripts/common/maps/maps.js deleted file mode 100644 index 38d11f2e..00000000 --- a/source/scripts/common/maps/maps.js +++ /dev/null @@ -1 +0,0 @@ -export { booleanToNumber } from './number/number.js' diff --git a/source/scripts/common/types/timeline/timeline-filter.d.type.d.ts b/source/scripts/common/types/timeline/timeline-filter.d.type.d.ts deleted file mode 100644 index a321b0b8..00000000 --- a/source/scripts/common/types/timeline/timeline-filter.d.type.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { type TimelineType, type SkillType } from '~/common/enums/enums.js' - -type TimelineFilter = { - skillTypes: Record<(typeof SkillType)[keyof typeof SkillType], boolean> - types: Record<(typeof TimelineType)[keyof typeof TimelineType], boolean> -} - -export { type TimelineFilter } diff --git a/source/scripts/form.js b/source/scripts/form.js index 91457cad..2dd13597 100644 --- a/source/scripts/form.js +++ b/source/scripts/form.js @@ -1,5 +1,5 @@ -import { Form } from '~/components/form/form.js' -import { timelineApi } from '~/services/services.js' +import { timelineApi } from '~/packages/timeline/timeline.js' +import { Form } from '~/pages/form/form.js' let form = new Form({ timelineApi, diff --git a/source/scripts/globals.d.ts b/source/scripts/globals.d.ts index 200414bf..e442fadd 100644 --- a/source/scripts/globals.d.ts +++ b/source/scripts/globals.d.ts @@ -1,4 +1,4 @@ -import { WhatisloveMath } from '~/services/whatislove-math/whatislove-math.service.js' +import { WhatisloveMath } from '~/libs/packages/whatislove-math/whatislove-math.js' declare global { var WhatisloveMath: WhatisloveMath diff --git a/source/scripts/helpers/api/api.js b/source/scripts/helpers/api/api.js deleted file mode 100644 index ef63b7fd..00000000 --- a/source/scripts/helpers/api/api.js +++ /dev/null @@ -1 +0,0 @@ -export { getServerApiUrl } from './get-server-api-url/get-server-api-url.helper.js' diff --git a/source/scripts/helpers/boolean/boolean.js b/source/scripts/helpers/boolean/boolean.js deleted file mode 100644 index 004d6dda..00000000 --- a/source/scripts/helpers/boolean/boolean.js +++ /dev/null @@ -1,2 +0,0 @@ -export { checkIsBeforeElement } from './check-is-before-element/check-is-before-element.helper.js' -export { checkIsOneOf } from './check-is-one-of/check-is-one-of.helper.js' diff --git a/source/scripts/helpers/date/date.js b/source/scripts/helpers/date/date.js deleted file mode 100644 index ebcc8f4d..00000000 --- a/source/scripts/helpers/date/date.js +++ /dev/null @@ -1 +0,0 @@ -export { getFormattedDate } from './get-formatted-date/get-formatted-date.helper.js' diff --git a/source/scripts/helpers/dom/dom.js b/source/scripts/helpers/dom/dom.js deleted file mode 100644 index ef9643a8..00000000 --- a/source/scripts/helpers/dom/dom.js +++ /dev/null @@ -1,3 +0,0 @@ -export { createElement } from './create-element/create-element.helper.js' -export { getCustomAttributeName } from './get-custom-attribute-name/get-custom-attribute-name.helper.js' -export { subscribeFocusTrap } from './subscribe-focus-trap/subscribe-focus-trap.helper.js' diff --git a/source/scripts/helpers/form/form.js b/source/scripts/helpers/form/form.js deleted file mode 100644 index cd812b6f..00000000 --- a/source/scripts/helpers/form/form.js +++ /dev/null @@ -1,4 +0,0 @@ -export { addSelectOptions } from './add-select-options/add-select-options.helper.js' -export { createSelectOptions } from './create-select-options/create-select-options.helper.js' -export { fillSelectOptions } from './fill-select-options/fill-select-options.helper.js' -export { getFormValues } from 'form-payload' diff --git a/source/scripts/helpers/helpers.js b/source/scripts/helpers/helpers.js deleted file mode 100644 index 2cc606d3..00000000 --- a/source/scripts/helpers/helpers.js +++ /dev/null @@ -1,17 +0,0 @@ -export { getServerApiUrl } from './api/api.js' -export { checkIsBeforeElement, checkIsOneOf } from './boolean/boolean.js' -export { getFormattedDate } from './date/date.js' -export { - createElement, - getCustomAttributeName, - subscribeFocusTrap, -} from './dom/dom.js' -export { - addSelectOptions, - createSelectOptions, - fillSelectOptions, - getFormValues, -} from './form/form.js' -export { getRandomNumber } from './number/number.js' -export { getStringWitCheck } from './string/string.js' -export { debounce, setAsyncTimeout } from './timeout/timeout.js' diff --git a/source/scripts/helpers/number/number.js b/source/scripts/helpers/number/number.js deleted file mode 100644 index 0b135bc1..00000000 --- a/source/scripts/helpers/number/number.js +++ /dev/null @@ -1 +0,0 @@ -export { getRandomNumber } from './get-random-number/get-random-number.helper.js' diff --git a/source/scripts/helpers/string/string.js b/source/scripts/helpers/string/string.js deleted file mode 100644 index 8b6e4a61..00000000 --- a/source/scripts/helpers/string/string.js +++ /dev/null @@ -1 +0,0 @@ -export { getStringWitCheck } from './get-string-with-check/get-string-with-check.helper.js' diff --git a/source/scripts/helpers/timeout/timeout.js b/source/scripts/helpers/timeout/timeout.js deleted file mode 100644 index 098c9e4d..00000000 --- a/source/scripts/helpers/timeout/timeout.js +++ /dev/null @@ -1,2 +0,0 @@ -export { debounce } from './debounce/debounce.helper.js' -export { setAsyncTimeout } from './set-async-timeout/set-async-timeout.helper.js' diff --git a/source/scripts/index.js b/source/scripts/index.js index 8d9b3c84..79bc5c7c 100644 --- a/source/scripts/index.js +++ b/source/scripts/index.js @@ -1,5 +1,7 @@ -import { Home } from '~/components/home/home.js' -import { storage, timelineApi, WhatisloveMath } from '~/services/services.js' +import { storage } from '~/libs/packages/storage/storage.js' +import { WhatisloveMath } from '~/libs/packages/whatislove-math/whatislove-math.package.js' +import { timelineApi } from '~/packages/timeline/timeline.js' +import { Home } from '~/pages/home/home.js' let home = new Home({ storage, diff --git a/source/scripts/components/common/common.js b/source/scripts/libs/components/components.js similarity index 100% rename from source/scripts/components/common/common.js rename to source/scripts/libs/components/components.js diff --git a/source/scripts/components/common/loader/helpers/get-loader-element/get-loader-element.helper.js b/source/scripts/libs/components/loader/libs/helpers/get-loader-element/get-loader-element.helper.js similarity index 79% rename from source/scripts/components/common/loader/helpers/get-loader-element/get-loader-element.helper.js rename to source/scripts/libs/components/loader/libs/helpers/get-loader-element/get-loader-element.helper.js index 78c96638..b407bbaa 100644 --- a/source/scripts/components/common/loader/helpers/get-loader-element/get-loader-element.helper.js +++ b/source/scripts/libs/components/loader/libs/helpers/get-loader-element/get-loader-element.helper.js @@ -1,4 +1,4 @@ -import { createElement } from '~/helpers/helpers.js' +import { createElement } from '~/libs/helpers/helpers.js' /** @returns {HTMLElement} */ let getLoaderElement = () => { diff --git a/source/scripts/components/common/loader/helpers/helpers.js b/source/scripts/libs/components/loader/libs/helpers/helpers.js similarity index 100% rename from source/scripts/components/common/loader/helpers/helpers.js rename to source/scripts/libs/components/loader/libs/helpers/helpers.js diff --git a/source/scripts/components/common/loader/loader.js b/source/scripts/libs/components/loader/loader.js similarity index 89% rename from source/scripts/components/common/loader/loader.js rename to source/scripts/libs/components/loader/loader.js index 22a80bd7..e4a9b8bd 100644 --- a/source/scripts/components/common/loader/loader.js +++ b/source/scripts/libs/components/loader/loader.js @@ -1,4 +1,4 @@ -import { getLoaderElement } from './helpers/helpers.js' +import { getLoaderElement } from './libs/helpers/helpers.js' class Loader { /** diff --git a/source/scripts/components/common/toast/common/constants.js b/source/scripts/libs/components/toast/libs/constants/constants.js similarity index 100% rename from source/scripts/components/common/toast/common/constants.js rename to source/scripts/libs/components/toast/libs/constants/constants.js diff --git a/source/scripts/components/common/toast/toast.js b/source/scripts/libs/components/toast/toast.js similarity index 90% rename from source/scripts/components/common/toast/toast.js rename to source/scripts/libs/components/toast/toast.js index 35e5d679..9bcf92d3 100644 --- a/source/scripts/components/common/toast/toast.js +++ b/source/scripts/libs/components/toast/toast.js @@ -1,12 +1,12 @@ -import { setAsyncTimeout } from '~/helpers/helpers.js' +import { setAsyncTimeout } from '~/libs/helpers/helpers.js' import { CLEAN_MESSAGE_DELAY, TOAST_DEFAULT_DURATION, TOAST_SHOW_CLASS_NAME, -} from './common/constants.js' +} from './libs/constants/constants.js' -/** @typedef {import('~/common/types/toast/toast').ToastMessagePayload} ToastMessagePayload */ +/** @typedef {import('~/libs/types/types').ToastMessagePayload} ToastMessagePayload */ class Toast { constructor() { diff --git a/source/scripts/common/enums/api/api-path.enum.js b/source/scripts/libs/enums/api-path.enum.js similarity index 100% rename from source/scripts/common/enums/api/api-path.enum.js rename to source/scripts/libs/enums/api-path.enum.js diff --git a/source/scripts/common/enums/app/app-config.enum.js b/source/scripts/libs/enums/app-config.enum.js similarity index 100% rename from source/scripts/common/enums/app/app-config.enum.js rename to source/scripts/libs/enums/app-config.enum.js diff --git a/source/scripts/common/enums/file/content-type.enum.js b/source/scripts/libs/enums/content-type.enum.js similarity index 100% rename from source/scripts/common/enums/file/content-type.enum.js rename to source/scripts/libs/enums/content-type.enum.js diff --git a/source/scripts/common/enums/exception/custom-exception-name.enum.js b/source/scripts/libs/enums/custom-exception-name.enum.js similarity index 100% rename from source/scripts/common/enums/exception/custom-exception-name.enum.js rename to source/scripts/libs/enums/custom-exception-name.enum.js diff --git a/source/scripts/libs/enums/enums.js b/source/scripts/libs/enums/enums.js new file mode 100644 index 00000000..335c63c2 --- /dev/null +++ b/source/scripts/libs/enums/enums.js @@ -0,0 +1,7 @@ +export { ApiPath } from './api-path.enum.js' +export { AppConfig } from './app-config.enum.js' +export { ContentType } from './content-type.enum.js' +export { CustomExceptionName } from './custom-exception-name.enum.js' +export { ErrorMessage } from './error-message.enum.js' +export { KeyboardKey } from './keyboard-key.enum.js' +export { NotificationMessage } from './notification-message.enum.js' diff --git a/source/scripts/libs/enums/error-message.enum.js b/source/scripts/libs/enums/error-message.enum.js new file mode 100644 index 00000000..1615e1e9 --- /dev/null +++ b/source/scripts/libs/enums/error-message.enum.js @@ -0,0 +1,5 @@ +let ErrorMessage = /** @type {const} */ ({ + NETWORK_ERROR: `Network Error`, +}) + +export { ErrorMessage } diff --git a/source/scripts/common/enums/event/keyboard-key.enum.js b/source/scripts/libs/enums/keyboard-key.enum.js similarity index 100% rename from source/scripts/common/enums/event/keyboard-key.enum.js rename to source/scripts/libs/enums/keyboard-key.enum.js diff --git a/source/scripts/common/enums/notification/notification-message.enum.js b/source/scripts/libs/enums/notification-message.enum.js similarity index 100% rename from source/scripts/common/enums/notification/notification-message.enum.js rename to source/scripts/libs/enums/notification-message.enum.js diff --git a/source/scripts/helpers/form/add-select-options/add-select-options.helper.js b/source/scripts/libs/helpers/add-select-options/add-select-options.helper.js similarity index 100% rename from source/scripts/helpers/form/add-select-options/add-select-options.helper.js rename to source/scripts/libs/helpers/add-select-options/add-select-options.helper.js diff --git a/source/scripts/helpers/boolean/check-is-before-element/check-is-before-element.helper.js b/source/scripts/libs/helpers/check-is-before-element/check-is-before-element.helper.js similarity index 100% rename from source/scripts/helpers/boolean/check-is-before-element/check-is-before-element.helper.js rename to source/scripts/libs/helpers/check-is-before-element/check-is-before-element.helper.js diff --git a/source/scripts/helpers/boolean/check-is-one-of/check-is-one-of.helper.js b/source/scripts/libs/helpers/check-is-one-of/check-is-one-of.helper.js similarity index 100% rename from source/scripts/helpers/boolean/check-is-one-of/check-is-one-of.helper.js rename to source/scripts/libs/helpers/check-is-one-of/check-is-one-of.helper.js diff --git a/source/scripts/helpers/dom/create-element/create-element.helper.js b/source/scripts/libs/helpers/create-element/create-element.helper.js similarity index 100% rename from source/scripts/helpers/dom/create-element/create-element.helper.js rename to source/scripts/libs/helpers/create-element/create-element.helper.js diff --git a/source/scripts/helpers/form/create-select-options/create-select-options.helper.js b/source/scripts/libs/helpers/create-select-options/create-select-options.helper.js similarity index 100% rename from source/scripts/helpers/form/create-select-options/create-select-options.helper.js rename to source/scripts/libs/helpers/create-select-options/create-select-options.helper.js diff --git a/source/scripts/helpers/form/fill-select-options/fill-select-options.helper.js b/source/scripts/libs/helpers/fill-select-options/fill-select-options.helper.js similarity index 57% rename from source/scripts/helpers/form/fill-select-options/fill-select-options.helper.js rename to source/scripts/libs/helpers/fill-select-options/fill-select-options.helper.js index 06fc880d..45f8e2fe 100644 --- a/source/scripts/helpers/form/fill-select-options/fill-select-options.helper.js +++ b/source/scripts/libs/helpers/fill-select-options/fill-select-options.helper.js @@ -1,5 +1,5 @@ -import { addSelectOptions } from '~/helpers/form/add-select-options/add-select-options.helper.js' -import { createSelectOptions } from '~/helpers/form/create-select-options/create-select-options.helper.js' +import { addSelectOptions } from '../add-select-options/add-select-options.helper.js' +import { createSelectOptions } from '../create-select-options/create-select-options.helper.js' /** * @param {HTMLSelectElement} selectNode diff --git a/source/scripts/helpers/dom/get-custom-attribute-name/get-custom-attribute-name.helper.js b/source/scripts/libs/helpers/get-custom-attribute-name/get-custom-attribute-name.helper.js similarity index 100% rename from source/scripts/helpers/dom/get-custom-attribute-name/get-custom-attribute-name.helper.js rename to source/scripts/libs/helpers/get-custom-attribute-name/get-custom-attribute-name.helper.js diff --git a/source/scripts/helpers/date/get-formatted-date/get-formatted-date.helper.js b/source/scripts/libs/helpers/get-formatted-date/get-formatted-date.helper.js similarity index 100% rename from source/scripts/helpers/date/get-formatted-date/get-formatted-date.helper.js rename to source/scripts/libs/helpers/get-formatted-date/get-formatted-date.helper.js diff --git a/source/scripts/helpers/number/get-random-number/get-random-number.helper.js b/source/scripts/libs/helpers/get-random-number/get-random-number.helper.js similarity index 100% rename from source/scripts/helpers/number/get-random-number/get-random-number.helper.js rename to source/scripts/libs/helpers/get-random-number/get-random-number.helper.js diff --git a/source/scripts/helpers/api/get-server-api-url/get-server-api-url.helper.js b/source/scripts/libs/helpers/get-server-api-url/get-server-api-url.helper.js similarity index 100% rename from source/scripts/helpers/api/get-server-api-url/get-server-api-url.helper.js rename to source/scripts/libs/helpers/get-server-api-url/get-server-api-url.helper.js diff --git a/source/scripts/helpers/string/get-string-with-check/get-string-with-check.helper.js b/source/scripts/libs/helpers/get-string-with-check/get-string-with-check.helper.js similarity index 100% rename from source/scripts/helpers/string/get-string-with-check/get-string-with-check.helper.js rename to source/scripts/libs/helpers/get-string-with-check/get-string-with-check.helper.js diff --git a/source/scripts/libs/helpers/helpers.js b/source/scripts/libs/helpers/helpers.js new file mode 100644 index 00000000..d66649ac --- /dev/null +++ b/source/scripts/libs/helpers/helpers.js @@ -0,0 +1,15 @@ +export { addSelectOptions } from './add-select-options/add-select-options.helper.js' +export { checkIsBeforeElement } from './check-is-before-element/check-is-before-element.helper.js' +export { checkIsOneOf } from './check-is-one-of/check-is-one-of.helper.js' +export { createElement } from './create-element/create-element.helper.js' +export { createSelectOptions } from './create-select-options/create-select-options.helper.js' +export { fillSelectOptions } from './fill-select-options/fill-select-options.helper.js' +export { getCustomAttributeName } from './get-custom-attribute-name/get-custom-attribute-name.helper.js' +export { getFormattedDate } from './get-formatted-date/get-formatted-date.helper.js' +export { getRandomNumber } from './get-random-number/get-random-number.helper.js' +export { getServerApiUrl } from './get-server-api-url/get-server-api-url.helper.js' +export { getStringWitCheck } from './get-string-with-check/get-string-with-check.helper.js' +export { initDebounce } from './init-debounce/init-debounce.helper.js' +export { setAsyncTimeout } from './set-async-timeout/set-async-timeout.helper.js' +export { subscribeFocusTrap } from './subscribe-focus-trap/subscribe-focus-trap.helper.js' +export { getFormValues } from 'form-payload' diff --git a/source/scripts/helpers/timeout/debounce/debounce.helper.js b/source/scripts/libs/helpers/init-debounce/init-debounce.helper.js similarity index 83% rename from source/scripts/helpers/timeout/debounce/debounce.helper.js rename to source/scripts/libs/helpers/init-debounce/init-debounce.helper.js index c8d5c925..d42be088 100644 --- a/source/scripts/helpers/timeout/debounce/debounce.helper.js +++ b/source/scripts/libs/helpers/init-debounce/init-debounce.helper.js @@ -3,7 +3,7 @@ * @param {number} delay * @returns {(...args: unknown[]) => unknown} */ -let debounce = (callback, delay) => { +let initDebounce = (callback, delay) => { let /** @type {undefined | number} */ timeout return (...arguments_) => { @@ -13,4 +13,4 @@ let debounce = (callback, delay) => { } } -export { debounce } +export { initDebounce } diff --git a/source/scripts/helpers/timeout/set-async-timeout/set-async-timeout.helper.js b/source/scripts/libs/helpers/set-async-timeout/set-async-timeout.helper.js similarity index 100% rename from source/scripts/helpers/timeout/set-async-timeout/set-async-timeout.helper.js rename to source/scripts/libs/helpers/set-async-timeout/set-async-timeout.helper.js diff --git a/source/scripts/helpers/dom/subscribe-focus-trap/subscribe-focus-trap.helper.js b/source/scripts/libs/helpers/subscribe-focus-trap/subscribe-focus-trap.helper.js similarity index 95% rename from source/scripts/helpers/dom/subscribe-focus-trap/subscribe-focus-trap.helper.js rename to source/scripts/libs/helpers/subscribe-focus-trap/subscribe-focus-trap.helper.js index e9d1d851..64536f88 100644 --- a/source/scripts/helpers/dom/subscribe-focus-trap/subscribe-focus-trap.helper.js +++ b/source/scripts/libs/helpers/subscribe-focus-trap/subscribe-focus-trap.helper.js @@ -1,4 +1,4 @@ -import { KeyboardKey } from '~/common/enums/enums.js' +import { KeyboardKey } from '~/libs/enums/enums.js' /** * @param {HTMLElement[]} elements diff --git a/source/scripts/common/maps/number/boolean-to-number.map.js b/source/scripts/libs/maps/boolean-to-number.map.js similarity index 100% rename from source/scripts/common/maps/number/boolean-to-number.map.js rename to source/scripts/libs/maps/boolean-to-number.map.js diff --git a/source/scripts/common/maps/number/number.js b/source/scripts/libs/maps/maps.js similarity index 100% rename from source/scripts/common/maps/number/number.js rename to source/scripts/libs/maps/maps.js diff --git a/source/scripts/libs/packages/http/http.js b/source/scripts/libs/packages/http/http.js new file mode 100644 index 00000000..6e6942c0 --- /dev/null +++ b/source/scripts/libs/packages/http/http.js @@ -0,0 +1,7 @@ +import { Http } from './http.package.js' + +let http = new Http() + +export { http } +export { Http } from './http.package.js' +export { HttpMethod } from './libs/enums/enums.js' diff --git a/source/scripts/services/http/http.service.js b/source/scripts/libs/packages/http/http.package.js similarity index 81% rename from source/scripts/services/http/http.service.js rename to source/scripts/libs/packages/http/http.package.js index 444e5ca7..455cb2c3 100644 --- a/source/scripts/services/http/http.service.js +++ b/source/scripts/libs/packages/http/http.package.js @@ -1,11 +1,8 @@ -import { - ApiErrorMessage, - ContentType, - HttpHeader, - HttpMethod, -} from '~/common/enums/enums.js' -import { HttpError } from '~/exceptions/exceptions.js' -import { checkIsOneOf } from '~/helpers/helpers.js' +import { ContentType, ErrorMessage } from '~/libs/enums/enums.js' +import { checkIsOneOf } from '~/libs/helpers/helpers.js' + +import { HttpHeader, HttpMethod } from './libs/enums/enums.js' +import { HttpError } from './libs/exceptions/exceptions.js' class Http { /** @@ -17,8 +14,8 @@ class Http { if (!response.ok) { throw new HttpError({ message: - /** @type {(typeof ApiErrorMessage)[keyof typeof ApiErrorMessage]} */ ( - response.statusText ?? ApiErrorMessage.NETWORK_ERROR + /** @type {(typeof ErrorMessage)[keyof typeof ErrorMessage]} */ ( + response.statusText ?? ErrorMessage.NETWORK_ERROR ), }) } diff --git a/source/scripts/common/enums/http/http.js b/source/scripts/libs/packages/http/libs/enums/enums.js similarity index 100% rename from source/scripts/common/enums/http/http.js rename to source/scripts/libs/packages/http/libs/enums/enums.js diff --git a/source/scripts/common/enums/http/http-code.enum.js b/source/scripts/libs/packages/http/libs/enums/http-code.enum.js similarity index 100% rename from source/scripts/common/enums/http/http-code.enum.js rename to source/scripts/libs/packages/http/libs/enums/http-code.enum.js diff --git a/source/scripts/common/enums/http/http-header.enum.js b/source/scripts/libs/packages/http/libs/enums/http-header.enum.js similarity index 100% rename from source/scripts/common/enums/http/http-header.enum.js rename to source/scripts/libs/packages/http/libs/enums/http-header.enum.js diff --git a/source/scripts/common/enums/http/http-method.enum.js b/source/scripts/libs/packages/http/libs/enums/http-method.enum.js similarity index 100% rename from source/scripts/common/enums/http/http-method.enum.js rename to source/scripts/libs/packages/http/libs/enums/http-method.enum.js diff --git a/source/scripts/exceptions/exceptions.js b/source/scripts/libs/packages/http/libs/exceptions/exceptions.js similarity index 100% rename from source/scripts/exceptions/exceptions.js rename to source/scripts/libs/packages/http/libs/exceptions/exceptions.js diff --git a/source/scripts/exceptions/http-error/http-error.exception.js b/source/scripts/libs/packages/http/libs/exceptions/http-error/http-error.exception.js similarity index 58% rename from source/scripts/exceptions/http-error/http-error.exception.js rename to source/scripts/libs/packages/http/libs/exceptions/http-error/http-error.exception.js index 40432523..b06b9372 100644 --- a/source/scripts/exceptions/http-error/http-error.exception.js +++ b/source/scripts/libs/packages/http/libs/exceptions/http-error/http-error.exception.js @@ -1,18 +1,16 @@ -import { - ApiErrorMessage, - CustomExceptionName, - HttpCode, -} from '~/common/enums/enums.js' +import { CustomExceptionName, ErrorMessage } from '~/libs/enums/enums.js' + +import { HttpCode } from '../../enums/enums.js' class HttpError extends Error { /** * @param {{ - * message?: (typeof ApiErrorMessage)[keyof typeof ApiErrorMessage] + * message?: (typeof ErrorMessage)[keyof typeof ErrorMessage] * status?: (typeof HttpCode)[keyof typeof HttpCode] * }} [properties] */ constructor({ - message = ApiErrorMessage.NETWORK_ERROR, + message = ErrorMessage.NETWORK_ERROR, status = HttpCode.INTERNAL_SERVER_ERROR, } = {}) { super(message) diff --git a/source/scripts/libs/packages/storage/storage.js b/source/scripts/libs/packages/storage/storage.js new file mode 100644 index 00000000..a0612625 --- /dev/null +++ b/source/scripts/libs/packages/storage/storage.js @@ -0,0 +1,8 @@ +import { Storage } from './storage.package.js' + +let storage = new Storage({ + storage: localStorage, +}) + +export { storage } +export { Storage } from './storage.package.js' diff --git a/source/scripts/services/storage/storage.service.js b/source/scripts/libs/packages/storage/storage.package.js similarity index 100% rename from source/scripts/services/storage/storage.service.js rename to source/scripts/libs/packages/storage/storage.package.js diff --git a/source/scripts/libs/packages/whatislove-math/whatislove-math.js b/source/scripts/libs/packages/whatislove-math/whatislove-math.js new file mode 100644 index 00000000..e27e869f --- /dev/null +++ b/source/scripts/libs/packages/whatislove-math/whatislove-math.js @@ -0,0 +1 @@ +export { WhatisloveMath } from './whatislove-math.package.js' diff --git a/source/scripts/services/whatislove-math/whatislove-math.service.js b/source/scripts/libs/packages/whatislove-math/whatislove-math.package.js similarity index 100% rename from source/scripts/services/whatislove-math/whatislove-math.service.js rename to source/scripts/libs/packages/whatislove-math/whatislove-math.package.js diff --git a/source/scripts/common/types/toast/toast-message-payload.type.d.ts b/source/scripts/libs/types/toast-message-payload.type.d.ts similarity index 100% rename from source/scripts/common/types/toast/toast-message-payload.type.d.ts rename to source/scripts/libs/types/toast-message-payload.type.d.ts diff --git a/source/scripts/common/types/toast/toast.d.ts b/source/scripts/libs/types/types.d.ts similarity index 100% rename from source/scripts/common/types/toast/toast.d.ts rename to source/scripts/libs/types/types.d.ts diff --git a/source/scripts/packages/timeline/libs/enums/enums.js b/source/scripts/packages/timeline/libs/enums/enums.js new file mode 100644 index 00000000..a7e7dc6d --- /dev/null +++ b/source/scripts/packages/timeline/libs/enums/enums.js @@ -0,0 +1,3 @@ +export { TimelineApiPath } from './timeline-api-path.enum.js' +export { TimelineSkillType } from './timeline-skill-type.enum.js' +export { TimelineType } from './timeline-type.enum.js' diff --git a/source/scripts/common/enums/api/timeline-api-path.enum.js b/source/scripts/packages/timeline/libs/enums/timeline-api-path.enum.js similarity index 100% rename from source/scripts/common/enums/api/timeline-api-path.enum.js rename to source/scripts/packages/timeline/libs/enums/timeline-api-path.enum.js diff --git a/source/scripts/packages/timeline/libs/enums/timeline-skill-type.enum.js b/source/scripts/packages/timeline/libs/enums/timeline-skill-type.enum.js new file mode 100644 index 00000000..852273a0 --- /dev/null +++ b/source/scripts/packages/timeline/libs/enums/timeline-skill-type.enum.js @@ -0,0 +1,6 @@ +let TimelineSkillType = /** @type {const} */ ({ + HARD_SKILL: `hardSkill`, + SOFT_SKILL: `softSkill`, +}) + +export { TimelineSkillType } diff --git a/source/scripts/common/enums/timeline/timeline-type.enum.js b/source/scripts/packages/timeline/libs/enums/timeline-type.enum.js similarity index 100% rename from source/scripts/common/enums/timeline/timeline-type.enum.js rename to source/scripts/packages/timeline/libs/enums/timeline-type.enum.js diff --git a/source/scripts/common/types/timeline/timeline-create-payload.type.d.ts b/source/scripts/packages/timeline/libs/types/timeline-create-payload.type.d.ts similarity index 63% rename from source/scripts/common/types/timeline/timeline-create-payload.type.d.ts rename to source/scripts/packages/timeline/libs/types/timeline-create-payload.type.d.ts index 5f633899..0b17df35 100644 --- a/source/scripts/common/types/timeline/timeline-create-payload.type.d.ts +++ b/source/scripts/packages/timeline/libs/types/timeline-create-payload.type.d.ts @@ -1,4 +1,4 @@ -import { type TimelineType, type SkillType } from '~/common/enums/enums.js' +import { type TimelineType, type TimelineSkillType } from '../enums/enums.js' type TimelineCreatePayload = { date: string @@ -9,7 +9,7 @@ type TimelineCreatePayload = { origin: string originDesc: string title: string - skillType: (typeof SkillType)[keyof typeof SkillType] + skillType: (typeof TimelineSkillType)[keyof typeof TimelineSkillType] type: (typeof TimelineType)[keyof typeof TimelineType] } diff --git a/source/scripts/packages/timeline/libs/types/timeline-filter.d.type.d.ts b/source/scripts/packages/timeline/libs/types/timeline-filter.d.type.d.ts new file mode 100644 index 00000000..180660fb --- /dev/null +++ b/source/scripts/packages/timeline/libs/types/timeline-filter.d.type.d.ts @@ -0,0 +1,11 @@ +import { type TimelineType, type TimelineSkillType } from '../enums/enums.js' + +type TimelineFilter = { + skillTypes: Record< + (typeof TimelineSkillType)[keyof typeof TimelineSkillType], + boolean + > + types: Record<(typeof TimelineType)[keyof typeof TimelineType], boolean> +} + +export { type TimelineFilter } diff --git a/source/scripts/common/types/timeline/timeline.type.d.ts b/source/scripts/packages/timeline/libs/types/timeline.type.d.ts similarity index 62% rename from source/scripts/common/types/timeline/timeline.type.d.ts rename to source/scripts/packages/timeline/libs/types/timeline.type.d.ts index d1549f79..7366057a 100644 --- a/source/scripts/common/types/timeline/timeline.type.d.ts +++ b/source/scripts/packages/timeline/libs/types/timeline.type.d.ts @@ -1,4 +1,4 @@ -import { type TimelineType, type SkillType } from '~/common/enums/enums.js' +import { type TimelineType, type TimelineSkillType } from '../enums/enums.js' type Timeline = { id: string @@ -10,7 +10,7 @@ type Timeline = { origin: string originDesc: string title: string - skillType: (typeof SkillType)[keyof typeof SkillType] + skillType: (typeof TimelineSkillType)[keyof typeof TimelineSkillType] type: (typeof TimelineType)[keyof typeof TimelineType] } diff --git a/source/scripts/common/types/timeline/timeline.d.ts b/source/scripts/packages/timeline/libs/types/types.d.ts similarity index 100% rename from source/scripts/common/types/timeline/timeline.d.ts rename to source/scripts/packages/timeline/libs/types/types.d.ts diff --git a/source/scripts/services/timeline-api/timeline-api.service.js b/source/scripts/packages/timeline/timeline-api.js similarity index 73% rename from source/scripts/services/timeline-api/timeline-api.service.js rename to source/scripts/packages/timeline/timeline-api.js index 5eac2234..dc625114 100644 --- a/source/scripts/services/timeline-api/timeline-api.service.js +++ b/source/scripts/packages/timeline/timeline-api.js @@ -1,13 +1,11 @@ -import { - ApiPath, - ContentType, - HttpMethod, - TimelineApiPath, -} from '~/common/enums/enums.js' - -/** @typedef {import('~/common/types/timeline/timeline').Timeline} Timeline */ -/** @typedef {import('~/services/http/http.service').Http} Http */ -/** @typedef {import('~/common/types/timeline/timeline')} TimelineCreatePayload */ +import { ApiPath, ContentType } from '~/libs/enums/enums.js' +import { HttpMethod } from '~/libs/packages/http/http.js' + +import { TimelineApiPath } from './libs/enums/enums.js' + +/** @typedef {import('~/libs/packages/http/http').Http} Http */ +/** @typedef {import('./libs/types/types').Timeline} Timeline */ +/** @typedef {import('./libs/types/types')} TimelineCreatePayload */ class TimelineApi { /** diff --git a/source/scripts/packages/timeline/timeline.js b/source/scripts/packages/timeline/timeline.js new file mode 100644 index 00000000..9bc7a341 --- /dev/null +++ b/source/scripts/packages/timeline/timeline.js @@ -0,0 +1,22 @@ +import { AppConfig } from '~/libs/enums/enums.js' +import { getServerApiUrl } from '~/libs/helpers/helpers.js' +import { http } from '~/libs/packages/http/http.js' + +import { TimelineApi } from './timeline-api.js' + +/** @typedef {import('./libs/types/types').Timeline} Timeline */ +/** @typedef {import('./libs/types/types').TimelineCreatePayload} TimelineCreatePayload */ +/** @typedef {import('./libs/types/types').TimelineFilter} TimelineFilter */ + +let timelineApi = new TimelineApi({ + baseUrl: getServerApiUrl({ + host: AppConfig.SERVER_HOST, + port: AppConfig.SERVER_PORT, + }), + filesApiPath: AppConfig.FILES_API_PATH, + http, +}) + +export { timelineApi } +export { TimelineSkillType, TimelineType } from './libs/enums/enums.js' +export { TimelineApi } from './timeline-api.js' diff --git a/source/scripts/components/form/form.js b/source/scripts/pages/form/form.js similarity index 75% rename from source/scripts/components/form/form.js rename to source/scripts/pages/form/form.js index 0836ee56..c36867af 100644 --- a/source/scripts/components/form/form.js +++ b/source/scripts/pages/form/form.js @@ -1,13 +1,16 @@ -import { SkillType, TimelineType } from '~/common/enums/enums.js' -import { fillSelectOptions, getFormValues } from '~/helpers/helpers.js' +import { fillSelectOptions, getFormValues } from '~/libs/helpers/helpers.js' +import { + TimelineSkillType, + TimelineType, +} from '~/packages/timeline/timeline.js' import { getTransformedTimeline } from './helpers/helpers.js' -/** @typedef {import('~/services/timeline-api/timeline-api.service.js').TimelineApi} TimelineApi */ -/** @typedef {import('~/common/types/timeline/timeline').TimelineCreatePayload} TimelineCreatePayload */ +/** @typedef {import('~/packages/timeline/timeline').TimelineApi} TimelineApi */ +/** @typedef {import('~/packages/timeline/timeline').TimelineCreatePayload} TimelineCreatePayload */ -let skillTypeOptions = Object.values(SkillType) -let TimelineTypeOptions = Object.values(TimelineType) +let timelineSkillTypes = Object.values(TimelineSkillType) +let timelineTypes = Object.values(TimelineType) class Form { /** @@ -56,13 +59,13 @@ class Form { /** @type {HTMLSelectElement} */ ( formNode.querySelector(`select[name="skillType"]`) ), - skillTypeOptions, + timelineSkillTypes, ) fillSelectOptions( /** @type {HTMLSelectElement} */ ( formNode.querySelector(`select[name="type"]`) ), - TimelineTypeOptions, + timelineTypes, ) } diff --git a/source/scripts/components/form/helpers/get-transformed-timeline/get-transformed-timeline.helper.js b/source/scripts/pages/form/helpers/get-transformed-timeline/get-transformed-timeline.helper.js similarity index 82% rename from source/scripts/components/form/helpers/get-transformed-timeline/get-transformed-timeline.helper.js rename to source/scripts/pages/form/helpers/get-transformed-timeline/get-transformed-timeline.helper.js index 3d3e3be0..af311d00 100644 --- a/source/scripts/components/form/helpers/get-transformed-timeline/get-transformed-timeline.helper.js +++ b/source/scripts/pages/form/helpers/get-transformed-timeline/get-transformed-timeline.helper.js @@ -1,4 +1,4 @@ -/** @typedef {import('~/common/types/timeline/timeline').TimelineCreatePayload} TimelineCreatePayload */ +/** @typedef {import('~/packages/timeline/timeline').TimelineCreatePayload} TimelineCreatePayload */ /** * @param {TimelineCreatePayload} timeline diff --git a/source/scripts/components/form/helpers/helpers.js b/source/scripts/pages/form/helpers/helpers.js similarity index 100% rename from source/scripts/components/form/helpers/helpers.js rename to source/scripts/pages/form/helpers/helpers.js diff --git a/source/scripts/components/home/home.js b/source/scripts/pages/home/home.js similarity index 74% rename from source/scripts/components/home/home.js rename to source/scripts/pages/home/home.js index 829223ff..2ce2edea 100644 --- a/source/scripts/components/home/home.js +++ b/source/scripts/pages/home/home.js @@ -1,16 +1,16 @@ -import { Toast } from '~/components/common/common.js' +import { Toast } from '~/libs/components/components.js' import { EasterEgg, Navigation, Settings, Timeline, -} from './components/components.js' +} from './libs/components/components.js' -/** @typedef {import('~/common/types/settings/settings').SettingButtonPayload} SettingButtonPayload */ -/** @typedef {import('~/common/types/toast/toast').ToastMessagePayload} ToastMessagePayload */ -/** @typedef {import('~/services/storage/storage.service').Storage} Storage */ -/** @typedef {import('~/services/timeline-api/timeline-api.service').TimelineApi} TimelineApi */ +/** @typedef {import('~/pages/home/libs/types/types').SettingButtonPayload} SettingButtonPayload */ +/** @typedef {import('~/libs/types/types').ToastMessagePayload} ToastMessagePayload */ +/** @typedef {import('~/libs/packages/storage/storage').Storage} Storage */ +/** @typedef {import('~/packages/timeline/timeline').TimelineApi} TimelineApi */ class Home { /** diff --git a/source/scripts/components/home/components/components.js b/source/scripts/pages/home/libs/components/components.js similarity index 100% rename from source/scripts/components/home/components/components.js rename to source/scripts/pages/home/libs/components/components.js diff --git a/source/scripts/components/home/components/easter-egg/easter-egg.js b/source/scripts/pages/home/libs/components/easter-egg/easter-egg.js similarity index 86% rename from source/scripts/components/home/components/easter-egg/easter-egg.js rename to source/scripts/pages/home/libs/components/easter-egg/easter-egg.js index 185acb69..370338aa 100644 --- a/source/scripts/components/home/components/easter-egg/easter-egg.js +++ b/source/scripts/pages/home/libs/components/easter-egg/easter-egg.js @@ -1,20 +1,22 @@ +import { NotificationMessage } from '~/libs/enums/enums.js' +import { initDebounce } from '~/libs/helpers/helpers.js' import { - NotificationMessage, SettingButtonLabel, SettingName, -} from '~/common/enums/enums.js' -import { debounce } from '~/helpers/helpers.js' +} from '~/pages/home/libs/enums/enums.js' import { NOTIFICATION_DELAY, RESIZE_DELAY, SOUND_SRC, -} from './common/constants.js' -import { getNodeRandomCoords, getPlayerElement } from './helpers/helpers.js' +} from './libs/constants/constants.js' +import { + getNodeRandomCoords, + getPlayerElement, +} from './libs/helpers/helpers.js' -/** @typedef {import('~/common/types/toast/toast').ToastMessagePayload} ToastMessagePayload */ -/** @typedef {import('~/common/types/settings/settings').SettingButtonPayload} SettingButtonPayload */ -/** @typedef {typeof import('~/common/enums/enums.js').SettingName} SettingName */ +/** @typedef {import('~/libs/types/types').ToastMessagePayload} ToastMessagePayload */ +/** @typedef {import('~/pages/home/libs/types/types').SettingButtonPayload} SettingButtonPayload */ class EasterEgg { /** @@ -37,7 +39,7 @@ class EasterEgg { this._handleEasterEggClick = this._handleEasterEggClick.bind(this) this._handleSettingBtnClick = this._handleSettingBtnClick.bind(this) - this._handleWindowResize = debounce( + this._handleWindowResize = initDebounce( this._handleWindowResize.bind(this), RESIZE_DELAY, ) diff --git a/source/scripts/components/home/components/easter-egg/common/constants.js b/source/scripts/pages/home/libs/components/easter-egg/libs/constants/constants.js similarity index 100% rename from source/scripts/components/home/components/easter-egg/common/constants.js rename to source/scripts/pages/home/libs/components/easter-egg/libs/constants/constants.js diff --git a/source/scripts/components/home/components/easter-egg/helpers/get-node-random-coords/get-node-random-coords.helper.js b/source/scripts/pages/home/libs/components/easter-egg/libs/helpers/get-node-random-coords/get-node-random-coords.helper.js similarity index 88% rename from source/scripts/components/home/components/easter-egg/helpers/get-node-random-coords/get-node-random-coords.helper.js rename to source/scripts/pages/home/libs/components/easter-egg/libs/helpers/get-node-random-coords/get-node-random-coords.helper.js index 4276dbef..ea64ff04 100644 --- a/source/scripts/components/home/components/easter-egg/helpers/get-node-random-coords/get-node-random-coords.helper.js +++ b/source/scripts/pages/home/libs/components/easter-egg/libs/helpers/get-node-random-coords/get-node-random-coords.helper.js @@ -1,4 +1,4 @@ -import { getRandomNumber } from '~/helpers/helpers.js' +import { getRandomNumber } from '~/libs/helpers/helpers.js' let MIN_COORD_NUMBER = /** @type {const} */ (0) diff --git a/source/scripts/components/home/components/easter-egg/helpers/get-player-element/get-player-element.helper.js b/source/scripts/pages/home/libs/components/easter-egg/libs/helpers/get-player-element/get-player-element.helper.js similarity index 82% rename from source/scripts/components/home/components/easter-egg/helpers/get-player-element/get-player-element.helper.js rename to source/scripts/pages/home/libs/components/easter-egg/libs/helpers/get-player-element/get-player-element.helper.js index bfe13127..f09ade06 100644 --- a/source/scripts/components/home/components/easter-egg/helpers/get-player-element/get-player-element.helper.js +++ b/source/scripts/pages/home/libs/components/easter-egg/libs/helpers/get-player-element/get-player-element.helper.js @@ -1,4 +1,4 @@ -import { createElement } from '~/helpers/helpers.js' +import { createElement } from '~/libs/helpers/helpers.js' /** * @param {string} source diff --git a/source/scripts/components/home/components/easter-egg/helpers/helpers.js b/source/scripts/pages/home/libs/components/easter-egg/libs/helpers/helpers.js similarity index 100% rename from source/scripts/components/home/components/easter-egg/helpers/helpers.js rename to source/scripts/pages/home/libs/components/easter-egg/libs/helpers/helpers.js diff --git a/source/scripts/components/home/components/navigation/common/constants.js b/source/scripts/pages/home/libs/components/navigation/libs/constants/constants.js similarity index 100% rename from source/scripts/components/home/components/navigation/common/constants.js rename to source/scripts/pages/home/libs/components/navigation/libs/constants/constants.js diff --git a/source/scripts/components/home/components/navigation/navigation.js b/source/scripts/pages/home/libs/components/navigation/navigation.js similarity index 94% rename from source/scripts/components/home/components/navigation/navigation.js rename to source/scripts/pages/home/libs/components/navigation/navigation.js index 093d8683..35ccb105 100644 --- a/source/scripts/components/home/components/navigation/navigation.js +++ b/source/scripts/pages/home/libs/components/navigation/navigation.js @@ -1,7 +1,7 @@ -import { KeyboardKey } from '~/common/enums/enums.js' -import { checkIsOneOf, subscribeFocusTrap } from '~/helpers/helpers.js' +import { KeyboardKey } from '~/libs/enums/enums.js' +import { checkIsOneOf, subscribeFocusTrap } from '~/libs/helpers/helpers.js' -import { HEADER_ACTIVE_CLASS } from './common/constants.js' +import { HEADER_ACTIVE_CLASS } from './libs/constants/constants.js' class Navigation { constructor() { diff --git a/source/scripts/components/home/components/settings/components/components.js b/source/scripts/pages/home/libs/components/settings/libs/components/components.js similarity index 100% rename from source/scripts/components/home/components/settings/components/components.js rename to source/scripts/pages/home/libs/components/settings/libs/components/components.js diff --git a/source/scripts/components/home/components/settings/components/control/control.js b/source/scripts/pages/home/libs/components/settings/libs/components/control/control.js similarity index 94% rename from source/scripts/components/home/components/settings/components/control/control.js rename to source/scripts/pages/home/libs/components/settings/libs/components/control/control.js index 3a7bf0da..6cabdf75 100644 --- a/source/scripts/components/home/components/settings/components/control/control.js +++ b/source/scripts/pages/home/libs/components/settings/libs/components/control/control.js @@ -1,4 +1,4 @@ -/** @typedef {typeof import('~/common/enums/enums.js').SettingName} SettingName */ +/** @typedef {typeof import('~/pages/home/libs/enums/enums').SettingName} SettingName */ class Control { /** diff --git a/source/scripts/components/home/components/settings/components/switch/common/constants.js b/source/scripts/pages/home/libs/components/settings/libs/components/switch/libs/constants/constants.js similarity index 100% rename from source/scripts/components/home/components/settings/components/switch/common/constants.js rename to source/scripts/pages/home/libs/components/settings/libs/components/switch/libs/constants/constants.js diff --git a/source/scripts/components/home/components/settings/components/switch/helpers/check-is-checked/check-is-checked.helper.js b/source/scripts/pages/home/libs/components/settings/libs/components/switch/libs/helpers/check-is-checked/check-is-checked.helper.js similarity index 74% rename from source/scripts/components/home/components/settings/components/switch/helpers/check-is-checked/check-is-checked.helper.js rename to source/scripts/pages/home/libs/components/settings/libs/components/switch/libs/helpers/check-is-checked/check-is-checked.helper.js index af4bb1fa..e13e2b81 100644 --- a/source/scripts/components/home/components/settings/components/switch/helpers/check-is-checked/check-is-checked.helper.js +++ b/source/scripts/pages/home/libs/components/settings/libs/components/switch/libs/helpers/check-is-checked/check-is-checked.helper.js @@ -1,6 +1,6 @@ -import { booleanToNumber } from '~/common/maps/maps.js' +import { booleanToNumber } from '~/libs/maps/maps.js' -import { CHECKED_ATTR } from '../../common/constants.js' +import { CHECKED_ATTR } from '../../constants/constants.js' /** * @param {HTMLElement} node diff --git a/source/scripts/components/home/components/settings/components/switch/helpers/helpers.js b/source/scripts/pages/home/libs/components/settings/libs/components/switch/libs/helpers/helpers.js similarity index 100% rename from source/scripts/components/home/components/settings/components/switch/helpers/helpers.js rename to source/scripts/pages/home/libs/components/settings/libs/components/switch/libs/helpers/helpers.js diff --git a/source/scripts/components/home/components/settings/components/switch/switch.js b/source/scripts/pages/home/libs/components/settings/libs/components/switch/switch.js similarity index 88% rename from source/scripts/components/home/components/settings/components/switch/switch.js rename to source/scripts/pages/home/libs/components/settings/libs/components/switch/switch.js index c87fdb67..031d1a95 100644 --- a/source/scripts/components/home/components/settings/components/switch/switch.js +++ b/source/scripts/pages/home/libs/components/settings/libs/components/switch/switch.js @@ -1,7 +1,7 @@ -import { CHECKED_ATTR } from './common/constants.js' -import { checkIsChecked } from './helpers/helpers.js' +import { CHECKED_ATTR } from './libs/constants/constants.js' +import { checkIsChecked } from './libs/helpers/helpers.js' -/** @typedef {typeof import('~/common/enums/enums.js').SettingName} SettingName */ +/** @typedef {typeof import('~/pages/home/libs/enums/enums').SettingName} SettingName */ class Switch { /** diff --git a/source/scripts/components/home/components/settings/helpers/get-setting-item-element/get-setting-item-element.helper.js b/source/scripts/pages/home/libs/components/settings/libs/helpers/get-setting-item-element/get-setting-item-element.helper.js similarity index 68% rename from source/scripts/components/home/components/settings/helpers/get-setting-item-element/get-setting-item-element.helper.js rename to source/scripts/pages/home/libs/components/settings/libs/helpers/get-setting-item-element/get-setting-item-element.helper.js index 93da012c..40cb8deb 100644 --- a/source/scripts/components/home/components/settings/helpers/get-setting-item-element/get-setting-item-element.helper.js +++ b/source/scripts/pages/home/libs/components/settings/libs/helpers/get-setting-item-element/get-setting-item-element.helper.js @@ -1,7 +1,7 @@ -import { createElement } from '~/helpers/helpers.js' +import { createElement } from '~/libs/helpers/helpers.js' -/** @typedef {typeof import('~/common/enums/enums.js').SettingName} SettingName */ -/** @typedef {typeof import('~/common/enums/enums.js').SettingButtonLabel} SettingButtonLabel */ +/** @typedef {typeof import('~/pages/home/libs/enums/enums').SettingName} SettingName */ +/** @typedef {typeof import('~/pages/home/libs/enums/enums').SettingButtonLabel} SettingButtonLabel */ /** * @param {{ diff --git a/source/scripts/components/home/components/settings/helpers/helpers.js b/source/scripts/pages/home/libs/components/settings/libs/helpers/helpers.js similarity index 100% rename from source/scripts/components/home/components/settings/helpers/helpers.js rename to source/scripts/pages/home/libs/components/settings/libs/helpers/helpers.js diff --git a/source/scripts/components/home/components/settings/settings.js b/source/scripts/pages/home/libs/components/settings/settings.js similarity index 85% rename from source/scripts/components/home/components/settings/settings.js rename to source/scripts/pages/home/libs/components/settings/settings.js index 9501e586..c4f0337d 100644 --- a/source/scripts/components/home/components/settings/settings.js +++ b/source/scripts/pages/home/libs/components/settings/settings.js @@ -1,13 +1,13 @@ -import { SettingName } from '~/common/enums/enums.js' -import { getCustomAttributeName } from '~/helpers/helpers.js' +import { getCustomAttributeName } from '~/libs/helpers/helpers.js' +import { SettingName } from '~/pages/home/libs/enums/enums.js' -import { Control, Switch } from './components/components.js' -import { getSettingItemElement } from './helpers/helpers.js' +import { Control, Switch } from './libs/components/components.js' +import { getSettingItemElement } from './libs/helpers/helpers.js' let RESULT_VALUE = /** @type {const} */ (`auto`) -/** @typedef {import('~/common/types/settings/settings').SettingButtonPayload} SettingButtonPayload */ -/** @typedef {import('~/services/storage/storage.service').Storage} Storage */ +/** @typedef {import('~/pages/home/libs/types/types').SettingButtonPayload} SettingButtonPayload */ +/** @typedef {import('~/libs/packages/storage/storage').Storage} Storage */ class Settings { /** diff --git a/source/scripts/components/home/components/timeline/components/components.js b/source/scripts/pages/home/libs/components/timeline/libs/components/components.js similarity index 100% rename from source/scripts/components/home/components/timeline/components/components.js rename to source/scripts/pages/home/libs/components/timeline/libs/components/components.js diff --git a/source/scripts/components/home/components/timeline/components/timeline-form/common/constants.js b/source/scripts/pages/home/libs/components/timeline/libs/components/timeline-form/libs/constants/constants.js similarity index 100% rename from source/scripts/components/home/components/timeline/components/timeline-form/common/constants.js rename to source/scripts/pages/home/libs/components/timeline/libs/components/timeline-form/libs/constants/constants.js diff --git a/source/scripts/components/home/components/timeline/components/timeline-form/timeline-form.js b/source/scripts/pages/home/libs/components/timeline/libs/components/timeline-form/timeline-form.js similarity index 76% rename from source/scripts/components/home/components/timeline/components/timeline-form/timeline-form.js rename to source/scripts/pages/home/libs/components/timeline/libs/components/timeline-form/timeline-form.js index ccb65c8a..bbc8db6c 100644 --- a/source/scripts/components/home/components/timeline/components/timeline-form/timeline-form.js +++ b/source/scripts/pages/home/libs/components/timeline/libs/components/timeline-form/timeline-form.js @@ -1,8 +1,8 @@ -import { debounce, getFormValues } from '~/helpers/helpers.js' +import { getFormValues, initDebounce } from '~/libs/helpers/helpers.js' -import { DEBOUNCE_DELAY } from './common/constants.js' +import { DEBOUNCE_DELAY } from './libs/constants/constants.js' -/** @typedef {import('~/common/types/timeline/timeline').TimelineFilter} TimelineFilter */ +/** @typedef {import('~/packages/timeline/timeline').TimelineFilter} TimelineFilter */ class TimelineForm { /** @@ -30,7 +30,7 @@ class TimelineForm { formNode.addEventListener( `change`, - debounce(this._handleFormChange, DEBOUNCE_DELAY), + initDebounce(this._handleFormChange, DEBOUNCE_DELAY), ) } diff --git a/source/scripts/components/home/components/timeline/components/timeline-list/helpers/get-timeline-template/get-timeline-template.helper.js b/source/scripts/pages/home/libs/components/timeline/libs/components/timeline-list/libs/helpers/get-timeline-template/get-timeline-template.helper.js similarity index 90% rename from source/scripts/components/home/components/timeline/components/timeline-list/helpers/get-timeline-template/get-timeline-template.helper.js rename to source/scripts/pages/home/libs/components/timeline/libs/components/timeline-list/libs/helpers/get-timeline-template/get-timeline-template.helper.js index 31d78d18..1c5ea545 100644 --- a/source/scripts/components/home/components/timeline/components/timeline-list/helpers/get-timeline-template/get-timeline-template.helper.js +++ b/source/scripts/pages/home/libs/components/timeline/libs/components/timeline-list/libs/helpers/get-timeline-template/get-timeline-template.helper.js @@ -1,6 +1,6 @@ -import { getFormattedDate, getStringWitCheck } from '~/helpers/helpers.js' +import { getFormattedDate, getStringWitCheck } from '~/libs/helpers/helpers.js' -/** @typedef {import('~/common/types/timeline/timeline').Timeline} Timeline */ +/** @typedef {import('~/packages/timeline/timeline').Timeline} Timeline */ /** * @param {Timeline} timeline diff --git a/source/scripts/components/home/components/timeline/components/timeline-list/helpers/get-timeline-templates/get-timeline-templates.helper.js b/source/scripts/pages/home/libs/components/timeline/libs/components/timeline-list/libs/helpers/get-timeline-templates/get-timeline-templates.helper.js similarity index 83% rename from source/scripts/components/home/components/timeline/components/timeline-list/helpers/get-timeline-templates/get-timeline-templates.helper.js rename to source/scripts/pages/home/libs/components/timeline/libs/components/timeline-list/libs/helpers/get-timeline-templates/get-timeline-templates.helper.js index 31a3f5e5..7544295c 100644 --- a/source/scripts/components/home/components/timeline/components/timeline-list/helpers/get-timeline-templates/get-timeline-templates.helper.js +++ b/source/scripts/pages/home/libs/components/timeline/libs/components/timeline-list/libs/helpers/get-timeline-templates/get-timeline-templates.helper.js @@ -1,6 +1,6 @@ import { getTimelineTemplate } from '../get-timeline-template/get-timeline-template.helper.js' -/** @typedef {import('~/common/types/timeline/timeline').Timeline} Timeline */ +/** @typedef {import('~/packages/timeline/timeline').Timeline} Timeline */ /** * @param {Timeline[]} timelines diff --git a/source/scripts/components/home/components/timeline/components/timeline-list/helpers/helpers.js b/source/scripts/pages/home/libs/components/timeline/libs/components/timeline-list/libs/helpers/helpers.js similarity index 100% rename from source/scripts/components/home/components/timeline/components/timeline-list/helpers/helpers.js rename to source/scripts/pages/home/libs/components/timeline/libs/components/timeline-list/libs/helpers/helpers.js diff --git a/source/scripts/components/home/components/timeline/components/timeline-list/timeline-list.js b/source/scripts/pages/home/libs/components/timeline/libs/components/timeline-list/timeline-list.js similarity index 78% rename from source/scripts/components/home/components/timeline/components/timeline-list/timeline-list.js rename to source/scripts/pages/home/libs/components/timeline/libs/components/timeline-list/timeline-list.js index 657b9dcc..fd9cd2c8 100644 --- a/source/scripts/components/home/components/timeline/components/timeline-list/timeline-list.js +++ b/source/scripts/pages/home/libs/components/timeline/libs/components/timeline-list/timeline-list.js @@ -1,6 +1,6 @@ -import { getTimelineTemplates } from './helpers/helpers.js' +import { getTimelineTemplates } from './libs/helpers/helpers.js' -/** @typedef {import('~/common/types/timeline/timeline').Timeline} Timeline */ +/** @typedef {import('~/packages/timeline/timeline').Timeline} Timeline */ class TimelineList { constructor() { diff --git a/source/scripts/components/home/components/timeline/helpers/check-is-timeline-suit/check-is-timeline-suit.helper.js b/source/scripts/pages/home/libs/components/timeline/libs/helpers/check-is-timeline-suit/check-is-timeline-suit.helper.js similarity index 67% rename from source/scripts/components/home/components/timeline/helpers/check-is-timeline-suit/check-is-timeline-suit.helper.js rename to source/scripts/pages/home/libs/components/timeline/libs/helpers/check-is-timeline-suit/check-is-timeline-suit.helper.js index 3b068662..22a68e4d 100644 --- a/source/scripts/components/home/components/timeline/helpers/check-is-timeline-suit/check-is-timeline-suit.helper.js +++ b/source/scripts/pages/home/libs/components/timeline/libs/helpers/check-is-timeline-suit/check-is-timeline-suit.helper.js @@ -1,5 +1,5 @@ -/** @typedef {import('~/common/types/timeline/timeline').Timeline} Timeline */ -/** @typedef {import('~/common/types/timeline/timeline').TimelineFilter} TimelineFilter */ +/** @typedef {import('~/packages/timeline/timeline').Timeline} Timeline */ +/** @typedef {import('~/packages/timeline/timeline').TimelineFilter} TimelineFilter */ /** * @param {Timeline} timelineItem diff --git a/source/scripts/components/home/components/timeline/helpers/get-suit-timelines/get-suit-timelines.helper.js b/source/scripts/pages/home/libs/components/timeline/libs/helpers/get-suit-timelines/get-suit-timelines.helper.js similarity index 69% rename from source/scripts/components/home/components/timeline/helpers/get-suit-timelines/get-suit-timelines.helper.js rename to source/scripts/pages/home/libs/components/timeline/libs/helpers/get-suit-timelines/get-suit-timelines.helper.js index f5ac68ae..70c74ba1 100644 --- a/source/scripts/components/home/components/timeline/helpers/get-suit-timelines/get-suit-timelines.helper.js +++ b/source/scripts/pages/home/libs/components/timeline/libs/helpers/get-suit-timelines/get-suit-timelines.helper.js @@ -1,7 +1,7 @@ import { checkIsTimelineSuit } from '../check-is-timeline-suit/check-is-timeline-suit.helper.js' -/** @typedef {import('~/common/types/timeline/timeline').Timeline} Timeline */ -/** @typedef {import('~/common/types/timeline/timeline').TimelineFilter} TimelineFilter */ +/** @typedef {import('~/packages/timeline/timeline').Timeline} Timeline */ +/** @typedef {import('~/packages/timeline/timeline').TimelineFilter} TimelineFilter */ /** * @param {Timeline[]} timelines diff --git a/source/scripts/components/home/components/timeline/helpers/helpers.js b/source/scripts/pages/home/libs/components/timeline/libs/helpers/helpers.js similarity index 100% rename from source/scripts/components/home/components/timeline/helpers/helpers.js rename to source/scripts/pages/home/libs/components/timeline/libs/helpers/helpers.js diff --git a/source/scripts/components/home/components/timeline/timeline.js b/source/scripts/pages/home/libs/components/timeline/timeline.js similarity index 81% rename from source/scripts/components/home/components/timeline/timeline.js rename to source/scripts/pages/home/libs/components/timeline/timeline.js index 8dbbbd6f..ba356ce6 100644 --- a/source/scripts/components/home/components/timeline/timeline.js +++ b/source/scripts/pages/home/libs/components/timeline/timeline.js @@ -1,12 +1,12 @@ -import { Loader } from '~/components/common/common.js' -import { checkIsBeforeElement } from '~/helpers/helpers.js' +import { Loader } from '~/libs/components/components.js' +import { checkIsBeforeElement } from '~/libs/helpers/helpers.js' -import { TimelineForm, TimelineList } from './components/components.js' -import { getSuitTimelines } from './helpers/helpers.js' +import { TimelineForm, TimelineList } from './libs/components/components.js' +import { getSuitTimelines } from './libs/helpers/helpers.js' -/** @typedef {import('~/common/types/timeline/timeline').Timeline} TTimeline */ -/** @typedef {import('~/common/types/timeline/timeline').TimelineFilter} TimelineFilter */ -/** @typedef {import('~/services/timeline-api/timeline-api.service.js').TimelineApi} TimelineApi */ +/** @typedef {import('~/packages/timeline/timeline').Timeline} TTimeline */ +/** @typedef {import('~/packages/timeline/timeline').TimelineFilter} TimelineFilter */ +/** @typedef {import('~/packages/timeline/timeline').TimelineApi} TimelineApi */ class Timeline { /** diff --git a/source/scripts/common/enums/setting/setting.js b/source/scripts/pages/home/libs/enums/enums.js similarity index 100% rename from source/scripts/common/enums/setting/setting.js rename to source/scripts/pages/home/libs/enums/enums.js diff --git a/source/scripts/common/enums/setting/setting-button-label.enum.js b/source/scripts/pages/home/libs/enums/setting-button-label.enum.js similarity index 100% rename from source/scripts/common/enums/setting/setting-button-label.enum.js rename to source/scripts/pages/home/libs/enums/setting-button-label.enum.js diff --git a/source/scripts/common/enums/setting/setting-name.enum.js b/source/scripts/pages/home/libs/enums/setting-name.enum.js similarity index 100% rename from source/scripts/common/enums/setting/setting-name.enum.js rename to source/scripts/pages/home/libs/enums/setting-name.enum.js diff --git a/source/scripts/common/types/settings/settings-button-payload.type.d.ts b/source/scripts/pages/home/libs/types/settings-button-payload.type.d.ts similarity index 81% rename from source/scripts/common/types/settings/settings-button-payload.type.d.ts rename to source/scripts/pages/home/libs/types/settings-button-payload.type.d.ts index 9db48c2d..1f91d232 100644 --- a/source/scripts/common/types/settings/settings-button-payload.type.d.ts +++ b/source/scripts/pages/home/libs/types/settings-button-payload.type.d.ts @@ -1,4 +1,4 @@ -import { SettingButtonLabel, SettingName } from '~/common/enums/enums.js' +import { SettingButtonLabel, SettingName } from '../enums/enums.js' type SettingButtonPayload = { isDefaultChecked: boolean diff --git a/source/scripts/common/types/settings/settings.d.ts b/source/scripts/pages/home/libs/types/types.d.ts similarity index 80% rename from source/scripts/common/types/settings/settings.d.ts rename to source/scripts/pages/home/libs/types/types.d.ts index 82e84265..07b16b02 100644 --- a/source/scripts/common/types/settings/settings.d.ts +++ b/source/scripts/pages/home/libs/types/types.d.ts @@ -1 +1 @@ -export { type SettingButtonPayload } from './settings-button-payload.type.d.js' +export { type SettingButtonPayload } from './settings-button-payload.type.js' diff --git a/source/scripts/services/services.js b/source/scripts/services/services.js deleted file mode 100644 index b2f2c9bf..00000000 --- a/source/scripts/services/services.js +++ /dev/null @@ -1,24 +0,0 @@ -import { AppConfig } from '~/common/enums/enums.js' -import { getServerApiUrl } from '~/helpers/helpers.js' - -import { Http } from './http/http.service.js' -import { Storage } from './storage/storage.service.js' -import { TimelineApi } from './timeline-api/timeline-api.service.js' - -let storage = new Storage({ - storage: localStorage, -}) - -let http = new Http() - -let timelineApi = new TimelineApi({ - baseUrl: getServerApiUrl({ - host: AppConfig.SERVER_HOST, - port: AppConfig.SERVER_PORT, - }), - filesApiPath: AppConfig.FILES_API_PATH, - http, -}) - -export { http, storage, timelineApi } -export { WhatisloveMath } from './whatislove-math/whatislove-math.service.js'