fatigue-kit 0.0.0-stage → 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.
Files changed (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +159 -2
  3. package/README.zh-CN.md +160 -0
  4. package/dist/adapters/alipay.cjs +52 -0
  5. package/dist/adapters/alipay.cjs.map +1 -0
  6. package/dist/adapters/alipay.d.cts +28 -0
  7. package/dist/adapters/alipay.d.ts +28 -0
  8. package/dist/adapters/alipay.js +52 -0
  9. package/dist/adapters/alipay.js.map +1 -0
  10. package/dist/adapters/async-storage.cjs +93 -0
  11. package/dist/adapters/async-storage.cjs.map +1 -0
  12. package/dist/adapters/async-storage.d.cts +49 -0
  13. package/dist/adapters/async-storage.d.ts +49 -0
  14. package/dist/adapters/async-storage.js +93 -0
  15. package/dist/adapters/async-storage.js.map +1 -0
  16. package/dist/adapters/local-storage.cjs +24 -0
  17. package/dist/adapters/local-storage.cjs.map +1 -0
  18. package/dist/adapters/local-storage.d.cts +14 -0
  19. package/dist/adapters/local-storage.d.ts +14 -0
  20. package/dist/adapters/local-storage.js +24 -0
  21. package/dist/adapters/local-storage.js.map +1 -0
  22. package/dist/adapters/memory.cjs +7 -0
  23. package/dist/adapters/memory.cjs.map +1 -0
  24. package/dist/adapters/memory.d.cts +15 -0
  25. package/dist/adapters/memory.d.ts +15 -0
  26. package/dist/adapters/memory.js +7 -0
  27. package/dist/adapters/memory.js.map +1 -0
  28. package/dist/adapters/node-file.cjs +53 -0
  29. package/dist/adapters/node-file.cjs.map +1 -0
  30. package/dist/adapters/node-file.d.cts +16 -0
  31. package/dist/adapters/node-file.d.ts +16 -0
  32. package/dist/adapters/node-file.js +53 -0
  33. package/dist/adapters/node-file.js.map +1 -0
  34. package/dist/adapters/session-storage.cjs +24 -0
  35. package/dist/adapters/session-storage.cjs.map +1 -0
  36. package/dist/adapters/session-storage.d.cts +14 -0
  37. package/dist/adapters/session-storage.d.ts +14 -0
  38. package/dist/adapters/session-storage.js +24 -0
  39. package/dist/adapters/session-storage.js.map +1 -0
  40. package/dist/adapters/weapp.cjs +51 -0
  41. package/dist/adapters/weapp.cjs.map +1 -0
  42. package/dist/adapters/weapp.d.cts +24 -0
  43. package/dist/adapters/weapp.d.ts +24 -0
  44. package/dist/adapters/weapp.js +51 -0
  45. package/dist/adapters/weapp.js.map +1 -0
  46. package/dist/chunk-DABM2TVR.cjs +58 -0
  47. package/dist/chunk-DABM2TVR.cjs.map +1 -0
  48. package/dist/chunk-DM2CAKGU.js +23 -0
  49. package/dist/chunk-DM2CAKGU.js.map +1 -0
  50. package/dist/chunk-GMM2BYRQ.js +58 -0
  51. package/dist/chunk-GMM2BYRQ.js.map +1 -0
  52. package/dist/chunk-K7E4LWUL.cjs +43 -0
  53. package/dist/chunk-K7E4LWUL.cjs.map +1 -0
  54. package/dist/chunk-NBDAXDB6.cjs +23 -0
  55. package/dist/chunk-NBDAXDB6.cjs.map +1 -0
  56. package/dist/chunk-ZNIZLIUO.js +43 -0
  57. package/dist/chunk-ZNIZLIUO.js.map +1 -0
  58. package/dist/global/index.global.js +2 -0
  59. package/dist/global/index.global.js.map +1 -0
  60. package/dist/index.cjs +334 -0
  61. package/dist/index.cjs.map +1 -0
  62. package/dist/index.d.cts +17 -0
  63. package/dist/index.d.ts +17 -0
  64. package/dist/index.js +334 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/legacy.cjs +45 -0
  67. package/dist/legacy.cjs.map +1 -0
  68. package/dist/legacy.d.cts +41 -0
  69. package/dist/legacy.d.ts +41 -0
  70. package/dist/legacy.js +45 -0
  71. package/dist/legacy.js.map +1 -0
  72. package/dist/types-hDxN5bc3.d.cts +89 -0
  73. package/dist/types-hDxN5bc3.d.ts +89 -0
  74. package/dist/web-GiaS0cnX.d.cts +8 -0
  75. package/dist/web-GiaS0cnX.d.ts +8 -0
  76. package/package.json +132 -4
@@ -0,0 +1,49 @@
1
+ import { SyncStorage } from '../index.cjs';
2
+
3
+ /**
4
+ * Minimal interface shared by `@react-native-async-storage/async-storage` and
5
+ * most RN-compatible storage libraries. Pass your storage instance directly.
6
+ */
7
+ interface AsyncStorageLike {
8
+ getItem(key: string): Promise<string | null>;
9
+ setItem(key: string, value: string): Promise<void>;
10
+ removeItem(key: string): Promise<void>;
11
+ }
12
+ interface AsyncStorageAdapter {
13
+ /** Synchronous view over the async backend. Only use it once `ready` resolved. */
14
+ storage: SyncStorage;
15
+ /** Resolves once the in-memory cache has been hydrated from the backend. */
16
+ ready: Promise<void>;
17
+ /** Persist pending writes now. Also runs automatically, debounced. */
18
+ flush(): Promise<void>;
19
+ }
20
+ interface AsyncStorageAdapterOptions {
21
+ /** Must match the `namespace` of the fatigue instance. Default `'fatigue-kit'`. */
22
+ namespace?: string;
23
+ /** Debounce window for background flushes, ms. Default `50`. */
24
+ flushDelay?: number;
25
+ onError?: (error: unknown) => void;
26
+ }
27
+ /**
28
+ * React Native (and any async backend) adapter.
29
+ *
30
+ * The core engine is synchronous for atomicity, so this adapter hydrates all
31
+ * known keys once up front (`ready`), serves reads from memory, and writes back
32
+ * in debounced batches. An index key keeps track of which keys belong to
33
+ * fatigue-kit. Call `flush()` from an `AppState` "background" listener so the
34
+ * last writes survive an app kill.
35
+ *
36
+ * ```ts
37
+ * import AsyncStorage from '@react-native-async-storage/async-storage'
38
+ * const handle = asyncStorageAdapter(AsyncStorage)
39
+ * await handle.ready
40
+ * const fatigue = createFatigue({ storage: handle.storage })
41
+ * AppState.addEventListener('change', (state) => {
42
+ * if (state === 'background') handle.flush()
43
+ * })
44
+ * ```
45
+ */
46
+ declare function asyncStorageAdapter(client: AsyncStorageLike, options?: AsyncStorageAdapterOptions): AsyncStorageAdapter;
47
+
48
+ export { asyncStorageAdapter };
49
+ export type { AsyncStorageAdapter, AsyncStorageAdapterOptions, AsyncStorageLike };
@@ -0,0 +1,49 @@
1
+ import { SyncStorage } from '../index.js';
2
+
3
+ /**
4
+ * Minimal interface shared by `@react-native-async-storage/async-storage` and
5
+ * most RN-compatible storage libraries. Pass your storage instance directly.
6
+ */
7
+ interface AsyncStorageLike {
8
+ getItem(key: string): Promise<string | null>;
9
+ setItem(key: string, value: string): Promise<void>;
10
+ removeItem(key: string): Promise<void>;
11
+ }
12
+ interface AsyncStorageAdapter {
13
+ /** Synchronous view over the async backend. Only use it once `ready` resolved. */
14
+ storage: SyncStorage;
15
+ /** Resolves once the in-memory cache has been hydrated from the backend. */
16
+ ready: Promise<void>;
17
+ /** Persist pending writes now. Also runs automatically, debounced. */
18
+ flush(): Promise<void>;
19
+ }
20
+ interface AsyncStorageAdapterOptions {
21
+ /** Must match the `namespace` of the fatigue instance. Default `'fatigue-kit'`. */
22
+ namespace?: string;
23
+ /** Debounce window for background flushes, ms. Default `50`. */
24
+ flushDelay?: number;
25
+ onError?: (error: unknown) => void;
26
+ }
27
+ /**
28
+ * React Native (and any async backend) adapter.
29
+ *
30
+ * The core engine is synchronous for atomicity, so this adapter hydrates all
31
+ * known keys once up front (`ready`), serves reads from memory, and writes back
32
+ * in debounced batches. An index key keeps track of which keys belong to
33
+ * fatigue-kit. Call `flush()` from an `AppState` "background" listener so the
34
+ * last writes survive an app kill.
35
+ *
36
+ * ```ts
37
+ * import AsyncStorage from '@react-native-async-storage/async-storage'
38
+ * const handle = asyncStorageAdapter(AsyncStorage)
39
+ * await handle.ready
40
+ * const fatigue = createFatigue({ storage: handle.storage })
41
+ * AppState.addEventListener('change', (state) => {
42
+ * if (state === 'background') handle.flush()
43
+ * })
44
+ * ```
45
+ */
46
+ declare function asyncStorageAdapter(client: AsyncStorageLike, options?: AsyncStorageAdapterOptions): AsyncStorageAdapter;
47
+
48
+ export { asyncStorageAdapter };
49
+ export type { AsyncStorageAdapter, AsyncStorageAdapterOptions, AsyncStorageLike };
@@ -0,0 +1,93 @@
1
+ // src/adapters/async-storage.ts
2
+ var DEFAULT_NAMESPACE = "fatigue-kit";
3
+ var DEFAULT_FLUSH_DELAY = 50;
4
+ function asyncStorageAdapter(client, options = {}) {
5
+ var _a, _b, _c;
6
+ const namespace = (_a = options.namespace) != null ? _a : DEFAULT_NAMESPACE;
7
+ const flushDelay = (_b = options.flushDelay) != null ? _b : DEFAULT_FLUSH_DELAY;
8
+ const onError = (_c = options.onError) != null ? _c : ((error) => {
9
+ console.warn("[fatigue-kit] async storage operation failed:", error);
10
+ });
11
+ const indexKey = `${namespace}:__index__`;
12
+ const cache = /* @__PURE__ */ new Map();
13
+ const pending = /* @__PURE__ */ new Map();
14
+ const index = /* @__PURE__ */ new Set();
15
+ let indexDirty = false;
16
+ let timer = null;
17
+ const safe = async (operation) => {
18
+ try {
19
+ return await operation();
20
+ } catch (error) {
21
+ onError(error);
22
+ return null;
23
+ }
24
+ };
25
+ const ready = (async () => {
26
+ const rawIndex = await safe(() => client.getItem(indexKey));
27
+ if (rawIndex !== null) {
28
+ try {
29
+ for (const key of JSON.parse(rawIndex)) index.add(key);
30
+ } catch (e) {
31
+ }
32
+ }
33
+ await Promise.all(
34
+ [...index].map(async (key) => {
35
+ cache.set(key, await safe(() => client.getItem(key)));
36
+ })
37
+ );
38
+ })();
39
+ async function flush() {
40
+ if (timer !== null) {
41
+ clearTimeout(timer);
42
+ timer = null;
43
+ }
44
+ const writes = [...pending];
45
+ pending.clear();
46
+ await Promise.all(
47
+ writes.map(
48
+ ([key, value]) => value === null ? safe(() => client.removeItem(key)) : safe(() => client.setItem(key, value))
49
+ )
50
+ );
51
+ if (indexDirty) {
52
+ indexDirty = false;
53
+ await safe(() => client.setItem(indexKey, JSON.stringify([...index])));
54
+ }
55
+ }
56
+ function schedule() {
57
+ if (timer !== null) return;
58
+ timer = setTimeout(() => {
59
+ timer = null;
60
+ void flush();
61
+ }, flushDelay);
62
+ }
63
+ const storage = {
64
+ get: (key) => {
65
+ var _a2;
66
+ return (_a2 = cache.get(key)) != null ? _a2 : null;
67
+ },
68
+ set: (key, value) => {
69
+ cache.set(key, value);
70
+ pending.set(key, value);
71
+ if (!index.has(key)) {
72
+ index.add(key);
73
+ indexDirty = true;
74
+ }
75
+ schedule();
76
+ },
77
+ remove: (key) => {
78
+ cache.delete(key);
79
+ pending.set(key, null);
80
+ if (index.has(key)) {
81
+ index.delete(key);
82
+ indexDirty = true;
83
+ }
84
+ schedule();
85
+ },
86
+ keys: () => [...index]
87
+ };
88
+ return { storage, ready, flush };
89
+ }
90
+ export {
91
+ asyncStorageAdapter
92
+ };
93
+ //# sourceMappingURL=async-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/async-storage.ts"],"sourcesContent":["import type { SyncStorage } from '../types'\n\n/**\n * Minimal interface shared by `@react-native-async-storage/async-storage` and\n * most RN-compatible storage libraries. Pass your storage instance directly.\n */\nexport interface AsyncStorageLike {\n\tgetItem(key: string): Promise<string | null>\n\tsetItem(key: string, value: string): Promise<void>\n\tremoveItem(key: string): Promise<void>\n}\n\nexport interface AsyncStorageAdapter {\n\t/** Synchronous view over the async backend. Only use it once `ready` resolved. */\n\tstorage: SyncStorage\n\t/** Resolves once the in-memory cache has been hydrated from the backend. */\n\tready: Promise<void>\n\t/** Persist pending writes now. Also runs automatically, debounced. */\n\tflush(): Promise<void>\n}\n\nexport interface AsyncStorageAdapterOptions {\n\t/** Must match the `namespace` of the fatigue instance. Default `'fatigue-kit'`. */\n\tnamespace?: string\n\t/** Debounce window for background flushes, ms. Default `50`. */\n\tflushDelay?: number\n\tonError?: (error: unknown) => void\n}\n\nconst DEFAULT_NAMESPACE = 'fatigue-kit'\nconst DEFAULT_FLUSH_DELAY = 50\n\n/**\n * React Native (and any async backend) adapter.\n *\n * The core engine is synchronous for atomicity, so this adapter hydrates all\n * known keys once up front (`ready`), serves reads from memory, and writes back\n * in debounced batches. An index key keeps track of which keys belong to\n * fatigue-kit. Call `flush()` from an `AppState` \"background\" listener so the\n * last writes survive an app kill.\n *\n * ```ts\n * import AsyncStorage from '@react-native-async-storage/async-storage'\n * const handle = asyncStorageAdapter(AsyncStorage)\n * await handle.ready\n * const fatigue = createFatigue({ storage: handle.storage })\n * AppState.addEventListener('change', (state) => {\n * if (state === 'background') handle.flush()\n * })\n * ```\n */\nexport function asyncStorageAdapter(\n\tclient: AsyncStorageLike,\n\toptions: AsyncStorageAdapterOptions = {},\n): AsyncStorageAdapter {\n\tconst namespace = options.namespace ?? DEFAULT_NAMESPACE\n\tconst flushDelay = options.flushDelay ?? DEFAULT_FLUSH_DELAY\n\tconst onError =\n\t\toptions.onError ??\n\t\t((error: unknown) => {\n\t\t\tconsole.warn('[fatigue-kit] async storage operation failed:', error)\n\t\t})\n\tconst indexKey = `${namespace}:__index__`\n\tconst cache = new Map<string, string | null>()\n\tconst pending = new Map<string, string | null>()\n\tconst index = new Set<string>()\n\tlet indexDirty = false\n\tlet timer: ReturnType<typeof setTimeout> | null = null\n\n\tconst safe = async <T>(operation: () => Promise<T>): Promise<T | null> => {\n\t\ttry {\n\t\t\treturn await operation()\n\t\t} catch (error) {\n\t\t\tonError(error)\n\t\t\treturn null\n\t\t}\n\t}\n\n\tconst ready = (async () => {\n\t\tconst rawIndex = await safe(() => client.getItem(indexKey))\n\t\tif (rawIndex !== null) {\n\t\t\ttry {\n\t\t\t\tfor (const key of JSON.parse(rawIndex) as string[]) index.add(key)\n\t\t\t} catch {\n\t\t\t\t// Corrupt index: start empty; keys re-register on their next write.\n\t\t\t}\n\t\t}\n\t\tawait Promise.all(\n\t\t\t[...index].map(async (key) => {\n\t\t\t\tcache.set(key, await safe(() => client.getItem(key)))\n\t\t\t}),\n\t\t)\n\t})()\n\n\tasync function flush(): Promise<void> {\n\t\tif (timer !== null) {\n\t\t\tclearTimeout(timer)\n\t\t\ttimer = null\n\t\t}\n\t\tconst writes = [...pending]\n\t\tpending.clear()\n\t\tawait Promise.all(\n\t\t\twrites.map(([key, value]) =>\n\t\t\t\tvalue === null\n\t\t\t\t\t? safe(() => client.removeItem(key))\n\t\t\t\t\t: safe(() => client.setItem(key, value)),\n\t\t\t),\n\t\t)\n\t\tif (indexDirty) {\n\t\t\tindexDirty = false\n\t\t\tawait safe(() => client.setItem(indexKey, JSON.stringify([...index])))\n\t\t}\n\t}\n\n\tfunction schedule(): void {\n\t\tif (timer !== null) return\n\t\ttimer = setTimeout(() => {\n\t\t\ttimer = null\n\t\t\tvoid flush()\n\t\t}, flushDelay)\n\t}\n\n\tconst storage: SyncStorage = {\n\t\tget: (key) => cache.get(key) ?? null,\n\t\tset: (key, value) => {\n\t\t\tcache.set(key, value)\n\t\t\tpending.set(key, value)\n\t\t\tif (!index.has(key)) {\n\t\t\t\tindex.add(key)\n\t\t\t\tindexDirty = true\n\t\t\t}\n\t\t\tschedule()\n\t\t},\n\t\tremove: (key) => {\n\t\t\tcache.delete(key)\n\t\t\tpending.set(key, null)\n\t\t\tif (index.has(key)) {\n\t\t\t\tindex.delete(key)\n\t\t\t\tindexDirty = true\n\t\t\t}\n\t\t\tschedule()\n\t\t},\n\t\tkeys: () => [...index],\n\t}\n\n\treturn { storage, ready, flush }\n}\n"],"mappings":";AA6BA,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAqBrB,SAAS,oBACf,QACA,UAAsC,CAAC,GACjB;AAtDvB;AAuDC,QAAM,aAAY,aAAQ,cAAR,YAAqB;AACvC,QAAM,cAAa,aAAQ,eAAR,YAAsB;AACzC,QAAM,WACL,aAAQ,YAAR,aACC,CAAC,UAAmB;AACpB,YAAQ,KAAK,iDAAiD,KAAK;AAAA,EACpE;AACD,QAAM,WAAW,GAAG,SAAS;AAC7B,QAAM,QAAQ,oBAAI,IAA2B;AAC7C,QAAM,UAAU,oBAAI,IAA2B;AAC/C,QAAM,QAAQ,oBAAI,IAAY;AAC9B,MAAI,aAAa;AACjB,MAAI,QAA8C;AAElD,QAAM,OAAO,OAAU,cAAmD;AACzE,QAAI;AACH,aAAO,MAAM,UAAU;AAAA,IACxB,SAAS,OAAO;AACf,cAAQ,KAAK;AACb,aAAO;AAAA,IACR;AAAA,EACD;AAEA,QAAM,SAAS,YAAY;AAC1B,UAAM,WAAW,MAAM,KAAK,MAAM,OAAO,QAAQ,QAAQ,CAAC;AAC1D,QAAI,aAAa,MAAM;AACtB,UAAI;AACH,mBAAW,OAAO,KAAK,MAAM,QAAQ,EAAe,OAAM,IAAI,GAAG;AAAA,MAClE,SAAQ;AAAA,MAER;AAAA,IACD;AACA,UAAM,QAAQ;AAAA,MACb,CAAC,GAAG,KAAK,EAAE,IAAI,OAAO,QAAQ;AAC7B,cAAM,IAAI,KAAK,MAAM,KAAK,MAAM,OAAO,QAAQ,GAAG,CAAC,CAAC;AAAA,MACrD,CAAC;AAAA,IACF;AAAA,EACD,GAAG;AAEH,iBAAe,QAAuB;AACrC,QAAI,UAAU,MAAM;AACnB,mBAAa,KAAK;AAClB,cAAQ;AAAA,IACT;AACA,UAAM,SAAS,CAAC,GAAG,OAAO;AAC1B,YAAQ,MAAM;AACd,UAAM,QAAQ;AAAA,MACb,OAAO;AAAA,QAAI,CAAC,CAAC,KAAK,KAAK,MACtB,UAAU,OACP,KAAK,MAAM,OAAO,WAAW,GAAG,CAAC,IACjC,KAAK,MAAM,OAAO,QAAQ,KAAK,KAAK,CAAC;AAAA,MACzC;AAAA,IACD;AACA,QAAI,YAAY;AACf,mBAAa;AACb,YAAM,KAAK,MAAM,OAAO,QAAQ,UAAU,KAAK,UAAU,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;AAAA,IACtE;AAAA,EACD;AAEA,WAAS,WAAiB;AACzB,QAAI,UAAU,KAAM;AACpB,YAAQ,WAAW,MAAM;AACxB,cAAQ;AACR,WAAK,MAAM;AAAA,IACZ,GAAG,UAAU;AAAA,EACd;AAEA,QAAM,UAAuB;AAAA,IAC5B,KAAK,CAAC,QAAK;AA3Hb,UAAAA;AA2HgB,cAAAA,MAAA,MAAM,IAAI,GAAG,MAAb,OAAAA,MAAkB;AAAA;AAAA,IAChC,KAAK,CAAC,KAAK,UAAU;AACpB,YAAM,IAAI,KAAK,KAAK;AACpB,cAAQ,IAAI,KAAK,KAAK;AACtB,UAAI,CAAC,MAAM,IAAI,GAAG,GAAG;AACpB,cAAM,IAAI,GAAG;AACb,qBAAa;AAAA,MACd;AACA,eAAS;AAAA,IACV;AAAA,IACA,QAAQ,CAAC,QAAQ;AAChB,YAAM,OAAO,GAAG;AAChB,cAAQ,IAAI,KAAK,IAAI;AACrB,UAAI,MAAM,IAAI,GAAG,GAAG;AACnB,cAAM,OAAO,GAAG;AAChB,qBAAa;AAAA,MACd;AACA,eAAS;AAAA,IACV;AAAA,IACA,MAAM,MAAM,CAAC,GAAG,KAAK;AAAA,EACtB;AAEA,SAAO,EAAE,SAAS,OAAO,MAAM;AAChC;","names":["_a"]}
@@ -0,0 +1,24 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkDABM2TVRcjs = require('../chunk-DABM2TVR.cjs');
5
+
6
+ // src/adapters/local-storage.ts
7
+ function requireLocalStorage() {
8
+ const storage = _chunkDABM2TVRcjs.globalStorage.call(void 0, "localStorage");
9
+ if (storage === void 0) {
10
+ throw new Error(
11
+ "[fatigue-kit] localStorageAdapter: `localStorage` is not available in this environment. Pass `{ storage }` explicitly (tests, SSR, webviews)."
12
+ );
13
+ }
14
+ return storage;
15
+ }
16
+ function localStorageAdapter(options = {}) {
17
+ var _a;
18
+ const storage = (_a = options.storage) != null ? _a : requireLocalStorage();
19
+ return _chunkDABM2TVRcjs.webStorageAdapter.call(void 0, () => storage, options.onError);
20
+ }
21
+
22
+
23
+ exports.localStorageAdapter = localStorageAdapter;
24
+ //# sourceMappingURL=local-storage.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/fatigue-kit/fatigue-kit/dist/adapters/local-storage.cjs","../../src/adapters/local-storage.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,yDAA8B;AAC9B;AACA;ACFA,SAAS,mBAAA,CAAA,EAA+B;AACvC,EAAA,MAAM,QAAA,EAAU,6CAAA,cAA4B,CAAA;AAC5C,EAAA,GAAA,CAAI,QAAA,IAAY,KAAA,CAAA,EAAW;AAC1B,IAAA,MAAM,IAAI,KAAA;AAAA,MACT;AAAA,IACD,CAAA;AAAA,EACD;AACA,EAAA,OAAO,OAAA;AACR;AAUO,SAAS,mBAAA,CAAoB,QAAA,EAAoC,CAAC,CAAA,EAAgB;AArBzF,EAAA,IAAA,EAAA;AAsBC,EAAA,MAAM,QAAA,EAAA,CAAU,GAAA,EAAA,OAAA,CAAQ,OAAA,EAAA,GAAR,KAAA,EAAA,GAAA,EAAmB,mBAAA,CAAoB,CAAA;AACvD,EAAA,OAAO,iDAAA,CAAkB,EAAA,GAAM,OAAA,EAAS,OAAA,CAAQ,OAAO,CAAA;AACxD;ADJA;AACE;AACF,kDAAC","file":"/home/runner/work/fatigue-kit/fatigue-kit/dist/adapters/local-storage.cjs","sourcesContent":[null,"import type { SyncStorage } from '../types'\nimport { globalStorage, type WebStorageAdapterOptions, webStorageAdapter } from './web'\n\nfunction requireLocalStorage(): Storage {\n\tconst storage = globalStorage('localStorage')\n\tif (storage === undefined) {\n\t\tthrow new Error(\n\t\t\t'[fatigue-kit] localStorageAdapter: `localStorage` is not available in this environment. Pass `{ storage }` explicitly (tests, SSR, webviews).',\n\t\t)\n\t}\n\treturn storage\n}\n\n/**\n * Web / H5 adapter backed by `localStorage`. Data survives reloads and browser\n * restarts, shared across all tabs of the origin.\n *\n * Throws at construction when `localStorage` is unavailable and no `storage`\n * option was given; failures during operation are reported via `onError`\n * instead of thrown.\n */\nexport function localStorageAdapter(options: WebStorageAdapterOptions = {}): SyncStorage {\n\tconst storage = options.storage ?? requireLocalStorage()\n\treturn webStorageAdapter(() => storage, options.onError)\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { SyncStorage } from '../index.cjs';
2
+ import { W as WebStorageAdapterOptions } from '../web-GiaS0cnX.cjs';
3
+
4
+ /**
5
+ * Web / H5 adapter backed by `localStorage`. Data survives reloads and browser
6
+ * restarts, shared across all tabs of the origin.
7
+ *
8
+ * Throws at construction when `localStorage` is unavailable and no `storage`
9
+ * option was given; failures during operation are reported via `onError`
10
+ * instead of thrown.
11
+ */
12
+ declare function localStorageAdapter(options?: WebStorageAdapterOptions): SyncStorage;
13
+
14
+ export { localStorageAdapter };
@@ -0,0 +1,14 @@
1
+ import { SyncStorage } from '../index.js';
2
+ import { W as WebStorageAdapterOptions } from '../web-GiaS0cnX.js';
3
+
4
+ /**
5
+ * Web / H5 adapter backed by `localStorage`. Data survives reloads and browser
6
+ * restarts, shared across all tabs of the origin.
7
+ *
8
+ * Throws at construction when `localStorage` is unavailable and no `storage`
9
+ * option was given; failures during operation are reported via `onError`
10
+ * instead of thrown.
11
+ */
12
+ declare function localStorageAdapter(options?: WebStorageAdapterOptions): SyncStorage;
13
+
14
+ export { localStorageAdapter };
@@ -0,0 +1,24 @@
1
+ import {
2
+ globalStorage,
3
+ webStorageAdapter
4
+ } from "../chunk-GMM2BYRQ.js";
5
+
6
+ // src/adapters/local-storage.ts
7
+ function requireLocalStorage() {
8
+ const storage = globalStorage("localStorage");
9
+ if (storage === void 0) {
10
+ throw new Error(
11
+ "[fatigue-kit] localStorageAdapter: `localStorage` is not available in this environment. Pass `{ storage }` explicitly (tests, SSR, webviews)."
12
+ );
13
+ }
14
+ return storage;
15
+ }
16
+ function localStorageAdapter(options = {}) {
17
+ var _a;
18
+ const storage = (_a = options.storage) != null ? _a : requireLocalStorage();
19
+ return webStorageAdapter(() => storage, options.onError);
20
+ }
21
+ export {
22
+ localStorageAdapter
23
+ };
24
+ //# sourceMappingURL=local-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/local-storage.ts"],"sourcesContent":["import type { SyncStorage } from '../types'\nimport { globalStorage, type WebStorageAdapterOptions, webStorageAdapter } from './web'\n\nfunction requireLocalStorage(): Storage {\n\tconst storage = globalStorage('localStorage')\n\tif (storage === undefined) {\n\t\tthrow new Error(\n\t\t\t'[fatigue-kit] localStorageAdapter: `localStorage` is not available in this environment. Pass `{ storage }` explicitly (tests, SSR, webviews).',\n\t\t)\n\t}\n\treturn storage\n}\n\n/**\n * Web / H5 adapter backed by `localStorage`. Data survives reloads and browser\n * restarts, shared across all tabs of the origin.\n *\n * Throws at construction when `localStorage` is unavailable and no `storage`\n * option was given; failures during operation are reported via `onError`\n * instead of thrown.\n */\nexport function localStorageAdapter(options: WebStorageAdapterOptions = {}): SyncStorage {\n\tconst storage = options.storage ?? requireLocalStorage()\n\treturn webStorageAdapter(() => storage, options.onError)\n}\n"],"mappings":";;;;;;AAGA,SAAS,sBAA+B;AACvC,QAAM,UAAU,cAAc,cAAc;AAC5C,MAAI,YAAY,QAAW;AAC1B,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;AAUO,SAAS,oBAAoB,UAAoC,CAAC,GAAgB;AArBzF;AAsBC,QAAM,WAAU,aAAQ,YAAR,YAAmB,oBAAoB;AACvD,SAAO,kBAAkB,MAAM,SAAS,QAAQ,OAAO;AACxD;","names":[]}
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkNBDAXDB6cjs = require('../chunk-NBDAXDB6.cjs');
4
+
5
+
6
+ exports.memoryAdapter = _chunkNBDAXDB6cjs.memoryAdapter;
7
+ //# sourceMappingURL=memory.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/fatigue-kit/fatigue-kit/dist/adapters/memory.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,wDAAC","file":"/home/runner/work/fatigue-kit/fatigue-kit/dist/adapters/memory.cjs"}
@@ -0,0 +1,15 @@
1
+ import { SyncStorage } from '../index.cjs';
2
+
3
+ interface MemoryAdapter extends SyncStorage {
4
+ /** Snapshot of the underlying map. Handy for tests and debugging. */
5
+ dump(): Record<string, string>;
6
+ }
7
+ /**
8
+ * In-memory adapter. This is the default storage of `createFatigue` and the
9
+ * right choice for unit tests, SSR and stateless Node.js scripts.
10
+ * Data lives exactly as long as the fatigue instance (or the process) does.
11
+ */
12
+ declare function memoryAdapter(initial?: Record<string, string>): MemoryAdapter;
13
+
14
+ export { memoryAdapter };
15
+ export type { MemoryAdapter };
@@ -0,0 +1,15 @@
1
+ import { SyncStorage } from '../index.js';
2
+
3
+ interface MemoryAdapter extends SyncStorage {
4
+ /** Snapshot of the underlying map. Handy for tests and debugging. */
5
+ dump(): Record<string, string>;
6
+ }
7
+ /**
8
+ * In-memory adapter. This is the default storage of `createFatigue` and the
9
+ * right choice for unit tests, SSR and stateless Node.js scripts.
10
+ * Data lives exactly as long as the fatigue instance (or the process) does.
11
+ */
12
+ declare function memoryAdapter(initial?: Record<string, string>): MemoryAdapter;
13
+
14
+ export { memoryAdapter };
15
+ export type { MemoryAdapter };
@@ -0,0 +1,7 @@
1
+ import {
2
+ memoryAdapter
3
+ } from "../chunk-DM2CAKGU.js";
4
+ export {
5
+ memoryAdapter
6
+ };
7
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,53 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/adapters/node-file.ts
2
+ var _fs = require('fs');
3
+ var _path = require('path');
4
+ function fileAdapter(filePath, options = {}) {
5
+ var _a;
6
+ const onError = (_a = options.onError) != null ? _a : ((error) => {
7
+ console.warn("[fatigue-kit] file storage operation failed:", error);
8
+ });
9
+ let cache = null;
10
+ const load = () => {
11
+ if (cache !== null) return cache;
12
+ try {
13
+ const parsed = JSON.parse(_fs.readFileSync.call(void 0, filePath, "utf8"));
14
+ cache = parsed !== null && typeof parsed === "object" ? parsed : {};
15
+ } catch (e) {
16
+ cache = {};
17
+ }
18
+ return cache;
19
+ };
20
+ const persist = () => {
21
+ try {
22
+ _fs.mkdirSync.call(void 0, _path.dirname.call(void 0, filePath), { recursive: true });
23
+ const tempPath = `${filePath}.${process.pid}.tmp`;
24
+ _fs.writeFileSync.call(void 0,
25
+ tempPath,
26
+ JSON.stringify(load(), null, options.pretty === true ? 2 : void 0),
27
+ "utf8"
28
+ );
29
+ _fs.renameSync.call(void 0, tempPath, filePath);
30
+ } catch (error) {
31
+ onError(error);
32
+ }
33
+ };
34
+ return {
35
+ get: (key) => {
36
+ var _a2;
37
+ return (_a2 = load()[key]) != null ? _a2 : null;
38
+ },
39
+ set: (key, value) => {
40
+ load()[key] = value;
41
+ persist();
42
+ },
43
+ remove: (key) => {
44
+ delete load()[key];
45
+ persist();
46
+ },
47
+ keys: () => Object.keys(load())
48
+ };
49
+ }
50
+
51
+
52
+ exports.fileAdapter = fileAdapter;
53
+ //# sourceMappingURL=node-file.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/fatigue-kit/fatigue-kit/dist/adapters/node-file.cjs","../../src/adapters/node-file.ts"],"names":["_a"],"mappings":"AAAA;ACAA,wBAAmE;AACnE,4BAAwB;AAcjB,SAAS,WAAA,CAAY,QAAA,EAAkB,QAAA,EAA8B,CAAC,CAAA,EAAgB;AAf7F,EAAA,IAAA,EAAA;AAgBC,EAAA,MAAM,QAAA,EAAA,CACL,GAAA,EAAA,OAAA,CAAQ,OAAA,EAAA,GAAR,KAAA,EAAA,GAAA,EAAA,CACC,CAAC,KAAA,EAAA,GAAmB;AACpB,IAAA,OAAA,CAAQ,IAAA,CAAK,8CAAA,EAAgD,KAAK,CAAA;AAAA,EACnE,CAAA,CAAA;AACD,EAAA,IAAI,MAAA,EAAuC,IAAA;AAE3C,EAAA,MAAM,KAAA,EAAO,CAAA,EAAA,GAA8B;AAC1C,IAAA,GAAA,CAAI,MAAA,IAAU,IAAA,EAAM,OAAO,KAAA;AAC3B,IAAA,IAAI;AACH,MAAA,MAAM,OAAA,EAAkB,IAAA,CAAK,KAAA,CAAM,8BAAA,QAAa,EAAU,MAAM,CAAC,CAAA;AACjE,MAAA,MAAA,EACC,OAAA,IAAW,KAAA,GAAQ,OAAO,OAAA,IAAW,SAAA,EAAY,OAAA,EAAoC,CAAC,CAAA;AAAA,IACxF,EAAA,MAAA,CAAQ,CAAA,EAAA;AACP,MAAA,MAAA,EAAQ,CAAC,CAAA;AAAA,IACV;AACA,IAAA,OAAO,KAAA;AAAA,EACR,CAAA;AAEA,EAAA,MAAM,QAAA,EAAU,CAAA,EAAA,GAAY;AAC3B,IAAA,IAAI;AACH,MAAA,2BAAA,2BAAU,QAAgB,CAAA,EAAG,EAAE,SAAA,EAAW,KAAK,CAAC,CAAA;AAChD,MAAA,MAAM,SAAA,EAAW,CAAA,EAAA;AACjB,MAAA;AACC,QAAA;AACe,QAAA;AACf,QAAA;AACD,MAAA;AACW,MAAA;AACI,IAAA;AACF,MAAA;AACd,IAAA;AACD,EAAA;AAEO,EAAA;AACK,IAAA;AAnDbA,MAAAA;AAmDgB,MAAA;AAAe,IAAA;AAClB,IAAA;AACI,MAAA;AACN,MAAA;AACT,IAAA;AACiB,IAAA;AACC,MAAA;AACT,MAAA;AACT,IAAA;AACmB,IAAA;AACpB,EAAA;AACD;ADbwB;AACA;AACA","file":"/home/runner/work/fatigue-kit/fatigue-kit/dist/adapters/node-file.cjs","sourcesContent":[null,"import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport type { SyncStorage } from '../types'\n\nexport interface FileAdapterOptions {\n\t/** Pretty-print the backing JSON file. Default `false`. */\n\tpretty?: boolean\n\tonError?: (error: unknown) => void\n}\n\n/**\n * Node.js adapter persisting all records in a single JSON file.\n * Writes go through a temp file + rename, so a crash never leaves a\n * half-written file behind. The first access creates parent directories.\n */\nexport function fileAdapter(filePath: string, options: FileAdapterOptions = {}): SyncStorage {\n\tconst onError =\n\t\toptions.onError ??\n\t\t((error: unknown) => {\n\t\t\tconsole.warn('[fatigue-kit] file storage operation failed:', error)\n\t\t})\n\tlet cache: Record<string, string> | null = null\n\n\tconst load = (): Record<string, string> => {\n\t\tif (cache !== null) return cache\n\t\ttry {\n\t\t\tconst parsed: unknown = JSON.parse(readFileSync(filePath, 'utf8'))\n\t\t\tcache =\n\t\t\t\tparsed !== null && typeof parsed === 'object' ? (parsed as Record<string, string>) : {}\n\t\t} catch {\n\t\t\tcache = {}\n\t\t}\n\t\treturn cache\n\t}\n\n\tconst persist = (): void => {\n\t\ttry {\n\t\t\tmkdirSync(dirname(filePath), { recursive: true })\n\t\t\tconst tempPath = `${filePath}.${process.pid}.tmp`\n\t\t\twriteFileSync(\n\t\t\t\ttempPath,\n\t\t\t\tJSON.stringify(load(), null, options.pretty === true ? 2 : undefined),\n\t\t\t\t'utf8',\n\t\t\t)\n\t\t\trenameSync(tempPath, filePath)\n\t\t} catch (error) {\n\t\t\tonError(error)\n\t\t}\n\t}\n\n\treturn {\n\t\tget: (key) => load()[key] ?? null,\n\t\tset: (key, value) => {\n\t\t\tload()[key] = value\n\t\t\tpersist()\n\t\t},\n\t\tremove: (key) => {\n\t\t\tdelete load()[key]\n\t\t\tpersist()\n\t\t},\n\t\tkeys: () => Object.keys(load()),\n\t}\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { SyncStorage } from '../index.cjs';
2
+
3
+ interface FileAdapterOptions {
4
+ /** Pretty-print the backing JSON file. Default `false`. */
5
+ pretty?: boolean;
6
+ onError?: (error: unknown) => void;
7
+ }
8
+ /**
9
+ * Node.js adapter persisting all records in a single JSON file.
10
+ * Writes go through a temp file + rename, so a crash never leaves a
11
+ * half-written file behind. The first access creates parent directories.
12
+ */
13
+ declare function fileAdapter(filePath: string, options?: FileAdapterOptions): SyncStorage;
14
+
15
+ export { fileAdapter };
16
+ export type { FileAdapterOptions };
@@ -0,0 +1,16 @@
1
+ import { SyncStorage } from '../index.js';
2
+
3
+ interface FileAdapterOptions {
4
+ /** Pretty-print the backing JSON file. Default `false`. */
5
+ pretty?: boolean;
6
+ onError?: (error: unknown) => void;
7
+ }
8
+ /**
9
+ * Node.js adapter persisting all records in a single JSON file.
10
+ * Writes go through a temp file + rename, so a crash never leaves a
11
+ * half-written file behind. The first access creates parent directories.
12
+ */
13
+ declare function fileAdapter(filePath: string, options?: FileAdapterOptions): SyncStorage;
14
+
15
+ export { fileAdapter };
16
+ export type { FileAdapterOptions };
@@ -0,0 +1,53 @@
1
+ // src/adapters/node-file.ts
2
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
3
+ import { dirname } from "path";
4
+ function fileAdapter(filePath, options = {}) {
5
+ var _a;
6
+ const onError = (_a = options.onError) != null ? _a : ((error) => {
7
+ console.warn("[fatigue-kit] file storage operation failed:", error);
8
+ });
9
+ let cache = null;
10
+ const load = () => {
11
+ if (cache !== null) return cache;
12
+ try {
13
+ const parsed = JSON.parse(readFileSync(filePath, "utf8"));
14
+ cache = parsed !== null && typeof parsed === "object" ? parsed : {};
15
+ } catch (e) {
16
+ cache = {};
17
+ }
18
+ return cache;
19
+ };
20
+ const persist = () => {
21
+ try {
22
+ mkdirSync(dirname(filePath), { recursive: true });
23
+ const tempPath = `${filePath}.${process.pid}.tmp`;
24
+ writeFileSync(
25
+ tempPath,
26
+ JSON.stringify(load(), null, options.pretty === true ? 2 : void 0),
27
+ "utf8"
28
+ );
29
+ renameSync(tempPath, filePath);
30
+ } catch (error) {
31
+ onError(error);
32
+ }
33
+ };
34
+ return {
35
+ get: (key) => {
36
+ var _a2;
37
+ return (_a2 = load()[key]) != null ? _a2 : null;
38
+ },
39
+ set: (key, value) => {
40
+ load()[key] = value;
41
+ persist();
42
+ },
43
+ remove: (key) => {
44
+ delete load()[key];
45
+ persist();
46
+ },
47
+ keys: () => Object.keys(load())
48
+ };
49
+ }
50
+ export {
51
+ fileAdapter
52
+ };
53
+ //# sourceMappingURL=node-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/node-file.ts"],"sourcesContent":["import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport type { SyncStorage } from '../types'\n\nexport interface FileAdapterOptions {\n\t/** Pretty-print the backing JSON file. Default `false`. */\n\tpretty?: boolean\n\tonError?: (error: unknown) => void\n}\n\n/**\n * Node.js adapter persisting all records in a single JSON file.\n * Writes go through a temp file + rename, so a crash never leaves a\n * half-written file behind. The first access creates parent directories.\n */\nexport function fileAdapter(filePath: string, options: FileAdapterOptions = {}): SyncStorage {\n\tconst onError =\n\t\toptions.onError ??\n\t\t((error: unknown) => {\n\t\t\tconsole.warn('[fatigue-kit] file storage operation failed:', error)\n\t\t})\n\tlet cache: Record<string, string> | null = null\n\n\tconst load = (): Record<string, string> => {\n\t\tif (cache !== null) return cache\n\t\ttry {\n\t\t\tconst parsed: unknown = JSON.parse(readFileSync(filePath, 'utf8'))\n\t\t\tcache =\n\t\t\t\tparsed !== null && typeof parsed === 'object' ? (parsed as Record<string, string>) : {}\n\t\t} catch {\n\t\t\tcache = {}\n\t\t}\n\t\treturn cache\n\t}\n\n\tconst persist = (): void => {\n\t\ttry {\n\t\t\tmkdirSync(dirname(filePath), { recursive: true })\n\t\t\tconst tempPath = `${filePath}.${process.pid}.tmp`\n\t\t\twriteFileSync(\n\t\t\t\ttempPath,\n\t\t\t\tJSON.stringify(load(), null, options.pretty === true ? 2 : undefined),\n\t\t\t\t'utf8',\n\t\t\t)\n\t\t\trenameSync(tempPath, filePath)\n\t\t} catch (error) {\n\t\t\tonError(error)\n\t\t}\n\t}\n\n\treturn {\n\t\tget: (key) => load()[key] ?? null,\n\t\tset: (key, value) => {\n\t\t\tload()[key] = value\n\t\t\tpersist()\n\t\t},\n\t\tremove: (key) => {\n\t\t\tdelete load()[key]\n\t\t\tpersist()\n\t\t},\n\t\tkeys: () => Object.keys(load()),\n\t}\n}\n"],"mappings":";AAAA,SAAS,WAAW,cAAc,YAAY,qBAAqB;AACnE,SAAS,eAAe;AAcjB,SAAS,YAAY,UAAkB,UAA8B,CAAC,GAAgB;AAf7F;AAgBC,QAAM,WACL,aAAQ,YAAR,aACC,CAAC,UAAmB;AACpB,YAAQ,KAAK,gDAAgD,KAAK;AAAA,EACnE;AACD,MAAI,QAAuC;AAE3C,QAAM,OAAO,MAA8B;AAC1C,QAAI,UAAU,KAAM,QAAO;AAC3B,QAAI;AACH,YAAM,SAAkB,KAAK,MAAM,aAAa,UAAU,MAAM,CAAC;AACjE,cACC,WAAW,QAAQ,OAAO,WAAW,WAAY,SAAoC,CAAC;AAAA,IACxF,SAAQ;AACP,cAAQ,CAAC;AAAA,IACV;AACA,WAAO;AAAA,EACR;AAEA,QAAM,UAAU,MAAY;AAC3B,QAAI;AACH,gBAAU,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;AAChD,YAAM,WAAW,GAAG,QAAQ,IAAI,QAAQ,GAAG;AAC3C;AAAA,QACC;AAAA,QACA,KAAK,UAAU,KAAK,GAAG,MAAM,QAAQ,WAAW,OAAO,IAAI,MAAS;AAAA,QACpE;AAAA,MACD;AACA,iBAAW,UAAU,QAAQ;AAAA,IAC9B,SAAS,OAAO;AACf,cAAQ,KAAK;AAAA,IACd;AAAA,EACD;AAEA,SAAO;AAAA,IACN,KAAK,CAAC,QAAK;AAnDb,UAAAA;AAmDgB,cAAAA,MAAA,KAAK,EAAE,GAAG,MAAV,OAAAA,MAAe;AAAA;AAAA,IAC7B,KAAK,CAAC,KAAK,UAAU;AACpB,WAAK,EAAE,GAAG,IAAI;AACd,cAAQ;AAAA,IACT;AAAA,IACA,QAAQ,CAAC,QAAQ;AAChB,aAAO,KAAK,EAAE,GAAG;AACjB,cAAQ;AAAA,IACT;AAAA,IACA,MAAM,MAAM,OAAO,KAAK,KAAK,CAAC;AAAA,EAC/B;AACD;","names":["_a"]}
@@ -0,0 +1,24 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkDABM2TVRcjs = require('../chunk-DABM2TVR.cjs');
5
+
6
+ // src/adapters/session-storage.ts
7
+ function requireSessionStorage() {
8
+ const storage = _chunkDABM2TVRcjs.globalStorage.call(void 0, "sessionStorage");
9
+ if (storage === void 0) {
10
+ throw new Error(
11
+ "[fatigue-kit] sessionStorageAdapter: `sessionStorage` is not available in this environment. Pass `{ storage }` explicitly (tests, SSR, webviews)."
12
+ );
13
+ }
14
+ return storage;
15
+ }
16
+ function sessionStorageAdapter(options = {}) {
17
+ var _a;
18
+ const storage = (_a = options.storage) != null ? _a : requireSessionStorage();
19
+ return _chunkDABM2TVRcjs.webStorageAdapter.call(void 0, () => storage, options.onError);
20
+ }
21
+
22
+
23
+ exports.sessionStorageAdapter = sessionStorageAdapter;
24
+ //# sourceMappingURL=session-storage.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/fatigue-kit/fatigue-kit/dist/adapters/session-storage.cjs","../../src/adapters/session-storage.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,yDAA8B;AAC9B;AACA;ACFA,SAAS,qBAAA,CAAA,EAAiC;AACzC,EAAA,MAAM,QAAA,EAAU,6CAAA,gBAA8B,CAAA;AAC9C,EAAA,GAAA,CAAI,QAAA,IAAY,KAAA,CAAA,EAAW;AAC1B,IAAA,MAAM,IAAI,KAAA;AAAA,MACT;AAAA,IACD,CAAA;AAAA,EACD;AACA,EAAA,OAAO,OAAA;AACR;AAUO,SAAS,qBAAA,CAAsB,QAAA,EAAoC,CAAC,CAAA,EAAgB;AArB3F,EAAA,IAAA,EAAA;AAsBC,EAAA,MAAM,QAAA,EAAA,CAAU,GAAA,EAAA,OAAA,CAAQ,OAAA,EAAA,GAAR,KAAA,EAAA,GAAA,EAAmB,qBAAA,CAAsB,CAAA;AACzD,EAAA,OAAO,iDAAA,CAAkB,EAAA,GAAM,OAAA,EAAS,OAAA,CAAQ,OAAO,CAAA;AACxD;ADJA;AACE;AACF,sDAAC","file":"/home/runner/work/fatigue-kit/fatigue-kit/dist/adapters/session-storage.cjs","sourcesContent":[null,"import type { SyncStorage } from '../types'\nimport { globalStorage, type WebStorageAdapterOptions, webStorageAdapter } from './web'\n\nfunction requireSessionStorage(): Storage {\n\tconst storage = globalStorage('sessionStorage')\n\tif (storage === undefined) {\n\t\tthrow new Error(\n\t\t\t'[fatigue-kit] sessionStorageAdapter: `sessionStorage` is not available in this environment. Pass `{ storage }` explicitly (tests, SSR, webviews).',\n\t\t)\n\t}\n\treturn storage\n}\n\n/**\n * Web / H5 adapter backed by `sessionStorage`. Data lives per tab and is\n * cleared when the tab closes — use it for \"once per visit\" style capping.\n *\n * Throws at construction when `sessionStorage` is unavailable and no `storage`\n * option was given; failures during operation are reported via `onError`\n * instead of thrown.\n */\nexport function sessionStorageAdapter(options: WebStorageAdapterOptions = {}): SyncStorage {\n\tconst storage = options.storage ?? requireSessionStorage()\n\treturn webStorageAdapter(() => storage, options.onError)\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { SyncStorage } from '../index.cjs';
2
+ import { W as WebStorageAdapterOptions } from '../web-GiaS0cnX.cjs';
3
+
4
+ /**
5
+ * Web / H5 adapter backed by `sessionStorage`. Data lives per tab and is
6
+ * cleared when the tab closes — use it for "once per visit" style capping.
7
+ *
8
+ * Throws at construction when `sessionStorage` is unavailable and no `storage`
9
+ * option was given; failures during operation are reported via `onError`
10
+ * instead of thrown.
11
+ */
12
+ declare function sessionStorageAdapter(options?: WebStorageAdapterOptions): SyncStorage;
13
+
14
+ export { sessionStorageAdapter };
@@ -0,0 +1,14 @@
1
+ import { SyncStorage } from '../index.js';
2
+ import { W as WebStorageAdapterOptions } from '../web-GiaS0cnX.js';
3
+
4
+ /**
5
+ * Web / H5 adapter backed by `sessionStorage`. Data lives per tab and is
6
+ * cleared when the tab closes — use it for "once per visit" style capping.
7
+ *
8
+ * Throws at construction when `sessionStorage` is unavailable and no `storage`
9
+ * option was given; failures during operation are reported via `onError`
10
+ * instead of thrown.
11
+ */
12
+ declare function sessionStorageAdapter(options?: WebStorageAdapterOptions): SyncStorage;
13
+
14
+ export { sessionStorageAdapter };
@@ -0,0 +1,24 @@
1
+ import {
2
+ globalStorage,
3
+ webStorageAdapter
4
+ } from "../chunk-GMM2BYRQ.js";
5
+
6
+ // src/adapters/session-storage.ts
7
+ function requireSessionStorage() {
8
+ const storage = globalStorage("sessionStorage");
9
+ if (storage === void 0) {
10
+ throw new Error(
11
+ "[fatigue-kit] sessionStorageAdapter: `sessionStorage` is not available in this environment. Pass `{ storage }` explicitly (tests, SSR, webviews)."
12
+ );
13
+ }
14
+ return storage;
15
+ }
16
+ function sessionStorageAdapter(options = {}) {
17
+ var _a;
18
+ const storage = (_a = options.storage) != null ? _a : requireSessionStorage();
19
+ return webStorageAdapter(() => storage, options.onError);
20
+ }
21
+ export {
22
+ sessionStorageAdapter
23
+ };
24
+ //# sourceMappingURL=session-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/session-storage.ts"],"sourcesContent":["import type { SyncStorage } from '../types'\nimport { globalStorage, type WebStorageAdapterOptions, webStorageAdapter } from './web'\n\nfunction requireSessionStorage(): Storage {\n\tconst storage = globalStorage('sessionStorage')\n\tif (storage === undefined) {\n\t\tthrow new Error(\n\t\t\t'[fatigue-kit] sessionStorageAdapter: `sessionStorage` is not available in this environment. Pass `{ storage }` explicitly (tests, SSR, webviews).',\n\t\t)\n\t}\n\treturn storage\n}\n\n/**\n * Web / H5 adapter backed by `sessionStorage`. Data lives per tab and is\n * cleared when the tab closes — use it for \"once per visit\" style capping.\n *\n * Throws at construction when `sessionStorage` is unavailable and no `storage`\n * option was given; failures during operation are reported via `onError`\n * instead of thrown.\n */\nexport function sessionStorageAdapter(options: WebStorageAdapterOptions = {}): SyncStorage {\n\tconst storage = options.storage ?? requireSessionStorage()\n\treturn webStorageAdapter(() => storage, options.onError)\n}\n"],"mappings":";;;;;;AAGA,SAAS,wBAAiC;AACzC,QAAM,UAAU,cAAc,gBAAgB;AAC9C,MAAI,YAAY,QAAW;AAC1B,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;AAUO,SAAS,sBAAsB,UAAoC,CAAC,GAAgB;AArB3F;AAsBC,QAAM,WAAU,aAAQ,YAAR,YAAmB,sBAAsB;AACzD,SAAO,kBAAkB,MAAM,SAAS,QAAQ,OAAO;AACxD;","names":[]}