ngx-webstore 0.0.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/LICENSE +21 -0
- package/README.md +782 -0
- package/angular.json +37 -0
- package/package.json +31 -0
- package/projects/ngx-storage-manager/README.md +122 -0
- package/projects/ngx-storage-manager/ng-package.json +7 -0
- package/projects/ngx-storage-manager/package.json +37 -0
- package/projects/ngx-storage-manager/src/lib/core/encryption.service.ts +217 -0
- package/projects/ngx-storage-manager/src/lib/core/index.ts +5 -0
- package/projects/ngx-storage-manager/src/lib/core/namespace-manager.service.ts +68 -0
- package/projects/ngx-storage-manager/src/lib/core/serialization.service.ts +145 -0
- package/projects/ngx-storage-manager/src/lib/core/storage-service.interface.ts +31 -0
- package/projects/ngx-storage-manager/src/lib/core/ttl-manager.service.ts +77 -0
- package/projects/ngx-storage-manager/src/lib/models/index.ts +3 -0
- package/projects/ngx-storage-manager/src/lib/models/storage-config.model.ts +85 -0
- package/projects/ngx-storage-manager/src/lib/models/storage-item.model.ts +26 -0
- package/projects/ngx-storage-manager/src/lib/models/storage-options.model.ts +41 -0
- package/projects/ngx-storage-manager/src/lib/ngx-storage-manager.module.ts +63 -0
- package/projects/ngx-storage-manager/src/lib/services/cookie.service.ts +281 -0
- package/projects/ngx-storage-manager/src/lib/services/global-state.service.ts +229 -0
- package/projects/ngx-storage-manager/src/lib/services/index.ts +6 -0
- package/projects/ngx-storage-manager/src/lib/services/indexeddb.service.ts +329 -0
- package/projects/ngx-storage-manager/src/lib/services/local-storage.service.ts +268 -0
- package/projects/ngx-storage-manager/src/lib/services/session-storage.service.ts +217 -0
- package/projects/ngx-storage-manager/src/lib/services/storage-manager.service.ts +183 -0
- package/projects/ngx-storage-manager/src/lib/utils/index.ts +2 -0
- package/projects/ngx-storage-manager/src/lib/utils/storage-availability.ts +73 -0
- package/projects/ngx-storage-manager/src/lib/utils/type-guards.ts +64 -0
- package/projects/ngx-storage-manager/src/public-api.ts +34 -0
- package/projects/ngx-storage-manager/tsconfig.lib.json +15 -0
- package/projects/ngx-storage-manager/tsconfig.lib.prod.json +11 -0
- package/projects/ngx-storage-manager/tsconfig.spec.json +15 -0
- package/tsconfig.json +32 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage availability detection utilities
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Check if localStorage is available
|
|
7
|
+
*/
|
|
8
|
+
export function isLocalStorageAvailable(): boolean {
|
|
9
|
+
try {
|
|
10
|
+
const testKey = '__storage_test__';
|
|
11
|
+
window.localStorage.setItem(testKey, testKey);
|
|
12
|
+
window.localStorage.removeItem(testKey);
|
|
13
|
+
return true;
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check if sessionStorage is available
|
|
21
|
+
*/
|
|
22
|
+
export function isSessionStorageAvailable(): boolean {
|
|
23
|
+
try {
|
|
24
|
+
const testKey = '__storage_test__';
|
|
25
|
+
window.sessionStorage.setItem(testKey, testKey);
|
|
26
|
+
window.sessionStorage.removeItem(testKey);
|
|
27
|
+
return true;
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Check if cookies are available
|
|
35
|
+
*/
|
|
36
|
+
export function isCookieAvailable(): boolean {
|
|
37
|
+
try {
|
|
38
|
+
if (typeof document === 'undefined') return false;
|
|
39
|
+
document.cookie = '__cookie_test__=1';
|
|
40
|
+
const result = document.cookie.indexOf('__cookie_test__') !== -1;
|
|
41
|
+
document.cookie = '__cookie_test__=; expires=Thu, 01 Jan 1970 00:00:00 GMT';
|
|
42
|
+
return result;
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Check if IndexedDB is available
|
|
50
|
+
*/
|
|
51
|
+
export function isIndexedDBAvailable(): boolean {
|
|
52
|
+
try {
|
|
53
|
+
return typeof window !== 'undefined' &&
|
|
54
|
+
typeof window.indexedDB !== 'undefined' &&
|
|
55
|
+
window.indexedDB !== null;
|
|
56
|
+
} catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Get list of all available storage types
|
|
63
|
+
*/
|
|
64
|
+
export function getAvailableStorages(): Array<'localStorage' | 'sessionStorage' | 'cookie' | 'indexedDB'> {
|
|
65
|
+
const available: Array<'localStorage' | 'sessionStorage' | 'cookie' | 'indexedDB'> = [];
|
|
66
|
+
|
|
67
|
+
if (isLocalStorageAvailable()) available.push('localStorage');
|
|
68
|
+
if (isSessionStorageAvailable()) available.push('sessionStorage');
|
|
69
|
+
if (isCookieAvailable()) available.push('cookie');
|
|
70
|
+
if (isIndexedDBAvailable()) available.push('indexedDB');
|
|
71
|
+
|
|
72
|
+
return available;
|
|
73
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard utilities for safe type checking
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Check if value is a plain object
|
|
7
|
+
*/
|
|
8
|
+
export function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
9
|
+
return typeof value === 'object' &&
|
|
10
|
+
value !== null &&
|
|
11
|
+
!Array.isArray(value) &&
|
|
12
|
+
Object.prototype.toString.call(value) === '[object Object]';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Check if value is a Date object
|
|
17
|
+
*/
|
|
18
|
+
export function isDate(value: unknown): value is Date {
|
|
19
|
+
return value instanceof Date && !isNaN(value.getTime());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Check if value is a Map
|
|
24
|
+
*/
|
|
25
|
+
export function isMap(value: unknown): value is Map<unknown, unknown> {
|
|
26
|
+
return value instanceof Map;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Check if value is a Set
|
|
31
|
+
*/
|
|
32
|
+
export function isSet(value: unknown): value is Set<unknown> {
|
|
33
|
+
return value instanceof Set;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Check if value is a primitive
|
|
38
|
+
*/
|
|
39
|
+
export function isPrimitive(value: unknown): value is string | number | boolean | null | undefined {
|
|
40
|
+
return value === null ||
|
|
41
|
+
value === undefined ||
|
|
42
|
+
typeof value === 'string' ||
|
|
43
|
+
typeof value === 'number' ||
|
|
44
|
+
typeof value === 'boolean';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Check if running in browser environment
|
|
49
|
+
*/
|
|
50
|
+
export function isBrowser(): boolean {
|
|
51
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Check if a string is valid JSON
|
|
56
|
+
*/
|
|
57
|
+
export function isValidJSON(str: string): boolean {
|
|
58
|
+
try {
|
|
59
|
+
JSON.parse(str);
|
|
60
|
+
return true;
|
|
61
|
+
} catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ngx-storage-manager
|
|
3
|
+
* A comprehensive Angular library for browser storage management
|
|
4
|
+
*
|
|
5
|
+
* Supports: LocalStorage, SessionStorage, Cookies, IndexedDB
|
|
6
|
+
* Features: TTL, Encryption, Namespacing, Reactive Updates, Fallback Strategy
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Module
|
|
10
|
+
export * from './lib/ngx-storage-manager.module';
|
|
11
|
+
|
|
12
|
+
// Services (Injectable in components)
|
|
13
|
+
export * from './lib/services/local-storage.service';
|
|
14
|
+
export * from './lib/services/session-storage.service';
|
|
15
|
+
export * from './lib/services/cookie.service';
|
|
16
|
+
export * from './lib/services/indexeddb.service';
|
|
17
|
+
export * from './lib/services/global-state.service';
|
|
18
|
+
export * from './lib/services/storage-manager.service';
|
|
19
|
+
|
|
20
|
+
// Core services (for advanced usage)
|
|
21
|
+
export * from './lib/core/encryption.service';
|
|
22
|
+
export * from './lib/core/serialization.service';
|
|
23
|
+
export * from './lib/core/ttl-manager.service';
|
|
24
|
+
export * from './lib/core/namespace-manager.service';
|
|
25
|
+
export * from './lib/core/storage-service.interface';
|
|
26
|
+
|
|
27
|
+
// Models
|
|
28
|
+
export * from './lib/models/storage-config.model';
|
|
29
|
+
export * from './lib/models/storage-options.model';
|
|
30
|
+
export * from './lib/models/storage-item.model';
|
|
31
|
+
|
|
32
|
+
// Utilities
|
|
33
|
+
export * from './lib/utils/storage-availability';
|
|
34
|
+
export * from './lib/utils/type-guards';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "../../out-tsc/lib",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"inlineSources": true,
|
|
10
|
+
"types": []
|
|
11
|
+
},
|
|
12
|
+
"exclude": [
|
|
13
|
+
"**/*.spec.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "./tsconfig.lib.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"declarationMap": false
|
|
7
|
+
},
|
|
8
|
+
"angularCompilerOptions": {
|
|
9
|
+
"compilationMode": "partial"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "../../out-tsc/spec",
|
|
7
|
+
"types": [
|
|
8
|
+
"jasmine"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"**/*.spec.ts",
|
|
13
|
+
"**/*.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compileOnSave": false,
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": "./",
|
|
5
|
+
"outDir": "./dist/out-tsc",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noImplicitOverride": true,
|
|
8
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"declaration": false,
|
|
16
|
+
"experimentalDecorators": true,
|
|
17
|
+
"moduleResolution": "bundler",
|
|
18
|
+
"importHelpers": true,
|
|
19
|
+
"target": "ES2022",
|
|
20
|
+
"module": "ES2022",
|
|
21
|
+
"lib": [
|
|
22
|
+
"ES2022",
|
|
23
|
+
"dom"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"angularCompilerOptions": {
|
|
27
|
+
"enableI18nLegacyMessageIdFormat": false,
|
|
28
|
+
"strictInjectionParameters": true,
|
|
29
|
+
"strictInputAccessModifiers": true,
|
|
30
|
+
"strictTemplates": true
|
|
31
|
+
}
|
|
32
|
+
}
|