@dxtmisha/functional 1.15.5 → 1.15.6

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/ai-description.md CHANGED
@@ -1,29 +1,7 @@
1
- 1. CORE PURPOSE
2
- This library (@dxtmisha/functional) provides Vue 3 reactive abstractions, abstract base classes for component architecture, and advanced composables. It elevates low-level functional utilities from @dxtmisha/functional-basic into Vue 3 reactivity system (refs, computed, lifecycle, reactive singletons) to handle REST API orchestration, localization, meta management, routing, client-side storage, lazy loading, list/search data structures, and standard component state construction.
3
-
4
- 2. KEY EXPOSITIONS
5
- Abstract Component Base Classes: DesignAbstract, DesignAsyncAbstract, DesignChanged, DesignComponents, DesignComp, DesignConstructorAbstract. These manage component state lifecycle, dynamic class and style processing, event hooks, slot rendering, component modifications, and property mutation tracking.
6
-
7
- Reactive API Composables: useApiRef, useApiAsyncRef, useApiManagementRef, useApiManagementAsyncRef, useApiGet, useApiPost, useApiPut, useApiDelete, useApiRequest. These handle REST operations with SSR prefetching, response contract validation, mutation handling, error contract mapping, client-side pagination/filtering, and automatic state reactivity.
8
-
9
- Singleton State & Execution Control: executeUse, executeUseGlobal, executeUseProvide, executeUseLocal, executeUseGlobalInit. These encapsulate factory initialization into global, component-tree inject/provide, or closure-local singletons.
10
-
11
- Localization & Formatting Classes and Composables: DatetimeRef, GeoFlagRef, GeoIntlRef, GeoRef, GeoUnitRef, useGeoIntlRef, useGeoUnitRef, useFormattersRef, useTranslateRef, t. These offer reactive locale-aware date/time formatting, unit conversion, flag retrieval, and multi-key translation refs.
12
-
13
- Data Structures & UI Management: ListDataRef, useRouterList, useSearchRef, useSearchValueRef, useLazyRef, useLazyItemByMarginRef, ScrollbarWidthRef, EventRef, EffectScopeGlobal. These provide reactive list data mapping, search query debounce and highlighting, lazy-loading via IntersectionObserver, scrollbar width tracking, and global effect scopes.
14
-
15
- State Persistence & Browser Composables: useBroadcastValueRef, useCookieRef, useHashRef, useQueryRef, useSessionRef, useStorageRef, useMeta. These control cross-tab communication, cookies, URL query/hash reactive synchronization, session/local storage, and reactive HTML document metadata.
16
-
17
- Utility Functions & Plugin: computedAsync, computedByLanguage, computedEternity, getBind, getBindRef, render, toBind, toBinds, dxtFunctionalPlugin.
18
-
19
- 3. TRIGGERS FOR STUDYING AI-TYPES.MD
20
- Reading ai-types.md is mandatory under any of the following conditions, keywords, or implementation tasks:
21
- - Extending or sub-classing DesignConstructorAbstract, DesignAbstract, DesignAsyncAbstract, or DesignComponents.
22
- - Configuring API integrations requiring complex typing, specifically ApiManagementGet, ApiManagementSearch, ApiManagementRequest, or ApiOptions.
23
- - Utilizing component metadata and binding types, such as ConstrBind, ConstrClasses, ConstrStyles, ConstrOptions, ConstrSetup, ConstrComponentMod, or ConstrProps.
24
- - Constructing managed singletons using executeUse, executeUseGlobal, executeUseProvide, or executeUseLocal.
25
- - Typing complex list inputs, search items, and reactive parameters using ListList, ListDataItem, ListDataFull, RefOrNormal, RefType, or RefOrNormalOrFunction.
26
- - Implementing contract validation functions (validateResponseContract, validateRequestContract) or error contracts (ApiErrorStorageList) with schema validation libraries.
27
-
28
- 4. INTEGRATION CONTEXT
29
- Initializes as a Vue 3 plugin via dxtFunctionalPlugin. Connects directly with Vue 3 reactivity and rendering APIs (ref, computed, VNode, provide/inject). Wraps base functional logic from @dxtmisha/functional-basic, integrates with vue-router via RouterItemRef, links to @dxtmisha/media for social icons, and supports runtime schema validation (such as @effect/schema) inside API payload contracts.
1
+ This library provides a reactive utility and component abstraction framework for Vue 3 built on top of functional basic utilities, standardizing UI design system architecture, reactive API request orchestration, localized data formatting, and state management. Its core capabilities span five main modules: the API & Network Module (`useApiRef`, `useApiAsyncRef`, `useApiManagementRef`, `useApiRequest`, and HTTP method composables) manages reactive request lifecycle, SSR prefetching, error contracts, response validation, and list mutations; the Design & Component Architecture Module (`DesignConstructorAbstract`, `DesignComponents`, `DesignAbstract`, `DesignChanged`) provides abstract base classes for component setup, dynamic rendering, class and style calculation, slot management, and prop change tracking; the Localization & Geo Module (`GeoRef`, `GeoIntlRef`, `GeoUnitRef`, `GeoFlagRef`, `DatetimeRef`, `useTranslateRef`) handles reactive internationalization, language/country metadata, locale-sensitive number and date formatting, unit conversions, and translation keys; the Storage & State Module (`useStorageRef`, `useCookieRef`, `useSessionRef`, `useBroadcastValueRef`, `useQueryRef`, `useHashRef`, `executeUse`) binds local/session storage, cookies, cross-tab communication, URL state, and singletons to Vue reactive references; and the DOM, Search & Navigation Module (`useLazyRef`, `RouterItemRef`, `useRouterList`, `useSearchRef`, `useMeta`, `EventRef`) provides lazy visibility tracking, router integration, search indexing, DOM event listeners, and reactive meta tag management. AI assistant study of ai-types.md is mandatory when extending design component abstractions like `DesignConstructorAbstract` or `DesignComponents`, typing component properties, modifications, or emits via `ConstrComponentMod`, `ConstrClasses`, `ConstrEmit`, or `ConstrBind`, configuring API management types including `ApiManagementGet`, `ApiManagementRequest`, or `ApiManagementSearch`, handling reactive input wrappers typed with `RefOrNormal` or `RefOrNormalOrFunction`, or structuring dataset records using `ListListInput`, `ListDataItem`, and `ListSelectedList`. The library seamlessly integrates with Vue 3, vue-router, and @dxtmisha/functional-basic to form a cohesive reactive application infrastructure.
2
+ ## Mandatory Rules
3
+ Read the corresponding file if your task relates to:
4
+ - 'node_modules/@dxtmisha/functional/ai-prompts/api-reference.md': Scope-isolated singleton factories and reactive REST API management
5
+ - 'node_modules/@dxtmisha/functional/ai-prompts/localization-seo.md': Geographic context, i18n formatting, translation primitives, document metadata, and scrollbar utilities
6
+ - 'node_modules/@dxtmisha/functional/ai-prompts/reactivity-lists.md': Async reactivity composables, list data models, search filters, and DOM observers
7
+ - 'node_modules/@dxtmisha/functional/ai-prompts/storage-state.md': Composables for reactive browser storage, session, cookies, cross-tab broadcasting, and URL hash state
package/ai-doc.md CHANGED
@@ -1,42 +1,8 @@
1
1
  # @dxtmisha/functional Reference
2
- Vue 3 reactive utilities built on `@dxtmisha/functional-basic`. See `ai-types.md` for full signatures.
3
-
4
- ## Usage Rules & Strategies
5
- - **Priority**: Always use this package over `@dxtmisha/functional-basic` in Vue.
6
- - **API/State Singletons**: **NEVER** call `useApi*` / `executeUse*` hooks directly in Vue components. Wrap them in `executeUseGlobal` (startup), `executeUseLocal` (lazy, session scope), or `executeUseProvide` (scoped tree) inside external service files. Components only import and call the resulting hook.
7
-
8
- ```typescript
9
- import { executeUseLocal, useApiManagementRef, useStorageRef, useSessionRef, useCookieRef, useBroadcastValueRef, useHashRef, GeoRef, useGeoIntlRef, useTranslateRef, useMeta, ScrollbarWidthRef, computedAsync, computedEternity, ListDataRef, useSearchRef, EventRef, useLazyRef } from '@dxtmisha/functional';
10
-
11
- // 1. API Management
12
- export const useUsers = executeUseLocal(() => useApiManagementRef(
13
- { path: '/api/users' }, { date: (v) => new Date(v).toLocaleString() }, { columns: ['name'] },
14
- { path: '/api/users' }, { path: (o) => `/api/users/${o.id}` }, { path: (o) => `/api/users/${o.id}` }
15
- ));
16
-
17
- // 2. Storage & State
18
- const theme = useStorageRef<'light' | 'dark'>('theme', 'light');
19
- const step = useSessionRef<number>('step', 1);
20
- const token = useCookieRef<string>('auth', '', { secure: true });
21
- const sync = useBroadcastValueRef<string>('ch', 'idle');
22
- const page = useHashRef<string>('page', 'home');
23
2
 
24
- // 3. Geo & Formatting
25
- const country = GeoRef.getCountry(); const intl = useGeoIntlRef(); intl.currency(150, 'EUR');
26
- const t = useTranslateRef(['global.save']);
27
-
28
- // 4. SEO & Layout
29
- useMeta().setTitle('Page'); const scrollW = new ScrollbarWidthRef().width;
30
-
31
- // 5. Reactivity Helpers
32
- const asyncData = computedAsync(async () => fetch(), 'loading...');
33
- const cached = computedEternity(async () => fetch(), 'loading...');
34
-
35
- // 6. Lists & Search
36
- const list = new ListDataRef(items, selectedId); list.isSelected;
37
- const { listSearch } = useSearchRef(items, ['label'], ref('query'));
3
+ Vue 3 reactive utilities built on `@dxtmisha/functional-basic`. See `ai-types.md` for full signatures.
38
4
 
39
- // 7. DOM Events & Lazy
40
- const listener = new EventRef(window, window, 'keydown', (e) => console.log(e.key));
41
- const lazy = useLazyRef(); lazy.addLazyItem(elementRef);
42
- ```
5
+ ## Core Architectural Rules & Strategies
6
+ - **Priority**: Always use `@dxtmisha/functional` reactive composables instead of low-level `@dxtmisha/functional-basic` primitives in Vue 3 applications.
7
+ - **API & State Singletons**: **NEVER** call `useApi*` / `executeUse*` hooks directly in Vue components (`<script setup>`). Wrap them in `executeUseGlobal` (startup), `executeUseLocal` (lazy, session scope), or `executeUseProvide` (scoped tree) inside external service files. Components only import and call the resulting hook.
8
+ - **Purity & Atomicity**: Keep Vue components minimal. Extract all reactive state management, network orchestration, and side effects into external composables.
package/ai-mcp.json ADDED
@@ -0,0 +1,26 @@
1
+ [
2
+ {
3
+ "uri": "@dxtmisha/functional/ai-prompts/api-reference.md",
4
+ "name": "API Management Reference",
5
+ "mimeType": "text/markdown",
6
+ "description": "Guidance and architectural patterns for REST API management and scope-isolated reactive singleton factories using the @dxtmisha/functional library."
7
+ },
8
+ {
9
+ "uri": "@dxtmisha/functional/ai-prompts/localization-seo.md",
10
+ "name": "Localization SEO Utilities",
11
+ "mimeType": "text/markdown",
12
+ "description": "Guidelines and reactive utilities for locale-aware formatting, multi-key translations, geographic context, and dynamic HTML document metadata management."
13
+ },
14
+ {
15
+ "uri": "@dxtmisha/functional/ai-prompts/reactivity-lists.md",
16
+ "name": "Reactivity and Lists",
17
+ "mimeType": "text/markdown",
18
+ "description": "Provides specifications and usage patterns for advanced async reactivity helpers, list selection models, debounced search filters, and DOM observer utilities."
19
+ },
20
+ {
21
+ "uri": "@dxtmisha/functional/ai-prompts/storage-state.md",
22
+ "name": "Browser State Composables",
23
+ "mimeType": "text/markdown",
24
+ "description": "Provides reactive composable wrappers for persistent and synchronized browser state management, including localStorage, sessionStorage, cookies, broadcast channels, and URL hash fragments."
25
+ }
26
+ ]
@@ -0,0 +1,25 @@
1
+ # API Management & Reactive Singletons
2
+
3
+ Guidance and usage patterns for REST API management and scope-isolated singleton factories in `@dxtmisha/functional`.
4
+
5
+ ## 1. Scope Factory Initialization (`executeUse*`)
6
+ - **`executeUseGlobal`**: Initializes a global singleton instance at application startup (shared across the entire application).
7
+ - **`executeUseLocal`**: Lazily creates a session-scoped or closure-local instance upon first invocation.
8
+ - **`executeUseProvide`**: Scope-bound singleton bound to a specific component subtree via Vue `provide` / `inject`.
9
+
10
+ ## 2. API Management (`useApiManagementRef`)
11
+ Handles REST CRUD operations with built-in reactivity, client-side caching, filtering, and contract validation.
12
+
13
+ ### Example
14
+ ```typescript
15
+ import { executeUseLocal, useApiManagementRef } from '@dxtmisha/functional';
16
+
17
+ export const useUsers = executeUseLocal(() => useApiManagementRef(
18
+ { path: '/api/users' },
19
+ { date: (v: string) => new Date(v).toLocaleString() },
20
+ { columns: ['name', 'email'] },
21
+ { path: '/api/users' },
22
+ { path: (o) => `/api/users/${o.id}` },
23
+ { path: (o) => `/api/users/${o.id}` }
24
+ ));
25
+ ```
@@ -0,0 +1,29 @@
1
+ # Localization, Geo & SEO Management
2
+
3
+ Locale-aware formatting, translation primitives, and reactive HTML document metadata handling.
4
+
5
+ ## Available Utilities
6
+ - **`GeoRef`**: Access country information and geographic context (`GeoRef.getCountry()`).
7
+ - **`useGeoIntlRef()`**: Reactive internationalization helper for currency, numbers, and dates.
8
+ - **`useTranslateRef(keys)`**: Multi-key reactive translation resolver.
9
+ - **`useMeta()`**: Reactive manager for HTML document title, meta tags, and open graph social tags.
10
+ - **`ScrollbarWidthRef`**: Helper to measure dynamic scrollbar width for fixed overlay calculations.
11
+
12
+ ### Example
13
+ ```typescript
14
+ import {
15
+ GeoRef,
16
+ useGeoIntlRef,
17
+ useTranslateRef,
18
+ useMeta,
19
+ ScrollbarWidthRef
20
+ } from '@dxtmisha/functional';
21
+
22
+ const country = GeoRef.getCountry();
23
+ const intl = useGeoIntlRef();
24
+ intl.currency(150, 'EUR');
25
+
26
+ const t = useTranslateRef(['global.save']);
27
+ useMeta().setTitle('User Dashboard');
28
+ const scrollW = new ScrollbarWidthRef().width;
29
+ ```
@@ -0,0 +1,34 @@
1
+ # Reactivity Helpers, Lists & DOM Utilities
2
+
3
+ Advanced async reactivity, list data models, search filters, and DOM observers.
4
+
5
+ ## Available Composables & Classes
6
+ - **`computedAsync(evaluator, defaultVal)`**: Asynchronous computed reference for promise resolution.
7
+ - **`computedEternity(evaluator, defaultVal)`**: Cached asynchronous computed ref that preserves state across re-evaluations.
8
+ - **`ListDataRef(items, selectedId)`**: Reactive list structure supporting selection state management.
9
+ - **`useSearchRef(items, fields, queryRef)`**: Debounced multi-field search and highlighting composable.
10
+ - **`EventRef(target, element, event, callback)`**: Managed DOM event listener with automatic lifecycle cleanup.
11
+ - **`useLazyRef()`**: IntersectionObserver helper for lazy rendering and dynamic element loading.
12
+
13
+ ### Example
14
+ ```typescript
15
+ import { ref } from 'vue';
16
+ import {
17
+ computedAsync,
18
+ computedEternity,
19
+ ListDataRef,
20
+ useSearchRef,
21
+ EventRef,
22
+ useLazyRef
23
+ } from '@dxtmisha/functional';
24
+
25
+ const asyncData = computedAsync(async () => fetch('/api/data').then(r => r.json()), 'loading...');
26
+ const cachedData = computedEternity(async () => fetch('/api/cached').then(r => r.json()), 'loading...');
27
+
28
+ const list = new ListDataRef(items, selectedId);
29
+ const query = ref('');
30
+ const { listSearch } = useSearchRef(items, ['name', 'description'], query);
31
+
32
+ const listener = new EventRef(window, window, 'keydown', (e) => console.log(e.key));
33
+ const lazy = useLazyRef();
34
+ ```
@@ -0,0 +1,27 @@
1
+ # Reactive Storage & Browser State
2
+
3
+ Composable wrappers for persistent and synchronized browser state management.
4
+
5
+ ## Available Composables
6
+ - **`useStorageRef<T>(key, defaultVal)`**: Reactive `localStorage` wrapper with cross-tab synchronization.
7
+ - **`useSessionRef<T>(key, defaultVal)`**: Reactive `sessionStorage` wrapper for session-scoped data.
8
+ - **`useCookieRef<T>(key, defaultVal, options)`**: SSR-safe reactive cookie state wrapper.
9
+ - **`useBroadcastValueRef<T>(channel, defaultVal)`**: Reactive cross-tab broadcast messaging using `BroadcastChannel`.
10
+ - **`useHashRef<T>(key, defaultVal)`**: Reactive synchronization with URL hash fragments.
11
+
12
+ ### Example
13
+ ```typescript
14
+ import {
15
+ useStorageRef,
16
+ useSessionRef,
17
+ useCookieRef,
18
+ useBroadcastValueRef,
19
+ useHashRef
20
+ } from '@dxtmisha/functional';
21
+
22
+ const theme = useStorageRef<'light' | 'dark'>('theme', 'light');
23
+ const step = useSessionRef<number>('step', 1);
24
+ const token = useCookieRef<string>('auth', '', { secure: true });
25
+ const sync = useBroadcastValueRef<string>('ch', 'idle');
26
+ const page = useHashRef<string>('page', 'home');
27
+ ```