@dxtmisha/functional-basic 1.3.13 → 1.3.15
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 +17 -0
- package/ai-description.md +18 -0
- package/ai-doc.md +341 -0
- package/{ai-types.txt → ai-types.md} +357 -171
- package/dist/library.js +28 -11
- package/dist/src/classes/Geo.d.ts +14 -0
- package/dist/src/classes/GeoInstance.d.ts +16 -1
- package/dist/src/types/geoTypes.d.ts +6 -0
- package/package.json +4 -4
- package/ai-description.txt +0 -18
- package/ai-doc.txt +0 -54
package/dist/library.js
CHANGED
|
@@ -797,12 +797,14 @@ var Te = () => E.get("__ui:cookie-items__", () => ({})), Ee = class e {
|
|
|
797
797
|
getLocation() {
|
|
798
798
|
return this.location;
|
|
799
799
|
}
|
|
800
|
+
getLocationCountry() {
|
|
801
|
+
return this.toCountry(this.getLocation());
|
|
802
|
+
}
|
|
803
|
+
getLocationLanguage() {
|
|
804
|
+
return this.toLanguage(this.getLocation());
|
|
805
|
+
}
|
|
800
806
|
getItem() {
|
|
801
|
-
return
|
|
802
|
-
...this.item,
|
|
803
|
-
language: this.language,
|
|
804
|
-
standard: `${this.language}-${this.item.country}`
|
|
805
|
-
};
|
|
807
|
+
return this.item;
|
|
806
808
|
}
|
|
807
809
|
getList() {
|
|
808
810
|
return e;
|
|
@@ -810,7 +812,7 @@ var Te = () => E.get("__ui:cookie-items__", () => ({})), Ee = class e {
|
|
|
810
812
|
getByCode(e) {
|
|
811
813
|
var t;
|
|
812
814
|
let n;
|
|
813
|
-
return e && (/([A-Z]{2}-[a-z]{2})|([a-z]{2}-[A-Z]{2})/.test(e) && (n = this.getByCodeFull(e)), !n && /[
|
|
815
|
+
return e && (/([A-Z]{2}-[a-z]{2})|([a-z]{2}-[A-Z]{2})/.test(e) && (n = this.getByCodeFull(e)), !n && /[A-Z]{2}/.test(e) && (n = this.getByCountry(this.toCountry(e))), !n && /[a-z]{2}/.test(e) && (n = this.getByLanguage(this.toLanguage(e)))), this.toFull((t = n) == null ? this.getList()[0] : t, e);
|
|
814
816
|
}
|
|
815
817
|
getByCodeFull(e) {
|
|
816
818
|
return this.getList().find((t) => x(e, [`${t.language}-${t.country}`, `${t.country}-${t.language}`]));
|
|
@@ -837,7 +839,12 @@ var Te = () => E.get("__ui:cookie-items__", () => ({})), Ee = class e {
|
|
|
837
839
|
find(e) {
|
|
838
840
|
return this.getByCode(e);
|
|
839
841
|
}
|
|
840
|
-
toStandard(e) {
|
|
842
|
+
toStandard(e, t) {
|
|
843
|
+
if (t) {
|
|
844
|
+
var n;
|
|
845
|
+
let r = (n = this.getByLanguage(t)) == null ? void 0 : n.language;
|
|
846
|
+
if (r) return `${r}-${e.country}`;
|
|
847
|
+
}
|
|
841
848
|
return `${e.language}-${e.country}`;
|
|
842
849
|
}
|
|
843
850
|
set(e, t) {
|
|
@@ -853,7 +860,7 @@ var Te = () => E.get("__ui:cookie-items__", () => ({})), Ee = class e {
|
|
|
853
860
|
return Ee.getInstance(De);
|
|
854
861
|
}
|
|
855
862
|
findLocation() {
|
|
856
|
-
return this.
|
|
863
|
+
return this.getCookie().get() || this.findLocationDom() || m(this.valueDefault) || "en-GB";
|
|
857
864
|
}
|
|
858
865
|
findLocationDom() {
|
|
859
866
|
var e;
|
|
@@ -868,11 +875,15 @@ var Te = () => E.get("__ui:cookie-items__", () => ({})), Ee = class e {
|
|
|
868
875
|
toLanguage(e) {
|
|
869
876
|
return e.replace(/[^a-z]+/g, "");
|
|
870
877
|
}
|
|
871
|
-
toFull(e) {
|
|
878
|
+
toFull(e, t) {
|
|
879
|
+
let n = t && this.toLanguage(t) || e.language, r = this.toStandard(e, n);
|
|
872
880
|
return {
|
|
873
881
|
...e,
|
|
874
|
-
standard:
|
|
875
|
-
firstDay: (e == null ? void 0 : e.firstDay) || "Mo"
|
|
882
|
+
standard: r,
|
|
883
|
+
firstDay: (e == null ? void 0 : e.firstDay) || "Mo",
|
|
884
|
+
location: t == null ? r : t,
|
|
885
|
+
locationCountry: t && this.toCountry(t) || e.country,
|
|
886
|
+
locationLanguage: n
|
|
876
887
|
};
|
|
877
888
|
}
|
|
878
889
|
}, k = class {
|
|
@@ -897,6 +908,12 @@ var Te = () => E.get("__ui:cookie-items__", () => ({})), Ee = class e {
|
|
|
897
908
|
static getLocation() {
|
|
898
909
|
return this.getObject().getLocation();
|
|
899
910
|
}
|
|
911
|
+
static getLocationCountry() {
|
|
912
|
+
return this.getObject().getLocationCountry();
|
|
913
|
+
}
|
|
914
|
+
static getLocationLanguage() {
|
|
915
|
+
return this.getObject().getLocationLanguage();
|
|
916
|
+
}
|
|
900
917
|
static getItem() {
|
|
901
918
|
return this.getObject().getItem();
|
|
902
919
|
}
|
|
@@ -57,6 +57,20 @@ export declare class Geo {
|
|
|
57
57
|
* @returns location string / строка местоположения
|
|
58
58
|
*/
|
|
59
59
|
static getLocation(): string;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the country code extracted from the location string.
|
|
62
|
+
*
|
|
63
|
+
* Возвращает код страны, извлеченный из строки местоположения.
|
|
64
|
+
* @returns country code / код страны
|
|
65
|
+
*/
|
|
66
|
+
static getLocationCountry(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Returns the language code extracted from the location string.
|
|
69
|
+
*
|
|
70
|
+
* Возвращает код языка, извлеченный из строки местоположения.
|
|
71
|
+
* @returns language code / код языка
|
|
72
|
+
*/
|
|
73
|
+
static getLocationLanguage(): string;
|
|
60
74
|
/**
|
|
61
75
|
* Returns fully processed geo data updated with the current language.
|
|
62
76
|
*
|
|
@@ -92,6 +92,20 @@ export declare class GeoInstance {
|
|
|
92
92
|
* @returns location string / строка местоположения
|
|
93
93
|
*/
|
|
94
94
|
getLocation(): string;
|
|
95
|
+
/**
|
|
96
|
+
* Getting the country code from the location.
|
|
97
|
+
*
|
|
98
|
+
* Получение кода страны из местоположения.
|
|
99
|
+
* @returns country code / код страны
|
|
100
|
+
*/
|
|
101
|
+
getLocationCountry(): string;
|
|
102
|
+
/**
|
|
103
|
+
* Getting the language code from the location.
|
|
104
|
+
*
|
|
105
|
+
* Получение кода языка из местоположения.
|
|
106
|
+
* @returns language code / код языка
|
|
107
|
+
*/
|
|
108
|
+
getLocationLanguage(): string;
|
|
95
109
|
/**
|
|
96
110
|
* Getting processed data including the current language.
|
|
97
111
|
*
|
|
@@ -167,7 +181,7 @@ export declare class GeoInstance {
|
|
|
167
181
|
* @param item geo item data / данные гео-объекта
|
|
168
182
|
* @returns standard code string / строка стандартного кода
|
|
169
183
|
*/
|
|
170
|
-
toStandard(item: GeoItem): string;
|
|
184
|
+
toStandard(item: GeoItem, language?: string): string;
|
|
171
185
|
/**
|
|
172
186
|
* Updates the current location and related data.
|
|
173
187
|
*
|
|
@@ -242,6 +256,7 @@ export declare class GeoInstance {
|
|
|
242
256
|
*
|
|
243
257
|
* Внутренний метод для заполнения отсутствующих полей в гео-объекте.
|
|
244
258
|
* @param item basic geo item / базовый гео-объект
|
|
259
|
+
* @param code country code, full form language-country or one of them / код страны, полный вид язык-страна или один из них
|
|
245
260
|
* @returns full geo item data / полные данные гео-объекта
|
|
246
261
|
*/
|
|
247
262
|
private toFull;
|
|
@@ -38,6 +38,12 @@ export interface GeoItemFull extends Omit<GeoItem, 'firstDay'> {
|
|
|
38
38
|
standard: string;
|
|
39
39
|
/** First day of week (required)/ Первый день недели (обязательный) */
|
|
40
40
|
firstDay: string;
|
|
41
|
+
/** Current location string/ Строка текущего местоположения */
|
|
42
|
+
location: string;
|
|
43
|
+
/** Current country code from location/ Текущий код страны из местоположения */
|
|
44
|
+
locationCountry: string;
|
|
45
|
+
/** Current language code from location/ Текущий код языка из местоположения */
|
|
46
|
+
locationLanguage: string;
|
|
41
47
|
}
|
|
42
48
|
/** Geographic flag item for country flag display/ Элемент географического флага для отображения флага страны */
|
|
43
49
|
export interface GeoFlagItem {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxtmisha/functional-basic",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.15",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Foundational utility library for modern web development — HTTP client, geolocation, i18n, SEO meta tags, caching, storage, DOM utilities, and more. Framework-agnostic, zero dependencies, TypeScript-first.",
|
|
7
7
|
"keywords": [
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
},
|
|
60
60
|
"files": [
|
|
61
61
|
"dist",
|
|
62
|
-
"ai-description.
|
|
63
|
-
"ai-doc.
|
|
64
|
-
"ai-types.
|
|
62
|
+
"ai-description.md",
|
|
63
|
+
"ai-doc.md",
|
|
64
|
+
"ai-types.md",
|
|
65
65
|
"CHANGELOG.md",
|
|
66
66
|
"LICENSE",
|
|
67
67
|
"package.json",
|
package/ai-description.txt
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
This library is a comprehensive, isomorphic utility toolkit for TypeScript applications, focusing on data management, HTTP communication, internationalization, and DOM manipulation.
|
|
2
|
-
|
|
3
|
-
1. Core Purpose:
|
|
4
|
-
The library acts as a centralized foundation for common application tasks. It provides a robust HTTP client (Fetch wrapper with built-in retries, caching, and hydration support), state management (localized storage, cookie handling, URL hash synchronization), internationalization (translation management, date/time/currency formatting), and DOM utility functions (event listeners, scroll management, meta tag management).
|
|
5
|
-
|
|
6
|
-
2. Usage Scenarios:
|
|
7
|
-
- API Orchestration: Use the Api/ApiInstance classes for unified fetch requests, centralized error handling (ErrorCenter), and automatic response caching.
|
|
8
|
-
- State Synchronization: Essential for SSR-compliant state management (ServerStorage) and syncing application state with URL hashes or Cookies.
|
|
9
|
-
- Localization: Indispensable for applications requiring multi-language support (Translate), dynamic date/time formatting (GeoIntl, Datetime), and locale-aware number/currency formatting.
|
|
10
|
-
- DOM & Event Management: Use EventItem for lifecycle-safe event listeners (with automatic cleanup) and scroll/resize optimizations; use Meta and its derivatives for SEO and social media metadata management.
|
|
11
|
-
- Data Processing: Highly useful for search-as-you-type implementations (SearchList) and complex data transformations (Formatters).
|
|
12
|
-
|
|
13
|
-
3. Integration Context:
|
|
14
|
-
- SSR & Hydration: The library includes specialized handlers (ApiHydration, ServerStorage, getHydrationData) designed to bridge the gap between server-rendered state and client-side execution, preventing hydration mismatches.
|
|
15
|
-
- Architecture: It follows a singleton-friendly patterns (e.g., Api.getItem(), Geo.getObject()) that facilitate global access to state and configurations across disparate modules without tight coupling.
|
|
16
|
-
- Type Safety: Extensively typed (TypeScript), providing full autocompletion and structural validation for search, API, translation, and formatting configurations.
|
|
17
|
-
|
|
18
|
-
An AI assistant should study this library when tasked with building enterprise-grade, localized web applications that require standardized API communication, cross-browser DOM event management, or robust SSR data state serialization.
|
package/ai-doc.txt
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
This is the basic functional library (@dxtmisha/functional-basic). It contains framework-agnostic algorithms, utilities, and classes.
|
|
2
|
-
|
|
3
|
-
ATTENTION FOR VUE ENVIRONMENT:
|
|
4
|
-
If you are developing in Vue, ALWAYS look for the required functionality (composables, reactive wrappers) inside the `@dxtmisha/functional` library FIRST.
|
|
5
|
-
And ONLY if there is no reactive or Vue-specific analog there, you may use the functionality directly from this library (@dxtmisha/functional-basic).
|
|
6
|
-
|
|
7
|
-
=============================================================================
|
|
8
|
-
CLASS STRUCTURE & CODING STANDARDS (RULES FOR AI)
|
|
9
|
-
=============================================================================
|
|
10
|
-
|
|
11
|
-
To maintain consistency and high industrial quality across the dxt-ui codebase, all TypeScript classes inside `@dxtmisha/functional-basic` must strictly adhere to the following rules regarding structure, member ordering, and styles.
|
|
12
|
-
|
|
13
|
-
1. ORDER OF MEMBERS WITHIN A CLASS
|
|
14
|
-
Members in every class MUST be ordered in the following sequence:
|
|
15
|
-
|
|
16
|
-
A. Class Properties / Member Variables:
|
|
17
|
-
- Placed at the very top of the class body.
|
|
18
|
-
- Ordered by visibility: Public first, then Protected, and Private last.
|
|
19
|
-
- Within each visibility level, group by logical connection or alphabetically.
|
|
20
|
-
- Initialize default values directly on declaration when possible.
|
|
21
|
-
|
|
22
|
-
B. Constructor:
|
|
23
|
-
- Placed immediately after all property declarations.
|
|
24
|
-
- Parameter properties (e.g., `protected url: string`) are allowed to simplify declaration.
|
|
25
|
-
|
|
26
|
-
C. Public Methods:
|
|
27
|
-
- Placed after the constructor.
|
|
28
|
-
- Grouped logically:
|
|
29
|
-
1. Getters, checkers, and status-check methods (e.g., `is*`, `get*`).
|
|
30
|
-
2. Setters and configuration methods (e.g., `set*`).
|
|
31
|
-
3. Core executors and action methods (e.g., `request()`, `fetch()`, `show()`).
|
|
32
|
-
|
|
33
|
-
D. Protected Methods:
|
|
34
|
-
- Placed after all public methods.
|
|
35
|
-
- Contain internal utility and helper logic accessible to subclasses.
|
|
36
|
-
|
|
37
|
-
E. Private Methods:
|
|
38
|
-
- Placed at the very end of the class.
|
|
39
|
-
- Strict encapsulation of internal logic.
|
|
40
|
-
|
|
41
|
-
2. CODING & STYLE CONVENTIONS
|
|
42
|
-
- Naming:
|
|
43
|
-
* Classes: PascalCase (e.g., `LoadingInstance`).
|
|
44
|
-
* Methods & Properties: camelCase (e.g., `registrationEvent`, `registrationList`).
|
|
45
|
-
* Constants inside files: UPPER_SNAKE_CASE (e.g., `LOADING_EVENT_NAME`).
|
|
46
|
-
- TypeScript Safety:
|
|
47
|
-
* Never use `any`. Use generic parameters or `unknown` if the type is dynamic/undefined.
|
|
48
|
-
* Explicitly declare return types for ALL public, protected, and private methods (including `void`).
|
|
49
|
-
* Use interfaces/types to define structural contracts for complex inputs and outputs.
|
|
50
|
-
- SSR Isolation (Server-Side Rendering):
|
|
51
|
-
* The library must be fully isomorphic and safe for SSR.
|
|
52
|
-
* Avoid storing request-specific state in global/static class properties directly.
|
|
53
|
-
* Use `ServerStorage.get('key', () => new Instance())` for request-isolated singletons.
|
|
54
|
-
* Use `isDomRuntime()` checks before accessing browser-only APIs like `window`, `document`, or `location`.
|