@jewel998/config 0.2.0 → 0.2.1
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/initConfig.d.ts +14 -1
- package/dist/initConfig.js +1 -0
- package/package.json +1 -1
package/dist/initConfig.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConfigEventCallback, ConfigEventType } from "./types.js";
|
|
1
|
+
import type { CacheStorage, ConfigEventCallback, ConfigEventType } from "./types.js";
|
|
2
2
|
import type { EvaluationContext } from "./plugins/types.js";
|
|
3
3
|
export interface InitConfigOptions {
|
|
4
4
|
/** Required. API key from the portal (cid_ for client, svr_ for server). */
|
|
@@ -17,6 +17,19 @@ export interface InitConfigOptions {
|
|
|
17
17
|
* @example "https://your-project.web.app/api"
|
|
18
18
|
*/
|
|
19
19
|
baseUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Cache storage adapter. Controls where resolved config values are persisted.
|
|
22
|
+
*
|
|
23
|
+
* - `memoryStorage()` (default) — In-memory, lost on page reload
|
|
24
|
+
* - `browserStorage()` — localStorage, persists across page reloads and sessions
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { browserStorage } from "@jewel998/config";
|
|
29
|
+
* initConfig({ storage: browserStorage({ prefix: "myapp" }) })
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
storage?: CacheStorage;
|
|
20
33
|
/**
|
|
21
34
|
* Polling interval in milliseconds for version checks.
|
|
22
35
|
* The SDK periodically calls /api/version (lightweight ~100 bytes)
|
package/dist/initConfig.js
CHANGED
|
@@ -42,6 +42,7 @@ export function initConfig(options) {
|
|
|
42
42
|
clientId: options.clientId,
|
|
43
43
|
loadingStrategy: "optimistic",
|
|
44
44
|
context: options.context,
|
|
45
|
+
storage: options.storage,
|
|
45
46
|
baseUrl,
|
|
46
47
|
});
|
|
47
48
|
// Version-based polling: check /api/version periodically, delta-fetch on change
|