@effuse/store 1.0.0
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/README.md +7 -0
- package/dist/index.cjs +1462 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +698 -0
- package/dist/index.d.ts +698 -0
- package/dist/index.js +1388 -0
- package/dist/index.js.map +1 -0
- package/package.json +65 -0
- package/src/actions/async.ts +386 -0
- package/src/actions/cancellation.ts +131 -0
- package/src/actions/index.ts +48 -0
- package/src/composition/compose.ts +194 -0
- package/src/composition/index.ts +31 -0
- package/src/config/constants.ts +110 -0
- package/src/config/index.ts +40 -0
- package/src/context/index.ts +39 -0
- package/src/context/scope.ts +136 -0
- package/src/core/index.ts +36 -0
- package/src/core/state.ts +48 -0
- package/src/core/store.ts +467 -0
- package/src/core/types.ts +107 -0
- package/src/devtools/connector.ts +115 -0
- package/src/devtools/index.ts +31 -0
- package/src/errors.ts +81 -0
- package/src/index.ts +157 -0
- package/src/middleware/index.ts +25 -0
- package/src/middleware/manager.ts +61 -0
- package/src/persistence/adapters.ts +96 -0
- package/src/persistence/index.ts +31 -0
- package/src/reactivity/derived.ts +170 -0
- package/src/reactivity/index.ts +42 -0
- package/src/reactivity/selectors.ts +180 -0
- package/src/reactivity/streams.ts +194 -0
- package/src/registry/index.ts +60 -0
- package/src/validation/index.ts +33 -0
- package/src/validation/schema.ts +142 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1462 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var effect = require('effect');
|
|
4
|
+
var core = require('@effuse/core');
|
|
5
|
+
|
|
6
|
+
// src/core/store.ts
|
|
7
|
+
var createAtomicState = (initial) => {
|
|
8
|
+
const ref = effect.Effect.runSync(effect.SubscriptionRef.make(initial));
|
|
9
|
+
return {
|
|
10
|
+
get: () => effect.Effect.runSync(effect.SubscriptionRef.get(ref)),
|
|
11
|
+
set: (value) => {
|
|
12
|
+
effect.Effect.runSync(effect.SubscriptionRef.set(ref, value));
|
|
13
|
+
},
|
|
14
|
+
update: (fn) => {
|
|
15
|
+
effect.Effect.runSync(effect.SubscriptionRef.update(ref, fn));
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
var STORAGE_PREFIX = "effuse-store:";
|
|
20
|
+
var ROOT_SCOPE_ID = "__root__";
|
|
21
|
+
var SCOPE_PREFIX = "scope_";
|
|
22
|
+
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
23
|
+
effect.Duration.millis(DEFAULT_TIMEOUT_MS);
|
|
24
|
+
var DEFAULT_RETRY_INITIAL_DELAY_MS = 100;
|
|
25
|
+
var DEFAULT_RETRY_MAX_DELAY_MS = 5e3;
|
|
26
|
+
var DEFAULT_RETRY_BACKOFF_FACTOR = 2;
|
|
27
|
+
var StoreConstants = {
|
|
28
|
+
STORAGE_PREFIX,
|
|
29
|
+
ROOT_SCOPE_ID,
|
|
30
|
+
SCOPE_PREFIX,
|
|
31
|
+
DEBUG_PREFIX: "[store]",
|
|
32
|
+
DEVTOOLS_PREFIX: "Effuse:",
|
|
33
|
+
DEFAULT_TIMEOUT_MS
|
|
34
|
+
};
|
|
35
|
+
var StoreConfigOptions = {
|
|
36
|
+
persistByDefault: effect.Config.boolean("EFFUSE_STORE_PERSIST").pipe(
|
|
37
|
+
effect.Config.withDefault(false)
|
|
38
|
+
),
|
|
39
|
+
storagePrefix: effect.Config.string("EFFUSE_STORE_PREFIX").pipe(
|
|
40
|
+
effect.Config.withDefault(STORAGE_PREFIX)
|
|
41
|
+
),
|
|
42
|
+
debug: effect.Config.boolean("EFFUSE_STORE_DEBUG").pipe(effect.Config.withDefault(false)),
|
|
43
|
+
devtools: effect.Config.boolean("EFFUSE_STORE_DEVTOOLS").pipe(
|
|
44
|
+
effect.Config.withDefault(false)
|
|
45
|
+
)
|
|
46
|
+
};
|
|
47
|
+
var loadStoreConfigValues = effect.Effect.all({
|
|
48
|
+
persistByDefault: StoreConfigOptions.persistByDefault,
|
|
49
|
+
storagePrefix: StoreConfigOptions.storagePrefix,
|
|
50
|
+
debug: StoreConfigOptions.debug,
|
|
51
|
+
devtools: StoreConfigOptions.devtools
|
|
52
|
+
}).pipe(
|
|
53
|
+
effect.Effect.catchAll(
|
|
54
|
+
() => effect.Effect.succeed({
|
|
55
|
+
persistByDefault: false,
|
|
56
|
+
storagePrefix: STORAGE_PREFIX,
|
|
57
|
+
debug: false,
|
|
58
|
+
devtools: false
|
|
59
|
+
})
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
var cachedConfig = null;
|
|
63
|
+
var getStoreConfig = () => {
|
|
64
|
+
if (!cachedConfig) {
|
|
65
|
+
cachedConfig = effect.Effect.runSync(loadStoreConfigValues);
|
|
66
|
+
}
|
|
67
|
+
return cachedConfig;
|
|
68
|
+
};
|
|
69
|
+
var resetStoreConfigCache = () => {
|
|
70
|
+
cachedConfig = null;
|
|
71
|
+
};
|
|
72
|
+
var createMiddlewareManager = () => {
|
|
73
|
+
const middlewares = [];
|
|
74
|
+
return {
|
|
75
|
+
add: (middleware) => {
|
|
76
|
+
middlewares.push(middleware);
|
|
77
|
+
return () => {
|
|
78
|
+
const idx = middlewares.indexOf(middleware);
|
|
79
|
+
if (idx > -1) middlewares.splice(idx, 1);
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
remove: (middleware) => {
|
|
83
|
+
const idx = middlewares.indexOf(middleware);
|
|
84
|
+
if (idx > -1) middlewares.splice(idx, 1);
|
|
85
|
+
},
|
|
86
|
+
execute: (state, action, args) => effect.Array.reduce(middlewares, state, (acc, mw) => mw(acc, action, args) ?? acc),
|
|
87
|
+
getAll: () => [...middlewares]
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
var StoreNotFoundError = class extends effect.Data.TaggedError("StoreNotFoundError") {
|
|
91
|
+
get message() {
|
|
92
|
+
return `Store "${this.name}" not found`;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var StoreAlreadyExistsError = class extends effect.Data.TaggedError(
|
|
96
|
+
"StoreAlreadyExistsError"
|
|
97
|
+
) {
|
|
98
|
+
get message() {
|
|
99
|
+
return `Store "${this.name}" already exists`;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var ActionNotFoundError = class extends effect.Data.TaggedError(
|
|
103
|
+
"ActionNotFoundError"
|
|
104
|
+
) {
|
|
105
|
+
};
|
|
106
|
+
var TimeoutError = class extends effect.Data.TaggedError("TimeoutError") {
|
|
107
|
+
get message() {
|
|
108
|
+
return `Operation timed out after ${String(this.ms)}ms`;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var CancellationError = class extends effect.Data.TaggedError("CancellationError") {
|
|
112
|
+
};
|
|
113
|
+
var ValidationError = class extends effect.Data.TaggedError("ValidationError") {
|
|
114
|
+
get message() {
|
|
115
|
+
return `Validation failed: ${this.errors.join(", ")}`;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
(class extends effect.Data.TaggedError("RaceEmptyError") {
|
|
119
|
+
get message() {
|
|
120
|
+
return "raceAll requires at least one effect";
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
var HydrationError = class extends effect.Data.TaggedError("HydrationError") {
|
|
124
|
+
get message() {
|
|
125
|
+
return "Failed to hydrate stores";
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// src/registry/index.ts
|
|
130
|
+
var stores = /* @__PURE__ */ new Map();
|
|
131
|
+
var registerStore = (name, store) => {
|
|
132
|
+
if (stores.has(name) && getStoreConfig().debug) {
|
|
133
|
+
console.warn(`[store] Overwriting existing store: ${name}`);
|
|
134
|
+
}
|
|
135
|
+
stores.set(name, store);
|
|
136
|
+
};
|
|
137
|
+
var getStore = (name) => {
|
|
138
|
+
const store = stores.get(name);
|
|
139
|
+
if (!store) {
|
|
140
|
+
throw new StoreNotFoundError({ name });
|
|
141
|
+
}
|
|
142
|
+
return store;
|
|
143
|
+
};
|
|
144
|
+
var hasStore = (name) => stores.has(name);
|
|
145
|
+
var removeStore = (name) => stores.delete(name);
|
|
146
|
+
var clearStores = () => {
|
|
147
|
+
stores.clear();
|
|
148
|
+
};
|
|
149
|
+
var getStoreNames = () => Array.from(stores.keys());
|
|
150
|
+
var localStorageAdapter = {
|
|
151
|
+
getItem: (key) => effect.Effect.try({
|
|
152
|
+
try: () => effect.Option.fromNullable(localStorage.getItem(key)),
|
|
153
|
+
catch: () => effect.Option.none()
|
|
154
|
+
}).pipe(effect.Effect.catchAll(() => effect.Effect.succeed(effect.Option.none()))),
|
|
155
|
+
setItem: (key, value) => effect.Effect.try(() => {
|
|
156
|
+
localStorage.setItem(key, value);
|
|
157
|
+
}).pipe(effect.Effect.catchAll(() => effect.Effect.void)),
|
|
158
|
+
removeItem: (key) => effect.Effect.try(() => {
|
|
159
|
+
localStorage.removeItem(key);
|
|
160
|
+
}).pipe(effect.Effect.catchAll(() => effect.Effect.void))
|
|
161
|
+
};
|
|
162
|
+
var runAdapter = {
|
|
163
|
+
getItem: (adapter, key) => effect.Effect.runSync(
|
|
164
|
+
adapter.getItem(key).pipe(effect.Effect.map((opt) => effect.Option.getOrNull(opt)))
|
|
165
|
+
),
|
|
166
|
+
setItem: (adapter, key, value) => {
|
|
167
|
+
effect.Effect.runSync(adapter.setItem(key, value));
|
|
168
|
+
},
|
|
169
|
+
removeItem: (adapter, key) => {
|
|
170
|
+
effect.Effect.runSync(adapter.removeItem(key));
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var createCancellationToken = () => {
|
|
174
|
+
let cancelled = false;
|
|
175
|
+
const callbacks = /* @__PURE__ */ new Set();
|
|
176
|
+
return {
|
|
177
|
+
get isCancelled() {
|
|
178
|
+
return cancelled;
|
|
179
|
+
},
|
|
180
|
+
cancel: () => {
|
|
181
|
+
if (!cancelled) {
|
|
182
|
+
cancelled = true;
|
|
183
|
+
for (const cb of callbacks) cb();
|
|
184
|
+
callbacks.clear();
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
throwIfCancelled: () => {
|
|
188
|
+
if (cancelled)
|
|
189
|
+
throw new CancellationError({ message: "Operation was cancelled" });
|
|
190
|
+
},
|
|
191
|
+
onCancel: (callback) => {
|
|
192
|
+
if (cancelled) {
|
|
193
|
+
callback();
|
|
194
|
+
return () => {
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
callbacks.add(callback);
|
|
198
|
+
return () => callbacks.delete(callback);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
var createCancellationScope = () => {
|
|
203
|
+
const children = /* @__PURE__ */ new Set();
|
|
204
|
+
const token = createCancellationToken();
|
|
205
|
+
return {
|
|
206
|
+
token,
|
|
207
|
+
createChild: () => {
|
|
208
|
+
const child = createCancellationToken();
|
|
209
|
+
children.add(child);
|
|
210
|
+
token.onCancel(() => {
|
|
211
|
+
child.cancel();
|
|
212
|
+
});
|
|
213
|
+
return child;
|
|
214
|
+
},
|
|
215
|
+
dispose: () => {
|
|
216
|
+
token.cancel();
|
|
217
|
+
for (const child of children) child.cancel();
|
|
218
|
+
children.clear();
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
var runWithAbortSignal = (effect$1, signal5) => {
|
|
223
|
+
if (signal5.aborted) {
|
|
224
|
+
return effect.Effect.fail(
|
|
225
|
+
new CancellationError({ message: "Operation was cancelled" })
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
return effect.Effect.async((resume) => {
|
|
229
|
+
const onAbort = () => {
|
|
230
|
+
resume(
|
|
231
|
+
effect.Effect.fail(
|
|
232
|
+
new CancellationError({ message: "Operation was cancelled" })
|
|
233
|
+
)
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
signal5.addEventListener("abort", onAbort, { once: true });
|
|
237
|
+
effect.Effect.runPromise(effect$1).then((result) => {
|
|
238
|
+
signal5.removeEventListener("abort", onAbort);
|
|
239
|
+
resume(effect.Effect.succeed(result));
|
|
240
|
+
}).catch((error) => {
|
|
241
|
+
signal5.removeEventListener("abort", onAbort);
|
|
242
|
+
resume(effect.Effect.fail(error));
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// src/core/store.ts
|
|
248
|
+
var getSnapshot = (signalMap) => {
|
|
249
|
+
const snapshot = {};
|
|
250
|
+
for (const [key, sig] of signalMap) {
|
|
251
|
+
snapshot[key] = sig.value;
|
|
252
|
+
}
|
|
253
|
+
return snapshot;
|
|
254
|
+
};
|
|
255
|
+
var createStore = (name, definition, options) => {
|
|
256
|
+
const config = getStoreConfig();
|
|
257
|
+
const shouldPersist = effect.pipe(
|
|
258
|
+
effect.Option.fromNullable(options),
|
|
259
|
+
effect.Option.flatMap((o) => effect.Option.fromNullable(o.persist)),
|
|
260
|
+
effect.Option.getOrElse(() => config.persistByDefault)
|
|
261
|
+
);
|
|
262
|
+
const storageKey = effect.pipe(
|
|
263
|
+
effect.Option.fromNullable(options),
|
|
264
|
+
effect.Option.flatMap((o) => effect.Option.fromNullable(o.storageKey)),
|
|
265
|
+
effect.Option.getOrElse(() => `${config.storagePrefix}${name}`)
|
|
266
|
+
);
|
|
267
|
+
const enableDevtools = effect.pipe(
|
|
268
|
+
effect.Option.fromNullable(options),
|
|
269
|
+
effect.Option.flatMap((o) => effect.Option.fromNullable(o.devtools)),
|
|
270
|
+
effect.Option.getOrElse(() => config.debug)
|
|
271
|
+
);
|
|
272
|
+
const adapter = effect.pipe(
|
|
273
|
+
effect.Option.fromNullable(options),
|
|
274
|
+
effect.Option.flatMap((o) => effect.Option.fromNullable(o.storage)),
|
|
275
|
+
effect.Option.getOrElse(() => localStorageAdapter)
|
|
276
|
+
);
|
|
277
|
+
if (config.debug) {
|
|
278
|
+
console.log(`[store] Creating: ${name}`);
|
|
279
|
+
}
|
|
280
|
+
const internals = {
|
|
281
|
+
signalMap: /* @__PURE__ */ new Map(),
|
|
282
|
+
initialState: {},
|
|
283
|
+
actions: {},
|
|
284
|
+
subscribers: /* @__PURE__ */ new Set(),
|
|
285
|
+
keySubscribers: /* @__PURE__ */ new Map(),
|
|
286
|
+
computedSelectors: /* @__PURE__ */ new Map(),
|
|
287
|
+
isBatching: false,
|
|
288
|
+
pendingActions: /* @__PURE__ */ new Map()
|
|
289
|
+
};
|
|
290
|
+
const middlewareManager = createMiddlewareManager();
|
|
291
|
+
for (const [key, value] of Object.entries(definition)) {
|
|
292
|
+
if (typeof value === "function") {
|
|
293
|
+
internals.actions[key] = value;
|
|
294
|
+
} else {
|
|
295
|
+
internals.initialState[key] = value;
|
|
296
|
+
internals.signalMap.set(key, core.signal(value));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const atomicState = createAtomicState({ ...internals.initialState });
|
|
300
|
+
if (shouldPersist) {
|
|
301
|
+
effect.pipe(
|
|
302
|
+
runAdapter.getItem(adapter, storageKey),
|
|
303
|
+
effect.Option.fromNullable,
|
|
304
|
+
effect.Option.flatMap(
|
|
305
|
+
(saved) => effect.Effect.runSync(
|
|
306
|
+
effect.Effect.try(() => JSON.parse(saved)).pipe(
|
|
307
|
+
effect.Effect.map(effect.Option.some),
|
|
308
|
+
effect.Effect.catchAll(
|
|
309
|
+
() => effect.Effect.succeed(effect.Option.none())
|
|
310
|
+
)
|
|
311
|
+
)
|
|
312
|
+
)
|
|
313
|
+
),
|
|
314
|
+
effect.Option.map((parsed) => {
|
|
315
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
316
|
+
const sig = internals.signalMap.get(key);
|
|
317
|
+
if (sig) sig.value = value;
|
|
318
|
+
}
|
|
319
|
+
atomicState.set({ ...atomicState.get(), ...parsed });
|
|
320
|
+
})
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
const notifySubscribers = () => {
|
|
324
|
+
if (internals.isBatching) return;
|
|
325
|
+
for (const callback of internals.subscribers) callback();
|
|
326
|
+
};
|
|
327
|
+
const notifyKeySubscribers = (key, value) => {
|
|
328
|
+
if (internals.isBatching) return;
|
|
329
|
+
const subs = internals.keySubscribers.get(key);
|
|
330
|
+
if (subs) for (const cb of subs) cb(value);
|
|
331
|
+
};
|
|
332
|
+
const persistState = () => {
|
|
333
|
+
if (!shouldPersist) return;
|
|
334
|
+
const snapshot = getSnapshot(internals.signalMap);
|
|
335
|
+
runAdapter.setItem(adapter, storageKey, JSON.stringify(snapshot));
|
|
336
|
+
};
|
|
337
|
+
const updateComputed = () => {
|
|
338
|
+
const snapshot = getSnapshot(internals.signalMap);
|
|
339
|
+
for (const [selector, sig] of internals.computedSelectors) {
|
|
340
|
+
const newValue = selector(snapshot);
|
|
341
|
+
if (sig.value !== newValue) sig.value = newValue;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
const stateProxy = new Proxy({}, {
|
|
345
|
+
get(_, prop) {
|
|
346
|
+
const sig = internals.signalMap.get(prop);
|
|
347
|
+
if (sig) return sig;
|
|
348
|
+
const action = internals.actions[prop];
|
|
349
|
+
if (action) return action.bind(stateProxy);
|
|
350
|
+
return void 0;
|
|
351
|
+
},
|
|
352
|
+
set(_, prop, value) {
|
|
353
|
+
if (!internals.signalMap.has(prop)) return false;
|
|
354
|
+
const sig = internals.signalMap.get(prop);
|
|
355
|
+
if (!sig) return false;
|
|
356
|
+
const newState = middlewareManager.execute(
|
|
357
|
+
{ ...atomicState.get(), [prop]: value },
|
|
358
|
+
`set:${prop}`,
|
|
359
|
+
[value]
|
|
360
|
+
);
|
|
361
|
+
sig.value = newState[prop];
|
|
362
|
+
atomicState.update((s) => ({ ...s, [prop]: newState[prop] }));
|
|
363
|
+
if (enableDevtools) {
|
|
364
|
+
const time = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
365
|
+
console.groupCollapsed(
|
|
366
|
+
`%caction %c${name}/set:${prop} %c@ ${time}`,
|
|
367
|
+
"color: gray; font-weight: lighter;",
|
|
368
|
+
"color: inherit; font-weight: bold;",
|
|
369
|
+
"color: gray; font-weight: lighter;"
|
|
370
|
+
);
|
|
371
|
+
console.log(
|
|
372
|
+
"%cprev state",
|
|
373
|
+
"color: #9E9E9E; font-weight: bold;",
|
|
374
|
+
atomicState.get()
|
|
375
|
+
);
|
|
376
|
+
console.log("%caction", "color: #03A9F4; font-weight: bold;", {
|
|
377
|
+
type: `set:${prop}`,
|
|
378
|
+
payload: value
|
|
379
|
+
});
|
|
380
|
+
console.log("%cnext state", "color: #4CAF50; font-weight: bold;", {
|
|
381
|
+
...atomicState.get(),
|
|
382
|
+
[prop]: newState[prop]
|
|
383
|
+
});
|
|
384
|
+
console.groupEnd();
|
|
385
|
+
}
|
|
386
|
+
notifySubscribers();
|
|
387
|
+
notifyKeySubscribers(prop, newState[prop]);
|
|
388
|
+
persistState();
|
|
389
|
+
updateComputed();
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
const boundActions = {};
|
|
394
|
+
for (const [key, action] of Object.entries(internals.actions)) {
|
|
395
|
+
boundActions[key] = (...args) => {
|
|
396
|
+
const prevState = enableDevtools ? getSnapshot(internals.signalMap) : void 0;
|
|
397
|
+
const existingToken = internals.pendingActions.get(key);
|
|
398
|
+
if (existingToken) {
|
|
399
|
+
existingToken.cancel();
|
|
400
|
+
}
|
|
401
|
+
const result = action.apply(stateProxy, args);
|
|
402
|
+
if (result instanceof Promise) {
|
|
403
|
+
const token = createCancellationToken();
|
|
404
|
+
internals.pendingActions.set(key, token);
|
|
405
|
+
return result.then((value) => {
|
|
406
|
+
if (!token.isCancelled) {
|
|
407
|
+
internals.pendingActions.delete(key);
|
|
408
|
+
const currentState2 = getSnapshot(internals.signalMap);
|
|
409
|
+
middlewareManager.execute(currentState2, key, args);
|
|
410
|
+
if (enableDevtools) {
|
|
411
|
+
const time = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
412
|
+
console.groupCollapsed(
|
|
413
|
+
`%caction %c${name}/${key} (async) %c@ ${time}`,
|
|
414
|
+
"color: gray; font-weight: lighter;",
|
|
415
|
+
"color: inherit; font-weight: bold;",
|
|
416
|
+
"color: gray; font-weight: lighter;"
|
|
417
|
+
);
|
|
418
|
+
console.log(
|
|
419
|
+
"%cprev state",
|
|
420
|
+
"color: #9E9E9E; font-weight: bold;",
|
|
421
|
+
prevState
|
|
422
|
+
);
|
|
423
|
+
console.log("%caction", "color: #03A9F4; font-weight: bold;", {
|
|
424
|
+
type: `${name}/${key}`,
|
|
425
|
+
payload: args
|
|
426
|
+
});
|
|
427
|
+
console.log(
|
|
428
|
+
"%cnext state",
|
|
429
|
+
"color: #4CAF50; font-weight: bold;",
|
|
430
|
+
currentState2
|
|
431
|
+
);
|
|
432
|
+
console.groupEnd();
|
|
433
|
+
}
|
|
434
|
+
notifySubscribers();
|
|
435
|
+
}
|
|
436
|
+
return value;
|
|
437
|
+
}).catch((error) => {
|
|
438
|
+
internals.pendingActions.delete(key);
|
|
439
|
+
throw error;
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
const currentState = getSnapshot(internals.signalMap);
|
|
443
|
+
middlewareManager.execute(currentState, key, args);
|
|
444
|
+
if (enableDevtools) {
|
|
445
|
+
const time = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
446
|
+
console.groupCollapsed(
|
|
447
|
+
`%caction %c${name}/${key} %c@ ${time}`,
|
|
448
|
+
"color: gray; font-weight: lighter;",
|
|
449
|
+
"color: inherit; font-weight: bold;",
|
|
450
|
+
"color: gray; font-weight: lighter;"
|
|
451
|
+
);
|
|
452
|
+
console.log(
|
|
453
|
+
"%cprev state",
|
|
454
|
+
"color: #9E9E9E; font-weight: bold;",
|
|
455
|
+
prevState
|
|
456
|
+
);
|
|
457
|
+
console.log("%caction", "color: #03A9F4; font-weight: bold;", {
|
|
458
|
+
type: `${name}/${key}`,
|
|
459
|
+
payload: args
|
|
460
|
+
});
|
|
461
|
+
console.log(
|
|
462
|
+
"%cnext state",
|
|
463
|
+
"color: #4CAF50; font-weight: bold;",
|
|
464
|
+
currentState
|
|
465
|
+
);
|
|
466
|
+
console.groupEnd();
|
|
467
|
+
}
|
|
468
|
+
notifySubscribers();
|
|
469
|
+
return result;
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
const storeState = {};
|
|
473
|
+
for (const [key, sig] of internals.signalMap) storeState[key] = sig;
|
|
474
|
+
for (const [key, action] of Object.entries(boundActions))
|
|
475
|
+
storeState[key] = action;
|
|
476
|
+
const store = {
|
|
477
|
+
name,
|
|
478
|
+
state: storeState,
|
|
479
|
+
subscribe: (callback) => {
|
|
480
|
+
internals.subscribers.add(callback);
|
|
481
|
+
return () => {
|
|
482
|
+
internals.subscribers.delete(callback);
|
|
483
|
+
};
|
|
484
|
+
},
|
|
485
|
+
subscribeToKey: (key, callback) => {
|
|
486
|
+
const keyStr = String(key);
|
|
487
|
+
let subs = internals.keySubscribers.get(keyStr);
|
|
488
|
+
if (!subs) {
|
|
489
|
+
subs = /* @__PURE__ */ new Set();
|
|
490
|
+
internals.keySubscribers.set(keyStr, subs);
|
|
491
|
+
}
|
|
492
|
+
const typedCallback = callback;
|
|
493
|
+
subs.add(typedCallback);
|
|
494
|
+
return () => {
|
|
495
|
+
const subsSet = internals.keySubscribers.get(keyStr);
|
|
496
|
+
if (effect.Predicate.isNotNullable(subsSet)) {
|
|
497
|
+
subsSet.delete(typedCallback);
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
},
|
|
501
|
+
getSnapshot: () => getSnapshot(internals.signalMap),
|
|
502
|
+
computed: (selector) => {
|
|
503
|
+
const selectorKey = selector;
|
|
504
|
+
const existing = internals.computedSelectors.get(selectorKey);
|
|
505
|
+
if (existing) return existing;
|
|
506
|
+
const initial = selector(getSnapshot(internals.signalMap));
|
|
507
|
+
const sig = core.signal(initial);
|
|
508
|
+
internals.computedSelectors.set(selectorKey, sig);
|
|
509
|
+
return sig;
|
|
510
|
+
},
|
|
511
|
+
batch: (updates) => {
|
|
512
|
+
internals.isBatching = true;
|
|
513
|
+
updates();
|
|
514
|
+
internals.isBatching = false;
|
|
515
|
+
notifySubscribers();
|
|
516
|
+
persistState();
|
|
517
|
+
updateComputed();
|
|
518
|
+
},
|
|
519
|
+
reset: () => {
|
|
520
|
+
for (const [key, value] of Object.entries(internals.initialState)) {
|
|
521
|
+
const sig = internals.signalMap.get(key);
|
|
522
|
+
if (sig) sig.value = value;
|
|
523
|
+
}
|
|
524
|
+
atomicState.set({ ...internals.initialState });
|
|
525
|
+
notifySubscribers();
|
|
526
|
+
persistState();
|
|
527
|
+
updateComputed();
|
|
528
|
+
},
|
|
529
|
+
use: (middleware) => middlewareManager.add(middleware),
|
|
530
|
+
toJSON: () => getSnapshot(internals.signalMap),
|
|
531
|
+
update: (updater) => {
|
|
532
|
+
const draft = { ...getSnapshot(internals.signalMap) };
|
|
533
|
+
updater(draft);
|
|
534
|
+
internals.isBatching = true;
|
|
535
|
+
for (const [key, val] of Object.entries(draft)) {
|
|
536
|
+
const sig = internals.signalMap.get(key);
|
|
537
|
+
if (sig && sig.value !== val) {
|
|
538
|
+
sig.value = val;
|
|
539
|
+
atomicState.update((s) => ({ ...s, [key]: val }));
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
internals.isBatching = false;
|
|
543
|
+
notifySubscribers();
|
|
544
|
+
persistState();
|
|
545
|
+
updateComputed();
|
|
546
|
+
},
|
|
547
|
+
select: (selector) => {
|
|
548
|
+
const selectorKey = selector;
|
|
549
|
+
const existing = internals.computedSelectors.get(selectorKey);
|
|
550
|
+
if (existing) return existing;
|
|
551
|
+
const initial = selector(getSnapshot(internals.signalMap));
|
|
552
|
+
const sig = core.signal(initial);
|
|
553
|
+
internals.computedSelectors.set(selectorKey, sig);
|
|
554
|
+
internals.subscribers.add(() => {
|
|
555
|
+
const newValue = selector(getSnapshot(internals.signalMap));
|
|
556
|
+
if (sig.value !== newValue) sig.value = newValue;
|
|
557
|
+
});
|
|
558
|
+
return sig;
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
const storeProxy = new Proxy(store, {
|
|
562
|
+
get(target, prop) {
|
|
563
|
+
const propStr = String(prop);
|
|
564
|
+
if (propStr === "toJSON") return () => getSnapshot(internals.signalMap);
|
|
565
|
+
if (propStr in target) return target[propStr];
|
|
566
|
+
const sig = internals.signalMap.get(propStr);
|
|
567
|
+
if (sig) return sig;
|
|
568
|
+
if (propStr in boundActions) return boundActions[propStr];
|
|
569
|
+
return void 0;
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
registerStore(name, storeProxy);
|
|
573
|
+
return storeProxy;
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
// src/context/scope.ts
|
|
577
|
+
var ROOT_SCOPE = {
|
|
578
|
+
id: "__root__",
|
|
579
|
+
parent: null,
|
|
580
|
+
stores: /* @__PURE__ */ new Map()
|
|
581
|
+
};
|
|
582
|
+
var currentScope = ROOT_SCOPE;
|
|
583
|
+
var scopeRegistry = /* @__PURE__ */ new Map([
|
|
584
|
+
[ROOT_SCOPE.id, ROOT_SCOPE]
|
|
585
|
+
]);
|
|
586
|
+
var scopeCounter = 0;
|
|
587
|
+
var createScope = (parentScope) => {
|
|
588
|
+
scopeCounter++;
|
|
589
|
+
const id = `scope_${String(scopeCounter)}`;
|
|
590
|
+
const node = {
|
|
591
|
+
id,
|
|
592
|
+
parent: parentScope ?? currentScope,
|
|
593
|
+
stores: /* @__PURE__ */ new Map()
|
|
594
|
+
};
|
|
595
|
+
scopeRegistry.set(id, node);
|
|
596
|
+
return node;
|
|
597
|
+
};
|
|
598
|
+
var disposeScope = (scope) => {
|
|
599
|
+
scope.stores.clear();
|
|
600
|
+
scopeRegistry.delete(scope.id);
|
|
601
|
+
};
|
|
602
|
+
var enterScope = (scope) => {
|
|
603
|
+
currentScope = scope;
|
|
604
|
+
};
|
|
605
|
+
var exitScope = () => {
|
|
606
|
+
if (currentScope.parent) {
|
|
607
|
+
currentScope = currentScope.parent;
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
var getCurrentScope = () => currentScope;
|
|
611
|
+
var getRootScope = () => ROOT_SCOPE;
|
|
612
|
+
var registerScopedStore = (name, store, scope = currentScope) => {
|
|
613
|
+
scope.stores.set(name, store);
|
|
614
|
+
};
|
|
615
|
+
var getScopedStore = (name, scope = currentScope) => {
|
|
616
|
+
let current = scope;
|
|
617
|
+
while (current) {
|
|
618
|
+
const store = current.stores.get(name);
|
|
619
|
+
if (store) return store;
|
|
620
|
+
current = current.parent;
|
|
621
|
+
}
|
|
622
|
+
return null;
|
|
623
|
+
};
|
|
624
|
+
var hasScopedStore = (name, scope = currentScope) => {
|
|
625
|
+
return getScopedStore(name, scope) !== null;
|
|
626
|
+
};
|
|
627
|
+
var runInScope = (scope, fn) => {
|
|
628
|
+
const prev = currentScope;
|
|
629
|
+
currentScope = scope;
|
|
630
|
+
try {
|
|
631
|
+
return fn();
|
|
632
|
+
} finally {
|
|
633
|
+
currentScope = prev;
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
var withScope = (fn) => {
|
|
637
|
+
const scope = createScope();
|
|
638
|
+
try {
|
|
639
|
+
return runInScope(scope, () => fn(scope));
|
|
640
|
+
} finally {
|
|
641
|
+
disposeScope(scope);
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
var createAsyncAction = (fn) => {
|
|
645
|
+
let pending = false;
|
|
646
|
+
const action = async (...args) => {
|
|
647
|
+
pending = true;
|
|
648
|
+
const result = await effect.Effect.runPromise(
|
|
649
|
+
effect.Effect.tryPromise({
|
|
650
|
+
try: async () => fn(...args),
|
|
651
|
+
catch: (error) => error
|
|
652
|
+
}).pipe(
|
|
653
|
+
effect.Effect.tapBoth({
|
|
654
|
+
onSuccess: () => effect.Effect.sync(() => {
|
|
655
|
+
pending = false;
|
|
656
|
+
}),
|
|
657
|
+
onFailure: () => effect.Effect.sync(() => {
|
|
658
|
+
pending = false;
|
|
659
|
+
})
|
|
660
|
+
})
|
|
661
|
+
)
|
|
662
|
+
);
|
|
663
|
+
return result;
|
|
664
|
+
};
|
|
665
|
+
Object.defineProperty(action, "pending", {
|
|
666
|
+
get: () => pending,
|
|
667
|
+
enumerable: true
|
|
668
|
+
});
|
|
669
|
+
return action;
|
|
670
|
+
};
|
|
671
|
+
var createCancellableAction = (fn) => {
|
|
672
|
+
let pending = false;
|
|
673
|
+
let currentController = null;
|
|
674
|
+
const action = async (...args) => {
|
|
675
|
+
if (currentController) {
|
|
676
|
+
currentController.abort();
|
|
677
|
+
}
|
|
678
|
+
currentController = new AbortController();
|
|
679
|
+
const signal5 = currentController.signal;
|
|
680
|
+
pending = true;
|
|
681
|
+
try {
|
|
682
|
+
const effect$1 = effect.Effect.tryPromise({
|
|
683
|
+
try: async () => fn(...args),
|
|
684
|
+
catch: (error) => error
|
|
685
|
+
});
|
|
686
|
+
const result = await effect.Effect.runPromise(
|
|
687
|
+
runWithAbortSignal(effect$1, signal5)
|
|
688
|
+
);
|
|
689
|
+
return result;
|
|
690
|
+
} finally {
|
|
691
|
+
pending = false;
|
|
692
|
+
currentController = null;
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
Object.defineProperty(action, "pending", {
|
|
696
|
+
get: () => pending,
|
|
697
|
+
enumerable: true
|
|
698
|
+
});
|
|
699
|
+
Object.defineProperty(action, "cancel", {
|
|
700
|
+
value: () => {
|
|
701
|
+
if (currentController) {
|
|
702
|
+
currentController.abort();
|
|
703
|
+
currentController = null;
|
|
704
|
+
pending = false;
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
enumerable: true
|
|
708
|
+
});
|
|
709
|
+
return action;
|
|
710
|
+
};
|
|
711
|
+
var withTimeout = (fn, timeoutMs) => {
|
|
712
|
+
return async (...args) => {
|
|
713
|
+
const effect$1 = effect.Effect.tryPromise({
|
|
714
|
+
try: async () => fn(...args),
|
|
715
|
+
catch: (error) => error
|
|
716
|
+
}).pipe(
|
|
717
|
+
effect.Effect.timeoutFail({
|
|
718
|
+
duration: effect.Duration.millis(timeoutMs),
|
|
719
|
+
onTimeout: () => new TimeoutError({ ms: timeoutMs })
|
|
720
|
+
})
|
|
721
|
+
);
|
|
722
|
+
return effect.Effect.runPromise(effect$1);
|
|
723
|
+
};
|
|
724
|
+
};
|
|
725
|
+
var withRetry = (fn, config) => {
|
|
726
|
+
const {
|
|
727
|
+
maxRetries,
|
|
728
|
+
initialDelayMs = DEFAULT_RETRY_INITIAL_DELAY_MS,
|
|
729
|
+
maxDelayMs = DEFAULT_RETRY_MAX_DELAY_MS,
|
|
730
|
+
backoffFactor = DEFAULT_RETRY_BACKOFF_FACTOR
|
|
731
|
+
} = config;
|
|
732
|
+
return async (...args) => {
|
|
733
|
+
const schedule = effect.Schedule.exponential(
|
|
734
|
+
effect.Duration.millis(initialDelayMs),
|
|
735
|
+
backoffFactor
|
|
736
|
+
).pipe(
|
|
737
|
+
effect.Schedule.either(effect.Schedule.recurs(maxRetries)),
|
|
738
|
+
effect.Schedule.upTo(effect.Duration.millis(maxDelayMs))
|
|
739
|
+
);
|
|
740
|
+
const effect$1 = effect.Effect.tryPromise({
|
|
741
|
+
try: async () => fn(...args),
|
|
742
|
+
catch: (error) => error
|
|
743
|
+
}).pipe(effect.Effect.retry(schedule));
|
|
744
|
+
return effect.Effect.runPromise(effect$1);
|
|
745
|
+
};
|
|
746
|
+
};
|
|
747
|
+
var takeLatest = (fn) => {
|
|
748
|
+
let pending = false;
|
|
749
|
+
let currentToken = createCancellationToken();
|
|
750
|
+
let callId = 0;
|
|
751
|
+
const action = async (...args) => {
|
|
752
|
+
currentToken.cancel();
|
|
753
|
+
currentToken = createCancellationToken();
|
|
754
|
+
const myToken = currentToken;
|
|
755
|
+
const myCallId = ++callId;
|
|
756
|
+
pending = true;
|
|
757
|
+
try {
|
|
758
|
+
const result = await fn(...args);
|
|
759
|
+
if (myToken.isCancelled || myCallId !== callId) {
|
|
760
|
+
throw new CancellationError({ message: "Superseded by newer call" });
|
|
761
|
+
}
|
|
762
|
+
return result;
|
|
763
|
+
} finally {
|
|
764
|
+
if (myCallId === callId) {
|
|
765
|
+
pending = false;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
Object.defineProperty(action, "pending", {
|
|
770
|
+
get: () => pending,
|
|
771
|
+
enumerable: true
|
|
772
|
+
});
|
|
773
|
+
Object.defineProperty(action, "cancel", {
|
|
774
|
+
value: () => {
|
|
775
|
+
currentToken.cancel();
|
|
776
|
+
pending = false;
|
|
777
|
+
},
|
|
778
|
+
enumerable: true
|
|
779
|
+
});
|
|
780
|
+
return action;
|
|
781
|
+
};
|
|
782
|
+
var takeFirst = (fn) => {
|
|
783
|
+
let pending = false;
|
|
784
|
+
const action = async (...args) => {
|
|
785
|
+
if (pending) {
|
|
786
|
+
return void 0;
|
|
787
|
+
}
|
|
788
|
+
pending = true;
|
|
789
|
+
try {
|
|
790
|
+
return await fn(...args);
|
|
791
|
+
} finally {
|
|
792
|
+
pending = false;
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
Object.defineProperty(action, "pending", {
|
|
796
|
+
get: () => pending,
|
|
797
|
+
enumerable: true
|
|
798
|
+
});
|
|
799
|
+
return action;
|
|
800
|
+
};
|
|
801
|
+
var debounceAction = (fn, delayMs) => {
|
|
802
|
+
let timeout = null;
|
|
803
|
+
let currentToken = createCancellationToken();
|
|
804
|
+
return (...args) => {
|
|
805
|
+
if (timeout) {
|
|
806
|
+
clearTimeout(timeout);
|
|
807
|
+
currentToken.cancel();
|
|
808
|
+
}
|
|
809
|
+
currentToken = createCancellationToken();
|
|
810
|
+
const myToken = currentToken;
|
|
811
|
+
return new Promise((resolve, reject) => {
|
|
812
|
+
timeout = setTimeout(() => {
|
|
813
|
+
if (myToken.isCancelled) return;
|
|
814
|
+
Promise.resolve(fn(...args)).then((result) => {
|
|
815
|
+
if (!myToken.isCancelled) resolve(result);
|
|
816
|
+
}).catch((error) => {
|
|
817
|
+
if (!myToken.isCancelled) reject(error);
|
|
818
|
+
});
|
|
819
|
+
}, delayMs);
|
|
820
|
+
});
|
|
821
|
+
};
|
|
822
|
+
};
|
|
823
|
+
var throttleAction = (fn, intervalMs) => {
|
|
824
|
+
let lastCallTime = 0;
|
|
825
|
+
let pending = false;
|
|
826
|
+
return async (...args) => {
|
|
827
|
+
const now = Date.now();
|
|
828
|
+
if (now - lastCallTime < intervalMs || pending) {
|
|
829
|
+
return void 0;
|
|
830
|
+
}
|
|
831
|
+
lastCallTime = now;
|
|
832
|
+
pending = true;
|
|
833
|
+
try {
|
|
834
|
+
return await fn(...args);
|
|
835
|
+
} finally {
|
|
836
|
+
pending = false;
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
};
|
|
840
|
+
var dispatch = (store, actionName, ...args) => {
|
|
841
|
+
const storeRecord = store;
|
|
842
|
+
const action = storeRecord[actionName];
|
|
843
|
+
if (typeof action !== "function") {
|
|
844
|
+
return Promise.reject(
|
|
845
|
+
new ActionNotFoundError({ actionName: String(actionName) })
|
|
846
|
+
);
|
|
847
|
+
}
|
|
848
|
+
const actionFn = action;
|
|
849
|
+
return effect.Effect.runPromise(
|
|
850
|
+
effect.Effect.tryPromise({
|
|
851
|
+
try: () => Promise.resolve(actionFn(...args)),
|
|
852
|
+
catch: (error) => error
|
|
853
|
+
})
|
|
854
|
+
);
|
|
855
|
+
};
|
|
856
|
+
var dispatchSync = (store, actionName, ...args) => {
|
|
857
|
+
const storeRecord = store;
|
|
858
|
+
const action = storeRecord[actionName];
|
|
859
|
+
if (typeof action !== "function") {
|
|
860
|
+
throw new ActionNotFoundError({ actionName: String(actionName) });
|
|
861
|
+
}
|
|
862
|
+
const actionFn = action;
|
|
863
|
+
return actionFn(...args);
|
|
864
|
+
};
|
|
865
|
+
var withAbortSignal = (fn) => {
|
|
866
|
+
return (signal5, ...args) => {
|
|
867
|
+
const effect$1 = effect.Effect.tryPromise({
|
|
868
|
+
try: async () => fn(...args),
|
|
869
|
+
catch: (error) => error
|
|
870
|
+
});
|
|
871
|
+
return effect.Effect.runPromise(runWithAbortSignal(effect$1, signal5));
|
|
872
|
+
};
|
|
873
|
+
};
|
|
874
|
+
var validateState = (schema, state) => {
|
|
875
|
+
const result = effect.Effect.runSync(
|
|
876
|
+
effect.Schema.decodeUnknown(schema)(state).pipe(
|
|
877
|
+
effect.Effect.map((data) => ({
|
|
878
|
+
success: true,
|
|
879
|
+
data,
|
|
880
|
+
errors: []
|
|
881
|
+
})),
|
|
882
|
+
effect.Effect.catchAll(
|
|
883
|
+
(error) => effect.Effect.succeed({
|
|
884
|
+
success: false,
|
|
885
|
+
data: null,
|
|
886
|
+
errors: [String(error)]
|
|
887
|
+
})
|
|
888
|
+
)
|
|
889
|
+
)
|
|
890
|
+
);
|
|
891
|
+
return result;
|
|
892
|
+
};
|
|
893
|
+
var validateStateAsync = (schema, state, timeoutMs = DEFAULT_TIMEOUT_MS) => {
|
|
894
|
+
return effect.Effect.runPromise(
|
|
895
|
+
effect.Schema.decodeUnknown(schema)(state).pipe(
|
|
896
|
+
effect.Effect.map((data) => ({
|
|
897
|
+
success: true,
|
|
898
|
+
data,
|
|
899
|
+
errors: []
|
|
900
|
+
})),
|
|
901
|
+
effect.Effect.timeoutFail({
|
|
902
|
+
duration: effect.Duration.millis(timeoutMs),
|
|
903
|
+
onTimeout: () => new TimeoutError({ ms: timeoutMs })
|
|
904
|
+
}),
|
|
905
|
+
effect.Effect.catchAll(
|
|
906
|
+
(error) => effect.Effect.succeed({
|
|
907
|
+
success: false,
|
|
908
|
+
data: null,
|
|
909
|
+
errors: [
|
|
910
|
+
error instanceof TimeoutError ? `Validation timed out after ${String(timeoutMs)}ms` : String(error)
|
|
911
|
+
]
|
|
912
|
+
})
|
|
913
|
+
)
|
|
914
|
+
)
|
|
915
|
+
);
|
|
916
|
+
};
|
|
917
|
+
var createValidatedSetter = (schema, onValid, onInvalid) => {
|
|
918
|
+
return (state) => {
|
|
919
|
+
const result = validateState(schema, state);
|
|
920
|
+
if (result.success && result.data) {
|
|
921
|
+
onValid(result.data);
|
|
922
|
+
return true;
|
|
923
|
+
}
|
|
924
|
+
if (effect.Predicate.isNotNullable(onInvalid)) {
|
|
925
|
+
onInvalid(result.errors);
|
|
926
|
+
}
|
|
927
|
+
return false;
|
|
928
|
+
};
|
|
929
|
+
};
|
|
930
|
+
var createFieldValidator = (schema) => {
|
|
931
|
+
return (value) => {
|
|
932
|
+
return effect.Effect.runSync(effect.Schema.decodeUnknown(schema)(value));
|
|
933
|
+
};
|
|
934
|
+
};
|
|
935
|
+
var createSafeFieldSetter = (schema, setter) => {
|
|
936
|
+
return (value) => {
|
|
937
|
+
const result = effect.Effect.runSync(
|
|
938
|
+
effect.Schema.decodeUnknown(schema)(value).pipe(
|
|
939
|
+
effect.Effect.map((decoded) => {
|
|
940
|
+
setter(decoded);
|
|
941
|
+
return true;
|
|
942
|
+
}),
|
|
943
|
+
effect.Effect.catchAll(() => effect.Effect.succeed(false))
|
|
944
|
+
)
|
|
945
|
+
);
|
|
946
|
+
return result;
|
|
947
|
+
};
|
|
948
|
+
};
|
|
949
|
+
var composeStores = (mainStore, dependencies) => {
|
|
950
|
+
const getDependencySnapshots = () => {
|
|
951
|
+
return dependencies.map((dep) => dep.getSnapshot());
|
|
952
|
+
};
|
|
953
|
+
return {
|
|
954
|
+
store: mainStore,
|
|
955
|
+
dependencies,
|
|
956
|
+
computed: (selector) => {
|
|
957
|
+
const mainSnapshot = mainStore.getSnapshot();
|
|
958
|
+
const depSnapshots = getDependencySnapshots();
|
|
959
|
+
const initialValue = selector(mainSnapshot, depSnapshots);
|
|
960
|
+
const derived = core.signal(initialValue);
|
|
961
|
+
const update = () => {
|
|
962
|
+
const mainState = mainStore.getSnapshot();
|
|
963
|
+
const depStates = getDependencySnapshots();
|
|
964
|
+
const newValue = selector(mainState, depStates);
|
|
965
|
+
if (derived.value !== newValue) {
|
|
966
|
+
derived.value = newValue;
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
mainStore.subscribe(update);
|
|
970
|
+
for (const dep of dependencies) {
|
|
971
|
+
dep.subscribe(update);
|
|
972
|
+
}
|
|
973
|
+
return derived;
|
|
974
|
+
},
|
|
975
|
+
computedAsync: (asyncSelector, initialValue) => {
|
|
976
|
+
const derived = core.signal(initialValue);
|
|
977
|
+
const pending = core.signal(false);
|
|
978
|
+
let currentToken = createCancellationToken();
|
|
979
|
+
const unsubscribers = [];
|
|
980
|
+
const update = () => {
|
|
981
|
+
currentToken.cancel();
|
|
982
|
+
currentToken = createCancellationToken();
|
|
983
|
+
const myToken = currentToken;
|
|
984
|
+
pending.value = true;
|
|
985
|
+
const mainState = mainStore.getSnapshot();
|
|
986
|
+
const depStates = getDependencySnapshots();
|
|
987
|
+
asyncSelector(mainState, depStates, myToken).then((newValue) => {
|
|
988
|
+
if (!myToken.isCancelled && derived.value !== newValue) {
|
|
989
|
+
derived.value = newValue;
|
|
990
|
+
}
|
|
991
|
+
}).catch(() => {
|
|
992
|
+
}).finally(() => {
|
|
993
|
+
if (!myToken.isCancelled) {
|
|
994
|
+
pending.value = false;
|
|
995
|
+
}
|
|
996
|
+
});
|
|
997
|
+
};
|
|
998
|
+
unsubscribers.push(mainStore.subscribe(update));
|
|
999
|
+
for (const dep of dependencies) {
|
|
1000
|
+
unsubscribers.push(dep.subscribe(update));
|
|
1001
|
+
}
|
|
1002
|
+
update();
|
|
1003
|
+
const result = derived;
|
|
1004
|
+
result.pending = pending;
|
|
1005
|
+
result.cleanup = () => {
|
|
1006
|
+
currentToken.cancel();
|
|
1007
|
+
for (const unsub of unsubscribers) unsub();
|
|
1008
|
+
};
|
|
1009
|
+
return result;
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
var defineSlice = (name, factory) => {
|
|
1014
|
+
return {
|
|
1015
|
+
create: (parent) => {
|
|
1016
|
+
const definition = factory(parent);
|
|
1017
|
+
return createStore(name, definition);
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
};
|
|
1021
|
+
var mergeStores = (storeA, storeB) => {
|
|
1022
|
+
return {
|
|
1023
|
+
getSnapshot: () => ({
|
|
1024
|
+
...storeA.getSnapshot(),
|
|
1025
|
+
...storeB.getSnapshot()
|
|
1026
|
+
}),
|
|
1027
|
+
subscribe: (callback) => {
|
|
1028
|
+
const unsubA = storeA.subscribe(callback);
|
|
1029
|
+
const unsubB = storeB.subscribe(callback);
|
|
1030
|
+
return () => {
|
|
1031
|
+
unsubA();
|
|
1032
|
+
unsubB();
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
};
|
|
1037
|
+
var deriveFrom = (stores2, selector) => {
|
|
1038
|
+
const getSnapshots = () => stores2.map((s) => s.getSnapshot());
|
|
1039
|
+
const initialValue = selector(...getSnapshots());
|
|
1040
|
+
const derivedSignal = core.signal(initialValue);
|
|
1041
|
+
const update = () => {
|
|
1042
|
+
const newValue = selector(...getSnapshots());
|
|
1043
|
+
if (derivedSignal.value !== newValue) {
|
|
1044
|
+
derivedSignal.value = newValue;
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
const unsubscribers = stores2.map((store) => store.subscribe(update));
|
|
1048
|
+
const signalWithCleanup = derivedSignal;
|
|
1049
|
+
signalWithCleanup.cleanup = () => {
|
|
1050
|
+
for (const unsub of unsubscribers) {
|
|
1051
|
+
unsub();
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
return signalWithCleanup;
|
|
1055
|
+
};
|
|
1056
|
+
var deriveFromAsync = (stores2, asyncSelector, initialValue) => {
|
|
1057
|
+
const getSnapshots = () => stores2.map((s) => s.getSnapshot());
|
|
1058
|
+
const derivedSignal = core.signal(initialValue);
|
|
1059
|
+
const pendingSignal = core.signal(false);
|
|
1060
|
+
let currentToken = createCancellationToken();
|
|
1061
|
+
const update = () => {
|
|
1062
|
+
currentToken.cancel();
|
|
1063
|
+
currentToken = createCancellationToken();
|
|
1064
|
+
const myToken = currentToken;
|
|
1065
|
+
pendingSignal.value = true;
|
|
1066
|
+
asyncSelector(getSnapshots(), myToken).then((newValue) => {
|
|
1067
|
+
if (!myToken.isCancelled && derivedSignal.value !== newValue) {
|
|
1068
|
+
derivedSignal.value = newValue;
|
|
1069
|
+
}
|
|
1070
|
+
}).catch(() => {
|
|
1071
|
+
}).finally(() => {
|
|
1072
|
+
if (!myToken.isCancelled) {
|
|
1073
|
+
pendingSignal.value = false;
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
};
|
|
1077
|
+
const unsubscribers = stores2.map((store) => store.subscribe(update));
|
|
1078
|
+
update();
|
|
1079
|
+
const signalWithCleanup = derivedSignal;
|
|
1080
|
+
signalWithCleanup.cleanup = () => {
|
|
1081
|
+
currentToken.cancel();
|
|
1082
|
+
for (const unsub of unsubscribers) {
|
|
1083
|
+
unsub();
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
signalWithCleanup.pending = pendingSignal;
|
|
1087
|
+
return signalWithCleanup;
|
|
1088
|
+
};
|
|
1089
|
+
var serializeStores = () => {
|
|
1090
|
+
const storeNames = getStoreNames();
|
|
1091
|
+
const allSnapshots = {};
|
|
1092
|
+
for (const name of storeNames) {
|
|
1093
|
+
const store = getStore(name);
|
|
1094
|
+
allSnapshots[name] = store.getSnapshot();
|
|
1095
|
+
}
|
|
1096
|
+
return JSON.stringify(allSnapshots);
|
|
1097
|
+
};
|
|
1098
|
+
var hydrateStores = (serialized) => effect.Effect.try({
|
|
1099
|
+
try: () => {
|
|
1100
|
+
const allSnapshots = JSON.parse(serialized);
|
|
1101
|
+
for (const [name, snapshot] of Object.entries(allSnapshots)) {
|
|
1102
|
+
effect.Effect.runSync(
|
|
1103
|
+
effect.Effect.try(() => {
|
|
1104
|
+
const store = getStore(name);
|
|
1105
|
+
store.update((draft) => {
|
|
1106
|
+
Object.assign(draft, snapshot);
|
|
1107
|
+
});
|
|
1108
|
+
}).pipe(effect.Effect.catchAll(() => effect.Effect.void))
|
|
1109
|
+
);
|
|
1110
|
+
}
|
|
1111
|
+
},
|
|
1112
|
+
catch: () => new HydrationError({})
|
|
1113
|
+
}).pipe(effect.Effect.catchAll(() => effect.Effect.void));
|
|
1114
|
+
var hydrateStoresSync = (serialized) => {
|
|
1115
|
+
effect.Effect.runSync(
|
|
1116
|
+
hydrateStores(serialized).pipe(
|
|
1117
|
+
effect.Effect.match({
|
|
1118
|
+
onSuccess: () => effect.Option.some(void 0),
|
|
1119
|
+
onFailure: () => effect.Option.none()
|
|
1120
|
+
})
|
|
1121
|
+
)
|
|
1122
|
+
);
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
// src/reactivity/streams.ts
|
|
1126
|
+
var createBaseStream = (addListener) => {
|
|
1127
|
+
return {
|
|
1128
|
+
subscribe: addListener,
|
|
1129
|
+
map: (fn) => {
|
|
1130
|
+
const mappedListeners = /* @__PURE__ */ new Set();
|
|
1131
|
+
addListener((value) => {
|
|
1132
|
+
const mapped = fn(value);
|
|
1133
|
+
for (const h of mappedListeners) h(mapped);
|
|
1134
|
+
});
|
|
1135
|
+
return createBaseStream((h) => {
|
|
1136
|
+
mappedListeners.add(h);
|
|
1137
|
+
return () => mappedListeners.delete(h);
|
|
1138
|
+
});
|
|
1139
|
+
},
|
|
1140
|
+
filter: (predicate) => {
|
|
1141
|
+
const filteredListeners = /* @__PURE__ */ new Set();
|
|
1142
|
+
addListener((value) => {
|
|
1143
|
+
if (predicate(value)) {
|
|
1144
|
+
for (const h of filteredListeners) h(value);
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
return createBaseStream((h) => {
|
|
1148
|
+
filteredListeners.add(h);
|
|
1149
|
+
return () => filteredListeners.delete(h);
|
|
1150
|
+
});
|
|
1151
|
+
},
|
|
1152
|
+
debounce: (ms) => {
|
|
1153
|
+
const debouncedListeners = /* @__PURE__ */ new Set();
|
|
1154
|
+
let timeout = null;
|
|
1155
|
+
let latestValue;
|
|
1156
|
+
let currentToken = createCancellationToken();
|
|
1157
|
+
addListener((value) => {
|
|
1158
|
+
latestValue = value;
|
|
1159
|
+
if (timeout) {
|
|
1160
|
+
clearTimeout(timeout);
|
|
1161
|
+
currentToken.cancel();
|
|
1162
|
+
}
|
|
1163
|
+
currentToken = createCancellationToken();
|
|
1164
|
+
const myToken = currentToken;
|
|
1165
|
+
timeout = setTimeout(() => {
|
|
1166
|
+
if (!myToken.isCancelled && latestValue !== void 0) {
|
|
1167
|
+
for (const h of debouncedListeners) h(latestValue);
|
|
1168
|
+
}
|
|
1169
|
+
}, ms);
|
|
1170
|
+
});
|
|
1171
|
+
return createBaseStream((h) => {
|
|
1172
|
+
debouncedListeners.add(h);
|
|
1173
|
+
return () => debouncedListeners.delete(h);
|
|
1174
|
+
});
|
|
1175
|
+
},
|
|
1176
|
+
throttle: (ms) => {
|
|
1177
|
+
const throttledListeners = /* @__PURE__ */ new Set();
|
|
1178
|
+
let lastEmitTime = 0;
|
|
1179
|
+
addListener((value) => {
|
|
1180
|
+
const now = Date.now();
|
|
1181
|
+
if (now - lastEmitTime >= ms) {
|
|
1182
|
+
lastEmitTime = now;
|
|
1183
|
+
for (const h of throttledListeners) h(value);
|
|
1184
|
+
}
|
|
1185
|
+
});
|
|
1186
|
+
return createBaseStream((h) => {
|
|
1187
|
+
throttledListeners.add(h);
|
|
1188
|
+
return () => throttledListeners.delete(h);
|
|
1189
|
+
});
|
|
1190
|
+
},
|
|
1191
|
+
takeLatest: (asyncHandler) => {
|
|
1192
|
+
const latestListeners = /* @__PURE__ */ new Set();
|
|
1193
|
+
let currentToken = createCancellationToken();
|
|
1194
|
+
addListener((value) => {
|
|
1195
|
+
currentToken.cancel();
|
|
1196
|
+
currentToken = createCancellationToken();
|
|
1197
|
+
const myToken = currentToken;
|
|
1198
|
+
asyncHandler(value, myToken).then((result) => {
|
|
1199
|
+
if (!myToken.isCancelled) {
|
|
1200
|
+
for (const h of latestListeners) h(result);
|
|
1201
|
+
}
|
|
1202
|
+
}).catch(() => {
|
|
1203
|
+
});
|
|
1204
|
+
});
|
|
1205
|
+
return createBaseStream((h) => {
|
|
1206
|
+
latestListeners.add(h);
|
|
1207
|
+
return () => latestListeners.delete(h);
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
};
|
|
1212
|
+
var createStoreStream = (store, key) => {
|
|
1213
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1214
|
+
let lastValue = store.getSnapshot()[key];
|
|
1215
|
+
store.subscribe(() => {
|
|
1216
|
+
const snapshot = store.getSnapshot();
|
|
1217
|
+
const newValue = snapshot[key];
|
|
1218
|
+
if (newValue !== lastValue) {
|
|
1219
|
+
lastValue = newValue;
|
|
1220
|
+
for (const listener of listeners) {
|
|
1221
|
+
listener(newValue);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
return createBaseStream((handler) => {
|
|
1226
|
+
listeners.add(handler);
|
|
1227
|
+
return () => listeners.delete(handler);
|
|
1228
|
+
});
|
|
1229
|
+
};
|
|
1230
|
+
var streamAll = (store) => {
|
|
1231
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1232
|
+
store.subscribe(() => {
|
|
1233
|
+
const snapshot = store.getSnapshot();
|
|
1234
|
+
for (const listener of listeners) {
|
|
1235
|
+
listener(snapshot);
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
return createBaseStream((handler) => {
|
|
1239
|
+
listeners.add(handler);
|
|
1240
|
+
return () => listeners.delete(handler);
|
|
1241
|
+
});
|
|
1242
|
+
};
|
|
1243
|
+
var shallowEqual = (a, b) => {
|
|
1244
|
+
if (Object.is(a, b)) return true;
|
|
1245
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
1246
|
+
return false;
|
|
1247
|
+
}
|
|
1248
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
1249
|
+
if (a.length !== b.length) return false;
|
|
1250
|
+
for (let i = 0; i < a.length; i++) {
|
|
1251
|
+
if (!Object.is(a[i], b[i])) return false;
|
|
1252
|
+
}
|
|
1253
|
+
return true;
|
|
1254
|
+
}
|
|
1255
|
+
const keysA = Object.keys(a);
|
|
1256
|
+
const keysB = Object.keys(b);
|
|
1257
|
+
if (keysA.length !== keysB.length) return false;
|
|
1258
|
+
for (const key of keysA) {
|
|
1259
|
+
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
1260
|
+
if (!Object.is(
|
|
1261
|
+
a[key],
|
|
1262
|
+
b[key]
|
|
1263
|
+
)) {
|
|
1264
|
+
return false;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
return true;
|
|
1268
|
+
};
|
|
1269
|
+
var createSelector = (store, selector, equalityFn = shallowEqual) => {
|
|
1270
|
+
const snapshot = store.getSnapshot();
|
|
1271
|
+
const initialValue = selector(snapshot);
|
|
1272
|
+
const derived = core.signal(initialValue);
|
|
1273
|
+
store.subscribe(() => {
|
|
1274
|
+
const currentSnapshot = store.getSnapshot();
|
|
1275
|
+
const newValue = selector(currentSnapshot);
|
|
1276
|
+
if (!equalityFn(derived.value, newValue)) {
|
|
1277
|
+
derived.value = newValue;
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
return derived;
|
|
1281
|
+
};
|
|
1282
|
+
var createSelectorAsync = (store, asyncSelector, initialValue) => {
|
|
1283
|
+
const derived = core.signal(initialValue);
|
|
1284
|
+
const pending = core.signal(false);
|
|
1285
|
+
let currentToken = createCancellationToken();
|
|
1286
|
+
const update = () => {
|
|
1287
|
+
currentToken.cancel();
|
|
1288
|
+
currentToken = createCancellationToken();
|
|
1289
|
+
const myToken = currentToken;
|
|
1290
|
+
pending.value = true;
|
|
1291
|
+
const snapshot = store.getSnapshot();
|
|
1292
|
+
asyncSelector(snapshot, myToken).then((newValue) => {
|
|
1293
|
+
if (!myToken.isCancelled && derived.value !== newValue) {
|
|
1294
|
+
derived.value = newValue;
|
|
1295
|
+
}
|
|
1296
|
+
}).catch(() => {
|
|
1297
|
+
}).finally(() => {
|
|
1298
|
+
if (!myToken.isCancelled) {
|
|
1299
|
+
pending.value = false;
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
};
|
|
1303
|
+
const unsub = store.subscribe(update);
|
|
1304
|
+
update();
|
|
1305
|
+
const result = derived;
|
|
1306
|
+
result.pending = pending;
|
|
1307
|
+
result.cleanup = () => {
|
|
1308
|
+
currentToken.cancel();
|
|
1309
|
+
unsub();
|
|
1310
|
+
};
|
|
1311
|
+
return result;
|
|
1312
|
+
};
|
|
1313
|
+
var pick = (store, keys) => {
|
|
1314
|
+
return createSelector(store, (state) => {
|
|
1315
|
+
const picked = {};
|
|
1316
|
+
for (const key of keys) {
|
|
1317
|
+
if (key in state) {
|
|
1318
|
+
picked[key] = state[key];
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
return picked;
|
|
1322
|
+
});
|
|
1323
|
+
};
|
|
1324
|
+
var combineSelectors = (store, selectors) => {
|
|
1325
|
+
return createSelector(store, (state) => {
|
|
1326
|
+
const result = {};
|
|
1327
|
+
for (const key of Object.keys(selectors)) {
|
|
1328
|
+
result[key] = selectors[key](state);
|
|
1329
|
+
}
|
|
1330
|
+
return result;
|
|
1331
|
+
});
|
|
1332
|
+
};
|
|
1333
|
+
var hasDevTools = () => {
|
|
1334
|
+
if (typeof globalThis === "undefined") return false;
|
|
1335
|
+
const w = globalThis;
|
|
1336
|
+
return w.__REDUX_DEVTOOLS_EXTENSION__ !== void 0;
|
|
1337
|
+
};
|
|
1338
|
+
var connections = /* @__PURE__ */ new Map();
|
|
1339
|
+
var connectDevTools = (store, options) => {
|
|
1340
|
+
if (!hasDevTools()) {
|
|
1341
|
+
return () => {
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
const w = globalThis;
|
|
1345
|
+
const extension = w.__REDUX_DEVTOOLS_EXTENSION__;
|
|
1346
|
+
if (!extension) return () => {
|
|
1347
|
+
};
|
|
1348
|
+
const storeName = effect.pipe(
|
|
1349
|
+
effect.Option.fromNullable(options),
|
|
1350
|
+
effect.Option.flatMap((o) => effect.Option.fromNullable(o.name)),
|
|
1351
|
+
effect.Option.getOrElse(() => store.name)
|
|
1352
|
+
);
|
|
1353
|
+
if (connections.has(storeName)) {
|
|
1354
|
+
return () => {
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
const devTools = extension.connect({ name: `Effuse: ${storeName}` });
|
|
1358
|
+
connections.set(storeName, devTools);
|
|
1359
|
+
devTools.init(store.getSnapshot());
|
|
1360
|
+
const unsubscribe = store.subscribe(() => {
|
|
1361
|
+
devTools.send({ type: `${storeName}/update` }, store.getSnapshot());
|
|
1362
|
+
});
|
|
1363
|
+
return () => {
|
|
1364
|
+
unsubscribe();
|
|
1365
|
+
connections.delete(storeName);
|
|
1366
|
+
};
|
|
1367
|
+
};
|
|
1368
|
+
var devToolsMiddleware = (storeName) => {
|
|
1369
|
+
return (state, action, args) => {
|
|
1370
|
+
const connection = connections.get(storeName);
|
|
1371
|
+
if (connection) {
|
|
1372
|
+
connection.send(
|
|
1373
|
+
{ type: action, payload: args.length === 1 ? args[0] : args },
|
|
1374
|
+
state
|
|
1375
|
+
);
|
|
1376
|
+
}
|
|
1377
|
+
return void 0;
|
|
1378
|
+
};
|
|
1379
|
+
};
|
|
1380
|
+
var createDevToolsMiddleware = (storeName) => devToolsMiddleware(storeName);
|
|
1381
|
+
var disconnectDevTools = (storeName) => {
|
|
1382
|
+
connections.delete(storeName);
|
|
1383
|
+
};
|
|
1384
|
+
var disconnectAllDevTools = () => {
|
|
1385
|
+
connections.clear();
|
|
1386
|
+
};
|
|
1387
|
+
|
|
1388
|
+
exports.ActionNotFoundError = ActionNotFoundError;
|
|
1389
|
+
exports.CancellationError = CancellationError;
|
|
1390
|
+
exports.DEFAULT_RETRY_BACKOFF_FACTOR = DEFAULT_RETRY_BACKOFF_FACTOR;
|
|
1391
|
+
exports.DEFAULT_RETRY_INITIAL_DELAY_MS = DEFAULT_RETRY_INITIAL_DELAY_MS;
|
|
1392
|
+
exports.DEFAULT_RETRY_MAX_DELAY_MS = DEFAULT_RETRY_MAX_DELAY_MS;
|
|
1393
|
+
exports.DEFAULT_TIMEOUT_MS = DEFAULT_TIMEOUT_MS;
|
|
1394
|
+
exports.ROOT_SCOPE_ID = ROOT_SCOPE_ID;
|
|
1395
|
+
exports.SCOPE_PREFIX = SCOPE_PREFIX;
|
|
1396
|
+
exports.STORAGE_PREFIX = STORAGE_PREFIX;
|
|
1397
|
+
exports.StoreAlreadyExistsError = StoreAlreadyExistsError;
|
|
1398
|
+
exports.StoreConstants = StoreConstants;
|
|
1399
|
+
exports.StoreNotFoundError = StoreNotFoundError;
|
|
1400
|
+
exports.TimeoutError = TimeoutError;
|
|
1401
|
+
exports.ValidationError = ValidationError;
|
|
1402
|
+
exports.clearStores = clearStores;
|
|
1403
|
+
exports.combineSelectors = combineSelectors;
|
|
1404
|
+
exports.composeStores = composeStores;
|
|
1405
|
+
exports.connectDevTools = connectDevTools;
|
|
1406
|
+
exports.createAsyncAction = createAsyncAction;
|
|
1407
|
+
exports.createAtomicState = createAtomicState;
|
|
1408
|
+
exports.createCancellableAction = createCancellableAction;
|
|
1409
|
+
exports.createCancellationScope = createCancellationScope;
|
|
1410
|
+
exports.createCancellationToken = createCancellationToken;
|
|
1411
|
+
exports.createDevToolsMiddleware = createDevToolsMiddleware;
|
|
1412
|
+
exports.createFieldValidator = createFieldValidator;
|
|
1413
|
+
exports.createMiddlewareManager = createMiddlewareManager;
|
|
1414
|
+
exports.createSafeFieldSetter = createSafeFieldSetter;
|
|
1415
|
+
exports.createScope = createScope;
|
|
1416
|
+
exports.createSelector = createSelector;
|
|
1417
|
+
exports.createSelectorAsync = createSelectorAsync;
|
|
1418
|
+
exports.createStore = createStore;
|
|
1419
|
+
exports.createStoreStream = createStoreStream;
|
|
1420
|
+
exports.createValidatedSetter = createValidatedSetter;
|
|
1421
|
+
exports.debounceAction = debounceAction;
|
|
1422
|
+
exports.defineSlice = defineSlice;
|
|
1423
|
+
exports.deriveFrom = deriveFrom;
|
|
1424
|
+
exports.deriveFromAsync = deriveFromAsync;
|
|
1425
|
+
exports.devToolsMiddleware = devToolsMiddleware;
|
|
1426
|
+
exports.disconnectAllDevTools = disconnectAllDevTools;
|
|
1427
|
+
exports.disconnectDevTools = disconnectDevTools;
|
|
1428
|
+
exports.dispatch = dispatch;
|
|
1429
|
+
exports.dispatchSync = dispatchSync;
|
|
1430
|
+
exports.disposeScope = disposeScope;
|
|
1431
|
+
exports.enterScope = enterScope;
|
|
1432
|
+
exports.exitScope = exitScope;
|
|
1433
|
+
exports.getCurrentScope = getCurrentScope;
|
|
1434
|
+
exports.getRootScope = getRootScope;
|
|
1435
|
+
exports.getScopedStore = getScopedStore;
|
|
1436
|
+
exports.getStore = getStore;
|
|
1437
|
+
exports.getStoreConfig = getStoreConfig;
|
|
1438
|
+
exports.getStoreNames = getStoreNames;
|
|
1439
|
+
exports.hasDevTools = hasDevTools;
|
|
1440
|
+
exports.hasScopedStore = hasScopedStore;
|
|
1441
|
+
exports.hasStore = hasStore;
|
|
1442
|
+
exports.hydrateStoresSync = hydrateStoresSync;
|
|
1443
|
+
exports.mergeStores = mergeStores;
|
|
1444
|
+
exports.pick = pick;
|
|
1445
|
+
exports.registerScopedStore = registerScopedStore;
|
|
1446
|
+
exports.removeStore = removeStore;
|
|
1447
|
+
exports.resetStoreConfigCache = resetStoreConfigCache;
|
|
1448
|
+
exports.runInScope = runInScope;
|
|
1449
|
+
exports.serializeStores = serializeStores;
|
|
1450
|
+
exports.shallowEqual = shallowEqual;
|
|
1451
|
+
exports.streamAll = streamAll;
|
|
1452
|
+
exports.takeFirst = takeFirst;
|
|
1453
|
+
exports.takeLatest = takeLatest;
|
|
1454
|
+
exports.throttleAction = throttleAction;
|
|
1455
|
+
exports.validateState = validateState;
|
|
1456
|
+
exports.validateStateAsync = validateStateAsync;
|
|
1457
|
+
exports.withAbortSignal = withAbortSignal;
|
|
1458
|
+
exports.withRetry = withRetry;
|
|
1459
|
+
exports.withScope = withScope;
|
|
1460
|
+
exports.withTimeout = withTimeout;
|
|
1461
|
+
//# sourceMappingURL=index.cjs.map
|
|
1462
|
+
//# sourceMappingURL=index.cjs.map
|