@alwatr/local-storage 8.0.2 → 9.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/dist/main.js +3 -3
- package/dist/main.js.map +1 -1
- package/dist/type.d.ts.map +1 -1
- package/package.json +22 -21
- package/src/type.ts +0 -2
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 📦 @alwatr/local-storage
|
|
2
|
-
import{createLogger as z}from"@alwatr/logger";class j{static version="
|
|
1
|
+
/* 📦 @alwatr/local-storage v9.1.0 */
|
|
2
|
+
import{createLogger as z}from"@alwatr/logger";class j{static version="9.1.0";key__;logger_;constructor(x){this.logger_=z(`local-storage-provider: ${x.name}, v: ${x.schemaVersion}`),this.logger_.logMethodArgs?.("constructor",{config:x}),this.key__=j.getKey(x),j.clearPreviousStorageVersions(x)}static getKey(x){return`${x.name}.v${x.schemaVersion}`}static clearPreviousStorageVersions(x){if(x.schemaVersion<1)return;for(let b=0;b<x.schemaVersion;b++){let q=j.getKey({name:x.name,schemaVersion:b});localStorage.removeItem(q)}}static has(x){let b=j.getKey(x);return localStorage.getItem(b)!==null}has(){return localStorage.getItem(this.key__)!==null}read(){let x=null;try{x=localStorage.getItem(this.key__)}catch(b){this.logger_.error("read","read_local_storage_error",{err:b})}if(!x)return this.logger_.logMethod?.("read//no_value"),null;try{let b=JSON.parse(x);return this.logger_.logMethodFull?.("read//value",void 0,{parsedValue:b}),b}catch(b){return this.logger_.error("read","read_parse_error",{err:b}),null}}write(x){this.logger_.logMethodArgs?.("write",{value:x});let b;try{b=JSON.stringify(x)}catch(q){throw this.logger_.error("write","write_stringify_error",{err:q}),Error("write_stringify_error")}try{localStorage.setItem(this.key__,b)}catch(q){this.logger_.error("write","write_local_storage_error",{err:q})}}remove(){localStorage.removeItem(this.key__)}}function E(x){return new j(x)}export{E as createLocalStorageProvider,j as LocalStorageProvider};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=1614C278BA0EAD5B64756E2164756E21
|
|
5
5
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"import {LocalStorageProvider} from './local-storage.provider.js';\n\nimport type {LocalStorageProviderConfig} from './type.js';\n\n/**\n * Factory function to create a new LocalStorageProvider.\n *\n * @param config - The configuration for the provider.\n * @returns An instance of LocalStorageProvider.\n *\n * @example\n * ```typescript\n * const userSettings = createLocalStorageProvider({\n * name: 'user-settings',\n * schemaVersion: 1\n * });\n *\n * // Write new settings\n * userSettings.write({ theme: 'dark', notifications: false });\n *\n * // Read the current settings\n * const currentSettings = userSettings.read();\n * console.log(currentSettings); // { theme: 'dark', notifications: false }\n * ```\n */\nexport function createLocalStorageProvider<T extends JsonValue>(config: LocalStorageProviderConfig): LocalStorageProvider<T> {\n return new LocalStorageProvider<T>(config);\n}\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";AAAA,uBAAQ,uBAuBD,MAAM,CAA0C,OAC9B,SAAU,QAEhB,MACE,QAEnB,WAAW,CAAC,EAAoC,CAC9C,KAAK,QAAU,EAAa,2BAA2B,EAAO,YAAY,EAAO,eAAe,EAChG,KAAK,QAAQ,gBAAgB,cAAe,CAAC,QAAM,CAAC,EACpD,KAAK,MAAQ,EAAqB,OAAO,CAAM,EAC/C,EAAqB,6BAA6B,CAAM,QAQ5C,OAAM,CAAC,EAA4C,CAC/D,MAAO,GAAG,EAAO,SAAS,EAAO,sBAMrB,6BAA4B,CAAC,EAA0C,CACnF,GAAI,EAAO,cAAgB,EAAG,OAG9B,QAAS,EAAI,EAAG,EAAI,EAAO,cAAe,IAAK,CAC7C,IAAM,EAAS,EAAqB,OAAO,CAAC,KAAM,EAAO,KAAM,cAAe,CAAC,CAAC,EAChF,aAAa,WAAW,CAAM,SAiBpB,IAAG,CAAC,EAA6C,CAC7D,IAAM,EAAM,EAAqB,OAAO,CAAM,EAC9C,OAAO,aAA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|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/local-storage",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "A modern, simple, and robust solution for managing versioned JSON objects in the browser's `localStorage`. This package provides a clean, class-based API with a factory function to ensure your application's data persistence is safe, maintainable, and future-proof.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
|
-
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
|
+
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
|
-
"directory": "packages/local-storage",
|
|
10
9
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/Alwatr/
|
|
10
|
+
"url": "https://github.com/Alwatr/alwatr",
|
|
11
|
+
"directory": "pkg/nanolib/local-storage"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://github.com/Alwatr/
|
|
14
|
-
"bugs": "https://github.com/Alwatr/
|
|
13
|
+
"homepage": "https://github.com/Alwatr/alwatr/tree/main/pkg/nanolib/local-storage#readme",
|
|
14
|
+
"bugs": "https://github.com/Alwatr/alwatr/issues",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./dist/main.d.ts",
|
|
18
|
+
"import": "./dist/main.js",
|
|
18
19
|
"default": "./dist/main.js"
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
22
|
"sideEffects": false,
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@alwatr/logger": "
|
|
24
|
+
"@alwatr/logger": "9.1.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@alwatr/nano-build": "
|
|
27
|
-
"@alwatr/
|
|
28
|
-
"@alwatr/
|
|
29
|
-
"@alwatr/type-helper": "8.0.2",
|
|
27
|
+
"@alwatr/nano-build": "9.1.0",
|
|
28
|
+
"@alwatr/tsconfig-base": "9.1.0",
|
|
29
|
+
"@alwatr/type-helper": "9.1.0",
|
|
30
30
|
"typescript": "^6.0.2"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
@@ -34,21 +34,23 @@
|
|
|
34
34
|
"build": "bun run build:ts && bun run build:es",
|
|
35
35
|
"build:es": "nano-build --preset=module src/main.ts",
|
|
36
36
|
"build:ts": "tsc --build",
|
|
37
|
-
"
|
|
38
|
-
"cb": "bun run clean && bun run build",
|
|
37
|
+
"cl": "bun run clean",
|
|
39
38
|
"clean": "rm -rfv dist *.tsbuildinfo",
|
|
40
|
-
"
|
|
39
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
40
|
+
"lint": "eslint src/ --ext .ts",
|
|
41
|
+
"t": "bun run test",
|
|
42
|
+
"test": "ALWATR_DEBUG=0 bun test",
|
|
41
43
|
"w": "bun run watch",
|
|
42
44
|
"watch": "bun run watch:ts & bun run watch:es",
|
|
43
45
|
"watch:es": "bun run build:es --watch",
|
|
44
46
|
"watch:ts": "bun run build:ts --watch --preserveWatchOutput"
|
|
45
47
|
},
|
|
46
48
|
"files": [
|
|
47
|
-
"
|
|
49
|
+
"dist",
|
|
50
|
+
"src/**/*.ts",
|
|
51
|
+
"!src/**/*.test.ts",
|
|
48
52
|
"README.md",
|
|
49
|
-
"LICENSE"
|
|
50
|
-
"!demo/**/*",
|
|
51
|
-
"!**/*.test.js"
|
|
53
|
+
"LICENSE"
|
|
52
54
|
],
|
|
53
55
|
"publishConfig": {
|
|
54
56
|
"access": "public"
|
|
@@ -59,7 +61,7 @@
|
|
|
59
61
|
"browser storage",
|
|
60
62
|
"cross-platform",
|
|
61
63
|
"data persistence",
|
|
62
|
-
"
|
|
64
|
+
"esm",
|
|
63
65
|
"facade factory",
|
|
64
66
|
"JavaScript",
|
|
65
67
|
"JSON storage",
|
|
@@ -71,6 +73,5 @@
|
|
|
71
73
|
"utility",
|
|
72
74
|
"versioning"
|
|
73
75
|
],
|
|
74
|
-
"
|
|
75
|
-
"gitHead": "95bb13efd0a5f485c6b09f1a911b99492017aed1"
|
|
76
|
+
"gitHead": "4a25cd3e0499cf61dd761e87d3711abf9b0cd208"
|
|
76
77
|
}
|