@nexim/alpine 1.0.0-alpha.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/main.cjs +15 -9
- package/dist/main.cjs.map +2 -2
- package/dist/main.mjs +15 -9
- package/dist/main.mjs.map +3 -3
- package/dist/store/store-with-backup.d.ts +2 -0
- package/dist/store/store-with-backup.d.ts.map +1 -1
- package/dist/store/store.d.ts.map +1 -1
- package/package.json +50 -19
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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.0](https://github.com/the-nexim/nanolib/compare/@nexim/alpine@1.0.0...@nexim/alpine@1.1.0) (2024-12-24)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **service-worker:** add service worker utilities and logging support ([#18](https://github.com/the-nexim/nanolib/issues/18)) ([d428086](https://github.com/the-nexim/nanolib/commit/d428086dd98fbb5dfd077d14de4de8dd29ed78dc)) by @
|
|
11
|
+
|
|
12
|
+
### Code Refactoring
|
|
13
|
+
|
|
14
|
+
* migrate scripts to use wireit for improved build process ([#23](https://github.com/the-nexim/nanolib/issues/23)) ([3376d29](https://github.com/the-nexim/nanolib/commit/3376d2944332f3f28a91eba6b63a8fa981faf774)) by @arashagp
|
|
15
|
+
|
|
16
|
+
## [1.0.0](https://github.com/the-nexim/nanolib/compare/@nexim/alpine@1.0.0-alpha.0...@nexim/alpine@1.0.0) (2024-12-12)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **alpine/store-with-backup:** load process ([2486cea](https://github.com/the-nexim/nanolib/commit/2486cea693e1101c6bd9fd47410a96cc6e225bd5)) by @njfamirm
|
|
21
|
+
* **alpine:** expiation data handling ([77eecce](https://github.com/the-nexim/nanolib/commit/77eecce118b11c2b00f9a90a5de2d74d11e67b2a)) by @njfamirm
|
|
22
|
+
* **alpine:** use generator in the store class ([c3b9768](https://github.com/the-nexim/nanolib/commit/c3b9768e9958f85ac244db4c3c5a0cb2e96c64fc)) by @njfamirm
|
|
23
|
+
|
|
6
24
|
## [1.0.0-alpha.0](https://github.com/the-nexim/nanolib/compare/@nexim/alpine@0.0.1...@nexim/alpine@1.0.0-alpha.0) (2024-12-10)
|
|
7
25
|
|
|
8
26
|
### Features
|
package/dist/main.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @nexim/alpine v1.
|
|
1
|
+
/* @nexim/alpine v1.1.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -43,7 +43,7 @@ var import_logger = require("@alwatr/logger");
|
|
|
43
43
|
var import_alpinejs = __toESM(require("alpinejs"), 1);
|
|
44
44
|
var logger = (0, import_logger.createLogger)("@nexim/alpine");
|
|
45
45
|
function alpineStoreGenerator(config) {
|
|
46
|
-
logger.logMethodArgs?.("alpineStoreGenerator", config);
|
|
46
|
+
logger.logMethodArgs?.("alpineStoreGenerator", { config });
|
|
47
47
|
import_alpinejs.default.store(config.name, config.defaultValue);
|
|
48
48
|
const store = import_alpinejs.default.store(config.name);
|
|
49
49
|
return store;
|
|
@@ -72,7 +72,7 @@ var AlpineStore = class {
|
|
|
72
72
|
constructor(config) {
|
|
73
73
|
this.logger_ = (0, import_logger2.createLogger)(`${"@nexim/alpine"}:${config.name}`);
|
|
74
74
|
this.logger_.logMethodArgs?.("constructor", config);
|
|
75
|
-
this.store = config
|
|
75
|
+
this.store = alpineStoreGenerator(config);
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
|
|
@@ -114,7 +114,7 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
114
114
|
data: `[${"@nexim/alpine"}:data:sv${schemaVersion}]:${this.config__.name}`,
|
|
115
115
|
expireTime: `[${"@nexim/alpine"}:expire-time:sv${schemaVersion}]:${this.config__.name}`
|
|
116
116
|
};
|
|
117
|
-
if (this.config__.expireDuration
|
|
117
|
+
if (this.config__.expireDuration != null) {
|
|
118
118
|
this.handleDataExpiration__();
|
|
119
119
|
}
|
|
120
120
|
this.load__();
|
|
@@ -150,10 +150,10 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
150
150
|
this.logger_.logMethod?.("handleDataExpiration__");
|
|
151
151
|
const expireDuration = import_local_storage.localJsonStorage.getItem(
|
|
152
152
|
this.localStorageKey__.expireTime,
|
|
153
|
-
{ time:
|
|
153
|
+
{ time: -1 },
|
|
154
154
|
this.config__.version
|
|
155
155
|
).time;
|
|
156
|
-
if (expireDuration < Date.now()) {
|
|
156
|
+
if (expireDuration !== -1 && expireDuration < Date.now()) {
|
|
157
157
|
this.clear();
|
|
158
158
|
}
|
|
159
159
|
}
|
|
@@ -161,11 +161,17 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
161
161
|
* Loads data from local storage and updates the store's data.
|
|
162
162
|
*
|
|
163
163
|
* When data is not found or invalid in local storage, it uses the default value.
|
|
164
|
+
*
|
|
165
|
+
* FIXME: remove `NonNullable` from <T['data']>, after local storage new version.
|
|
164
166
|
*/
|
|
165
167
|
load__() {
|
|
166
168
|
this.logger_.logMethod?.("load__");
|
|
167
|
-
const newData = import_local_storage.localJsonStorage.getItem(
|
|
168
|
-
|
|
169
|
+
const newData = import_local_storage.localJsonStorage.getItem(
|
|
170
|
+
this.localStorageKey__.data,
|
|
171
|
+
this.config__.defaultValue.data,
|
|
172
|
+
this.config__.version
|
|
173
|
+
);
|
|
174
|
+
this.store.data = newData;
|
|
169
175
|
}
|
|
170
176
|
/**
|
|
171
177
|
* Updates the expiration time in local storage to the current time plus the configured expiration duration.
|
|
@@ -180,7 +186,7 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
180
186
|
};
|
|
181
187
|
|
|
182
188
|
// src/main.ts
|
|
183
|
-
__dev_mode__: import_package_tracer.packageTracer.add("@nexim/alpine", "1.
|
|
189
|
+
__dev_mode__: import_package_tracer.packageTracer.add("@nexim/alpine", "1.1.0");
|
|
184
190
|
// Annotate the CommonJS export names for ESM import in node:
|
|
185
191
|
0 && (module.exports = {
|
|
186
192
|
AlpineStore,
|
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 * @template T - The type of the default value.\n * @property {string} name - The name of the store.\n * @property {T} defaultValue - The default value of the store.\n */\nexport type AlpineStoreGeneratorOptions<T extends DictionaryReq> = {\n name: string;\n defaultValue: T;\n};\n\n/**\n * Generates an Alpine.js store with default value.\n *\n * @template T - The type of the data.\n * @param {AlpineStoreGeneratorOptions} config - The configuration object for the store.\n * @returns {T} - The initialized store instance.\n *\n * @example\n * const store = alpineStoreGenerator({\n * name: 'user',\n * defaultValue: {type: 'root'},\n * });\n *\n * console.log(store.type); // Output: root\n *\n * @description\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 https://alpinejs.dev/globals/alpine-store\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\n/**\n * AlpineStore Options.\n *\n * @template T - The type of the store value.\n * @param {string} name - The name of the store.\n * @param {T} 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 {AlpineStoreOptions} config - Configuration object.\n *\n * @example\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 constructor(config: AlpineStoreOptions<T>) {\n this.logger_ = createLogger(`${__package_name__}:${config.name}`);\n this.logger_.logMethodArgs?.('constructor', config);\n\n this.store = config
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA4B;;;ACA5B,oBAA2B;AAC3B,sBAAmB;AAEnB,IAAM,aAAS,4BAAa,eAAgB;AAqCrC,SAAS,qBAA8C,QAA2C;AACvG,SAAO,gBAAgB,wBAAwB,
|
|
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 * @template T - The type of the default value.\n * @property {string} name - The name of the store.\n * @property {T} defaultValue - The default value of the store.\n */\nexport type AlpineStoreGeneratorOptions<T extends DictionaryReq> = {\n name: string;\n defaultValue: T;\n};\n\n/**\n * Generates an Alpine.js store with default value.\n *\n * @template T - The type of the data.\n * @param {AlpineStoreGeneratorOptions} config - The configuration object for the store.\n * @returns {T} - The initialized store instance.\n *\n * @example\n * const store = alpineStoreGenerator({\n * name: 'user',\n * defaultValue: {type: 'root'},\n * });\n *\n * console.log(store.type); // Output: root\n *\n * @description\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 https://alpinejs.dev/globals/alpine-store\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 * @template T - The type of the store value.\n * @param {string} name - The name of the store.\n * @param {T} 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 {AlpineStoreOptions} config - Configuration object.\n *\n * @example\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 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 * @template T - The type of the store value.\n * @param {string} name - The name of the store.\n * @param {number} version - The version of the store.\n * @param {T} defaultValue - The default value of the store.\n * @param {Duration} [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 {AlpineStoreWithBackupOptions} config__ - Configuration object.\n *\n * @example\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 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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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;;;AH7JA,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
|
+
/* @nexim/alpine v1.1.0 */
|
|
2
2
|
|
|
3
3
|
// src/main.ts
|
|
4
4
|
import { packageTracer } from "@alwatr/package-tracer";
|
|
@@ -8,7 +8,7 @@ import { createLogger } from "@alwatr/logger";
|
|
|
8
8
|
import alpine from "alpinejs";
|
|
9
9
|
var logger = createLogger("@nexim/alpine");
|
|
10
10
|
function alpineStoreGenerator(config) {
|
|
11
|
-
logger.logMethodArgs?.("alpineStoreGenerator", config);
|
|
11
|
+
logger.logMethodArgs?.("alpineStoreGenerator", { config });
|
|
12
12
|
alpine.store(config.name, config.defaultValue);
|
|
13
13
|
const store = alpine.store(config.name);
|
|
14
14
|
return store;
|
|
@@ -37,7 +37,7 @@ var AlpineStore = class {
|
|
|
37
37
|
constructor(config) {
|
|
38
38
|
this.logger_ = createLogger2(`${"@nexim/alpine"}:${config.name}`);
|
|
39
39
|
this.logger_.logMethodArgs?.("constructor", config);
|
|
40
|
-
this.store = config
|
|
40
|
+
this.store = alpineStoreGenerator(config);
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -79,7 +79,7 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
79
79
|
data: `[${"@nexim/alpine"}:data:sv${schemaVersion}]:${this.config__.name}`,
|
|
80
80
|
expireTime: `[${"@nexim/alpine"}:expire-time:sv${schemaVersion}]:${this.config__.name}`
|
|
81
81
|
};
|
|
82
|
-
if (this.config__.expireDuration
|
|
82
|
+
if (this.config__.expireDuration != null) {
|
|
83
83
|
this.handleDataExpiration__();
|
|
84
84
|
}
|
|
85
85
|
this.load__();
|
|
@@ -115,10 +115,10 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
115
115
|
this.logger_.logMethod?.("handleDataExpiration__");
|
|
116
116
|
const expireDuration = localJsonStorage.getItem(
|
|
117
117
|
this.localStorageKey__.expireTime,
|
|
118
|
-
{ time:
|
|
118
|
+
{ time: -1 },
|
|
119
119
|
this.config__.version
|
|
120
120
|
).time;
|
|
121
|
-
if (expireDuration < Date.now()) {
|
|
121
|
+
if (expireDuration !== -1 && expireDuration < Date.now()) {
|
|
122
122
|
this.clear();
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -126,11 +126,17 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
126
126
|
* Loads data from local storage and updates the store's data.
|
|
127
127
|
*
|
|
128
128
|
* When data is not found or invalid in local storage, it uses the default value.
|
|
129
|
+
*
|
|
130
|
+
* FIXME: remove `NonNullable` from <T['data']>, after local storage new version.
|
|
129
131
|
*/
|
|
130
132
|
load__() {
|
|
131
133
|
this.logger_.logMethod?.("load__");
|
|
132
|
-
const newData = localJsonStorage.getItem(
|
|
133
|
-
|
|
134
|
+
const newData = localJsonStorage.getItem(
|
|
135
|
+
this.localStorageKey__.data,
|
|
136
|
+
this.config__.defaultValue.data,
|
|
137
|
+
this.config__.version
|
|
138
|
+
);
|
|
139
|
+
this.store.data = newData;
|
|
134
140
|
}
|
|
135
141
|
/**
|
|
136
142
|
* Updates the expiration time in local storage to the current time plus the configured expiration duration.
|
|
@@ -145,7 +151,7 @@ var AlpineStoreWithBackup = class extends AlpineStore {
|
|
|
145
151
|
};
|
|
146
152
|
|
|
147
153
|
// src/main.ts
|
|
148
|
-
__dev_mode__: packageTracer.add("@nexim/alpine", "1.
|
|
154
|
+
__dev_mode__: packageTracer.add("@nexim/alpine", "1.1.0");
|
|
149
155
|
export {
|
|
150
156
|
AlpineStore,
|
|
151
157
|
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 * @template T - The type of the default value.\n * @property {string} name - The name of the store.\n * @property {T} defaultValue - The default value of the store.\n */\nexport type AlpineStoreGeneratorOptions<T extends DictionaryReq> = {\n name: string;\n defaultValue: T;\n};\n\n/**\n * Generates an Alpine.js store with default value.\n *\n * @template T - The type of the data.\n * @param {AlpineStoreGeneratorOptions} config - The configuration object for the store.\n * @returns {T} - The initialized store instance.\n *\n * @example\n * const store = alpineStoreGenerator({\n * name: 'user',\n * defaultValue: {type: 'root'},\n * });\n *\n * console.log(store.type); // Output: root\n *\n * @description\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 https://alpinejs.dev/globals/alpine-store\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\n/**\n * AlpineStore Options.\n *\n * @template T - The type of the store value.\n * @param {string} name - The name of the store.\n * @param {T} 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 {AlpineStoreOptions} config - Configuration object.\n *\n * @example\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 constructor(config: AlpineStoreOptions<T>) {\n this.logger_ = createLogger(`${__package_name__}:${config.name}`);\n this.logger_.logMethodArgs?.('constructor', config);\n\n this.store = config
|
|
5
|
-
"mappings": ";;;AAAA,SAAQ,qBAAoB;;;ACA5B,SAAQ,oBAAmB;AAC3B,OAAO,YAAY;AAEnB,IAAM,SAAS,aAAa,eAAgB;AAqCrC,SAAS,qBAA8C,QAA2C;AACvG,SAAO,gBAAgB,wBAAwB,
|
|
6
|
-
"names": ["createLogger"]
|
|
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 * @template T - The type of the default value.\n * @property {string} name - The name of the store.\n * @property {T} defaultValue - The default value of the store.\n */\nexport type AlpineStoreGeneratorOptions<T extends DictionaryReq> = {\n name: string;\n defaultValue: T;\n};\n\n/**\n * Generates an Alpine.js store with default value.\n *\n * @template T - The type of the data.\n * @param {AlpineStoreGeneratorOptions} config - The configuration object for the store.\n * @returns {T} - The initialized store instance.\n *\n * @example\n * const store = alpineStoreGenerator({\n * name: 'user',\n * defaultValue: {type: 'root'},\n * });\n *\n * console.log(store.type); // Output: root\n *\n * @description\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 https://alpinejs.dev/globals/alpine-store\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 * @template T - The type of the store value.\n * @param {string} name - The name of the store.\n * @param {T} 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 {AlpineStoreOptions} config - Configuration object.\n *\n * @example\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 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 * @template T - The type of the store value.\n * @param {string} name - The name of the store.\n * @param {number} version - The version of the store.\n * @param {T} defaultValue - The default value of the store.\n * @param {Duration} [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 {AlpineStoreWithBackupOptions} config__ - Configuration object.\n *\n * @example\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 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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7C,UAAM,gBAAgB,KAAK,IAAI,IAAI,cAAc,KAAK,SAAS,cAAc;AAC7E,qBAAiB,QAAQ,KAAK,kBAAkB,YAAY,EAAC,MAAM,cAAa,GAAG,KAAK,SAAS,OAAO;AAExG,SAAK,QAAQ,WAAW,uBAAuB,EAAC,cAAa,CAAC;AAAA,EAChE;AACF;;;AH7JA,aAAc,eAAc,IAAI,iBAAkB,OAAmB;",
|
|
6
|
+
"names": ["createLogger", "createLogger"]
|
|
7
7
|
}
|
|
@@ -73,6 +73,8 @@ export declare class AlpineStoreWithBackup<T extends AlpineStoreWithBackupType>
|
|
|
73
73
|
* Loads data from local storage and updates the store's data.
|
|
74
74
|
*
|
|
75
75
|
* When data is not found or invalid in local storage, it uses the default value.
|
|
76
|
+
*
|
|
77
|
+
* FIXME: remove `NonNullable` from <T['data']>, after local storage new version.
|
|
76
78
|
*/
|
|
77
79
|
private load__;
|
|
78
80
|
/**
|
|
@@ -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;;;;;;;;GAQG;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;IAgChF,OAAO,CAAC,QAAQ;IA/B5B;;OAEG;IACH,OAAO,CAAC,iBAAiB,CAGvB;IAEF;;;;;;;;;;;;;;;;;;;;;;OAsBG;gBACiB,QAAQ,EAAE,4BAA4B,CAAC,CAAC,CAAC;
|
|
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;;;;;;;;GAQG;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;IAgChF,OAAO,CAAC,QAAQ;IA/B5B;;OAEG;IACH,OAAO,CAAC,iBAAiB,CAGvB;IAEF;;;;;;;;;;;;;;;;;;;;;;OAsBG;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"}
|
|
@@ -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;
|
|
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;;;;;;;;;;;;;;;;OAgBG;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.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Utility functions to enhance Alpine.js usage with backup support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"alpinejs",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"directory": "packages/alpine"
|
|
20
20
|
},
|
|
21
21
|
"license": "AGPL-3.0-only",
|
|
22
|
-
"author": "S. Amir Mohammad Najafi <njfamirm@gmail.com> (www.njfamirm.ir)",
|
|
22
|
+
"author": "S. Amir Mohammad Najafi <njfamirm@gmail.com> (https://www.njfamirm.ir)",
|
|
23
23
|
"contributors": [
|
|
24
24
|
"Arash Ghardashpoor <arash.qardashpoor@gmail.com> (https://www.agpagp.ir)"
|
|
25
25
|
],
|
|
@@ -41,27 +41,16 @@
|
|
|
41
41
|
"!demo/**/*"
|
|
42
42
|
],
|
|
43
43
|
"scripts": {
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"build:ts": "tsc --build",
|
|
48
|
-
"c": "yarn run clean",
|
|
49
|
-
"cb": "yarn run clean && yarn run build",
|
|
50
|
-
"clean": "rm -rfv dist *.tsbuildinfo",
|
|
51
|
-
"d": "yarn run build:es && yarn node --enable-source-maps --trace-warnings",
|
|
52
|
-
"t": "yarn run test",
|
|
53
|
-
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --enable-source-maps --experimental-vm-modules\" ava",
|
|
54
|
-
"w": "yarn run watch",
|
|
55
|
-
"watch": "yarn run watch:ts & yarn run watch:es",
|
|
56
|
-
"watch:es": "yarn run build:es --watch",
|
|
57
|
-
"watch:ts": "yarn run build:ts --watch --preserveWatchOutput"
|
|
44
|
+
"build": "wireit",
|
|
45
|
+
"test": "wireit",
|
|
46
|
+
"watch": "wireit"
|
|
58
47
|
},
|
|
59
48
|
"dependencies": {
|
|
60
49
|
"@alwatr/local-storage": "^5.0.0",
|
|
61
50
|
"@alwatr/logger": "^5.0.0",
|
|
62
51
|
"@alwatr/package-tracer": "^5.0.0",
|
|
63
52
|
"@alwatr/parse-duration": "^5.0.0",
|
|
64
|
-
"alpinejs": "^3.14.
|
|
53
|
+
"alpinejs": "^3.14.8"
|
|
65
54
|
},
|
|
66
55
|
"devDependencies": {
|
|
67
56
|
"@alwatr/nano-build": "^5.0.0",
|
|
@@ -69,10 +58,52 @@
|
|
|
69
58
|
"@nexim/typescript-config": "^1.0.1",
|
|
70
59
|
"@types/alpinejs": "^3.13.11",
|
|
71
60
|
"ava": "^6.2.0",
|
|
72
|
-
"typescript": "^5.
|
|
61
|
+
"typescript": "^5.7.2",
|
|
62
|
+
"wireit": "^0.14.9"
|
|
73
63
|
},
|
|
74
64
|
"publishConfig": {
|
|
75
65
|
"access": "public"
|
|
76
66
|
},
|
|
77
|
-
"
|
|
67
|
+
"wireit": {
|
|
68
|
+
"test": {
|
|
69
|
+
"command": "NODE_OPTIONS=\"$NODE_OPTIONS --enable-source-maps --experimental-vm-modules\" ava"
|
|
70
|
+
},
|
|
71
|
+
"build": {
|
|
72
|
+
"dependencies": [
|
|
73
|
+
"build:type",
|
|
74
|
+
"build:es"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
"build:es": {
|
|
78
|
+
"command": "nano-build --preset=module",
|
|
79
|
+
"files": [
|
|
80
|
+
"src",
|
|
81
|
+
"tsconfig.json"
|
|
82
|
+
],
|
|
83
|
+
"clean": "if-file-deleted",
|
|
84
|
+
"output": [
|
|
85
|
+
"dist/es",
|
|
86
|
+
"tsconfig.tsbuildinfo"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"build:type": {
|
|
90
|
+
"command": "tsc --build"
|
|
91
|
+
},
|
|
92
|
+
"watch": {
|
|
93
|
+
"dependencies": [
|
|
94
|
+
"watch:ts"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"watch:ts": {
|
|
98
|
+
"command": "tsc --build --watch --preserveWatchOutput",
|
|
99
|
+
"dependencies": [
|
|
100
|
+
"watch:es"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"watch:es": {
|
|
104
|
+
"command": "nano-build --preset=module -- --watch",
|
|
105
|
+
"service": true
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"gitHead": "bc359427982999632efc472ee14238e4317e6320"
|
|
78
109
|
}
|