@yh-ui/request 0.1.21

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 (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +274 -0
  3. package/dist/adapters/fetch.cjs +157 -0
  4. package/dist/adapters/fetch.d.ts +25 -0
  5. package/dist/adapters/fetch.mjs +148 -0
  6. package/dist/adapters/index.cjs +27 -0
  7. package/dist/adapters/index.d.ts +5 -0
  8. package/dist/adapters/index.mjs +2 -0
  9. package/dist/adapters/platform.cjs +394 -0
  10. package/dist/adapters/platform.d.ts +72 -0
  11. package/dist/adapters/platform.mjs +369 -0
  12. package/dist/cache/index.cjs +56 -0
  13. package/dist/cache/index.d.ts +21 -0
  14. package/dist/cache/index.mjs +14 -0
  15. package/dist/cache/indexedDB.cjs +188 -0
  16. package/dist/cache/indexedDB.d.ts +58 -0
  17. package/dist/cache/indexedDB.mjs +176 -0
  18. package/dist/cache/localStorage.cjs +158 -0
  19. package/dist/cache/localStorage.d.ts +58 -0
  20. package/dist/cache/localStorage.mjs +153 -0
  21. package/dist/cache/memory.cjs +112 -0
  22. package/dist/cache/memory.d.ts +71 -0
  23. package/dist/cache/memory.mjs +103 -0
  24. package/dist/graphql.cjs +255 -0
  25. package/dist/graphql.d.ts +192 -0
  26. package/dist/graphql.mjs +235 -0
  27. package/dist/http-cache.cjs +248 -0
  28. package/dist/http-cache.d.ts +156 -0
  29. package/dist/http-cache.mjs +233 -0
  30. package/dist/index.cjs +181 -0
  31. package/dist/index.d.ts +23 -0
  32. package/dist/index.mjs +16 -0
  33. package/dist/interceptors/debug.cjs +139 -0
  34. package/dist/interceptors/debug.d.ts +92 -0
  35. package/dist/interceptors/debug.mjs +130 -0
  36. package/dist/interceptors/index.cjs +38 -0
  37. package/dist/interceptors/index.d.ts +6 -0
  38. package/dist/interceptors/index.mjs +3 -0
  39. package/dist/interceptors/progress.cjs +185 -0
  40. package/dist/interceptors/progress.d.ts +97 -0
  41. package/dist/interceptors/progress.mjs +177 -0
  42. package/dist/interceptors/security.cjs +154 -0
  43. package/dist/interceptors/security.d.ts +83 -0
  44. package/dist/interceptors/security.mjs +134 -0
  45. package/dist/plugin.cjs +166 -0
  46. package/dist/plugin.d.ts +106 -0
  47. package/dist/plugin.mjs +163 -0
  48. package/dist/request.cjs +396 -0
  49. package/dist/request.d.ts +111 -0
  50. package/dist/request.mjs +339 -0
  51. package/dist/types.cjs +13 -0
  52. package/dist/types.d.ts +157 -0
  53. package/dist/types.mjs +7 -0
  54. package/dist/useAIStream.cjs +125 -0
  55. package/dist/useAIStream.d.ts +89 -0
  56. package/dist/useAIStream.mjs +108 -0
  57. package/dist/useLoadMore.cjs +136 -0
  58. package/dist/useLoadMore.d.ts +84 -0
  59. package/dist/useLoadMore.mjs +134 -0
  60. package/dist/usePagination.cjs +141 -0
  61. package/dist/usePagination.d.ts +89 -0
  62. package/dist/usePagination.mjs +132 -0
  63. package/dist/useQueue.cjs +243 -0
  64. package/dist/useQueue.d.ts +118 -0
  65. package/dist/useQueue.mjs +239 -0
  66. package/dist/useRequest.cjs +325 -0
  67. package/dist/useRequest.d.ts +126 -0
  68. package/dist/useRequest.mjs +329 -0
  69. package/dist/useRequestQueue.cjs +36 -0
  70. package/dist/useRequestQueue.d.ts +52 -0
  71. package/dist/useRequestQueue.mjs +27 -0
  72. package/dist/useSSE.cjs +241 -0
  73. package/dist/useSSE.d.ts +74 -0
  74. package/dist/useSSE.mjs +226 -0
  75. package/dist/websocket.cjs +325 -0
  76. package/dist/websocket.d.ts +163 -0
  77. package/dist/websocket.mjs +316 -0
  78. package/package.json +61 -0
@@ -0,0 +1,176 @@
1
+ export class IndexedDBCache {
2
+ dbName;
3
+ storeName;
4
+ dbVersion;
5
+ db = null;
6
+ constructor(options = {}) {
7
+ this.dbName = options.dbName || "yh_request_cache";
8
+ this.storeName = options.storeName || "cache";
9
+ this.dbVersion = options.dbVersion || 1;
10
+ }
11
+ /**
12
+ * 打开数据库
13
+ */
14
+ async openDB() {
15
+ if (this.db) return this.db;
16
+ return new Promise((resolve, reject) => {
17
+ const request = indexedDB.open(this.dbName, this.dbVersion);
18
+ request.onerror = () => {
19
+ reject(request.error);
20
+ };
21
+ request.onsuccess = () => {
22
+ this.db = request.result;
23
+ resolve(this.db);
24
+ };
25
+ request.onupgradeneeded = (event) => {
26
+ const db = event.target.result;
27
+ if (!db.objectStoreNames.contains(this.storeName)) {
28
+ db.createObjectStore(this.storeName, { keyPath: "key" });
29
+ }
30
+ };
31
+ });
32
+ }
33
+ /**
34
+ * 获取缓存
35
+ */
36
+ async get(key, _staleTime) {
37
+ try {
38
+ const db = await this.openDB();
39
+ const transaction = db.transaction(this.storeName, "readonly");
40
+ const store = transaction.objectStore(this.storeName);
41
+ const request = store.get(key);
42
+ return new Promise((resolve, reject) => {
43
+ request.onsuccess = () => {
44
+ if (!request.result) {
45
+ resolve(void 0);
46
+ return;
47
+ }
48
+ const item = request.result;
49
+ if (item.expireTime && Date.now() > item.expireTime) {
50
+ this.delete(key);
51
+ resolve(void 0);
52
+ return;
53
+ }
54
+ resolve(item.data);
55
+ };
56
+ request.onerror = () => {
57
+ reject(request.error);
58
+ };
59
+ });
60
+ } catch {
61
+ return void 0;
62
+ }
63
+ }
64
+ /**
65
+ * 设置缓存
66
+ */
67
+ async set(key, data, options = {}) {
68
+ try {
69
+ const { staleTime = 5 * 60 * 1e3 } = options;
70
+ const now = Date.now();
71
+ const item = {
72
+ data,
73
+ expireTime: now + staleTime,
74
+ createTime: now
75
+ };
76
+ const db = await this.openDB();
77
+ const transaction = db.transaction(this.storeName, "readwrite");
78
+ const store = transaction.objectStore(this.storeName);
79
+ store.put({ key, ...item });
80
+ await new Promise((resolve, reject) => {
81
+ transaction.oncomplete = () => resolve();
82
+ transaction.onerror = () => reject(transaction.error);
83
+ });
84
+ } catch (error) {
85
+ console.warn("IndexedDB cache set failed:", error);
86
+ }
87
+ }
88
+ /**
89
+ * 删除缓存
90
+ */
91
+ async delete(key) {
92
+ try {
93
+ const db = await this.openDB();
94
+ const transaction = db.transaction(this.storeName, "readwrite");
95
+ const store = transaction.objectStore(this.storeName);
96
+ store.delete(key);
97
+ await new Promise((resolve, reject) => {
98
+ transaction.oncomplete = () => resolve();
99
+ transaction.onerror = () => reject(transaction.error);
100
+ });
101
+ return true;
102
+ } catch {
103
+ return false;
104
+ }
105
+ }
106
+ /**
107
+ * 清空缓存
108
+ */
109
+ async clear() {
110
+ try {
111
+ const db = await this.openDB();
112
+ const transaction = db.transaction(this.storeName, "readwrite");
113
+ const store = transaction.objectStore(this.storeName);
114
+ store.clear();
115
+ await new Promise((resolve, reject) => {
116
+ transaction.oncomplete = () => resolve();
117
+ transaction.onerror = () => reject(transaction.error);
118
+ });
119
+ } catch {
120
+ }
121
+ }
122
+ /**
123
+ * 检查缓存是否存在
124
+ */
125
+ async has(key) {
126
+ const data = await this.get(key);
127
+ return data !== void 0;
128
+ }
129
+ /**
130
+ * 获取所有缓存 keys
131
+ */
132
+ async keys() {
133
+ try {
134
+ const db = await this.openDB();
135
+ const transaction = db.transaction(this.storeName, "readonly");
136
+ const store = transaction.objectStore(this.storeName);
137
+ const request = store.getAllKeys();
138
+ return new Promise((resolve, reject) => {
139
+ request.onsuccess = () => {
140
+ resolve(request.result);
141
+ };
142
+ request.onerror = () => {
143
+ reject(request.error);
144
+ };
145
+ });
146
+ } catch {
147
+ return [];
148
+ }
149
+ }
150
+ /**
151
+ * 清理过期缓存
152
+ */
153
+ async cleanup() {
154
+ try {
155
+ const db = await this.openDB();
156
+ const transaction = db.transaction(this.storeName, "readwrite");
157
+ const store = transaction.objectStore(this.storeName);
158
+ const request = store.getAll();
159
+ await new Promise((resolve, reject) => {
160
+ request.onsuccess = async () => {
161
+ const now = Date.now();
162
+ const items = request.result;
163
+ for (const item of items) {
164
+ if (item.expireTime && now > item.expireTime) {
165
+ store.delete(item.key);
166
+ }
167
+ }
168
+ resolve();
169
+ };
170
+ request.onerror = () => reject(request.error);
171
+ });
172
+ } catch {
173
+ }
174
+ }
175
+ }
176
+ export const indexedDBCache = new IndexedDBCache();
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.localStorageCache = exports.LocalStorageCache = void 0;
7
+ class LocalStorageCache {
8
+ prefix;
9
+ maxSize;
10
+ constructor(options = {}) {
11
+ this.prefix = options.prefix || "yh_request_cache_";
12
+ this.maxSize = options.maxSize || 5 * 1024 * 1024;
13
+ }
14
+ /**
15
+ * 生成存储 key
16
+ */
17
+ getStorageKey(key) {
18
+ return `${this.prefix}${key}`;
19
+ }
20
+ /**
21
+ * 获取缓存
22
+ */
23
+ get(key, _staleTime) {
24
+ try {
25
+ const storageKey = this.getStorageKey(key);
26
+ const itemStr = localStorage.getItem(storageKey);
27
+ if (!itemStr) return void 0;
28
+ const item = JSON.parse(itemStr);
29
+ if (item.expireTime && Date.now() > item.expireTime) {
30
+ this.delete(key);
31
+ return void 0;
32
+ }
33
+ return item.data;
34
+ } catch {
35
+ return void 0;
36
+ }
37
+ }
38
+ /**
39
+ * 设置缓存
40
+ */
41
+ set(key, data, options = {}) {
42
+ try {
43
+ const {
44
+ staleTime = 5 * 60 * 1e3
45
+ } = options;
46
+ const now = Date.now();
47
+ const item = {
48
+ data,
49
+ expireTime: now + staleTime,
50
+ createTime: now
51
+ };
52
+ const storageKey = this.getStorageKey(key);
53
+ const itemStr = JSON.stringify(item);
54
+ if (this.calculateSize() + itemStr.length > this.maxSize) {
55
+ this.cleanup();
56
+ }
57
+ localStorage.setItem(storageKey, itemStr);
58
+ } catch (error) {
59
+ console.warn("LocalStorage cache set failed:", error);
60
+ }
61
+ }
62
+ /**
63
+ * 删除缓存
64
+ */
65
+ delete(key) {
66
+ try {
67
+ const storageKey = this.getStorageKey(key);
68
+ localStorage.removeItem(storageKey);
69
+ return true;
70
+ } catch {
71
+ return false;
72
+ }
73
+ }
74
+ /**
75
+ * 清空缓存
76
+ */
77
+ clear() {
78
+ try {
79
+ const keys = this.keys();
80
+ keys.forEach(key => {
81
+ localStorage.removeItem(this.getStorageKey(key));
82
+ });
83
+ } catch {}
84
+ }
85
+ /**
86
+ * 检查缓存是否存在
87
+ */
88
+ has(key) {
89
+ return this.get(key) !== void 0;
90
+ }
91
+ /**
92
+ * 获取所有缓存 keys
93
+ */
94
+ keys() {
95
+ const result = [];
96
+ try {
97
+ for (let i = 0; i < localStorage.length; i++) {
98
+ const key = localStorage.key(i);
99
+ if (key && key.startsWith(this.prefix)) {
100
+ result.push(key.slice(this.prefix.length));
101
+ }
102
+ }
103
+ } catch {}
104
+ return result;
105
+ }
106
+ /**
107
+ * 计算当前存储使用量
108
+ */
109
+ calculateSize() {
110
+ let size = 0;
111
+ try {
112
+ for (let i = 0; i < localStorage.length; i++) {
113
+ const key = localStorage.key(i);
114
+ if (key && key.startsWith(this.prefix)) {
115
+ const value = localStorage.getItem(key);
116
+ if (value) {
117
+ size += key.length + value.length;
118
+ }
119
+ }
120
+ }
121
+ } catch {}
122
+ return size;
123
+ }
124
+ /**
125
+ * 清理过期缓存
126
+ */
127
+ cleanup() {
128
+ const keys = this.keys();
129
+ const now = Date.now();
130
+ for (const key of keys) {
131
+ try {
132
+ const storageKey = this.getStorageKey(key);
133
+ const itemStr = localStorage.getItem(storageKey);
134
+ if (itemStr) {
135
+ const item = JSON.parse(itemStr);
136
+ if (item.expireTime && now > item.expireTime) {
137
+ localStorage.removeItem(storageKey);
138
+ }
139
+ }
140
+ } catch {}
141
+ }
142
+ if (this.calculateSize() > this.maxSize) {
143
+ const sortedKeys = keys.sort((a, b) => {
144
+ const itemA = this.get(a);
145
+ const itemB = this.get(b);
146
+ const timeA = itemA ? itemA.createTime || 0 : 0;
147
+ const timeB = itemB ? itemB.createTime || 0 : 0;
148
+ return timeA - timeB;
149
+ });
150
+ const removeCount = Math.ceil(keys.length * 0.2);
151
+ for (let i = 0; i < removeCount; i++) {
152
+ this.delete(sortedKeys[i]);
153
+ }
154
+ }
155
+ }
156
+ }
157
+ exports.LocalStorageCache = LocalStorageCache;
158
+ const localStorageCache = exports.localStorageCache = new LocalStorageCache();
@@ -0,0 +1,58 @@
1
+ /**
2
+ * LocalStorage 缓存实现
3
+ * 适用于小量数据的持久化缓存
4
+ */
5
+ export interface LocalStorageCacheOptions {
6
+ /** 缓存前缀 */
7
+ prefix?: string;
8
+ /** 存储上限 (bytes) */
9
+ maxSize?: number;
10
+ }
11
+ /**
12
+ * LocalStorage 缓存类
13
+ */
14
+ export declare class LocalStorageCache {
15
+ private prefix;
16
+ private maxSize;
17
+ constructor(options?: LocalStorageCacheOptions);
18
+ /**
19
+ * 生成存储 key
20
+ */
21
+ private getStorageKey;
22
+ /**
23
+ * 获取缓存
24
+ */
25
+ get<T>(key: string, _staleTime?: number): T | undefined;
26
+ /**
27
+ * 设置缓存
28
+ */
29
+ set<T>(key: string, data: T, options?: {
30
+ staleTime?: number;
31
+ cacheTime?: number;
32
+ }): void;
33
+ /**
34
+ * 删除缓存
35
+ */
36
+ delete(key: string): boolean;
37
+ /**
38
+ * 清空缓存
39
+ */
40
+ clear(): void;
41
+ /**
42
+ * 检查缓存是否存在
43
+ */
44
+ has(key: string): boolean;
45
+ /**
46
+ * 获取所有缓存 keys
47
+ */
48
+ keys(): string[];
49
+ /**
50
+ * 计算当前存储使用量
51
+ */
52
+ private calculateSize;
53
+ /**
54
+ * 清理过期缓存
55
+ */
56
+ private cleanup;
57
+ }
58
+ export declare const localStorageCache: LocalStorageCache;
@@ -0,0 +1,153 @@
1
+ export class LocalStorageCache {
2
+ prefix;
3
+ maxSize;
4
+ constructor(options = {}) {
5
+ this.prefix = options.prefix || "yh_request_cache_";
6
+ this.maxSize = options.maxSize || 5 * 1024 * 1024;
7
+ }
8
+ /**
9
+ * 生成存储 key
10
+ */
11
+ getStorageKey(key) {
12
+ return `${this.prefix}${key}`;
13
+ }
14
+ /**
15
+ * 获取缓存
16
+ */
17
+ get(key, _staleTime) {
18
+ try {
19
+ const storageKey = this.getStorageKey(key);
20
+ const itemStr = localStorage.getItem(storageKey);
21
+ if (!itemStr) return void 0;
22
+ const item = JSON.parse(itemStr);
23
+ if (item.expireTime && Date.now() > item.expireTime) {
24
+ this.delete(key);
25
+ return void 0;
26
+ }
27
+ return item.data;
28
+ } catch {
29
+ return void 0;
30
+ }
31
+ }
32
+ /**
33
+ * 设置缓存
34
+ */
35
+ set(key, data, options = {}) {
36
+ try {
37
+ const { staleTime = 5 * 60 * 1e3 } = options;
38
+ const now = Date.now();
39
+ const item = {
40
+ data,
41
+ expireTime: now + staleTime,
42
+ createTime: now
43
+ };
44
+ const storageKey = this.getStorageKey(key);
45
+ const itemStr = JSON.stringify(item);
46
+ if (this.calculateSize() + itemStr.length > this.maxSize) {
47
+ this.cleanup();
48
+ }
49
+ localStorage.setItem(storageKey, itemStr);
50
+ } catch (error) {
51
+ console.warn("LocalStorage cache set failed:", error);
52
+ }
53
+ }
54
+ /**
55
+ * 删除缓存
56
+ */
57
+ delete(key) {
58
+ try {
59
+ const storageKey = this.getStorageKey(key);
60
+ localStorage.removeItem(storageKey);
61
+ return true;
62
+ } catch {
63
+ return false;
64
+ }
65
+ }
66
+ /**
67
+ * 清空缓存
68
+ */
69
+ clear() {
70
+ try {
71
+ const keys = this.keys();
72
+ keys.forEach((key) => {
73
+ localStorage.removeItem(this.getStorageKey(key));
74
+ });
75
+ } catch {
76
+ }
77
+ }
78
+ /**
79
+ * 检查缓存是否存在
80
+ */
81
+ has(key) {
82
+ return this.get(key) !== void 0;
83
+ }
84
+ /**
85
+ * 获取所有缓存 keys
86
+ */
87
+ keys() {
88
+ const result = [];
89
+ try {
90
+ for (let i = 0; i < localStorage.length; i++) {
91
+ const key = localStorage.key(i);
92
+ if (key && key.startsWith(this.prefix)) {
93
+ result.push(key.slice(this.prefix.length));
94
+ }
95
+ }
96
+ } catch {
97
+ }
98
+ return result;
99
+ }
100
+ /**
101
+ * 计算当前存储使用量
102
+ */
103
+ calculateSize() {
104
+ let size = 0;
105
+ try {
106
+ for (let i = 0; i < localStorage.length; i++) {
107
+ const key = localStorage.key(i);
108
+ if (key && key.startsWith(this.prefix)) {
109
+ const value = localStorage.getItem(key);
110
+ if (value) {
111
+ size += key.length + value.length;
112
+ }
113
+ }
114
+ }
115
+ } catch {
116
+ }
117
+ return size;
118
+ }
119
+ /**
120
+ * 清理过期缓存
121
+ */
122
+ cleanup() {
123
+ const keys = this.keys();
124
+ const now = Date.now();
125
+ for (const key of keys) {
126
+ try {
127
+ const storageKey = this.getStorageKey(key);
128
+ const itemStr = localStorage.getItem(storageKey);
129
+ if (itemStr) {
130
+ const item = JSON.parse(itemStr);
131
+ if (item.expireTime && now > item.expireTime) {
132
+ localStorage.removeItem(storageKey);
133
+ }
134
+ }
135
+ } catch {
136
+ }
137
+ }
138
+ if (this.calculateSize() > this.maxSize) {
139
+ const sortedKeys = keys.sort((a, b) => {
140
+ const itemA = this.get(a);
141
+ const itemB = this.get(b);
142
+ const timeA = itemA ? itemA.createTime || 0 : 0;
143
+ const timeB = itemB ? itemB.createTime || 0 : 0;
144
+ return timeA - timeB;
145
+ });
146
+ const removeCount = Math.ceil(keys.length * 0.2);
147
+ for (let i = 0; i < removeCount; i++) {
148
+ this.delete(sortedKeys[i]);
149
+ }
150
+ }
151
+ }
152
+ }
153
+ export const localStorageCache = new LocalStorageCache();
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.memoryCache = exports.MemoryCache = void 0;
7
+ class MemoryCache {
8
+ cache = /* @__PURE__ */new Map();
9
+ cleanupTimer = null;
10
+ /**
11
+ * 获取缓存
12
+ */
13
+ get(key, _staleTime) {
14
+ const item = this.cache.get(key);
15
+ if (!item) return void 0;
16
+ const now = Date.now();
17
+ if (item.expireTime && now > item.expireTime) {
18
+ this.cache.delete(key);
19
+ return void 0;
20
+ }
21
+ return item.data;
22
+ }
23
+ /**
24
+ * 设置缓存
25
+ */
26
+ set(key, data, options = {}) {
27
+ const {
28
+ staleTime = 5 * 60 * 1e3,
29
+ cacheTime = 10 * 60 * 1e3
30
+ } = options;
31
+ const now = Date.now();
32
+ this.cache.set(key, {
33
+ data,
34
+ expireTime: now + staleTime,
35
+ createTime: now
36
+ });
37
+ setTimeout(() => {
38
+ const item = this.cache.get(key);
39
+ if (item && item.expireTime <= Date.now()) {
40
+ this.cache.delete(key);
41
+ }
42
+ }, cacheTime);
43
+ }
44
+ /**
45
+ * 删除缓存
46
+ */
47
+ delete(key) {
48
+ return this.cache.delete(key);
49
+ }
50
+ /**
51
+ * 清空缓存
52
+ */
53
+ clear() {
54
+ this.cache.clear();
55
+ }
56
+ /**
57
+ * 检查缓存是否存在
58
+ */
59
+ has(key) {
60
+ const item = this.cache.get(key);
61
+ if (!item) return false;
62
+ if (item.expireTime && Date.now() > item.expireTime) {
63
+ this.cache.delete(key);
64
+ return false;
65
+ }
66
+ return true;
67
+ }
68
+ /**
69
+ * 通过标签清除缓存
70
+ */
71
+ deleteByTags(_tags) {}
72
+ /**
73
+ * 获取缓存大小
74
+ */
75
+ size() {
76
+ return this.cache.size;
77
+ }
78
+ /**
79
+ * 批量获取缓存 keys
80
+ */
81
+ keys() {
82
+ return Array.from(this.cache.keys());
83
+ }
84
+ /**
85
+ * 启动定时清理
86
+ */
87
+ startCleanup(interval = 60 * 1e3) {
88
+ if (this.cleanupTimer) return;
89
+ this.cleanupTimer = setInterval(() => {
90
+ const now = Date.now();
91
+ for (const [key, item] of this.cache.entries()) {
92
+ if (item.expireTime && now > item.expireTime) {
93
+ this.cache.delete(key);
94
+ }
95
+ }
96
+ }, interval);
97
+ }
98
+ /**
99
+ * 停止定时清理
100
+ */
101
+ stopCleanup() {
102
+ if (this.cleanupTimer) {
103
+ clearInterval(this.cleanupTimer);
104
+ this.cleanupTimer = null;
105
+ }
106
+ }
107
+ }
108
+ exports.MemoryCache = MemoryCache;
109
+ const memoryCache = exports.memoryCache = new MemoryCache();
110
+ if (typeof window !== "undefined") {
111
+ memoryCache.startCleanup();
112
+ }