cross-state 0.31.5 → 0.33.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.
@@ -0,0 +1,381 @@
1
+ "use strict";
2
+ const store = require("./store.cjs");
3
+ const scope = require("./scope.cjs");
4
+ class ResourceGroup {
5
+ constructor(name) {
6
+ this.name = name;
7
+ this.refMap = /* @__PURE__ */ new WeakMap();
8
+ this.refSet = /* @__PURE__ */ new Set();
9
+ store.autobind(ResourceGroup);
10
+ }
11
+ add(resource) {
12
+ const ref = new WeakRef(resource);
13
+ this.refMap.set(resource, ref);
14
+ this.refSet.add(ref);
15
+ }
16
+ delete(resource) {
17
+ const ref = this.refMap.get(resource);
18
+ if (ref) {
19
+ this.refMap.delete(resource);
20
+ this.refSet.delete(ref);
21
+ }
22
+ }
23
+ invalidateAll() {
24
+ for (const ref of this.refSet) {
25
+ const resource = ref.deref();
26
+ if (resource) {
27
+ resource.invalidateAll();
28
+ } else {
29
+ this.refSet.delete(ref);
30
+ }
31
+ }
32
+ }
33
+ clearAll() {
34
+ for (const ref of this.refSet) {
35
+ const resource = ref.deref();
36
+ if (resource) {
37
+ resource.clearAll();
38
+ } else {
39
+ this.refSet.delete(ref);
40
+ }
41
+ }
42
+ }
43
+ }
44
+ const allResources = /* @__PURE__ */ new ResourceGroup();
45
+ function createResourceGroup(name) {
46
+ return new ResourceGroup(name);
47
+ }
48
+ class InstanceCache {
49
+ constructor(factory, cacheTime) {
50
+ this.factory = factory;
51
+ this.cacheTime = cacheTime;
52
+ this.cache = /* @__PURE__ */ new Map();
53
+ this.interval = this.cacheTime ? setInterval(() => this.cleanup(), Math.max(this.cacheTime / 10, 1)) : void 0;
54
+ }
55
+ cleanup() {
56
+ var _a;
57
+ const cutoff = this.now() - (this.cacheTime ?? 0);
58
+ for (const [key, entry] of this.cache.entries()) {
59
+ if (entry.ref && entry.t <= cutoff) {
60
+ delete entry.ref;
61
+ }
62
+ if (!entry.ref && !((_a = entry.weakRef) == null ? void 0 : _a.deref())) {
63
+ this.cache.delete(key);
64
+ }
65
+ }
66
+ }
67
+ get(...args) {
68
+ var _a;
69
+ const key = scope.hash(args);
70
+ let entry = this.cache.get(key);
71
+ let value = (entry == null ? void 0 : entry.ref) ?? ((_a = entry == null ? void 0 : entry.weakRef) == null ? void 0 : _a.deref());
72
+ if (!entry || !value) {
73
+ value = this.factory(...args);
74
+ entry = {
75
+ t: this.now(),
76
+ ref: value,
77
+ weakRef: new WeakRef(value)
78
+ };
79
+ this.cache.set(key, entry);
80
+ } else {
81
+ entry.t = this.now();
82
+ entry.ref ?? (entry.ref = value);
83
+ }
84
+ return value;
85
+ }
86
+ values() {
87
+ return [...this.cache.values()].map((entry) => {
88
+ var _a;
89
+ return entry.ref ?? ((_a = entry.weakRef) == null ? void 0 : _a.deref());
90
+ }).filter((value) => !!value);
91
+ }
92
+ stop() {
93
+ if (this.interval) {
94
+ clearInterval(this.interval);
95
+ }
96
+ }
97
+ stats() {
98
+ return {
99
+ count: this.cache.size,
100
+ withRef: [...this.cache.values()].filter((x) => !!x.ref).length,
101
+ withWeakRef: [...this.cache.values()].filter((x) => {
102
+ var _a;
103
+ return !!((_a = x.weakRef) == null ? void 0 : _a.deref());
104
+ }).length
105
+ };
106
+ }
107
+ now() {
108
+ return performance.now();
109
+ }
110
+ }
111
+ class PromiseWithState extends Promise {
112
+ constructor(value, state = { status: "pending" }) {
113
+ super((resolve) => resolve(value));
114
+ this.state = state;
115
+ value.then((value2) => {
116
+ this.state = { status: "value", value: value2 };
117
+ }).catch((error) => {
118
+ this.state = { status: "error", error };
119
+ });
120
+ }
121
+ static resolve(value) {
122
+ return new PromiseWithState(Promise.resolve(value), {
123
+ status: "value",
124
+ value
125
+ });
126
+ }
127
+ static reject(error) {
128
+ return new PromiseWithState(Promise.reject(error), { status: "error", error });
129
+ }
130
+ }
131
+ class Cache extends store.Store {
132
+ constructor(getter, options = {}, derivedFromCache, _call) {
133
+ super(
134
+ function() {
135
+ let result = getter.apply(this);
136
+ if (result instanceof Function) {
137
+ result = result(this);
138
+ }
139
+ return result;
140
+ },
141
+ options,
142
+ void 0,
143
+ _call
144
+ );
145
+ this.options = options;
146
+ this.derivedFromCache = derivedFromCache;
147
+ this.state = store.createStore({
148
+ status: "pending",
149
+ isStale: true,
150
+ isUpdating: false
151
+ });
152
+ store.autobind(Cache);
153
+ this.calculationHelper.options.onInvalidate = () => this.invalidate({ invalidateDependencies: false });
154
+ this.watchPromise();
155
+ this.watchFocus();
156
+ }
157
+ get({ update = "whenStale", backgroundUpdate = false } = {}) {
158
+ var _a;
159
+ const promise = (_a = this._value) == null ? void 0 : _a.v;
160
+ const stalePromise = this.stalePromise;
161
+ if (update === "whenMissing" && !promise && !stalePromise || update === "whenStale" && !promise || update === "force") {
162
+ this.calculationHelper.execute();
163
+ if (!promise && !stalePromise || !backgroundUpdate) {
164
+ return super.get();
165
+ }
166
+ }
167
+ if (!promise || stalePromise && backgroundUpdate) {
168
+ return stalePromise;
169
+ }
170
+ return promise;
171
+ }
172
+ updateValue(value) {
173
+ this.set(PromiseWithState.resolve(value));
174
+ }
175
+ updateError(error) {
176
+ this.set(PromiseWithState.reject(error));
177
+ }
178
+ invalidate({ invalidateDependencies = true } = {}) {
179
+ var _a;
180
+ const { clearOnInvalidate = createCache.defaultOptions.clearOnInvalidate } = this.options;
181
+ if (clearOnInvalidate) {
182
+ return this.clear({ invalidateDependencies });
183
+ }
184
+ if (invalidateDependencies) {
185
+ this.calculationHelper.invalidateDependencies();
186
+ }
187
+ const { status, isStale, isUpdating } = this.state.get();
188
+ if (status !== "pending" && !isStale && !isUpdating) {
189
+ this.stalePromise = (_a = this._value) == null ? void 0 : _a.v;
190
+ }
191
+ this.state.set((state) => ({
192
+ ...state,
193
+ isStale: true,
194
+ isUpdating: false
195
+ }));
196
+ this.calculationHelper.stop();
197
+ super.reset();
198
+ }
199
+ clear({ invalidateDependencies = true } = {}) {
200
+ if (invalidateDependencies) {
201
+ this.calculationHelper.invalidateDependencies();
202
+ }
203
+ this.state.set({
204
+ status: "pending",
205
+ isStale: true,
206
+ isUpdating: false
207
+ });
208
+ delete this.stalePromise;
209
+ this.calculationHelper.stop();
210
+ super.reset();
211
+ }
212
+ mapValue(_selector) {
213
+ const selector = store.makeSelector(_selector);
214
+ const derivedFromCache = {
215
+ cache: this.derivedFromCache ? this.derivedFromCache.cache : this,
216
+ selectors: this.derivedFromCache ? [...this.derivedFromCache.selectors, _selector] : [_selector]
217
+ };
218
+ const that = this;
219
+ return new Cache(
220
+ async function() {
221
+ const value = await this.use(that);
222
+ return selector(value);
223
+ },
224
+ {},
225
+ derivedFromCache
226
+ );
227
+ }
228
+ watchPromise() {
229
+ this.subscribe(
230
+ async (promise) => {
231
+ var _a, _b;
232
+ if (promise instanceof PromiseWithState) {
233
+ this.state.set({
234
+ ...promise.state,
235
+ isStale: false,
236
+ isUpdating: false
237
+ });
238
+ delete this.stalePromise;
239
+ this.setTimers();
240
+ return;
241
+ }
242
+ this.state.set((state) => ({
243
+ ...state,
244
+ isUpdating: true
245
+ }));
246
+ this.setTimers();
247
+ try {
248
+ const value = await promise;
249
+ if (promise !== ((_a = this._value) == null ? void 0 : _a.v)) {
250
+ return;
251
+ }
252
+ this.state.set({
253
+ status: "value",
254
+ value,
255
+ isStale: false,
256
+ isUpdating: false
257
+ });
258
+ delete this.stalePromise;
259
+ this.setTimers();
260
+ } catch (error) {
261
+ if (promise !== ((_b = this._value) == null ? void 0 : _b.v)) {
262
+ return;
263
+ }
264
+ this.state.set({
265
+ status: "error",
266
+ error,
267
+ isStale: false,
268
+ isUpdating: false
269
+ });
270
+ delete this.stalePromise;
271
+ this.setTimers();
272
+ }
273
+ },
274
+ { passive: true }
275
+ );
276
+ }
277
+ setTimers() {
278
+ if (this.invalidationTimer) {
279
+ clearTimeout(this.invalidationTimer);
280
+ }
281
+ this.invalidationTimer = void 0;
282
+ const state = this.state.get();
283
+ let { invalidateAfter = createCache.defaultOptions.invalidateAfter } = this.options;
284
+ const ref = new WeakRef(this);
285
+ if (state.status === "pending") {
286
+ return;
287
+ }
288
+ if (invalidateAfter instanceof Function) {
289
+ invalidateAfter = invalidateAfter(state);
290
+ }
291
+ if (invalidateAfter !== null && invalidateAfter !== void 0) {
292
+ this.invalidationTimer = setTimeout(
293
+ () => {
294
+ var _a;
295
+ return (_a = ref == null ? void 0 : ref.deref()) == null ? void 0 : _a.invalidate();
296
+ },
297
+ store.calcDuration(invalidateAfter)
298
+ );
299
+ }
300
+ }
301
+ watchFocus() {
302
+ const { invalidateOnWindowFocus = createCache.defaultOptions.invalidateOnWindowFocus } = this.options;
303
+ if (!invalidateOnWindowFocus || typeof document === "undefined" || typeof document.addEventListener === "undefined") {
304
+ return;
305
+ }
306
+ const ref = new WeakRef(this);
307
+ const onFocus = () => {
308
+ const that = ref == null ? void 0 : ref.deref();
309
+ if (!that) {
310
+ document.removeEventListener("visibilitychange", onFocus);
311
+ return;
312
+ }
313
+ if (!document.hidden) {
314
+ that.invalidate();
315
+ }
316
+ };
317
+ document.addEventListener("visibilitychange", onFocus);
318
+ }
319
+ }
320
+ function create(cacheFunction, options) {
321
+ const { clearUnusedAfter = createCache.defaultOptions.clearUnusedAfter, resourceGroup } = options ?? {};
322
+ let baseInstance;
323
+ const instanceCache = new InstanceCache(
324
+ (...args) => {
325
+ if (args.length === 0 && baseInstance) {
326
+ return baseInstance;
327
+ }
328
+ return new Cache(function() {
329
+ return cacheFunction.apply(this, args);
330
+ }, options);
331
+ },
332
+ clearUnusedAfter ? store.calcDuration(clearUnusedAfter) : void 0
333
+ );
334
+ const get = (...args) => {
335
+ return instanceCache.get(...args);
336
+ };
337
+ const invalidateAll = () => {
338
+ for (const instance of instanceCache.values()) {
339
+ instance.invalidate();
340
+ }
341
+ };
342
+ const clearAll = () => {
343
+ for (const instance of instanceCache.values()) {
344
+ instance.clear();
345
+ }
346
+ };
347
+ baseInstance = Object.assign(
348
+ new Cache(
349
+ function() {
350
+ return cacheFunction.apply(this);
351
+ },
352
+ options,
353
+ void 0,
354
+ get
355
+ ),
356
+ {
357
+ invalidateAll,
358
+ clearAll
359
+ }
360
+ );
361
+ const groups = Array.isArray(resourceGroup) ? resourceGroup : resourceGroup ? [resourceGroup] : [];
362
+ for (const group of groups.concat(allResources)) {
363
+ group.add(baseInstance);
364
+ }
365
+ get(...[]);
366
+ return baseInstance;
367
+ }
368
+ const createCache = /* @__PURE__ */ Object.assign(create, {
369
+ defaultOptions: {
370
+ invalidateOnWindowFocus: true,
371
+ invalidateOnActivation: true,
372
+ clearUnusedAfter: { days: 1 }
373
+ }
374
+ });
375
+ exports.Cache = Cache;
376
+ exports.InstanceCache = InstanceCache;
377
+ exports.ResourceGroup = ResourceGroup;
378
+ exports.allResources = allResources;
379
+ exports.createCache = createCache;
380
+ exports.createResourceGroup = createResourceGroup;
381
+ //# sourceMappingURL=cache.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.cjs","sources":["../../src/core/resourceGroup.ts","../../src/lib/instanceCache.ts","../../src/lib/promiseWithState.ts","../../src/core/cache.ts"],"sourcesContent":["import { autobind } from '@lib/autobind';\n\nexport interface Resource {\n invalidateAll(): void;\n clearAll(): void;\n}\n\nexport class ResourceGroup {\n private refMap = new WeakMap<Resource, WeakRef<Resource>>();\n\n private refSet = new Set<WeakRef<Resource>>();\n\n constructor(public readonly name?: string) {\n autobind(ResourceGroup);\n }\n\n add(resource: Resource) {\n const ref = new WeakRef(resource);\n this.refMap.set(resource, ref);\n this.refSet.add(ref);\n }\n\n delete(resource: Resource) {\n const ref = this.refMap.get(resource);\n if (ref) {\n this.refMap.delete(resource);\n this.refSet.delete(ref);\n }\n }\n\n invalidateAll() {\n for (const ref of this.refSet) {\n const resource = ref.deref();\n if (resource) {\n resource.invalidateAll();\n } else {\n this.refSet.delete(ref);\n }\n }\n }\n\n clearAll() {\n for (const ref of this.refSet) {\n const resource = ref.deref();\n if (resource) {\n resource.clearAll();\n } else {\n this.refSet.delete(ref);\n }\n }\n }\n}\n\nexport const allResources = /* @__PURE__ */ new ResourceGroup();\n\nexport function createResourceGroup(name?: string) {\n return new ResourceGroup(name);\n}\n","import { hash } from './hash';\n\nexport class InstanceCache<Args extends any[], T extends object> {\n private cache = new Map<string, { t: number; ref?: T; weakRef: WeakRef<T> }>();\n\n private interval = this.cacheTime\n ? setInterval(() => this.cleanup(), Math.max(this.cacheTime / 10, 1))\n : undefined;\n\n constructor(public readonly factory: (...args: Args) => T, public readonly cacheTime?: number) {}\n\n cleanup() {\n const cutoff = this.now() - (this.cacheTime ?? 0);\n\n for (const [key, entry] of this.cache.entries()) {\n if (entry.ref && entry.t <= cutoff) {\n delete entry.ref;\n }\n\n if (!entry.ref && !entry.weakRef?.deref()) {\n this.cache.delete(key);\n }\n }\n }\n\n get(...args: Args) {\n const key = hash(args);\n let entry = this.cache.get(key);\n let value = entry?.ref ?? entry?.weakRef?.deref();\n\n if (!entry || !value) {\n value = this.factory(...args);\n entry = {\n t: this.now(),\n ref: value,\n weakRef: new WeakRef(value),\n };\n\n this.cache.set(key, entry);\n } else {\n entry.t = this.now();\n entry.ref ??= value;\n }\n\n return value;\n }\n\n values() {\n return [...this.cache.values()]\n .map((entry) => entry.ref ?? entry.weakRef?.deref())\n .filter((value): value is T => !!value);\n }\n\n stop() {\n if (this.interval) {\n clearInterval(this.interval);\n }\n }\n\n stats() {\n return {\n count: this.cache.size,\n withRef: [...this.cache.values()].filter((x) => !!x.ref).length,\n withWeakRef: [...this.cache.values()].filter((x) => !!x.weakRef?.deref()).length,\n };\n }\n\n private now() {\n return performance.now();\n }\n}\n","import { type ErrorState, type PendingState, type ValueState } from './cacheState';\nimport { type MaybePromise } from './maybePromise';\n\nexport class PromiseWithState<T> extends Promise<T> {\n static override resolve(): PromiseWithState<void>;\n\n static override resolve<T>(value: MaybePromise<T>): PromiseWithState<T>;\n\n static override resolve<T>(value?: MaybePromise<T>) {\n return new PromiseWithState<T>(Promise.resolve(value as MaybePromise<T>), {\n status: 'value',\n value: value as T,\n });\n }\n\n static override reject<T = never>(error: unknown) {\n return new PromiseWithState<T>(Promise.reject(error), { status: 'error', error });\n }\n\n constructor(\n value: Promise<T>,\n public state: ValueState<T> | ErrorState | PendingState = { status: 'pending' },\n ) {\n super((resolve) => resolve(value));\n\n value\n .then((value) => {\n this.state = { status: 'value', value };\n })\n .catch((error) => {\n this.state = { status: 'error', error };\n });\n }\n}\n","import type { Duration, Selector, Use } from './commonTypes';\nimport { allResources, type ResourceGroup } from './resourceGroup';\nimport { Store, createStore } from './store';\nimport { autobind } from '@lib/autobind';\nimport type { CacheState, ErrorState, ValueState } from '@lib/cacheState';\nimport { calcDuration } from '@lib/calcDuration';\nimport { InstanceCache } from '@lib/instanceCache';\nimport { makeSelector } from '@lib/makeSelector';\nimport { type MaybePromise } from '@lib/maybePromise';\nimport type { Path, Value } from '@lib/path';\nimport { PromiseWithState } from '@lib/promiseWithState';\n\nexport interface CacheGetOptions {\n update?: 'whenMissing' | 'whenStale' | 'force';\n backgroundUpdate?: boolean;\n}\n\nexport interface CacheFunction<T, Args extends any[] = []> {\n (this: { use: Use }, ...args: Args): Promise<T> | ((cache: { use: Use }) => Promise<T>);\n}\n\nexport interface CacheOptions<T> {\n invalidateAfter?: Duration | ((state: ValueState<T> | ErrorState) => Duration | null) | null;\n invalidateOnWindowFocus?: boolean;\n invalidateOnActivation?: boolean;\n clearOnInvalidate?: boolean;\n clearUnusedAfter?: Duration | null;\n resourceGroup?: ResourceGroup | ResourceGroup[];\n retain?: number;\n}\n\nexport class Cache<T> extends Store<Promise<T>> {\n readonly state = createStore<CacheState<T>>({\n status: 'pending',\n isStale: true,\n isUpdating: false,\n });\n\n protected stalePromise?: Promise<T>;\n\n protected invalidationTimer?: ReturnType<typeof setTimeout>;\n\n constructor(\n getter: CacheFunction<T>,\n public readonly options: CacheOptions<T> = {},\n public readonly derivedFromCache?: {\n cache: Cache<any>;\n selectors: (Selector<any, any> | Path<any>)[];\n },\n _call?: (...args: any[]) => any,\n ) {\n super(\n function () {\n let result = getter.apply(this);\n\n if (result instanceof Function) {\n result = result(this);\n }\n\n return result;\n },\n options,\n undefined,\n _call,\n );\n autobind(Cache);\n\n this.calculationHelper.options.onInvalidate = () =>\n this.invalidate({ invalidateDependencies: false });\n this.watchPromise();\n this.watchFocus();\n }\n\n get({ update = 'whenStale', backgroundUpdate = false }: CacheGetOptions = {}) {\n const promise = this._value?.v;\n const stalePromise = this.stalePromise;\n\n if (\n (update === 'whenMissing' && !promise && !stalePromise) ||\n (update === 'whenStale' && !promise) ||\n update === 'force'\n ) {\n this.calculationHelper.execute();\n\n if ((!promise && !stalePromise) || !backgroundUpdate) {\n return super.get();\n }\n }\n\n if (!promise || (stalePromise && backgroundUpdate)) {\n return stalePromise!;\n }\n\n return promise;\n }\n\n updateValue(value: MaybePromise<T>) {\n this.set(PromiseWithState.resolve(value));\n }\n\n updateError(error: unknown) {\n this.set(PromiseWithState.reject(error));\n }\n\n invalidate({ invalidateDependencies = true }: { invalidateDependencies?: boolean } = {}) {\n const { clearOnInvalidate = createCache.defaultOptions.clearOnInvalidate } = this.options;\n\n if (clearOnInvalidate) {\n return this.clear({ invalidateDependencies });\n }\n\n if (invalidateDependencies) {\n this.calculationHelper.invalidateDependencies();\n }\n\n const { status, isStale, isUpdating } = this.state.get();\n if (status !== 'pending' && !isStale && !isUpdating) {\n this.stalePromise = this._value?.v;\n }\n\n this.state.set((state) => ({\n ...state,\n isStale: true,\n isUpdating: false,\n }));\n\n this.calculationHelper.stop();\n super.reset();\n }\n\n clear({ invalidateDependencies = true }: { invalidateDependencies?: boolean } = {}): void {\n if (invalidateDependencies) {\n this.calculationHelper.invalidateDependencies();\n }\n\n this.state.set({\n status: 'pending',\n isStale: true,\n isUpdating: false,\n });\n delete this.stalePromise;\n\n this.calculationHelper.stop();\n super.reset();\n }\n\n mapValue<S>(selector: Selector<T, S>): Cache<S>;\n\n mapValue<P extends Path<T>>(selector: P): Cache<Value<T, P>>;\n\n mapValue<S>(_selector: Selector<T, S> | Path<any>): Cache<S> {\n const selector = makeSelector(_selector);\n const derivedFromCache = {\n cache: this.derivedFromCache ? this.derivedFromCache.cache : this,\n selectors: this.derivedFromCache\n ? [...this.derivedFromCache.selectors, _selector]\n : [_selector],\n };\n const that = this;\n\n return new Cache(\n async function () {\n const value = await this.use(that);\n return selector(value);\n },\n {},\n derivedFromCache,\n );\n }\n\n protected watchPromise() {\n this.subscribe(\n async (promise) => {\n if (promise instanceof PromiseWithState) {\n this.state.set({\n ...promise.state,\n isStale: false,\n isUpdating: false,\n });\n\n delete this.stalePromise;\n this.setTimers();\n return;\n }\n\n this.state.set((state) => ({\n ...state,\n isUpdating: true,\n }));\n\n this.setTimers();\n\n try {\n const value = await promise;\n\n if (promise !== this._value?.v) {\n return;\n }\n\n this.state.set({\n status: 'value',\n value,\n isStale: false,\n isUpdating: false,\n });\n delete this.stalePromise;\n this.setTimers();\n } catch (error) {\n if (promise !== this._value?.v) {\n return;\n }\n\n this.state.set({\n status: 'error',\n error,\n isStale: false,\n isUpdating: false,\n });\n delete this.stalePromise;\n this.setTimers();\n }\n },\n { passive: true },\n );\n }\n\n protected setTimers() {\n if (this.invalidationTimer) {\n clearTimeout(this.invalidationTimer);\n }\n this.invalidationTimer = undefined;\n\n const state = this.state.get();\n let { invalidateAfter = createCache.defaultOptions.invalidateAfter } = this.options;\n const ref = new WeakRef(this);\n\n if (state.status === 'pending') {\n return;\n }\n\n if (invalidateAfter instanceof Function) {\n invalidateAfter = invalidateAfter(state);\n }\n\n if (invalidateAfter !== null && invalidateAfter !== undefined) {\n this.invalidationTimer = setTimeout(\n () => ref?.deref()?.invalidate(),\n calcDuration(invalidateAfter),\n );\n }\n }\n\n protected watchFocus() {\n const { invalidateOnWindowFocus = createCache.defaultOptions.invalidateOnWindowFocus } =\n this.options;\n\n if (\n !invalidateOnWindowFocus ||\n typeof document === 'undefined' ||\n typeof document.addEventListener === 'undefined'\n ) {\n return;\n }\n\n const ref = new WeakRef(this);\n\n const onFocus = () => {\n const that = ref?.deref();\n if (!that) {\n document.removeEventListener('visibilitychange', onFocus);\n return;\n }\n\n if (!document.hidden) {\n that.invalidate();\n }\n };\n\n document.addEventListener('visibilitychange', onFocus);\n }\n}\n\ntype CreateReturnType<T, Args extends any[]> = {\n (...args: Args): Cache<T>;\n invalidateAll: () => void;\n clearAll: () => void;\n} & ([] extends Args ? Cache<T> : {});\n\nfunction create<T, Args extends any[]>(\n cacheFunction: CacheFunction<T, Args>,\n options?: CacheOptions<T>,\n): CreateReturnType<T, Args> {\n const { clearUnusedAfter = createCache.defaultOptions.clearUnusedAfter, resourceGroup } =\n options ?? {};\n\n let baseInstance: CreateReturnType<T, Args> & Cache<T>;\n\n const instanceCache = new InstanceCache<Args, Cache<T>>(\n (...args: Args): Cache<T> => {\n if (args.length === 0 && baseInstance) {\n return baseInstance;\n }\n\n return new Cache(function () {\n return cacheFunction.apply(this, args);\n }, options);\n },\n clearUnusedAfter ? calcDuration(clearUnusedAfter) : undefined,\n );\n\n const get = (...args: Args) => {\n return instanceCache.get(...args);\n };\n\n const invalidateAll = () => {\n for (const instance of instanceCache.values()) {\n instance.invalidate();\n }\n };\n\n const clearAll = () => {\n for (const instance of instanceCache.values()) {\n instance.clear();\n }\n };\n\n baseInstance = Object.assign(\n new Cache(\n function () {\n return cacheFunction.apply(this);\n },\n options,\n undefined,\n get,\n ),\n {\n invalidateAll,\n clearAll,\n },\n ) as CreateReturnType<T, Args> & Cache<T>;\n\n const groups = Array.isArray(resourceGroup)\n ? resourceGroup\n : resourceGroup\n ? [resourceGroup]\n : [];\n for (const group of groups.concat(allResources)) {\n group.add(baseInstance);\n }\n\n get(...([] as any));\n\n return baseInstance;\n}\n\nexport const createCache = /* @__PURE__ */ Object.assign(create, {\n defaultOptions: {\n invalidateOnWindowFocus: true,\n invalidateOnActivation: true,\n clearUnusedAfter: { days: 1 },\n } as CacheOptions<unknown>,\n});\n"],"names":["autobind","hash","value","Store","createStore","makeSelector","calcDuration"],"mappings":";;;AAOO,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AAE,MAAM,EAAE;AAAA,EAC9B;AACF,CAAC;;;;;;;"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const cache = require("./cache.cjs");
3
4
  const scope = require("./scope.cjs");
4
5
  const store = require("./store.cjs");
5
6
  const urlStore = require("./urlStore.cjs");
6
- require("./hash.cjs");
7
7
  class SubstriptionCache extends store.Store {
8
8
  constructor(connectFunction, options, derivedFromSubscriptionCache, _call) {
9
9
  super(options.default, options, void 0, _call);
@@ -68,7 +68,7 @@ function create(cacheFunction, ...[options = {}]) {
68
68
  options = Object.assign({}, defaultOptions, options);
69
69
  const { clearUnusedAfter, resourceGroup } = options;
70
70
  let baseInstance;
71
- const instanceCache = new scope.InstanceCache(
71
+ const instanceCache = new cache.InstanceCache(
72
72
  (...args) => {
73
73
  if (args.length === 0 && baseInstance) {
74
74
  return baseInstance;
@@ -107,7 +107,7 @@ function create(cacheFunction, ...[options = {}]) {
107
107
  }
108
108
  );
109
109
  const groups = Array.isArray(resourceGroup) ? resourceGroup : resourceGroup ? [resourceGroup] : [];
110
- for (const group of groups.concat(scope.allResources)) {
110
+ for (const group of groups.concat(cache.allResources)) {
111
111
  group.add(baseInstance);
112
112
  }
113
113
  get(...[]);
@@ -420,13 +420,13 @@ class Sync {
420
420
  function createSync(store2) {
421
421
  return new Sync(store2);
422
422
  }
423
- exports.Cache = scope.Cache;
424
- exports.InstanceCache = scope.InstanceCache;
425
- exports.ResourceGroup = scope.ResourceGroup;
423
+ exports.Cache = cache.Cache;
424
+ exports.InstanceCache = cache.InstanceCache;
425
+ exports.ResourceGroup = cache.ResourceGroup;
426
+ exports.allResources = cache.allResources;
427
+ exports.createCache = cache.createCache;
428
+ exports.createResourceGroup = cache.createResourceGroup;
426
429
  exports.Scope = scope.Scope;
427
- exports.allResources = scope.allResources;
428
- exports.createCache = scope.createCache;
429
- exports.createResourceGroup = scope.createResourceGroup;
430
430
  exports.createScope = scope.createScope;
431
431
  exports.Store = store.Store;
432
432
  exports.arrayMethods = store.arrayMethods;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const scope = require("../scope2.cjs");
3
+ const useCache = require("../useCache.cjs");
4
4
  const require$$0 = require("react");
5
5
  const store = require("../store.cjs");
6
- const hash = require("../hash.cjs");
6
+ const scope = require("../scope.cjs");
7
7
  const jsxRuntime = require("react/jsx-runtime");
8
8
  const urlStore = require("../urlStore.cjs");
9
9
  function CustomInput({ name, children, ...props }) {
@@ -375,7 +375,7 @@ class Form {
375
375
  }
376
376
  useFormState(selector, useStoreOptions) {
377
377
  const form = this.useForm();
378
- return scope.useStore(
378
+ return useCache.useStore(
379
379
  form.derivedState.map(
380
380
  (state) => selector({
381
381
  ...form,
@@ -486,7 +486,7 @@ class Form {
486
486
  );
487
487
  }
488
488
  return void 0;
489
- }, [formState, hash.hash(urlState)]);
489
+ }, [formState, scope.hash(urlState)]);
490
490
  require$$0.useEffect(() => {
491
491
  var _a;
492
492
  const handles = (_a = options.transform) == null ? void 0 : _a.map(({ trigger, update }) => {
@@ -531,7 +531,7 @@ function createForm(options) {
531
531
  return new Form(options);
532
532
  }
533
533
  function read(cache, options) {
534
- const { status, value, error } = scope.useCache(cache, options);
534
+ const { status, value, error } = useCache.useCache(cache, options);
535
535
  if (status === "value") {
536
536
  return value;
537
537
  }
@@ -565,7 +565,7 @@ function useDecoupledState(value, onChange, options = {}) {
565
565
  setDirty({ v: value2 });
566
566
  delayedUpdate(value2);
567
567
  };
568
- }, [hash.hash([options.debounce, options.throttle])]);
568
+ }, [scope.hash([options.debounce, options.throttle])]);
569
569
  return [dirty ? dirty.v : value, update];
570
570
  }
571
571
  function castArray(value) {
@@ -585,15 +585,17 @@ function useUrlParamScope({
585
585
  url[type] = parameters.toString();
586
586
  window.history.replaceState(null, "", url.toString());
587
587
  },
588
- [hash.hash(key), type]
588
+ [scope.hash(key), type]
589
589
  );
590
590
  }
591
- exports.ScopeProvider = scope.ScopeProvider;
592
- exports.reactMethods = scope.reactMethods;
593
- exports.useCache = scope.useCache;
594
- exports.useProp = scope.useProp;
595
- exports.useScope = scope.useScope;
596
- exports.useStore = scope.useStore;
591
+ exports.LoadingBoundary = useCache.LoadingBoundary;
592
+ exports.ScopeProvider = useCache.ScopeProvider;
593
+ exports.reactMethods = useCache.reactMethods;
594
+ exports.useCache = useCache.useCache;
595
+ exports.useLoadingBoundary = useCache.useLoadingBoundary;
596
+ exports.useProp = useCache.useProp;
597
+ exports.useScope = useCache.useScope;
598
+ exports.useStore = useCache.useStore;
597
599
  exports.CustomInput = CustomInput;
598
600
  exports.Form = Form;
599
601
  exports.createForm = createForm;