universe-code 0.0.69 → 0.0.70
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// idb.config.
|
|
1
|
+
// idb.config.ts
|
|
2
2
|
import { InjectionToken } from '@angular/core';
|
|
3
3
|
|
|
4
|
-
export const IDB_CONFIG = new InjectionToken('IDB_CONFIG');
|
|
5
|
-
|
|
6
4
|
/** @typedef {Object} IdbConfig
|
|
7
5
|
* @property {string} dbName
|
|
8
6
|
* @property {number} version
|
|
9
7
|
* @property {string} storeName
|
|
10
8
|
*/
|
|
9
|
+
|
|
10
|
+
export const IDB_CONFIG = new InjectionToken<IdbConfig>('IDB_CONFIG');
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
// idbService.mjs
|
|
2
|
+
import { DBManager, DB } from 'universe-code';
|
|
3
|
+
import { inject } from '@angular/core';
|
|
4
|
+
import { IDB_CONFIG } from '../../idb.config';
|
|
3
5
|
|
|
4
6
|
export class IdbService {
|
|
5
7
|
db = null;
|
|
6
8
|
manager = null;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
options = inject(IDB_CONFIG); // <-- Angular will inject the config
|
|
10
|
+
isBrowser = typeof window !== 'undefined';
|
|
9
11
|
|
|
10
|
-
constructor() {
|
|
12
|
+
constructor() {}
|
|
11
13
|
|
|
12
14
|
async connect() {
|
|
13
15
|
if (!this.isBrowser) return null;
|