@nexim/alpine 1.1.1 → 1.1.3
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 +12 -0
- package/dist/main.cjs +9 -5
- package/dist/main.cjs.map +2 -2
- package/dist/main.mjs +9 -5
- package/dist/main.mjs.map +2 -2
- package/dist/store/store-generator.d.ts +22 -14
- package/dist/store/store-generator.d.ts.map +1 -1
- package/dist/store/store-with-backup.d.ts +10 -7
- package/dist/store/store-with-backup.d.ts.map +1 -1
- package/dist/store/store.d.ts +6 -4
- package/dist/store/store.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.1.3](https://github.com/the-nexim/nanolib/compare/@nexim/alpine@1.1.2...@nexim/alpine@1.1.3) (2025-01-09)
|
|
7
|
+
|
|
8
|
+
### Code Refactoring
|
|
9
|
+
|
|
10
|
+
* update output paths in package.json ([#30](https://github.com/the-nexim/nanolib/issues/30)) ([2e03380](https://github.com/the-nexim/nanolib/commit/2e033802420b65644b2af19d29b9c2c5f06332b0)) by @
|
|
11
|
+
|
|
12
|
+
## [1.1.2](https://github.com/the-nexim/nanolib/compare/@nexim/alpine@1.1.1...@nexim/alpine@1.1.2) (2025-01-06)
|
|
13
|
+
|
|
14
|
+
### Code Refactoring
|
|
15
|
+
|
|
16
|
+
* use new @nexim/typescript-config api ([6d656b4](https://github.com/the-nexim/nanolib/commit/6d656b483f27d556e59bdcec1220511c5c819cc8)) by @njfamirm
|
|
17
|
+
|
|
6
18
|
## [1.1.1](https://github.com/the-nexim/nanolib/compare/@nexim/alpine@1.1.0...@nexim/alpine@1.1.1) (2025-01-05)
|
|
7
19
|
|
|
8
20
|
### Bug Fixes
|
package/dist/main.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @nexim/alpine v1.1.
|
|
1
|
+
/* @nexim/alpine v1.1.3 */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -55,9 +55,10 @@ var AlpineStore = class {
|
|
|
55
55
|
/**
|
|
56
56
|
* Provides a Alpine.js pure store implementation with logger.
|
|
57
57
|
*
|
|
58
|
-
* @param
|
|
58
|
+
* @param config - Configuration object.
|
|
59
59
|
*
|
|
60
60
|
* @example
|
|
61
|
+
* ```
|
|
61
62
|
* import {AlpineStore} from '@nexim/alpine';
|
|
62
63
|
*
|
|
63
64
|
* const {store} = new AlpineStore({
|
|
@@ -68,6 +69,7 @@ var AlpineStore = class {
|
|
|
68
69
|
*
|
|
69
70
|
* store.data = 'user';
|
|
70
71
|
* console.log(store.data); // Output: { data: 'user' }
|
|
72
|
+
* ```
|
|
71
73
|
*/
|
|
72
74
|
constructor(config) {
|
|
73
75
|
this.logger_ = (0, import_logger2.createLogger)(`${"@nexim/alpine"}:${config.name}`);
|
|
@@ -84,9 +86,10 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
84
86
|
/**
|
|
85
87
|
* Provides a Alpine.js store implementation with backup and expiration.
|
|
86
88
|
*
|
|
87
|
-
* @param
|
|
89
|
+
* @param config__ - Configuration object.
|
|
88
90
|
*
|
|
89
91
|
* @example
|
|
92
|
+
* ```
|
|
90
93
|
* import {AlpineStoreWithBackup} from '@nexim/alpine';
|
|
91
94
|
*
|
|
92
95
|
* const storeWithBackup = new AlpineStoreWithBackup({
|
|
@@ -103,6 +106,7 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
103
106
|
*
|
|
104
107
|
* storeWithBackup.clear();
|
|
105
108
|
* console.log(storeWithBackup.store.data); // Output: { data: 'root' }
|
|
109
|
+
* ```
|
|
106
110
|
*/
|
|
107
111
|
constructor(config__) {
|
|
108
112
|
super(config__);
|
|
@@ -162,7 +166,7 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
162
166
|
*
|
|
163
167
|
* When data is not found or invalid in local storage, it uses the default value.
|
|
164
168
|
*
|
|
165
|
-
* FIXME: remove `NonNullable` from
|
|
169
|
+
* FIXME: remove `NonNullable` from `<T['data']>`, after local storage new version.
|
|
166
170
|
*/
|
|
167
171
|
load__() {
|
|
168
172
|
this.logger_.logMethod?.("load__");
|
|
@@ -186,6 +190,6 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
186
190
|
};
|
|
187
191
|
|
|
188
192
|
// src/main.ts
|
|
189
|
-
__dev_mode__: import_package_tracer.packageTracer.add("@nexim/alpine", "1.1.
|
|
193
|
+
__dev_mode__: import_package_tracer.packageTracer.add("@nexim/alpine", "1.1.3");
|
|
190
194
|
/*! For license information please see main.cjs.LEGAL.txt */
|
|
191
195
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts", "../src/store/store-generator.ts", "../src/store/store.ts", "../src/store/store-with-backup.ts"],
|
|
4
|
-
"sourcesContent": ["import {packageTracer} from '@alwatr/package-tracer';\n\n__dev_mode__: packageTracer.add(__package_name__, __package_version__);\n\nexport * from './store/store-generator.js';\nexport * from './store/store.js';\nexport * from './store/store-with-backup.js';\n", "import {createLogger} from '@alwatr/logger';\nimport alpine from 'alpinejs';\n\nconst logger = createLogger(__package_name__);\n\n/**\n * alpineStoreGenerator Options.\n *\n * @
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA4B;;;ACA5B,oBAA2B;AAC3B,sBAAmB;AAEnB,IAAM,aAAS,4BAAa,eAAgB;
|
|
4
|
+
"sourcesContent": ["import {packageTracer} from '@alwatr/package-tracer';\n\n__dev_mode__: packageTracer.add(__package_name__, __package_version__);\n\nexport * from './store/store-generator.js';\nexport * from './store/store.js';\nexport * from './store/store-with-backup.js';\n", "import {createLogger} from '@alwatr/logger';\nimport alpine from 'alpinejs';\n\nconst logger = createLogger(__package_name__);\n\n/**\n * alpineStoreGenerator Options.\n *\n * @typeParam T - The type of the default value.\n */\nexport type AlpineStoreGeneratorOptions<T extends DictionaryReq> = {\n /**\n * The name of the store.\n */\n name: string;\n\n /**\n * The default value of the store.\n */\n defaultValue: T;\n};\n\n/**\n * Generates an Alpine.js store with default value.\n *\n * @typeParam T - The type of the data.\n *\n * @param config - The configuration object for the store.\n * @returns - The initialized store instance.\n *\n * @remarks\n *\n * This function uses Alpine.js to create a reactive store with a default value.\n * The store is identified by a unique name and can be accessed and manipulated\n * throughout the application. Alpine.js stores provide a simple way to manage\n * data in your application, making it easy to keep your UI in sync with your data.\n *\n * @see {@link https://alpinejs.dev/globals/alpine-store}\n *\n * @example\n * ```\n * const store = alpineStoreGenerator({\n * name: 'user',\n * defaultValue: {type: 'root'},\n * });\n *\n * console.log(store.type); // Output: root\n *```\n */\nexport function alpineStoreGenerator<T extends DictionaryReq>(config: AlpineStoreGeneratorOptions<T>): T {\n logger.logMethodArgs?.('alpineStoreGenerator', {config});\n\n alpine.store(config.name, config.defaultValue);\n\n // Get store Proxy\n const store = alpine.store(config.name) as T;\n return store;\n}\n", "import {type AlwatrLogger, createLogger} from '@alwatr/logger';\n\nimport {alpineStoreGenerator} from './store-generator.js';\n\n/**\n * AlpineStore Options.\n *\n * @typeParam T - The type of the store value.\n * @param name - The name of the store.\n * @param defaultValue - The default value of the store.\n */\nexport type AlpineStoreOptions<T extends DictionaryReq> = {\n name: string;\n defaultValue: T;\n};\n\n/**\n * Provides a Alpine.js pure store implementation with logger.\n */\nexport class AlpineStore<T extends DictionaryReq> {\n /**\n * The store's data.\n */\n store: T;\n\n protected logger_: AlwatrLogger;\n\n /**\n * Provides a Alpine.js pure store implementation with logger.\n *\n * @param config - Configuration object.\n *\n * @example\n * ```\n * import {AlpineStore} from '@nexim/alpine';\n *\n * const {store} = new AlpineStore({\n * name: 'myStore',\n * defaultValue: {data: 'root'},\n * });\n * console.log(store.data); // Output: { data: 'root' }\n *\n * store.data = 'user';\n * console.log(store.data); // Output: { data: 'user' }\n * ```\n */\n constructor(config: AlpineStoreOptions<T>) {\n this.logger_ = createLogger(`${__package_name__}:${config.name}`);\n this.logger_.logMethodArgs?.('constructor', config);\n\n this.store = alpineStoreGenerator(config);\n }\n}\n", "import {localJsonStorage} from '@alwatr/local-storage';\nimport {parseDuration, type Duration} from '@alwatr/parse-duration';\n\nimport {AlpineStore} from './store.js';\n\n/**\n * Type for the store's data to extends from them.\n */\nexport type AlpineStoreWithBackupType = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: DictionaryReq<any> | null;\n};\n\n/**\n * AlpineStoreWithBackup Options.\n *\n * @typeParam T - The type of the store value.\n *\n * @param name - The name of the store.\n * @param version - The version of the store.\n * @param defaultValue - The default value of the store.\n * @param expireDuration - Optional. The duration after which the store expires.\n */\nexport type AlpineStoreWithBackupOptions<T extends AlpineStoreWithBackupType> = {\n name: string;\n version: number;\n defaultValue: T;\n expireDuration?: Duration;\n};\n\n/**\n * Version of the schema for storing data in local storage.\n *\n * Change when this schema changes.\n */\nconst schemaVersion = 1;\n\n/**\n * Provides a Alpine.js store implementation with backup and expiration.\n */\nexport class AlpineStoreWithBackup<T extends AlpineStoreWithBackupType> extends AlpineStore<T> {\n /**\n * Keys for storing data and expire time in local storage with version.\n */\n private localStorageKey__ = {\n data: `[${__package_name__}:data:sv${schemaVersion}]:${this.config__.name}`,\n expireTime: `[${__package_name__}:expire-time:sv${schemaVersion}]:${this.config__.name}`,\n };\n\n /**\n * Provides a Alpine.js store implementation with backup and expiration.\n *\n * @param config__ - Configuration object.\n *\n * @example\n * ```\n * import {AlpineStoreWithBackup} from '@nexim/alpine';\n *\n * const storeWithBackup = new AlpineStoreWithBackup({\n * name: 'myStoreWithBackup',\n * version: 1,\n * defaultValue: {data: 'root'},\n * expireDuration: '1d',\n * });\n *\n * storeWithBackup.store.data = 'user';\n *\n * storeWithBackup.save();\n * console.log(storeWithBackup.store.data); // Output: { data: 'user' }\n *\n * storeWithBackup.clear();\n * console.log(storeWithBackup.store.data); // Output: { data: 'root' }\n * ```\n */\n constructor(private config__: AlpineStoreWithBackupOptions<T>) {\n super(config__);\n\n if (this.config__.expireDuration != null) {\n this.handleDataExpiration__();\n }\n\n this.load__();\n }\n\n /**\n * Saves the current data to local storage. If the data is null, it clears the stored data.\n *\n * Also updates the expiration time.\n */\n save(): void {\n this.logger_.logMethodArgs?.('save', {data: this.store.data});\n\n if (this.store.data === null) {\n this.clear();\n return;\n }\n\n localJsonStorage.setItem(this.localStorageKey__.data, this.store.data, this.config__.version);\n this.updateExpireTime__();\n }\n\n /**\n * Clears the stored data.\n */\n clear(): void {\n this.logger_.logMethod?.('clear');\n\n localJsonStorage.removeItem(this.localStorageKey__.data, this.config__.version);\n localJsonStorage.removeItem(this.localStorageKey__.expireTime, this.config__.version);\n\n this.store = this.config__.defaultValue;\n }\n\n /**\n * Handles the expiration duration by checking if the stored data has expired.\n * If expired, it clears the stored data.\n */\n private handleDataExpiration__(): void {\n this.logger_.logMethod?.('handleDataExpiration__');\n\n // FIXME: use null if not set, after local storage new version.\n const expireDuration = localJsonStorage.getItem<{time: number}>(\n this.localStorageKey__.expireTime,\n {time: -1},\n this.config__.version,\n ).time;\n\n if (expireDuration !== -1 && expireDuration < Date.now()) {\n this.clear();\n }\n }\n\n /**\n * Loads data from local storage and updates the store's data.\n *\n * When data is not found or invalid in local storage, it uses the default value.\n *\n * FIXME: remove `NonNullable` from `<T['data']>`, after local storage new version.\n */\n private load__(): void {\n this.logger_.logMethod?.('load__');\n\n const newData = localJsonStorage.getItem<NonNullable<T['data']>>(\n this.localStorageKey__.data,\n this.config__.defaultValue.data as NonNullable<T['data']>,\n this.config__.version,\n ) as T['data'];\n this.store.data = newData;\n }\n\n /**\n * Updates the expiration time in local storage to the current time plus the configured expiration duration.\n */\n private updateExpireTime__(): void {\n if (this.config__.expireDuration == null) return;\n this.logger_.logMethod?.('updateExpireTime__');\n\n const newExpireTime = Date.now() + parseDuration(this.config__.expireDuration);\n localJsonStorage.setItem(this.localStorageKey__.expireTime, {time: newExpireTime}, this.config__.version);\n\n this.logger_.logOther?.('updated_expire_time', {newExpireTime});\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA4B;;;ACA5B,oBAA2B;AAC3B,sBAAmB;AAEnB,IAAM,aAAS,4BAAa,eAAgB;AA8CrC,SAAS,qBAA8C,QAA2C;AACvG,SAAO,gBAAgB,wBAAwB,EAAC,OAAM,CAAC;AAEvD,kBAAAA,QAAO,MAAM,OAAO,MAAM,OAAO,YAAY;AAG7C,QAAM,QAAQ,gBAAAA,QAAO,MAAM,OAAO,IAAI;AACtC,SAAO;AACT;;;ACzDA,IAAAC,iBAA8C;AAmBvC,IAAM,cAAN,MAA2C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BhD,YAAY,QAA+B;AACzC,SAAK,cAAU,6BAAa,GAAG,eAAgB,IAAI,OAAO,IAAI,EAAE;AAChE,SAAK,QAAQ,gBAAgB,eAAe,MAAM;AAElD,SAAK,QAAQ,qBAAqB,MAAM;AAAA,EAC1C;AACF;;;ACpDA,2BAA+B;AAC/B,4BAA2C;AAkC3C,IAAM,gBAAgB;AAKf,IAAM,wBAAN,cAAyE,YAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AAA,EASQ,SAAe;AACrB,SAAK,QAAQ,YAAY,QAAQ;AAEjC,UAAM,UAAU,sCAAiB;AAAA,MAC/B,KAAK,kBAAkB;AAAA,MACvB,KAAK,SAAS,aAAa;AAAA,MAC3B,KAAK,SAAS;AAAA,IAChB;AACA,SAAK,MAAM,OAAO;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKQ,qBAA2B;AACjC,QAAI,KAAK,SAAS,kBAAkB,KAAM;AAC1C,SAAK,QAAQ,YAAY,oBAAoB;AAE7C,UAAM,gBAAgB,KAAK,IAAI,QAAI,qCAAc,KAAK,SAAS,cAAc;AAC7E,0CAAiB,QAAQ,KAAK,kBAAkB,YAAY,EAAC,MAAM,cAAa,GAAG,KAAK,SAAS,OAAO;AAExG,SAAK,QAAQ,WAAW,uBAAuB,EAAC,cAAa,CAAC;AAAA,EAChE;AACF;;;AHhKA,aAAc,qCAAc,IAAI,iBAAkB,OAAmB;",
|
|
6
6
|
"names": ["alpine", "import_logger"]
|
|
7
7
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @nexim/alpine v1.1.
|
|
1
|
+
/* @nexim/alpine v1.1.3 */
|
|
2
2
|
|
|
3
3
|
// src/main.ts
|
|
4
4
|
import { packageTracer } from "@alwatr/package-tracer";
|
|
@@ -20,9 +20,10 @@ var AlpineStore = class {
|
|
|
20
20
|
/**
|
|
21
21
|
* Provides a Alpine.js pure store implementation with logger.
|
|
22
22
|
*
|
|
23
|
-
* @param
|
|
23
|
+
* @param config - Configuration object.
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
|
+
* ```
|
|
26
27
|
* import {AlpineStore} from '@nexim/alpine';
|
|
27
28
|
*
|
|
28
29
|
* const {store} = new AlpineStore({
|
|
@@ -33,6 +34,7 @@ var AlpineStore = class {
|
|
|
33
34
|
*
|
|
34
35
|
* store.data = 'user';
|
|
35
36
|
* console.log(store.data); // Output: { data: 'user' }
|
|
37
|
+
* ```
|
|
36
38
|
*/
|
|
37
39
|
constructor(config) {
|
|
38
40
|
this.logger_ = createLogger2(`${"@nexim/alpine"}:${config.name}`);
|
|
@@ -49,9 +51,10 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
49
51
|
/**
|
|
50
52
|
* Provides a Alpine.js store implementation with backup and expiration.
|
|
51
53
|
*
|
|
52
|
-
* @param
|
|
54
|
+
* @param config__ - Configuration object.
|
|
53
55
|
*
|
|
54
56
|
* @example
|
|
57
|
+
* ```
|
|
55
58
|
* import {AlpineStoreWithBackup} from '@nexim/alpine';
|
|
56
59
|
*
|
|
57
60
|
* const storeWithBackup = new AlpineStoreWithBackup({
|
|
@@ -68,6 +71,7 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
68
71
|
*
|
|
69
72
|
* storeWithBackup.clear();
|
|
70
73
|
* console.log(storeWithBackup.store.data); // Output: { data: 'root' }
|
|
74
|
+
* ```
|
|
71
75
|
*/
|
|
72
76
|
constructor(config__) {
|
|
73
77
|
super(config__);
|
|
@@ -127,7 +131,7 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
127
131
|
*
|
|
128
132
|
* When data is not found or invalid in local storage, it uses the default value.
|
|
129
133
|
*
|
|
130
|
-
* FIXME: remove `NonNullable` from
|
|
134
|
+
* FIXME: remove `NonNullable` from `<T['data']>`, after local storage new version.
|
|
131
135
|
*/
|
|
132
136
|
load__() {
|
|
133
137
|
this.logger_.logMethod?.("load__");
|
|
@@ -151,7 +155,7 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
151
155
|
};
|
|
152
156
|
|
|
153
157
|
// src/main.ts
|
|
154
|
-
__dev_mode__: packageTracer.add("@nexim/alpine", "1.1.
|
|
158
|
+
__dev_mode__: packageTracer.add("@nexim/alpine", "1.1.3");
|
|
155
159
|
export {
|
|
156
160
|
AlpineStore,
|
|
157
161
|
AlpineStoreWithBackup,
|
package/dist/main.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts", "../src/store/store-generator.ts", "../src/store/store.ts", "../src/store/store-with-backup.ts"],
|
|
4
|
-
"sourcesContent": ["import {packageTracer} from '@alwatr/package-tracer';\n\n__dev_mode__: packageTracer.add(__package_name__, __package_version__);\n\nexport * from './store/store-generator.js';\nexport * from './store/store.js';\nexport * from './store/store-with-backup.js';\n", "import {createLogger} from '@alwatr/logger';\nimport alpine from 'alpinejs';\n\nconst logger = createLogger(__package_name__);\n\n/**\n * alpineStoreGenerator Options.\n *\n * @
|
|
5
|
-
"mappings": ";;;AAAA,SAAQ,qBAAoB;;;ACA5B,SAAQ,oBAAmB;AAC3B,OAAO,YAAY;AAEnB,IAAM,SAAS,aAAa,eAAgB;
|
|
4
|
+
"sourcesContent": ["import {packageTracer} from '@alwatr/package-tracer';\n\n__dev_mode__: packageTracer.add(__package_name__, __package_version__);\n\nexport * from './store/store-generator.js';\nexport * from './store/store.js';\nexport * from './store/store-with-backup.js';\n", "import {createLogger} from '@alwatr/logger';\nimport alpine from 'alpinejs';\n\nconst logger = createLogger(__package_name__);\n\n/**\n * alpineStoreGenerator Options.\n *\n * @typeParam T - The type of the default value.\n */\nexport type AlpineStoreGeneratorOptions<T extends DictionaryReq> = {\n /**\n * The name of the store.\n */\n name: string;\n\n /**\n * The default value of the store.\n */\n defaultValue: T;\n};\n\n/**\n * Generates an Alpine.js store with default value.\n *\n * @typeParam T - The type of the data.\n *\n * @param config - The configuration object for the store.\n * @returns - The initialized store instance.\n *\n * @remarks\n *\n * This function uses Alpine.js to create a reactive store with a default value.\n * The store is identified by a unique name and can be accessed and manipulated\n * throughout the application. Alpine.js stores provide a simple way to manage\n * data in your application, making it easy to keep your UI in sync with your data.\n *\n * @see {@link https://alpinejs.dev/globals/alpine-store}\n *\n * @example\n * ```\n * const store = alpineStoreGenerator({\n * name: 'user',\n * defaultValue: {type: 'root'},\n * });\n *\n * console.log(store.type); // Output: root\n *```\n */\nexport function alpineStoreGenerator<T extends DictionaryReq>(config: AlpineStoreGeneratorOptions<T>): T {\n logger.logMethodArgs?.('alpineStoreGenerator', {config});\n\n alpine.store(config.name, config.defaultValue);\n\n // Get store Proxy\n const store = alpine.store(config.name) as T;\n return store;\n}\n", "import {type AlwatrLogger, createLogger} from '@alwatr/logger';\n\nimport {alpineStoreGenerator} from './store-generator.js';\n\n/**\n * AlpineStore Options.\n *\n * @typeParam T - The type of the store value.\n * @param name - The name of the store.\n * @param defaultValue - The default value of the store.\n */\nexport type AlpineStoreOptions<T extends DictionaryReq> = {\n name: string;\n defaultValue: T;\n};\n\n/**\n * Provides a Alpine.js pure store implementation with logger.\n */\nexport class AlpineStore<T extends DictionaryReq> {\n /**\n * The store's data.\n */\n store: T;\n\n protected logger_: AlwatrLogger;\n\n /**\n * Provides a Alpine.js pure store implementation with logger.\n *\n * @param config - Configuration object.\n *\n * @example\n * ```\n * import {AlpineStore} from '@nexim/alpine';\n *\n * const {store} = new AlpineStore({\n * name: 'myStore',\n * defaultValue: {data: 'root'},\n * });\n * console.log(store.data); // Output: { data: 'root' }\n *\n * store.data = 'user';\n * console.log(store.data); // Output: { data: 'user' }\n * ```\n */\n constructor(config: AlpineStoreOptions<T>) {\n this.logger_ = createLogger(`${__package_name__}:${config.name}`);\n this.logger_.logMethodArgs?.('constructor', config);\n\n this.store = alpineStoreGenerator(config);\n }\n}\n", "import {localJsonStorage} from '@alwatr/local-storage';\nimport {parseDuration, type Duration} from '@alwatr/parse-duration';\n\nimport {AlpineStore} from './store.js';\n\n/**\n * Type for the store's data to extends from them.\n */\nexport type AlpineStoreWithBackupType = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: DictionaryReq<any> | null;\n};\n\n/**\n * AlpineStoreWithBackup Options.\n *\n * @typeParam T - The type of the store value.\n *\n * @param name - The name of the store.\n * @param version - The version of the store.\n * @param defaultValue - The default value of the store.\n * @param expireDuration - Optional. The duration after which the store expires.\n */\nexport type AlpineStoreWithBackupOptions<T extends AlpineStoreWithBackupType> = {\n name: string;\n version: number;\n defaultValue: T;\n expireDuration?: Duration;\n};\n\n/**\n * Version of the schema for storing data in local storage.\n *\n * Change when this schema changes.\n */\nconst schemaVersion = 1;\n\n/**\n * Provides a Alpine.js store implementation with backup and expiration.\n */\nexport class AlpineStoreWithBackup<T extends AlpineStoreWithBackupType> extends AlpineStore<T> {\n /**\n * Keys for storing data and expire time in local storage with version.\n */\n private localStorageKey__ = {\n data: `[${__package_name__}:data:sv${schemaVersion}]:${this.config__.name}`,\n expireTime: `[${__package_name__}:expire-time:sv${schemaVersion}]:${this.config__.name}`,\n };\n\n /**\n * Provides a Alpine.js store implementation with backup and expiration.\n *\n * @param config__ - Configuration object.\n *\n * @example\n * ```\n * import {AlpineStoreWithBackup} from '@nexim/alpine';\n *\n * const storeWithBackup = new AlpineStoreWithBackup({\n * name: 'myStoreWithBackup',\n * version: 1,\n * defaultValue: {data: 'root'},\n * expireDuration: '1d',\n * });\n *\n * storeWithBackup.store.data = 'user';\n *\n * storeWithBackup.save();\n * console.log(storeWithBackup.store.data); // Output: { data: 'user' }\n *\n * storeWithBackup.clear();\n * console.log(storeWithBackup.store.data); // Output: { data: 'root' }\n * ```\n */\n constructor(private config__: AlpineStoreWithBackupOptions<T>) {\n super(config__);\n\n if (this.config__.expireDuration != null) {\n this.handleDataExpiration__();\n }\n\n this.load__();\n }\n\n /**\n * Saves the current data to local storage. If the data is null, it clears the stored data.\n *\n * Also updates the expiration time.\n */\n save(): void {\n this.logger_.logMethodArgs?.('save', {data: this.store.data});\n\n if (this.store.data === null) {\n this.clear();\n return;\n }\n\n localJsonStorage.setItem(this.localStorageKey__.data, this.store.data, this.config__.version);\n this.updateExpireTime__();\n }\n\n /**\n * Clears the stored data.\n */\n clear(): void {\n this.logger_.logMethod?.('clear');\n\n localJsonStorage.removeItem(this.localStorageKey__.data, this.config__.version);\n localJsonStorage.removeItem(this.localStorageKey__.expireTime, this.config__.version);\n\n this.store = this.config__.defaultValue;\n }\n\n /**\n * Handles the expiration duration by checking if the stored data has expired.\n * If expired, it clears the stored data.\n */\n private handleDataExpiration__(): void {\n this.logger_.logMethod?.('handleDataExpiration__');\n\n // FIXME: use null if not set, after local storage new version.\n const expireDuration = localJsonStorage.getItem<{time: number}>(\n this.localStorageKey__.expireTime,\n {time: -1},\n this.config__.version,\n ).time;\n\n if (expireDuration !== -1 && expireDuration < Date.now()) {\n this.clear();\n }\n }\n\n /**\n * Loads data from local storage and updates the store's data.\n *\n * When data is not found or invalid in local storage, it uses the default value.\n *\n * FIXME: remove `NonNullable` from `<T['data']>`, after local storage new version.\n */\n private load__(): void {\n this.logger_.logMethod?.('load__');\n\n const newData = localJsonStorage.getItem<NonNullable<T['data']>>(\n this.localStorageKey__.data,\n this.config__.defaultValue.data as NonNullable<T['data']>,\n this.config__.version,\n ) as T['data'];\n this.store.data = newData;\n }\n\n /**\n * Updates the expiration time in local storage to the current time plus the configured expiration duration.\n */\n private updateExpireTime__(): void {\n if (this.config__.expireDuration == null) return;\n this.logger_.logMethod?.('updateExpireTime__');\n\n const newExpireTime = Date.now() + parseDuration(this.config__.expireDuration);\n localJsonStorage.setItem(this.localStorageKey__.expireTime, {time: newExpireTime}, this.config__.version);\n\n this.logger_.logOther?.('updated_expire_time', {newExpireTime});\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;AAAA,SAAQ,qBAAoB;;;ACA5B,SAAQ,oBAAmB;AAC3B,OAAO,YAAY;AAEnB,IAAM,SAAS,aAAa,eAAgB;AA8CrC,SAAS,qBAA8C,QAA2C;AACvG,SAAO,gBAAgB,wBAAwB,EAAC,OAAM,CAAC;AAEvD,SAAO,MAAM,OAAO,MAAM,OAAO,YAAY;AAG7C,QAAM,QAAQ,OAAO,MAAM,OAAO,IAAI;AACtC,SAAO;AACT;;;ACzDA,SAA2B,gBAAAA,qBAAmB;AAmBvC,IAAM,cAAN,MAA2C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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
|
-
* @
|
|
5
|
-
* @property {string} name - The name of the store.
|
|
6
|
-
* @property {T} defaultValue - The default value of the store.
|
|
4
|
+
* @typeParam T - The type of the default value.
|
|
7
5
|
*/
|
|
8
6
|
export type AlpineStoreGeneratorOptions<T extends DictionaryReq> = {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the store.
|
|
9
|
+
*/
|
|
9
10
|
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* The default value of the store.
|
|
13
|
+
*/
|
|
10
14
|
defaultValue: T;
|
|
11
15
|
};
|
|
12
16
|
/**
|
|
13
17
|
* Generates an Alpine.js store with default value.
|
|
14
18
|
*
|
|
15
|
-
* @
|
|
16
|
-
* @param {AlpineStoreGeneratorOptions} config - The configuration object for the store.
|
|
17
|
-
* @returns {T} - The initialized store instance.
|
|
19
|
+
* @typeParam T - The type of the data.
|
|
18
20
|
*
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
* name: 'user',
|
|
22
|
-
* defaultValue: {type: 'root'},
|
|
23
|
-
* });
|
|
21
|
+
* @param config - The configuration object for the store.
|
|
22
|
+
* @returns - The initialized store instance.
|
|
24
23
|
*
|
|
25
|
-
*
|
|
24
|
+
* @remarks
|
|
26
25
|
*
|
|
27
|
-
* @description
|
|
28
26
|
* This function uses Alpine.js to create a reactive store with a default value.
|
|
29
27
|
* The store is identified by a unique name and can be accessed and manipulated
|
|
30
28
|
* throughout the application. Alpine.js stores provide a simple way to manage
|
|
31
29
|
* data in your application, making it easy to keep your UI in sync with your data.
|
|
32
30
|
*
|
|
33
|
-
* @see https://alpinejs.dev/globals/alpine-store
|
|
31
|
+
* @see {@link https://alpinejs.dev/globals/alpine-store}
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```
|
|
35
|
+
* const store = alpineStoreGenerator({
|
|
36
|
+
* name: 'user',
|
|
37
|
+
* defaultValue: {type: 'root'},
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* console.log(store.type); // Output: root
|
|
41
|
+
*```
|
|
34
42
|
*/
|
|
35
43
|
export declare function alpineStoreGenerator<T extends DictionaryReq>(config: AlpineStoreGeneratorOptions<T>): T;
|
|
36
44
|
//# sourceMappingURL=store-generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-generator.d.ts","sourceRoot":"","sources":["../../src/store/store-generator.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"store-generator.d.ts","sourceRoot":"","sources":["../../src/store/store-generator.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,aAAa,IAAI;IACjE;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,YAAY,EAAE,CAAC,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,aAAa,EAAE,MAAM,EAAE,2BAA2B,CAAC,CAAC,CAAC,GAAG,CAAC,CAQvG"}
|
|
@@ -9,11 +9,12 @@ export type AlpineStoreWithBackupType = {
|
|
|
9
9
|
/**
|
|
10
10
|
* AlpineStoreWithBackup Options.
|
|
11
11
|
*
|
|
12
|
-
* @
|
|
13
|
-
*
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
12
|
+
* @typeParam T - The type of the store value.
|
|
13
|
+
*
|
|
14
|
+
* @param name - The name of the store.
|
|
15
|
+
* @param version - The version of the store.
|
|
16
|
+
* @param defaultValue - The default value of the store.
|
|
17
|
+
* @param expireDuration - Optional. The duration after which the store expires.
|
|
17
18
|
*/
|
|
18
19
|
export type AlpineStoreWithBackupOptions<T extends AlpineStoreWithBackupType> = {
|
|
19
20
|
name: string;
|
|
@@ -33,9 +34,10 @@ export declare class AlpineStoreWithBackup<T extends AlpineStoreWithBackupType>
|
|
|
33
34
|
/**
|
|
34
35
|
* Provides a Alpine.js store implementation with backup and expiration.
|
|
35
36
|
*
|
|
36
|
-
* @param
|
|
37
|
+
* @param config__ - Configuration object.
|
|
37
38
|
*
|
|
38
39
|
* @example
|
|
40
|
+
* ```
|
|
39
41
|
* import {AlpineStoreWithBackup} from '@nexim/alpine';
|
|
40
42
|
*
|
|
41
43
|
* const storeWithBackup = new AlpineStoreWithBackup({
|
|
@@ -52,6 +54,7 @@ export declare class AlpineStoreWithBackup<T extends AlpineStoreWithBackupType>
|
|
|
52
54
|
*
|
|
53
55
|
* storeWithBackup.clear();
|
|
54
56
|
* console.log(storeWithBackup.store.data); // Output: { data: 'root' }
|
|
57
|
+
* ```
|
|
55
58
|
*/
|
|
56
59
|
constructor(config__: AlpineStoreWithBackupOptions<T>);
|
|
57
60
|
/**
|
|
@@ -74,7 +77,7 @@ export declare class AlpineStoreWithBackup<T extends AlpineStoreWithBackupType>
|
|
|
74
77
|
*
|
|
75
78
|
* When data is not found or invalid in local storage, it uses the default value.
|
|
76
79
|
*
|
|
77
|
-
* FIXME: remove `NonNullable` from
|
|
80
|
+
* FIXME: remove `NonNullable` from `<T['data']>`, after local storage new version.
|
|
78
81
|
*/
|
|
79
82
|
private load__;
|
|
80
83
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-with-backup.d.ts","sourceRoot":"","sources":["../../src/store/store-with-backup.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IAEtC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"store-with-backup.d.ts","sourceRoot":"","sources":["../../src/store/store-with-backup.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IAEtC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,4BAA4B,CAAC,CAAC,SAAS,yBAAyB,IAAI;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,CAAC,CAAC;IAChB,cAAc,CAAC,EAAE,QAAQ,CAAC;CAC3B,CAAC;AASF;;GAEG;AACH,qBAAa,qBAAqB,CAAC,CAAC,SAAS,yBAAyB,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IAkChF,OAAO,CAAC,QAAQ;IAjC5B;;OAEG;IACH,OAAO,CAAC,iBAAiB,CAGvB;IAEF;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;gBACiB,QAAQ,EAAE,4BAA4B,CAAC,CAAC,CAAC;IAU7D;;;;OAIG;IACH,IAAI,IAAI,IAAI;IAYZ;;OAEG;IACH,KAAK,IAAI,IAAI;IASb;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM;IAWd;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAS3B"}
|
package/dist/store/store.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { type AlwatrLogger } from '@alwatr/logger';
|
|
|
2
2
|
/**
|
|
3
3
|
* AlpineStore Options.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
5
|
+
* @typeParam T - The type of the store value.
|
|
6
|
+
* @param name - The name of the store.
|
|
7
|
+
* @param defaultValue - The default value of the store.
|
|
8
8
|
*/
|
|
9
9
|
export type AlpineStoreOptions<T extends DictionaryReq> = {
|
|
10
10
|
name: string;
|
|
@@ -22,9 +22,10 @@ export declare class AlpineStore<T extends DictionaryReq> {
|
|
|
22
22
|
/**
|
|
23
23
|
* Provides a Alpine.js pure store implementation with logger.
|
|
24
24
|
*
|
|
25
|
-
* @param
|
|
25
|
+
* @param config - Configuration object.
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
|
+
* ```
|
|
28
29
|
* import {AlpineStore} from '@nexim/alpine';
|
|
29
30
|
*
|
|
30
31
|
* const {store} = new AlpineStore({
|
|
@@ -35,6 +36,7 @@ export declare class AlpineStore<T extends DictionaryReq> {
|
|
|
35
36
|
*
|
|
36
37
|
* store.data = 'user';
|
|
37
38
|
* console.log(store.data); // Output: { data: 'user' }
|
|
39
|
+
* ```
|
|
38
40
|
*/
|
|
39
41
|
constructor(config: AlpineStoreOptions<T>);
|
|
40
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,YAAY,EAAe,MAAM,gBAAgB,CAAC;AAI/D;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,aAAa,IAAI;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,CAAC,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,aAAa;IAC9C;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;IAET,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC;IAEhC
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,YAAY,EAAe,MAAM,gBAAgB,CAAC;AAI/D;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,aAAa,IAAI;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,CAAC,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,aAAa;IAC9C;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;IAET,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC;IAEhC;;;;;;;;;;;;;;;;;;OAkBG;gBACS,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;CAM1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexim/alpine",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Utility functions to enhance Alpine.js usage with backup support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"alpinejs",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@alwatr/nano-build": "^5.0.0",
|
|
56
56
|
"@alwatr/type-helper": "^5.0.0",
|
|
57
|
-
"@nexim/typescript-config": "^
|
|
57
|
+
"@nexim/typescript-config": "^2.0.0",
|
|
58
58
|
"@types/alpinejs": "^3.13.11",
|
|
59
59
|
"ava": "^6.2.0",
|
|
60
60
|
"typescript": "^5.7.2",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
],
|
|
85
85
|
"clean": "if-file-deleted",
|
|
86
86
|
"output": [
|
|
87
|
-
"dist
|
|
87
|
+
"dist",
|
|
88
88
|
"tsconfig.tsbuildinfo"
|
|
89
89
|
]
|
|
90
90
|
},
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"service": true
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "67de35829cde30ef70d87361d7f104762f6ccfd5"
|
|
111
111
|
}
|