@dxtmisha/functional 1.13.5 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/ai-description.md +16 -0
- package/ai-doc.md +226 -0
- package/{ai-types.txt → ai-types.md} +87 -163
- package/dist/library.js +178 -156
- package/dist/src/classes/ref/GeoRef.d.ts +21 -0
- package/dist/src/composables/ref/useQueryRef.d.ts +9 -0
- package/dist/src/library.d.ts +1 -0
- package/package.json +4 -5
- package/ai-description.txt +0 -18
- package/ai-doc.ru.txt +0 -45
- package/ai-doc.txt +0 -45
|
@@ -43,6 +43,27 @@ export declare class GeoRef {
|
|
|
43
43
|
* реактивная строка, представляющая первый день недели
|
|
44
44
|
*/
|
|
45
45
|
static getFirstDay(): ComputedRef<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Current location string.
|
|
48
|
+
*
|
|
49
|
+
* Текущее местоположение.
|
|
50
|
+
* @returns reactive string with the current location/ реактивная строка с текущим местоположением
|
|
51
|
+
*/
|
|
52
|
+
static getLocation(): ComputedRef<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Current country code from the location.
|
|
55
|
+
*
|
|
56
|
+
* Текущий код страны из местоположения.
|
|
57
|
+
* @returns reactive string with the current country code from location/ реактивная строка с кодом текущей страны из местоположения
|
|
58
|
+
*/
|
|
59
|
+
static getLocationCountry(): ComputedRef<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Current language code from the location.
|
|
62
|
+
*
|
|
63
|
+
* Текущий код языка из местоположения.
|
|
64
|
+
* @returns reactive string with the current language code from location/ реактивная строка с кодом текущего языка из местоположения
|
|
65
|
+
*/
|
|
66
|
+
static getLocationLanguage(): ComputedRef<string>;
|
|
46
67
|
/**
|
|
47
68
|
* Changes the data by the full code.
|
|
48
69
|
*
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ShallowRef } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a reactive variable to manage URL query parameters.
|
|
4
|
+
*
|
|
5
|
+
* Создает реактивную переменную для управления query-параметрами URL.
|
|
6
|
+
* @param name value name / название значения
|
|
7
|
+
* @param defaultValue default value / значение по умолчанию
|
|
8
|
+
*/
|
|
9
|
+
export declare function useQueryRef<T>(name: string, defaultValue?: T | (() => T)): ShallowRef<T>;
|
package/dist/src/library.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export * from './composables/ref/useLazyItemByMarginRef';
|
|
|
31
31
|
export * from './composables/ref/useLazyRef';
|
|
32
32
|
export * from './composables/ref/useLoadingRef';
|
|
33
33
|
export * from './composables/ref/useMeta';
|
|
34
|
+
export * from './composables/ref/useQueryRef';
|
|
34
35
|
export * from './composables/ref/useRouterList';
|
|
35
36
|
export * from './composables/ref/useSearchRef';
|
|
36
37
|
export * from './composables/ref/useSearchValueRef';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxtmisha/functional",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.14.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A comprehensive library of utilities, base classes, and Vue 3 composables for reactive web development. Extends @dxtmisha/functional-basic with Composition API.",
|
|
7
7
|
"keywords": [
|
|
@@ -46,10 +46,9 @@
|
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"dist",
|
|
49
|
-
"ai-description.
|
|
50
|
-
"ai-doc.
|
|
51
|
-
"ai-
|
|
52
|
-
"ai-types.txt",
|
|
49
|
+
"ai-description.md",
|
|
50
|
+
"ai-doc.md",
|
|
51
|
+
"ai-types.md",
|
|
53
52
|
"CHANGELOG.md",
|
|
54
53
|
"LICENSE",
|
|
55
54
|
"package.json",
|
package/ai-description.txt
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
This library is a collection of Vue 3-based utility classes and composables designed for building complex, reactive, and SSR-ready interfaces. It provides a standardized framework for API management, component state, geographic/localization data, and dynamic rendering.
|
|
2
|
-
|
|
3
|
-
1. Core Purpose:
|
|
4
|
-
An infrastructure-level toolkit for Vue 3 that abstracts asynchronous data fetching, state management, and UI rendering logic. It provides structured classes and composables to handle API lifecycle (GET/POST/PUT/DELETE), reactive data transformations, internationalization (Intl), and component orchestration.
|
|
5
|
-
|
|
6
|
-
2. Usage Scenarios:
|
|
7
|
-
- API Orchestration: When building complex forms, data tables, or dashboards requiring integrated state, validation (via @effect/schema compatibility), and SSR support. Use `useApiManagementRef` for unified CRUD handling or `useApiRef` for individual requests.
|
|
8
|
-
- Reactive Data Management: When you need synchronized data across browser tabs (`useBroadcastValueRef`) or persistence across reloads (`useStorageRef`, `useCookieRef`).
|
|
9
|
-
- Localization & Formatting: When the application needs to dynamically handle geographic data, currency formatting, file sizes, or date manipulation via `GeoIntlRef` and `useGeoIntlRef`.
|
|
10
|
-
- Component Design System: When building modular UI components that require consistent prop-to-style/class mapping (`DesignConstructorAbstract`, `DesignComponents`).
|
|
11
|
-
- Lifecycle & DOM Utilities: When implementing lazy loading (`useLazyRef`) or global state management using `executeUse` for singletons.
|
|
12
|
-
|
|
13
|
-
3. Integration Context:
|
|
14
|
-
- Vue 3 Core: Heavily leverages `Ref`, `ComputedRef`, and `provide/inject`.
|
|
15
|
-
- Data Fetching: Acts as a high-level wrapper over an underlying `functional-basic` library.
|
|
16
|
-
- Routing: Integrates with `vue-router` via `RouterItemRef` and `useRouterList`.
|
|
17
|
-
- SSR: Provides specific `Async` variants (e.g., `useApiAsyncRef`) for server-side pre-fetching.
|
|
18
|
-
- Schema Validation: Designed to work with `@effect/schema` for robust API contract validation.
|
package/ai-doc.ru.txt
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
Это главная функциональная библиотека для среды Vue (@dxtmisha/functional). Здесь собраны утилиты, composables и реактивные классы, заточенные под Vue.
|
|
2
|
-
|
|
3
|
-
ПРАВИЛА ИСПОЛЬЗОВАНИЯ:
|
|
4
|
-
1. При разработке на Vue всегда отдавайте приоритет этой библиотеке для работы с логикой и composables, а не `@dxtmisha/functional-basic`.
|
|
5
|
-
2. Библиотека оборачивает базовую нереактивную логику в систему реактивности Vue. Если нужная функция или класс есть здесь, они имеют абсолютный приоритет.
|
|
6
|
-
3. Импортируйте утилиты из `@dxtmisha/functional` для реактивного поведения UI, composables и управления состоянием.
|
|
7
|
-
|
|
8
|
-
РАБОТА С API И СОСТОЯНИЕМ (useApi / executeUse):
|
|
9
|
-
Для работы с сетевыми запросами в библиотеке предусмотрен набор хуков: `useApiGet`, `useApiPost`, `useApiPut`, `useApiDelete`, `useApiRequest`, `useApiRef`, `useApiAsyncRef`, `useApiManagementRef`, `useApiManagementAsyncRef`.
|
|
10
|
-
Строго соблюдайте следующие правила их применения:
|
|
11
|
-
|
|
12
|
-
1. НЕ ВЫЗЫВАЙТЕ эти хуки напрямую в компонентах (SFC).
|
|
13
|
-
2. Выносите всю настройку и вызовы `useApi*` в ОТДЕЛЬНЫЕ ФАЙЛЫ (сервисы / хранилища).
|
|
14
|
-
3. Оборачивайте настройку API в фабрику `executeUse` (а именно: `executeUseGlobal`, `executeUseProvide` или `executeUseLocal` из `src/functions/executeUse.ts`). Это гарантирует создание синглтонов (одна точка доступа) и предотвращает создание дубликатов запросов и хранилищ состояния.
|
|
15
|
-
4. Выполняйте любую дополнительную обработку запросов (например: маппинг данных, подготовка структуры для отображения скелетона перед загрузкой формы) в этом же файле, внутри коллбэка `executeUse`, а наружу возвращайте уже полностью готовый набор данных и методов.
|
|
16
|
-
*Пример правильного использования:*
|
|
17
|
-
```ts
|
|
18
|
-
import { executeUseGlobal } from '@dxtmisha/functional';
|
|
19
|
-
import { useApiManagementRef } from '@dxtmisha/functional';
|
|
20
|
-
|
|
21
|
-
export const useUserManagement = executeUseGlobal(() => {
|
|
22
|
-
return useApiManagementRef(
|
|
23
|
-
{ path: '/api/users' }, // GET setup
|
|
24
|
-
{ date: (v) => new Date(v).toLocaleString() }, // Formatters
|
|
25
|
-
{ columns: ['name', 'email'] }, // Search
|
|
26
|
-
{ path: '/api/users' }, // POST
|
|
27
|
-
{ path: (o) => `/api/users/${o.id}` }, // PUT
|
|
28
|
-
{ path: (o) => `/api/users/${o.id}` } // DELETE
|
|
29
|
-
);
|
|
30
|
-
// Здесь же можно добавить логику подготовки скелетонов, форматирования и т.д.
|
|
31
|
-
// и затем вернуть расширенный объект
|
|
32
|
-
});
|
|
33
|
-
```
|
|
34
|
-
5. В самом Vue-компоненте просто импортируйте и вызывайте созданный синглтон-хук: `const { list, loading, sendPost } = useUserManagement();`
|
|
35
|
-
|
|
36
|
-
ВЫБОР СТРАТЕГИИ executeUse:
|
|
37
|
-
1. `executeUseLocal` (ПРЕДПОЧТИТЕЛЬНО):
|
|
38
|
-
- Когда использовать: Для большинства API-запросов и сервисов.
|
|
39
|
-
- Особенности: Работает «лениво» (lazy) — инициализируется только в момент первого вызова. Экземпляр сохраняется до конца сессии. Это позволяет не перегружать старт приложения лишними запросами.
|
|
40
|
-
2. `executeUseGlobal`:
|
|
41
|
-
- Когда использовать: Когда данные или сервис должны быть загружены/инициализированы СРАЗУ при старте приложения (например: критические настройки, SDK).
|
|
42
|
-
- Особенности: Создает один экземпляр на всё приложение. Все глобальные синглтоны инициализируются принудительно через `executeUseGlobalInit()`.
|
|
43
|
-
3. `executeUseProvide`:
|
|
44
|
-
- Когда использовать: Для состояния, разделяемого между родителем и группой дочерних компонентов (например: табы, сложные формы с подкомпонентами).
|
|
45
|
-
- Особенности: Использует provide/inject. Первый компонент в дереве, вызвавший хук, становится «провайдером», остальные — потребителями.
|
package/ai-doc.txt
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
This is the main functional library for the Vue environment (@dxtmisha/functional). It contains Vue-specific utilities, composables, and reactive classes.
|
|
2
|
-
|
|
3
|
-
USAGE RULES:
|
|
4
|
-
1. When developing in Vue, always use this library for functionality, logic, and composables instead of `@dxtmisha/functional-basic` whenever possible.
|
|
5
|
-
2. It wraps basic non-reactive logic into Vue's reactivity system. If the required function or composable exists here, it has absolute priority.
|
|
6
|
-
3. Import utilities from `@dxtmisha/functional` for reactive UI behavior, composables, and state management.
|
|
7
|
-
|
|
8
|
-
WORKING WITH API AND STATE (useApi / executeUse):
|
|
9
|
-
A set of composables is provided for network requests: `useApiGet`, `useApiPost`, `useApiPut`, `useApiDelete`, `useApiRequest`, `useApiRef`, `useApiAsyncRef`, `useApiManagementRef`, `useApiManagementAsyncRef`.
|
|
10
|
-
Strictly follow these rules for their application:
|
|
11
|
-
|
|
12
|
-
1. DO NOT call these composables directly in the Vue components (SFC).
|
|
13
|
-
2. Move all API configurations and `useApi*` calls into SEPARATE FILES (services/stores).
|
|
14
|
-
3. Wrap the API configurations inside the `executeUse` factory (specifically: `executeUseGlobal`, `executeUseProvide`, or `executeUseLocal` from `src/functions/executeUse.ts`). This guarantees the creation of managed singletons (single access point) and prevents duplicated requests and reactive states.
|
|
15
|
-
4. Perform any additional request processing (e.g., data mapping, preparing structures for skeletons before loading a form) in the same file, inside the `executeUse` callback, and return a fully prepared set of data and methods.
|
|
16
|
-
*Example of correct usage:*
|
|
17
|
-
```ts
|
|
18
|
-
import { executeUseGlobal } from '@dxtmisha/functional';
|
|
19
|
-
import { useApiManagementRef } from '@dxtmisha/functional';
|
|
20
|
-
|
|
21
|
-
export const useUserManagement = executeUseGlobal(() => {
|
|
22
|
-
return useApiManagementRef(
|
|
23
|
-
{ path: '/api/users' }, // GET setup
|
|
24
|
-
{ date: (v) => new Date(v).toLocaleString() }, // Formatters
|
|
25
|
-
{ columns: ['name', 'email'] }, // Search
|
|
26
|
-
{ path: '/api/users' }, // POST
|
|
27
|
-
{ path: (o) => `/api/users/${o.id}` }, // PUT
|
|
28
|
-
{ path: (o) => `/api/users/${o.id}` } // DELETE
|
|
29
|
-
);
|
|
30
|
-
// Logic for skeletons, additional formatting, etc., should be added here,
|
|
31
|
-
// and then return the extended object.
|
|
32
|
-
});
|
|
33
|
-
```
|
|
34
|
-
5. Within the Vue component itself, simply import and call your custom singleton composable: `const { list, loading, sendPost } = useUserManagement();`
|
|
35
|
-
|
|
36
|
-
CHOOSING THE executeUse STRATEGY:
|
|
37
|
-
1. `executeUseLocal` (PREFERRED):
|
|
38
|
-
- When to use: For most API requests and services.
|
|
39
|
-
- Key Features: Works "lazily" (lazy initialization) — initializes only when first called. The instance persists until the end of the session. This prevents overloading the application start with unnecessary requests.
|
|
40
|
-
2. `executeUseGlobal`:
|
|
41
|
-
- When to use: When data or a service must be loaded/initialized IMMEDIATELY at application start (e.g., critical settings, SDKs).
|
|
42
|
-
- Key Features: Creates a single instance for the entire application. All global singletons are forcibly initialized via `executeUseGlobalInit()`.
|
|
43
|
-
3. `executeUseProvide`:
|
|
44
|
-
- When to use: For state shared between a parent and a group of child components (e.g., tabs, complex forms with sub-components).
|
|
45
|
-
- Key Features: Uses provide/inject. The first component in the tree that calls the hook becomes the "provider", others become consumers.
|