@nexim/alpine 1.1.2 → 1.1.4
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 +10 -0
- package/README.md +4 -95
- package/dist/main.cjs +13 -10
- package/dist/main.cjs.map +2 -2
- package/dist/main.mjs +13 -10
- package/dist/main.mjs.map +2 -2
- package/dist/main.test.d.ts +2 -0
- package/dist/main.test.d.ts.map +1 -0
- 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 +18 -8
- package/dist/store/store-with-backup.d.ts.map +1 -1
- package/dist/store/store.d.ts +10 -4
- package/dist/store/store.d.ts.map +1 -1
- package/docs/README.md +23 -0
- package/docs/classes/AlpineStore.md +55 -0
- package/docs/classes/AlpineStoreWithBackup.md +91 -0
- package/docs/functions/alpineStoreGenerator.md +47 -0
- package/docs/type-aliases/AlpineStoreGeneratorOptions.md +29 -0
- package/docs/type-aliases/AlpineStoreOptions.md +29 -0
- package/docs/type-aliases/AlpineStoreWithBackupOptions.md +45 -0
- package/docs/type-aliases/AlpineStoreWithBackupType.md +13 -0
- package/package.json +22 -15
- package/dist/main.cjs.LEGAL.txt +0 -0
- package/dist/main.mjs.LEGAL.txt +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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.4](https://github.com/the-nexim/nanolib/compare/@nexim/alpine@1.1.3...@nexim/alpine@1.1.4) (2025-04-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @nexim/alpine
|
|
9
|
+
|
|
10
|
+
## [1.1.3](https://github.com/the-nexim/nanolib/compare/@nexim/alpine@1.1.2...@nexim/alpine@1.1.3) (2025-01-09)
|
|
11
|
+
|
|
12
|
+
### Code Refactoring
|
|
13
|
+
|
|
14
|
+
* 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 @
|
|
15
|
+
|
|
6
16
|
## [1.1.2](https://github.com/the-nexim/nanolib/compare/@nexim/alpine@1.1.1...@nexim/alpine@1.1.2) (2025-01-06)
|
|
7
17
|
|
|
8
18
|
### Code Refactoring
|
package/README.md
CHANGED
|
@@ -21,101 +21,10 @@ npm install @nexim/alpine
|
|
|
21
21
|
yarn add @nexim/alpine
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
##
|
|
24
|
+
## Documentation
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Read full documentation [here](./docs/README.md).
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
## TODO
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```ts
|
|
33
|
-
import {alpineStoreGenerator} from '@nexim/alpine';
|
|
34
|
-
|
|
35
|
-
const store = alpineStoreGenerator({
|
|
36
|
-
name: 'user',
|
|
37
|
-
defaultValue: {type: 'root'},
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
console.log(store.type); // Output: root
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### AlpineStore
|
|
44
|
-
|
|
45
|
-
Provides a Alpine.js pure store implementation with logger.
|
|
46
|
-
|
|
47
|
-
#### Constructor
|
|
48
|
-
|
|
49
|
-
Creates an instance of `AlpineStore`.
|
|
50
|
-
|
|
51
|
-
- **config**: The configuration object for the store.
|
|
52
|
-
- **name**: The name of the store.
|
|
53
|
-
- **defaultValue**: The default value of the store.
|
|
54
|
-
|
|
55
|
-
### Properties
|
|
56
|
-
|
|
57
|
-
- **store**: alpine store proxy.
|
|
58
|
-
|
|
59
|
-
#### Example Usage
|
|
60
|
-
|
|
61
|
-
```ts
|
|
62
|
-
import {AlpineStore} from '@nexim/alpine';
|
|
63
|
-
|
|
64
|
-
const {store} = new AlpineStore({
|
|
65
|
-
name: 'myStore',
|
|
66
|
-
defaultValue: {data: 'root'},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
console.log(store.data); // Output: { data: 'root' }
|
|
70
|
-
store.data = 'user';
|
|
71
|
-
|
|
72
|
-
console.log(store.data); // Output: { data: 'user' }
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### AlpineStoreWithBackup
|
|
76
|
-
|
|
77
|
-
Extends `AlpineStore` to add backup and restore functionality with local storage support and expiration handling.
|
|
78
|
-
|
|
79
|
-
#### Constructor
|
|
80
|
-
|
|
81
|
-
Creates an instance of `AlpineStoreWithBackup`.
|
|
82
|
-
|
|
83
|
-
- **config**: The configuration object for the store.
|
|
84
|
-
- **name**: The name of the store.
|
|
85
|
-
- **version**: The version of the store.
|
|
86
|
-
- **defaultValue**: The default value of the store.
|
|
87
|
-
- **expireDuration**: Optional. The duration after which the store expires.
|
|
88
|
-
|
|
89
|
-
### Properties
|
|
90
|
-
|
|
91
|
-
- **store**: alpine store proxy.
|
|
92
|
-
|
|
93
|
-
#### Methods
|
|
94
|
-
|
|
95
|
-
- **save()**: Saves the current data to local storage. If the data is null, it clears the stored data. Also updates the expiration time.
|
|
96
|
-
- **clear()**: Clears the local storage and set default value to store.
|
|
97
|
-
|
|
98
|
-
#### Example Usage
|
|
99
|
-
|
|
100
|
-
```ts
|
|
101
|
-
import {AlpineStoreWithBackup} from '@nexim/alpine';
|
|
102
|
-
|
|
103
|
-
const storeWithBackup = new AlpineStoreWithBackup({
|
|
104
|
-
name: 'myStoreWithBackup',
|
|
105
|
-
version: 1,
|
|
106
|
-
defaultValue: {data: 'root'},
|
|
107
|
-
expireDuration: '1d',
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
storeWithBackup.store.data = 'user';
|
|
111
|
-
|
|
112
|
-
storeWithBackup.save();
|
|
113
|
-
console.log(storeWithBackup.store.data); // Output: { data: 'user' }
|
|
114
|
-
|
|
115
|
-
storeWithBackup.clear();
|
|
116
|
-
console.log(storeWithBackup.store.data); // Output: { data: 'root' }
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### TODO
|
|
120
|
-
|
|
121
|
-
- Analyze [@alwatr/context](https://github.com/Alwatr/flux/tree/next/packages/context) for use here.
|
|
30
|
+
- [ ] Analyze [@alwatr/context](https://github.com/Alwatr/flux/tree/next/packages/context) for use here.
|
package/dist/main.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @nexim/alpine v1.1.
|
|
1
|
+
/* @nexim/alpine v1.1.4 */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -39,8 +39,8 @@ module.exports = __toCommonJS(main_exports);
|
|
|
39
39
|
var import_package_tracer = require("@alwatr/package-tracer");
|
|
40
40
|
|
|
41
41
|
// src/store/store-generator.ts
|
|
42
|
-
var import_logger = require("@alwatr/logger");
|
|
43
42
|
var import_alpinejs = __toESM(require("alpinejs"), 1);
|
|
43
|
+
var import_logger = require("@alwatr/logger");
|
|
44
44
|
var logger = (0, import_logger.createLogger)("@nexim/alpine");
|
|
45
45
|
function alpineStoreGenerator(config) {
|
|
46
46
|
logger.logMethodArgs?.("alpineStoreGenerator", { config });
|
|
@@ -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
|
+
* ```ts
|
|
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}`);
|
|
@@ -77,16 +79,17 @@ var AlpineStore = class {
|
|
|
77
79
|
};
|
|
78
80
|
|
|
79
81
|
// src/store/store-with-backup.ts
|
|
80
|
-
var import_local_storage = require("@alwatr/local-storage");
|
|
81
82
|
var import_parse_duration = require("@alwatr/parse-duration");
|
|
83
|
+
var import_local_storage = require("@alwatr/local-storage");
|
|
82
84
|
var schemaVersion = 1;
|
|
83
85
|
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
|
+
* ```ts
|
|
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__);
|
|
@@ -111,8 +115,8 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
111
115
|
* Keys for storing data and expire time in local storage with version.
|
|
112
116
|
*/
|
|
113
117
|
this.localStorageKey__ = {
|
|
114
|
-
data: `[${"@nexim/alpine"}:data:sv${schemaVersion}]:${this.config__.name}`,
|
|
115
|
-
expireTime: `[${"@nexim/alpine"}:expire-time:sv${schemaVersion}]:${this.config__.name}`
|
|
118
|
+
data: `[${"@nexim/alpine"}:data:sv${schemaVersion.toString()}]:${this.config__.name}`,
|
|
119
|
+
expireTime: `[${"@nexim/alpine"}:expire-time:sv${schemaVersion.toString()}]:${this.config__.name}`
|
|
116
120
|
};
|
|
117
121
|
if (this.config__.expireDuration != null) {
|
|
118
122
|
this.handleDataExpiration__();
|
|
@@ -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,5 @@ 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.
|
|
190
|
-
/*! For license information please see main.cjs.LEGAL.txt */
|
|
193
|
+
__dev_mode__: import_package_tracer.packageTracer.add("@nexim/alpine", "1.1.4");
|
|
191
194
|
//# 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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
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 alpine from 'alpinejs';\nimport { createLogger } from '@alwatr/logger';\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 * ```ts\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 */\nexport type AlpineStoreOptions<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 * 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 * ```ts\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 { type Duration, parseDuration } from '@alwatr/parse-duration';\nimport { AlpineStore } from './store.js';\nimport { localJsonStorage } from '@alwatr/local-storage';\n\n/**\n * Type for the store's data to extends from them.\n */\nexport type AlpineStoreWithBackupType = {\n data: DictionaryReq | null;\n};\n\n/**\n * AlpineStoreWithBackup Options.\n *\n * @typeParam T - The type of the store value.\n */\nexport type AlpineStoreWithBackupOptions<T extends AlpineStoreWithBackupType> = {\n /**\n * The name of the store.\n */\n name: string;\n\n /**\n * The version of the store.\n */\n version: number;\n\n /**\n * The default value of the store.\n */\n defaultValue: T;\n\n /**\n * Optional. The duration after which the store expires.\n */\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.toString()}]:${this.config__.name}`,\n expireTime: `[${__package_name__}:expire-time:sv${schemaVersion.toString()}]:${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 * ```ts\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": "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",
|
|
6
6
|
"names": ["alpine", "import_logger"]
|
|
7
7
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/* @nexim/alpine v1.1.
|
|
1
|
+
/* @nexim/alpine v1.1.4 */
|
|
2
2
|
|
|
3
3
|
// src/main.ts
|
|
4
4
|
import { packageTracer } from "@alwatr/package-tracer";
|
|
5
5
|
|
|
6
6
|
// src/store/store-generator.ts
|
|
7
|
-
import { createLogger } from "@alwatr/logger";
|
|
8
7
|
import alpine from "alpinejs";
|
|
8
|
+
import { createLogger } from "@alwatr/logger";
|
|
9
9
|
var logger = createLogger("@nexim/alpine");
|
|
10
10
|
function alpineStoreGenerator(config) {
|
|
11
11
|
logger.logMethodArgs?.("alpineStoreGenerator", { config });
|
|
@@ -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
|
+
* ```ts
|
|
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}`);
|
|
@@ -42,16 +44,17 @@ var AlpineStore = class {
|
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
// src/store/store-with-backup.ts
|
|
45
|
-
import { localJsonStorage } from "@alwatr/local-storage";
|
|
46
47
|
import { parseDuration } from "@alwatr/parse-duration";
|
|
48
|
+
import { localJsonStorage } from "@alwatr/local-storage";
|
|
47
49
|
var schemaVersion = 1;
|
|
48
50
|
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
|
+
* ```ts
|
|
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__);
|
|
@@ -76,8 +80,8 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
76
80
|
* Keys for storing data and expire time in local storage with version.
|
|
77
81
|
*/
|
|
78
82
|
this.localStorageKey__ = {
|
|
79
|
-
data: `[${"@nexim/alpine"}:data:sv${schemaVersion}]:${this.config__.name}`,
|
|
80
|
-
expireTime: `[${"@nexim/alpine"}:expire-time:sv${schemaVersion}]:${this.config__.name}`
|
|
83
|
+
data: `[${"@nexim/alpine"}:data:sv${schemaVersion.toString()}]:${this.config__.name}`,
|
|
84
|
+
expireTime: `[${"@nexim/alpine"}:expire-time:sv${schemaVersion.toString()}]:${this.config__.name}`
|
|
81
85
|
};
|
|
82
86
|
if (this.config__.expireDuration != null) {
|
|
83
87
|
this.handleDataExpiration__();
|
|
@@ -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,11 +155,10 @@ 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.4");
|
|
155
159
|
export {
|
|
156
160
|
AlpineStore,
|
|
157
161
|
AlpineStoreWithBackup,
|
|
158
162
|
alpineStoreGenerator
|
|
159
163
|
};
|
|
160
|
-
/*! For license information please see main.mjs.LEGAL.txt */
|
|
161
164
|
//# sourceMappingURL=main.mjs.map
|
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
|
|
5
|
-
"mappings": ";;;AAAA,
|
|
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 alpine from 'alpinejs';\nimport { createLogger } from '@alwatr/logger';\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 * ```ts\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 */\nexport type AlpineStoreOptions<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 * 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 * ```ts\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 { type Duration, parseDuration } from '@alwatr/parse-duration';\nimport { AlpineStore } from './store.js';\nimport { localJsonStorage } from '@alwatr/local-storage';\n\n/**\n * Type for the store's data to extends from them.\n */\nexport type AlpineStoreWithBackupType = {\n data: DictionaryReq | null;\n};\n\n/**\n * AlpineStoreWithBackup Options.\n *\n * @typeParam T - The type of the store value.\n */\nexport type AlpineStoreWithBackupOptions<T extends AlpineStoreWithBackupType> = {\n /**\n * The name of the store.\n */\n name: string;\n\n /**\n * The version of the store.\n */\n version: number;\n\n /**\n * The default value of the store.\n */\n defaultValue: T;\n\n /**\n * Optional. The duration after which the store expires.\n */\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.toString()}]:${this.config__.name}`,\n expireTime: `[${__package_name__}:expire-time:sv${schemaVersion.toString()}]:${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 * ```ts\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": "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",
|
|
6
6
|
"names": ["createLogger", "createLogger"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.test.d.ts","sourceRoot":"","sources":["../src/main.test.js"],"names":[],"mappings":""}
|
|
@@ -1,36 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* alpineStoreGenerator Options.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
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
|
+
* ```ts
|
|
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"}
|
|
@@ -4,21 +4,29 @@ import { AlpineStore } from './store.js';
|
|
|
4
4
|
* Type for the store's data to extends from them.
|
|
5
5
|
*/
|
|
6
6
|
export type AlpineStoreWithBackupType = {
|
|
7
|
-
data: DictionaryReq
|
|
7
|
+
data: DictionaryReq | null;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
10
|
* AlpineStoreWithBackup Options.
|
|
11
11
|
*
|
|
12
|
-
* @
|
|
13
|
-
* @param {string} name - The name of the store.
|
|
14
|
-
* @param {number} version - The version of the store.
|
|
15
|
-
* @param {T} defaultValue - The default value of the store.
|
|
16
|
-
* @param {Duration} [expireDuration] - Optional. The duration after which the store expires.
|
|
12
|
+
* @typeParam T - The type of the store value.
|
|
17
13
|
*/
|
|
18
14
|
export type AlpineStoreWithBackupOptions<T extends AlpineStoreWithBackupType> = {
|
|
15
|
+
/**
|
|
16
|
+
* The name of the store.
|
|
17
|
+
*/
|
|
19
18
|
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* The version of the store.
|
|
21
|
+
*/
|
|
20
22
|
version: number;
|
|
23
|
+
/**
|
|
24
|
+
* The default value of the store.
|
|
25
|
+
*/
|
|
21
26
|
defaultValue: T;
|
|
27
|
+
/**
|
|
28
|
+
* Optional. The duration after which the store expires.
|
|
29
|
+
*/
|
|
22
30
|
expireDuration?: Duration;
|
|
23
31
|
};
|
|
24
32
|
/**
|
|
@@ -33,9 +41,10 @@ export declare class AlpineStoreWithBackup<T extends AlpineStoreWithBackupType>
|
|
|
33
41
|
/**
|
|
34
42
|
* Provides a Alpine.js store implementation with backup and expiration.
|
|
35
43
|
*
|
|
36
|
-
* @param
|
|
44
|
+
* @param config__ - Configuration object.
|
|
37
45
|
*
|
|
38
46
|
* @example
|
|
47
|
+
* ```ts
|
|
39
48
|
* import {AlpineStoreWithBackup} from '@nexim/alpine';
|
|
40
49
|
*
|
|
41
50
|
* const storeWithBackup = new AlpineStoreWithBackup({
|
|
@@ -52,6 +61,7 @@ export declare class AlpineStoreWithBackup<T extends AlpineStoreWithBackupType>
|
|
|
52
61
|
*
|
|
53
62
|
* storeWithBackup.clear();
|
|
54
63
|
* console.log(storeWithBackup.store.data); // Output: { data: 'root' }
|
|
64
|
+
* ```
|
|
55
65
|
*/
|
|
56
66
|
constructor(config__: AlpineStoreWithBackupOptions<T>);
|
|
57
67
|
/**
|
|
@@ -74,7 +84,7 @@ export declare class AlpineStoreWithBackup<T extends AlpineStoreWithBackupType>
|
|
|
74
84
|
*
|
|
75
85
|
* When data is not found or invalid in local storage, it uses the default value.
|
|
76
86
|
*
|
|
77
|
-
* FIXME: remove `NonNullable` from
|
|
87
|
+
* FIXME: remove `NonNullable` from `<T['data']>`, after local storage new version.
|
|
78
88
|
*/
|
|
79
89
|
private load__;
|
|
80
90
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-with-backup.d.ts","sourceRoot":"","sources":["../../src/store/store-with-backup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store-with-backup.d.ts","sourceRoot":"","sources":["../../src/store/store-with-backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,4BAA4B,CAAC,CAAC,SAAS,yBAAyB,IAAI;IAC9E;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,YAAY,EAAE,CAAC,CAAC;IAEhB;;OAEG;IACH,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,12 +2,16 @@ import { type AlwatrLogger } from '@alwatr/logger';
|
|
|
2
2
|
/**
|
|
3
3
|
* AlpineStore Options.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
* @param {string} name - The name of the store.
|
|
7
|
-
* @param {T} defaultValue - The default value of the store.
|
|
5
|
+
* @typeParam T - The type of the store value.
|
|
8
6
|
*/
|
|
9
7
|
export type AlpineStoreOptions<T extends DictionaryReq> = {
|
|
8
|
+
/**
|
|
9
|
+
* The name of the store.
|
|
10
|
+
*/
|
|
10
11
|
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* The default value of the store.
|
|
14
|
+
*/
|
|
11
15
|
defaultValue: T;
|
|
12
16
|
};
|
|
13
17
|
/**
|
|
@@ -22,9 +26,10 @@ export declare class AlpineStore<T extends DictionaryReq> {
|
|
|
22
26
|
/**
|
|
23
27
|
* Provides a Alpine.js pure store implementation with logger.
|
|
24
28
|
*
|
|
25
|
-
* @param
|
|
29
|
+
* @param config - Configuration object.
|
|
26
30
|
*
|
|
27
31
|
* @example
|
|
32
|
+
* ```ts
|
|
28
33
|
* import {AlpineStore} from '@nexim/alpine';
|
|
29
34
|
*
|
|
30
35
|
* const {store} = new AlpineStore({
|
|
@@ -35,6 +40,7 @@ export declare class AlpineStore<T extends DictionaryReq> {
|
|
|
35
40
|
*
|
|
36
41
|
* store.data = 'user';
|
|
37
42
|
* console.log(store.data); // Output: { data: 'user' }
|
|
43
|
+
* ```
|
|
38
44
|
*/
|
|
39
45
|
constructor(config: AlpineStoreOptions<T>);
|
|
40
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAIjE;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,aAAa,IAAI;IACxD;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,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/docs/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @nexim/alpine
|
|
2
|
+
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
| Class | Description |
|
|
6
|
+
| --------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
7
|
+
| [AlpineStore](classes/AlpineStore.md) | Provides a Alpine.js pure store implementation with logger. |
|
|
8
|
+
| [AlpineStoreWithBackup](classes/AlpineStoreWithBackup.md) | Provides a Alpine.js store implementation with backup and expiration. |
|
|
9
|
+
|
|
10
|
+
## Type Aliases
|
|
11
|
+
|
|
12
|
+
| Type Alias | Description |
|
|
13
|
+
| ---------------------------------------------------------------------------- | ----------------------------------------------- |
|
|
14
|
+
| [AlpineStoreGeneratorOptions](type-aliases/AlpineStoreGeneratorOptions.md) | alpineStoreGenerator Options. |
|
|
15
|
+
| [AlpineStoreOptions](type-aliases/AlpineStoreOptions.md) | AlpineStore Options. |
|
|
16
|
+
| [AlpineStoreWithBackupOptions](type-aliases/AlpineStoreWithBackupOptions.md) | AlpineStoreWithBackup Options. |
|
|
17
|
+
| [AlpineStoreWithBackupType](type-aliases/AlpineStoreWithBackupType.md) | Type for the store's data to extends from them. |
|
|
18
|
+
|
|
19
|
+
## Functions
|
|
20
|
+
|
|
21
|
+
| Function | Description |
|
|
22
|
+
| --------------------------------------------------------- | ------------------------------------------------ |
|
|
23
|
+
| [alpineStoreGenerator](functions/alpineStoreGenerator.md) | Generates an Alpine.js store with default value. |
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[@nexim/alpine](../README.md) / AlpineStore
|
|
2
|
+
|
|
3
|
+
# Class: AlpineStore\<T\>
|
|
4
|
+
|
|
5
|
+
Provides a Alpine.js pure store implementation with logger.
|
|
6
|
+
|
|
7
|
+
## Extended by
|
|
8
|
+
|
|
9
|
+
- [`AlpineStoreWithBackup`](AlpineStoreWithBackup.md)
|
|
10
|
+
|
|
11
|
+
## Type Parameters
|
|
12
|
+
|
|
13
|
+
| Type Parameter |
|
|
14
|
+
| ----------------------------- |
|
|
15
|
+
| `T` _extends_ `DictionaryReq` |
|
|
16
|
+
|
|
17
|
+
## Constructors
|
|
18
|
+
|
|
19
|
+
### Constructor
|
|
20
|
+
|
|
21
|
+
> **new AlpineStore**\<`T`\>(`config`: [`AlpineStoreOptions`](../type-aliases/AlpineStoreOptions.md)\<`T`\>): `AlpineStore`\<`T`\>
|
|
22
|
+
|
|
23
|
+
Provides a Alpine.js pure store implementation with logger.
|
|
24
|
+
|
|
25
|
+
#### Parameters
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
| --------- | -------------------------------------------------------------------- | --------------------- |
|
|
29
|
+
| `config` | [`AlpineStoreOptions`](../type-aliases/AlpineStoreOptions.md)\<`T`\> | Configuration object. |
|
|
30
|
+
|
|
31
|
+
#### Returns
|
|
32
|
+
|
|
33
|
+
`AlpineStore`\<`T`\>
|
|
34
|
+
|
|
35
|
+
#### Example
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { AlpineStore } from '@nexim/alpine';
|
|
39
|
+
|
|
40
|
+
const { store } = new AlpineStore({
|
|
41
|
+
name: 'myStore',
|
|
42
|
+
defaultValue: { data: 'root' },
|
|
43
|
+
});
|
|
44
|
+
console.log(store.data); // Output: { data: 'root' }
|
|
45
|
+
|
|
46
|
+
store.data = 'user';
|
|
47
|
+
console.log(store.data); // Output: { data: 'user' }
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Properties
|
|
51
|
+
|
|
52
|
+
| Property | Modifier | Type | Description |
|
|
53
|
+
| ------------------------------ | ----------- | -------------- | ----------------- |
|
|
54
|
+
| <a id="logger_"></a> `logger_` | `protected` | `AlwatrLogger` | - |
|
|
55
|
+
| <a id="store"></a> `store` | `public` | `T` | The store's data. |
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
[@nexim/alpine](../README.md) / AlpineStoreWithBackup
|
|
2
|
+
|
|
3
|
+
# Class: AlpineStoreWithBackup\<T\>
|
|
4
|
+
|
|
5
|
+
Provides a Alpine.js store implementation with backup and expiration.
|
|
6
|
+
|
|
7
|
+
## Extends
|
|
8
|
+
|
|
9
|
+
- [`AlpineStore`](AlpineStore.md)\<`T`\>
|
|
10
|
+
|
|
11
|
+
## Type Parameters
|
|
12
|
+
|
|
13
|
+
| Type Parameter |
|
|
14
|
+
| ----------------------------------------------------------------------------------------- |
|
|
15
|
+
| `T` _extends_ [`AlpineStoreWithBackupType`](../type-aliases/AlpineStoreWithBackupType.md) |
|
|
16
|
+
|
|
17
|
+
## Constructors
|
|
18
|
+
|
|
19
|
+
### Constructor
|
|
20
|
+
|
|
21
|
+
> **new AlpineStoreWithBackup**\<`T`\>(`config__`: [`AlpineStoreWithBackupOptions`](../type-aliases/AlpineStoreWithBackupOptions.md)\<`T`\>): `AlpineStoreWithBackup`\<`T`\>
|
|
22
|
+
|
|
23
|
+
Provides a Alpine.js store implementation with backup and expiration.
|
|
24
|
+
|
|
25
|
+
#### Parameters
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
| ---------- | ---------------------------------------------------------------------------------------- | --------------------- |
|
|
29
|
+
| `config__` | [`AlpineStoreWithBackupOptions`](../type-aliases/AlpineStoreWithBackupOptions.md)\<`T`\> | Configuration object. |
|
|
30
|
+
|
|
31
|
+
#### Returns
|
|
32
|
+
|
|
33
|
+
`AlpineStoreWithBackup`\<`T`\>
|
|
34
|
+
|
|
35
|
+
#### Example
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { AlpineStoreWithBackup } from '@nexim/alpine';
|
|
39
|
+
|
|
40
|
+
const storeWithBackup = new AlpineStoreWithBackup({
|
|
41
|
+
name: 'myStoreWithBackup',
|
|
42
|
+
version: 1,
|
|
43
|
+
defaultValue: { data: 'root' },
|
|
44
|
+
expireDuration: '1d',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
storeWithBackup.store.data = 'user';
|
|
48
|
+
|
|
49
|
+
storeWithBackup.save();
|
|
50
|
+
console.log(storeWithBackup.store.data); // Output: { data: 'user' }
|
|
51
|
+
|
|
52
|
+
storeWithBackup.clear();
|
|
53
|
+
console.log(storeWithBackup.store.data); // Output: { data: 'root' }
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### Overrides
|
|
57
|
+
|
|
58
|
+
[`AlpineStore`](AlpineStore.md).[`constructor`](AlpineStore.md#constructor)
|
|
59
|
+
|
|
60
|
+
## Properties
|
|
61
|
+
|
|
62
|
+
| Property | Modifier | Type | Description | Inherited from |
|
|
63
|
+
| ------------------------------ | ----------- | -------------- | ----------------- | ------------------------------------------------------------------- |
|
|
64
|
+
| <a id="logger_"></a> `logger_` | `protected` | `AlwatrLogger` | - | [`AlpineStore`](AlpineStore.md).[`logger_`](AlpineStore.md#logger_) |
|
|
65
|
+
| <a id="store"></a> `store` | `public` | `T` | The store's data. | [`AlpineStore`](AlpineStore.md).[`store`](AlpineStore.md#store) |
|
|
66
|
+
|
|
67
|
+
## Methods
|
|
68
|
+
|
|
69
|
+
### clear()
|
|
70
|
+
|
|
71
|
+
> **clear**(): `void`
|
|
72
|
+
|
|
73
|
+
Clears the stored data.
|
|
74
|
+
|
|
75
|
+
#### Returns
|
|
76
|
+
|
|
77
|
+
`void`
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### save()
|
|
82
|
+
|
|
83
|
+
> **save**(): `void`
|
|
84
|
+
|
|
85
|
+
Saves the current data to local storage. If the data is null, it clears the stored data.
|
|
86
|
+
|
|
87
|
+
Also updates the expiration time.
|
|
88
|
+
|
|
89
|
+
#### Returns
|
|
90
|
+
|
|
91
|
+
`void`
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[@nexim/alpine](../README.md) / alpineStoreGenerator
|
|
2
|
+
|
|
3
|
+
# Function: alpineStoreGenerator()
|
|
4
|
+
|
|
5
|
+
> **alpineStoreGenerator**\<`T`\>(`config`: [`AlpineStoreGeneratorOptions`](../type-aliases/AlpineStoreGeneratorOptions.md)\<`T`\>): `T`
|
|
6
|
+
|
|
7
|
+
Generates an Alpine.js store with default value.
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
| Type Parameter | Description |
|
|
12
|
+
| -------------------------------------- | --------------------- |
|
|
13
|
+
| `T` _extends_ `DictionaryReq`\<`any`\> | The type of the data. |
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Description |
|
|
18
|
+
| --------- | -------------------------------------------------------------------------------------- | --------------------------------------- |
|
|
19
|
+
| `config` | [`AlpineStoreGeneratorOptions`](../type-aliases/AlpineStoreGeneratorOptions.md)\<`T`\> | The configuration object for the store. |
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
`T`
|
|
24
|
+
|
|
25
|
+
- The initialized store instance.
|
|
26
|
+
|
|
27
|
+
## Remarks
|
|
28
|
+
|
|
29
|
+
This function uses Alpine.js to create a reactive store with a default value.
|
|
30
|
+
The store is identified by a unique name and can be accessed and manipulated
|
|
31
|
+
throughout the application. Alpine.js stores provide a simple way to manage
|
|
32
|
+
data in your application, making it easy to keep your UI in sync with your data.
|
|
33
|
+
|
|
34
|
+
## See
|
|
35
|
+
|
|
36
|
+
[https://alpinejs.dev/globals/alpine-store](https://alpinejs.dev/globals/alpine-store)
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const store = alpineStoreGenerator({
|
|
42
|
+
name: 'user',
|
|
43
|
+
defaultValue: { type: 'root' },
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
console.log(store.type); // Output: root
|
|
47
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[@nexim/alpine](../README.md) / AlpineStoreGeneratorOptions
|
|
2
|
+
|
|
3
|
+
# Type Alias: AlpineStoreGeneratorOptions\<T\>
|
|
4
|
+
|
|
5
|
+
> **AlpineStoreGeneratorOptions**\<`T`\> = `object`
|
|
6
|
+
|
|
7
|
+
alpineStoreGenerator Options.
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
| Type Parameter | Description |
|
|
12
|
+
| ----------------------------- | ------------------------------ |
|
|
13
|
+
| `T` _extends_ `DictionaryReq` | The type of the default value. |
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### defaultValue
|
|
18
|
+
|
|
19
|
+
> **defaultValue**: `T`
|
|
20
|
+
|
|
21
|
+
The default value of the store.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### name
|
|
26
|
+
|
|
27
|
+
> **name**: `string`
|
|
28
|
+
|
|
29
|
+
The name of the store.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[@nexim/alpine](../README.md) / AlpineStoreOptions
|
|
2
|
+
|
|
3
|
+
# Type Alias: AlpineStoreOptions\<T\>
|
|
4
|
+
|
|
5
|
+
> **AlpineStoreOptions**\<`T`\> = `object`
|
|
6
|
+
|
|
7
|
+
AlpineStore Options.
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
| Type Parameter | Description |
|
|
12
|
+
| ----------------------------- | ---------------------------- |
|
|
13
|
+
| `T` _extends_ `DictionaryReq` | The type of the store value. |
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### defaultValue
|
|
18
|
+
|
|
19
|
+
> **defaultValue**: `T`
|
|
20
|
+
|
|
21
|
+
The default value of the store.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### name
|
|
26
|
+
|
|
27
|
+
> **name**: `string`
|
|
28
|
+
|
|
29
|
+
The name of the store.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[@nexim/alpine](../README.md) / AlpineStoreWithBackupOptions
|
|
2
|
+
|
|
3
|
+
# Type Alias: AlpineStoreWithBackupOptions\<T\>
|
|
4
|
+
|
|
5
|
+
> **AlpineStoreWithBackupOptions**\<`T`\> = `object`
|
|
6
|
+
|
|
7
|
+
AlpineStoreWithBackup Options.
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
| Type Parameter | Description |
|
|
12
|
+
| ------------------------------------------------------------------------- | ---------------------------- |
|
|
13
|
+
| `T` _extends_ [`AlpineStoreWithBackupType`](AlpineStoreWithBackupType.md) | The type of the store value. |
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### defaultValue
|
|
18
|
+
|
|
19
|
+
> **defaultValue**: `T`
|
|
20
|
+
|
|
21
|
+
The default value of the store.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### expireDuration?
|
|
26
|
+
|
|
27
|
+
> `optional` **expireDuration**: `Duration`
|
|
28
|
+
|
|
29
|
+
Optional. The duration after which the store expires.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### name
|
|
34
|
+
|
|
35
|
+
> **name**: `string`
|
|
36
|
+
|
|
37
|
+
The name of the store.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
### version
|
|
42
|
+
|
|
43
|
+
> **version**: `number`
|
|
44
|
+
|
|
45
|
+
The version of the store.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[@nexim/alpine](../README.md) / AlpineStoreWithBackupType
|
|
2
|
+
|
|
3
|
+
# Type Alias: AlpineStoreWithBackupType
|
|
4
|
+
|
|
5
|
+
> **AlpineStoreWithBackupType** = `object`
|
|
6
|
+
|
|
7
|
+
Type for the store's data to extends from them.
|
|
8
|
+
|
|
9
|
+
## Properties
|
|
10
|
+
|
|
11
|
+
### data
|
|
12
|
+
|
|
13
|
+
> **data**: `DictionaryReq` \| `null`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexim/alpine",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Utility functions to enhance Alpine.js usage with backup support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"alpinejs",
|
|
@@ -41,24 +41,28 @@
|
|
|
41
41
|
],
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "wireit",
|
|
44
|
+
"doc": "wireit",
|
|
44
45
|
"test": "wireit",
|
|
45
46
|
"watch": "wireit"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"@alwatr/local-storage": "^5.
|
|
49
|
-
"@alwatr/logger": "^5.
|
|
50
|
-
"@alwatr/package-tracer": "^5.
|
|
51
|
-
"@alwatr/parse-duration": "^5.
|
|
52
|
-
"alpinejs": "^3.14.
|
|
49
|
+
"@alwatr/local-storage": "^5.5.3",
|
|
50
|
+
"@alwatr/logger": "^5.5.3",
|
|
51
|
+
"@alwatr/package-tracer": "^5.5.3",
|
|
52
|
+
"@alwatr/parse-duration": "^5.5.4",
|
|
53
|
+
"alpinejs": "^3.14.9"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@alwatr/nano-build": "^5.
|
|
56
|
-
"@alwatr/type-helper": "^5.
|
|
57
|
-
"@nexim/typescript-config": "^2.0.
|
|
56
|
+
"@alwatr/nano-build": "^5.5.3",
|
|
57
|
+
"@alwatr/type-helper": "^5.4.1",
|
|
58
|
+
"@nexim/typescript-config": "^2.0.1",
|
|
58
59
|
"@types/alpinejs": "^3.13.11",
|
|
59
60
|
"ava": "^6.2.0",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
61
|
+
"typedoc": "^0.28.3",
|
|
62
|
+
"typedoc-plugin-markdown": "^4.6.2",
|
|
63
|
+
"typedoc-plugin-no-inherit": "^1.6.1",
|
|
64
|
+
"typescript": "^5.8.3",
|
|
65
|
+
"wireit": "^0.14.12"
|
|
62
66
|
},
|
|
63
67
|
"publishConfig": {
|
|
64
68
|
"access": "public"
|
|
@@ -77,14 +81,14 @@
|
|
|
77
81
|
]
|
|
78
82
|
},
|
|
79
83
|
"build:es": {
|
|
80
|
-
"command": "nano-build --preset=module",
|
|
84
|
+
"command": "yarn nano-build --preset=module",
|
|
81
85
|
"files": [
|
|
82
86
|
"src",
|
|
83
87
|
"tsconfig.json"
|
|
84
88
|
],
|
|
85
89
|
"clean": "if-file-deleted",
|
|
86
90
|
"output": [
|
|
87
|
-
"dist
|
|
91
|
+
"dist",
|
|
88
92
|
"tsconfig.tsbuildinfo"
|
|
89
93
|
]
|
|
90
94
|
},
|
|
@@ -103,9 +107,12 @@
|
|
|
103
107
|
]
|
|
104
108
|
},
|
|
105
109
|
"watch:es": {
|
|
106
|
-
"command": "nano-build --preset=module -- --watch",
|
|
110
|
+
"command": "yarn nano-build --preset=module -- --watch",
|
|
107
111
|
"service": true
|
|
112
|
+
},
|
|
113
|
+
"doc": {
|
|
114
|
+
"command": "typedoc"
|
|
108
115
|
}
|
|
109
116
|
},
|
|
110
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "f20da89af20ee0c17c96e1ea15c6dfd831717ee6"
|
|
111
118
|
}
|
package/dist/main.cjs.LEGAL.txt
DELETED
|
File without changes
|
package/dist/main.mjs.LEGAL.txt
DELETED
|
File without changes
|