synapse-storage 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.cjs +1 -0
- package/dist/api.d.cts +365 -0
- package/dist/api.d.ts +365 -0
- package/dist/api.js +1 -0
- package/dist/chunk-22J2S57D.cjs +1 -0
- package/dist/chunk-4USKKL5R.js +1 -0
- package/dist/chunk-5X65PSGD.js +1 -0
- package/dist/chunk-635Q6YJZ.cjs +1 -0
- package/dist/chunk-6RNZVHSR.js +1 -0
- package/dist/chunk-FW5NGLPP.cjs +1 -0
- package/dist/chunk-IPUPRMZK.js +1 -0
- package/dist/chunk-NMDHQXMS.cjs +1 -0
- package/dist/chunk-S7X7IDBT.js +1 -0
- package/dist/chunk-UFBCZ25Y.cjs +1 -0
- package/dist/chunk-VSIVOWZF.cjs +1 -0
- package/dist/chunk-WC5TDS6C.cjs +1 -0
- package/dist/chunk-WQNH3LVB.js +1 -0
- package/dist/chunk-ZE2EJX2Y.js +1 -0
- package/dist/core.cjs +1 -0
- package/dist/core.d.cts +397 -0
- package/dist/{core/storage/modules/plugin/plugin.interface.d.ts → core.d.ts} +203 -7
- package/dist/core.js +1 -0
- package/dist/dispatcher.module-CdpmkplA.d.cts +363 -0
- package/dist/dispatcher.module-jd8U_ZEs.d.ts +363 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -10
- package/dist/index.js +1 -14
- package/dist/react.cjs +1 -0
- package/dist/react.d.cts +74 -0
- package/dist/react.d.ts +74 -0
- package/dist/react.js +1 -0
- package/dist/reactive.cjs +1 -0
- package/dist/reactive.d.cts +35 -0
- package/dist/reactive.d.ts +35 -0
- package/dist/reactive.js +1 -0
- package/dist/{core/selector/selector.interface.d.ts → selector.interface-CA5y-kD_.d.cts} +7 -35
- package/dist/selector.interface-CA5y-kD_.d.ts +63 -0
- package/dist/storage.interface-Dl8SLUd1.d.cts +128 -0
- package/dist/storage.interface-Dl8SLUd1.d.ts +128 -0
- package/dist/utils.cjs +1 -0
- package/dist/utils.d.cts +92 -0
- package/dist/utils.d.ts +92 -0
- package/dist/utils.js +1 -0
- package/package.json +54 -17
- package/dist/_utils/chunk.util.d.ts +0 -8
- package/dist/_utils/chunk.util.d.ts.map +0 -1
- package/dist/_utils/chunk.util.js +0 -21
- package/dist/_utils/chunk.util.js.map +0 -1
- package/dist/_utils/deepMerge.util.d.ts +0 -2
- package/dist/_utils/deepMerge.util.d.ts.map +0 -1
- package/dist/_utils/deepMerge.util.js +0 -16
- package/dist/_utils/deepMerge.util.js.map +0 -1
- package/dist/_utils/flatMap.util.d.ts +0 -10
- package/dist/_utils/flatMap.util.d.ts.map +0 -1
- package/dist/_utils/flatMap.util.js +0 -23
- package/dist/_utils/flatMap.util.js.map +0 -1
- package/dist/_utils/index.d.ts +0 -4
- package/dist/_utils/index.d.ts.map +0 -1
- package/dist/_utils/index.js +0 -4
- package/dist/_utils/index.js.map +0 -1
- package/dist/api/api.module.d.ts +0 -38
- package/dist/api/api.module.d.ts.map +0 -1
- package/dist/api/api.module.js +0 -82
- package/dist/api/api.module.js.map +0 -1
- package/dist/api/components/endpoint.d.ts +0 -26
- package/dist/api/components/endpoint.d.ts.map +0 -1
- package/dist/api/components/endpoint.js +0 -253
- package/dist/api/components/endpoint.js.map +0 -1
- package/dist/api/components/query-storage.d.ts +0 -84
- package/dist/api/components/query-storage.d.ts.map +0 -1
- package/dist/api/components/query-storage.js +0 -221
- package/dist/api/components/query-storage.js.map +0 -1
- package/dist/api/example.d.ts +0 -83
- package/dist/api/example.d.ts.map +0 -1
- package/dist/api/example.js +0 -85
- package/dist/api/example.js.map +0 -1
- package/dist/api/index.d.ts +0 -4
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -6
- package/dist/api/index.js.map +0 -1
- package/dist/api/types/api.interface.d.ts +0 -108
- package/dist/api/types/api.interface.d.ts.map +0 -1
- package/dist/api/types/api.interface.js +0 -19
- package/dist/api/types/api.interface.js.map +0 -1
- package/dist/api/types/endpoint.interface.d.ts +0 -116
- package/dist/api/types/endpoint.interface.d.ts.map +0 -1
- package/dist/api/types/endpoint.interface.js +0 -2
- package/dist/api/types/endpoint.interface.js.map +0 -1
- package/dist/api/types/query.interface.d.ts +0 -87
- package/dist/api/types/query.interface.d.ts.map +0 -1
- package/dist/api/types/query.interface.js +0 -2
- package/dist/api/types/query.interface.js.map +0 -1
- package/dist/api/utils/api-helpers.d.ts +0 -22
- package/dist/api/utils/api-helpers.d.ts.map +0 -1
- package/dist/api/utils/api-helpers.js +0 -44
- package/dist/api/utils/api-helpers.js.map +0 -1
- package/dist/api/utils/create-header-context.d.ts +0 -10
- package/dist/api/utils/create-header-context.d.ts.map +0 -1
- package/dist/api/utils/create-header-context.js +0 -36
- package/dist/api/utils/create-header-context.js.map +0 -1
- package/dist/api/utils/endpoint-headers.d.ts +0 -23
- package/dist/api/utils/endpoint-headers.d.ts.map +0 -1
- package/dist/api/utils/endpoint-headers.js +0 -57
- package/dist/api/utils/endpoint-headers.js.map +0 -1
- package/dist/api/utils/fetch-base-query.d.ts +0 -9
- package/dist/api/utils/fetch-base-query.d.ts.map +0 -1
- package/dist/api/utils/fetch-base-query.js +0 -181
- package/dist/api/utils/fetch-base-query.js.map +0 -1
- package/dist/api/utils/file-utils.d.ts +0 -43
- package/dist/api/utils/file-utils.d.ts.map +0 -1
- package/dist/api/utils/file-utils.js +0 -108
- package/dist/api/utils/file-utils.js.map +0 -1
- package/dist/api/utils/get-cacheable-headers.d.ts +0 -8
- package/dist/api/utils/get-cacheable-headers.d.ts.map +0 -1
- package/dist/api/utils/get-cacheable-headers.js +0 -21
- package/dist/api/utils/get-cacheable-headers.js.map +0 -1
- package/dist/core/index.d.ts +0 -3
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -3
- package/dist/core/index.js.map +0 -1
- package/dist/core/selector/index.d.ts +0 -3
- package/dist/core/selector/index.d.ts.map +0 -1
- package/dist/core/selector/index.js +0 -2
- package/dist/core/selector/index.js.map +0 -1
- package/dist/core/selector/selector.interface.d.ts.map +0 -1
- package/dist/core/selector/selector.interface.js +0 -2
- package/dist/core/selector/selector.interface.js.map +0 -1
- package/dist/core/selector/selector.module.d.ts +0 -29
- package/dist/core/selector/selector.module.d.ts.map +0 -1
- package/dist/core/selector/selector.module.js +0 -467
- package/dist/core/selector/selector.module.js.map +0 -1
- package/dist/core/storage/adapters/base-storage.service.d.ts +0 -65
- package/dist/core/storage/adapters/base-storage.service.d.ts.map +0 -1
- package/dist/core/storage/adapters/base-storage.service.js +0 -660
- package/dist/core/storage/adapters/base-storage.service.js.map +0 -1
- package/dist/core/storage/adapters/indexed-DB.service.d.ts +0 -63
- package/dist/core/storage/adapters/indexed-DB.service.d.ts.map +0 -1
- package/dist/core/storage/adapters/indexed-DB.service.js +0 -595
- package/dist/core/storage/adapters/indexed-DB.service.js.map +0 -1
- package/dist/core/storage/adapters/indexed-DB.service.old.d.ts +0 -38
- package/dist/core/storage/adapters/indexed-DB.service.old.d.ts.map +0 -1
- package/dist/core/storage/adapters/indexed-DB.service.old.js +0 -318
- package/dist/core/storage/adapters/indexed-DB.service.old.js.map +0 -1
- package/dist/core/storage/adapters/local-storage.service.d.ts +0 -21
- package/dist/core/storage/adapters/local-storage.service.d.ts.map +0 -1
- package/dist/core/storage/adapters/local-storage.service.js +0 -99
- package/dist/core/storage/adapters/local-storage.service.js.map +0 -1
- package/dist/core/storage/adapters/memory-storage.service.d.ts +0 -22
- package/dist/core/storage/adapters/memory-storage.service.d.ts.map +0 -1
- package/dist/core/storage/adapters/memory-storage.service.js +0 -99
- package/dist/core/storage/adapters/memory-storage.service.js.map +0 -1
- package/dist/core/storage/adapters/path.utils.d.ts +0 -5
- package/dist/core/storage/adapters/path.utils.d.ts.map +0 -1
- package/dist/core/storage/adapters/path.utils.js +0 -35
- package/dist/core/storage/adapters/path.utils.js.map +0 -1
- package/dist/core/storage/index.d.ts +0 -11
- package/dist/core/storage/index.d.ts.map +0 -1
- package/dist/core/storage/index.js +0 -12
- package/dist/core/storage/index.js.map +0 -1
- package/dist/core/storage/middlewares/broadcast.middleware.d.ts +0 -9
- package/dist/core/storage/middlewares/broadcast.middleware.d.ts.map +0 -1
- package/dist/core/storage/middlewares/broadcast.middleware.js +0 -115
- package/dist/core/storage/middlewares/broadcast.middleware.js.map +0 -1
- package/dist/core/storage/middlewares/index.d.ts +0 -4
- package/dist/core/storage/middlewares/index.d.ts.map +0 -1
- package/dist/core/storage/middlewares/index.js +0 -3
- package/dist/core/storage/middlewares/index.js.map +0 -1
- package/dist/core/storage/middlewares/storage-batching.middleware.d.ts +0 -7
- package/dist/core/storage/middlewares/storage-batching.middleware.d.ts.map +0 -1
- package/dist/core/storage/middlewares/storage-batching.middleware.js +0 -36
- package/dist/core/storage/middlewares/storage-batching.middleware.js.map +0 -1
- package/dist/core/storage/middlewares/storage-shallow-compare.middleware.d.ts +0 -7
- package/dist/core/storage/middlewares/storage-shallow-compare.middleware.d.ts.map +0 -1
- package/dist/core/storage/middlewares/storage-shallow-compare.middleware.js +0 -46
- package/dist/core/storage/middlewares/storage-shallow-compare.middleware.js.map +0 -1
- package/dist/core/storage/modules/plugin/plugin.interface.d.ts.map +0 -1
- package/dist/core/storage/modules/plugin/plugin.interface.js +0 -2
- package/dist/core/storage/modules/plugin/plugin.interface.js.map +0 -1
- package/dist/core/storage/modules/plugin/plugin.service.d.ts +0 -25
- package/dist/core/storage/modules/plugin/plugin.service.d.ts.map +0 -1
- package/dist/core/storage/modules/plugin/plugin.service.js +0 -186
- package/dist/core/storage/modules/plugin/plugin.service.js.map +0 -1
- package/dist/core/storage/storage.interface.d.ts +0 -70
- package/dist/core/storage/storage.interface.d.ts.map +0 -1
- package/dist/core/storage/storage.interface.js +0 -10
- package/dist/core/storage/storage.interface.js.map +0 -1
- package/dist/core/storage/utils/batch.utils.d.ts +0 -33
- package/dist/core/storage/utils/batch.utils.d.ts.map +0 -1
- package/dist/core/storage/utils/batch.utils.js +0 -88
- package/dist/core/storage/utils/batch.utils.js.map +0 -1
- package/dist/core/storage/utils/broadcast.util.d.ts +0 -48
- package/dist/core/storage/utils/broadcast.util.d.ts.map +0 -1
- package/dist/core/storage/utils/broadcast.util.js +0 -162
- package/dist/core/storage/utils/broadcast.util.js.map +0 -1
- package/dist/core/storage/utils/cache.util.d.ts +0 -33
- package/dist/core/storage/utils/cache.util.d.ts.map +0 -1
- package/dist/core/storage/utils/cache.util.js +0 -47
- package/dist/core/storage/utils/cache.util.js.map +0 -1
- package/dist/core/storage/utils/middleware-module.d.ts +0 -46
- package/dist/core/storage/utils/middleware-module.d.ts.map +0 -1
- package/dist/core/storage/utils/middleware-module.js +0 -109
- package/dist/core/storage/utils/middleware-module.js.map +0 -1
- package/dist/core/storage/utils/storage-key.d.ts +0 -11
- package/dist/core/storage/utils/storage-key.d.ts.map +0 -1
- package/dist/core/storage/utils/storage-key.js +0 -21
- package/dist/core/storage/utils/storage-key.js.map +0 -1
- package/dist/core/storage/utils/storage.utils.d.ts +0 -17
- package/dist/core/storage/utils/storage.utils.d.ts.map +0 -1
- package/dist/core/storage/utils/storage.utils.js +0 -57
- package/dist/core/storage/utils/storage.utils.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/react/hooks/index.d.ts +0 -3
- package/dist/react/hooks/index.d.ts.map +0 -1
- package/dist/react/hooks/index.js +0 -3
- package/dist/react/hooks/index.js.map +0 -1
- package/dist/react/hooks/useSelector.d.ts +0 -22
- package/dist/react/hooks/useSelector.d.ts.map +0 -1
- package/dist/react/hooks/useSelector.js +0 -104
- package/dist/react/hooks/useSelector.js.map +0 -1
- package/dist/react/hooks/useStorageSubscribe.d.ts +0 -12
- package/dist/react/hooks/useStorageSubscribe.d.ts.map +0 -1
- package/dist/react/hooks/useStorageSubscribe.js +0 -49
- package/dist/react/hooks/useStorageSubscribe.js.map +0 -1
- package/dist/react/index.d.ts +0 -3
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js +0 -3
- package/dist/react/index.js.map +0 -1
- package/dist/react/utils/createSynapseCtx.d.ts +0 -40
- package/dist/react/utils/createSynapseCtx.d.ts.map +0 -1
- package/dist/react/utils/createSynapseCtx.js +0 -125
- package/dist/react/utils/createSynapseCtx.js.map +0 -1
- package/dist/react/utils/index.d.ts +0 -2
- package/dist/react/utils/index.d.ts.map +0 -1
- package/dist/react/utils/index.js +0 -2
- package/dist/react/utils/index.js.map +0 -1
- package/dist/reactive/dispatcher/dispatcher.module.d.ts +0 -195
- package/dist/reactive/dispatcher/dispatcher.module.d.ts.map +0 -1
- package/dist/reactive/dispatcher/dispatcher.module.js +0 -288
- package/dist/reactive/dispatcher/dispatcher.module.js.map +0 -1
- package/dist/reactive/dispatcher/index.d.ts +0 -3
- package/dist/reactive/dispatcher/index.d.ts.map +0 -1
- package/dist/reactive/dispatcher/index.js +0 -3
- package/dist/reactive/dispatcher/index.js.map +0 -1
- package/dist/reactive/dispatcher/middlewares/index.d.ts +0 -2
- package/dist/reactive/dispatcher/middlewares/index.d.ts.map +0 -1
- package/dist/reactive/dispatcher/middlewares/index.js +0 -2
- package/dist/reactive/dispatcher/middlewares/index.js.map +0 -1
- package/dist/reactive/dispatcher/middlewares/logger.middleware.d.ts +0 -31
- package/dist/reactive/dispatcher/middlewares/logger.middleware.d.ts.map +0 -1
- package/dist/reactive/dispatcher/middlewares/logger.middleware.js +0 -126
- package/dist/reactive/dispatcher/middlewares/logger.middleware.js.map +0 -1
- package/dist/reactive/effects/effects.module.d.ts +0 -150
- package/dist/reactive/effects/effects.module.d.ts.map +0 -1
- package/dist/reactive/effects/effects.module.js +0 -277
- package/dist/reactive/effects/effects.module.js.map +0 -1
- package/dist/reactive/effects/index.d.ts +0 -2
- package/dist/reactive/effects/index.d.ts.map +0 -1
- package/dist/reactive/effects/index.js +0 -2
- package/dist/reactive/effects/index.js.map +0 -1
- package/dist/reactive/effects/utils/chunkRequestConsistent.d.ts +0 -12
- package/dist/reactive/effects/utils/chunkRequestConsistent.d.ts.map +0 -1
- package/dist/reactive/effects/utils/chunkRequestConsistent.js +0 -16
- package/dist/reactive/effects/utils/chunkRequestConsistent.js.map +0 -1
- package/dist/reactive/effects/utils/chunkRequestParallel.d.ts +0 -12
- package/dist/reactive/effects/utils/chunkRequestParallel.d.ts.map +0 -1
- package/dist/reactive/effects/utils/chunkRequestParallel.js +0 -13
- package/dist/reactive/effects/utils/chunkRequestParallel.js.map +0 -1
- package/dist/reactive/effects/utils/index.d.ts +0 -3
- package/dist/reactive/effects/utils/index.d.ts.map +0 -1
- package/dist/reactive/effects/utils/index.js +0 -3
- package/dist/reactive/effects/utils/index.js.map +0 -1
- package/dist/reactive/index.d.ts +0 -3
- package/dist/reactive/index.d.ts.map +0 -1
- package/dist/reactive/index.js +0 -3
- package/dist/reactive/index.js.map +0 -1
- package/dist/utils/createSynapse.d.ts +0 -92
- package/dist/utils/createSynapse.d.ts.map +0 -1
- package/dist/utils/createSynapse.js +0 -79
- package/dist/utils/createSynapse.js.map +0 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -2
- package/dist/utils/index.js.map +0 -1
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { Observable, OperatorFunction } from 'rxjs';
|
|
2
|
+
import { I as IStorage } from './storage.interface-Dl8SLUd1.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Разбиение запроса на порции
|
|
6
|
+
* Отправляется ПОСЛЕДОВАТЕЛЬНО n-запросов и дожидается ответа от каждого
|
|
7
|
+
* @param fn - функция в которую передается chunk и возвращается функция api
|
|
8
|
+
* @param arr - массив который нужно поделить
|
|
9
|
+
* @param size - размер порции
|
|
10
|
+
* @param delayMs - задержка между запросами в миллисекундах
|
|
11
|
+
*/
|
|
12
|
+
declare const chunkRequestConsistent: <T, R>(fn: (chunk: T[]) => Observable<R>, arr: T[], size: number, delayMs?: number) => Observable<R[]>;
|
|
13
|
+
type ChunkRequestConsistent = typeof chunkRequestConsistent;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Разбиение запроса на порции
|
|
17
|
+
* Отправляется ПАРАЛЛЕЛЬНО n-запросов и дожидается ответа от каждого
|
|
18
|
+
* @param fn - функция в которую передается chunk и возвращается функция api
|
|
19
|
+
* @param arr - массив который нужно поделить
|
|
20
|
+
* @param size - размер порции
|
|
21
|
+
* @param delayMs - задержка между запросами в миллисекундах
|
|
22
|
+
*/
|
|
23
|
+
declare const chunkRequestParallel: <T, R>(fn: (chunk: T[]) => Observable<R>, arr: T[], size: number, delayMs?: number) => Observable<R[]>;
|
|
24
|
+
type ChunkRequestParallel = typeof chunkRequestParallel;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Тип действия с типизированным payload
|
|
28
|
+
*/
|
|
29
|
+
interface TypedAction<P> extends Action<P> {
|
|
30
|
+
type: string;
|
|
31
|
+
payload: P;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Тип для внешних состояний
|
|
35
|
+
*/
|
|
36
|
+
type ExternalStates = Record<string, Observable<any>>;
|
|
37
|
+
/**
|
|
38
|
+
* Тип для базового эффекта без доступа к состоянию
|
|
39
|
+
*/
|
|
40
|
+
type EffectBase<TDispatchers extends Record<string, Dispatcher<any, any>> = Record<string, never>, TServices extends Record<string, any> = Record<string, never>> = (action$: Observable<Action>, dispatchers: TDispatchers, services: TServices) => Observable<unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* Тип для эффекта с доступом к состоянию и конфигурации - это основной тип, который используется по умолчанию
|
|
43
|
+
*/
|
|
44
|
+
type Effect<TState extends Record<string, any> = any, TDispatchers extends Record<string, Dispatcher<any, any>> = Record<string, never>, TServices extends Record<string, any> = Record<string, never>, TConfig extends Record<string, any> = Record<string, never>, TExternalStates extends ExternalStates = Record<string, never>> = (action$: Observable<Action>, state$: Observable<TState>, externalStates: TExternalStates, dispatchers: TDispatchers, services: TServices, config: TConfig) => Observable<unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Тип для получения типов действий диспетчера
|
|
47
|
+
*/
|
|
48
|
+
type DispatcherActions<T> = T extends Dispatcher<any, infer A> ? ActionsResult<A> : Record<string, DispatchFunction<any, any>>;
|
|
49
|
+
/**
|
|
50
|
+
* Конфигурация для валидации в validateMap
|
|
51
|
+
*/
|
|
52
|
+
interface ValidateConfig {
|
|
53
|
+
conditions: boolean[];
|
|
54
|
+
skipAction: (() => any) | any | ((() => any) | any)[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Утилиты для запросов в validateMap
|
|
58
|
+
*/
|
|
59
|
+
interface ValidateMapRequestUtils {
|
|
60
|
+
chunkRequest: ChunkRequestParallel;
|
|
61
|
+
chunkRequestConsistent: ChunkRequestConsistent;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Оператор для фильтрации действий по типу с сохранением типа payload
|
|
65
|
+
*/
|
|
66
|
+
declare function ofType<T extends DispatchFunction<any, any> | WatcherFunction<any>>(actionFn: T): OperatorFunction<Action, TypedAction<T extends WatcherFunction<infer R> ? R : ExtractResultType<T>>>;
|
|
67
|
+
/**
|
|
68
|
+
* Оператор для фильтрации действий по нескольким типам с объединением типов payload
|
|
69
|
+
* @param actionFns Массив функций действий
|
|
70
|
+
*/
|
|
71
|
+
declare function ofTypes<T extends DispatchFunction<any, any>[]>(actionFns: [...T]): OperatorFunction<Action, TypedAction<ExtractResultType<T[number]>>>;
|
|
72
|
+
/**
|
|
73
|
+
* Оператор для ожидания выполнения всех указанных действий
|
|
74
|
+
* @param actionFns Массив функций действий
|
|
75
|
+
*/
|
|
76
|
+
declare function ofTypesWaitAll<T extends DispatchFunction<any, any>[]>(actionFns: [...T]): (source$: Observable<Action>) => Observable<{ [K in keyof T]: TypedAction<ExtractResultType<T[K]>>; }>;
|
|
77
|
+
/**
|
|
78
|
+
* Создает Observable с выбранными данными из состояния
|
|
79
|
+
* @param state$ Поток состояния
|
|
80
|
+
* @param selectors Селекторы для выбора частей состояния
|
|
81
|
+
* @returns Observable с массивом выбранных значений
|
|
82
|
+
*/
|
|
83
|
+
declare function selectorMap<TState, TResults extends any[]>(state$: Observable<TState>, ...selectors: {
|
|
84
|
+
[K in keyof TResults]: (state: TState) => TResults[K];
|
|
85
|
+
}): Observable<TResults>;
|
|
86
|
+
/**
|
|
87
|
+
* Создает именованный объект вместо массива
|
|
88
|
+
* @param state$ Поток состояния
|
|
89
|
+
* @param selectors Объект с селекторами
|
|
90
|
+
* @returns Observable с объектом выбранных значений
|
|
91
|
+
*/
|
|
92
|
+
declare function selectorObject<TState, TResult extends Record<string, any>>(state$: Observable<TState>, selectors: {
|
|
93
|
+
[K in keyof TResult]: (state: TState) => TResult[K];
|
|
94
|
+
}): Observable<TResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Оператор validateMap для валидации данных и условного вызова API
|
|
97
|
+
*/
|
|
98
|
+
declare function validateMap<T, TResult = any>({ validator, apiCall, }: {
|
|
99
|
+
validator?: (value: T) => ValidateConfig;
|
|
100
|
+
apiCall: (value: T, utils: ValidateMapRequestUtils) => Observable<TResult>;
|
|
101
|
+
}): OperatorFunction<T, any>;
|
|
102
|
+
/**
|
|
103
|
+
* Класс для управления эффектами с поддержкой доступа к состоянию и конфигурации
|
|
104
|
+
* Основной класс, который следует использовать
|
|
105
|
+
*/
|
|
106
|
+
declare class EffectsModule<TState extends Record<string, any> = any, TDispatchers extends Record<string, Dispatcher<any, any>> = Record<string, never>, TServices extends Record<string, any> = Record<string, never>, TConfig extends Record<string, any> = Record<string, never>, TExternalStates extends ExternalStates = Record<string, never>> {
|
|
107
|
+
private storage;
|
|
108
|
+
private externalStates;
|
|
109
|
+
private dispatchers;
|
|
110
|
+
private services;
|
|
111
|
+
private config;
|
|
112
|
+
private effects;
|
|
113
|
+
private subscriptions;
|
|
114
|
+
private running;
|
|
115
|
+
private action$;
|
|
116
|
+
/**
|
|
117
|
+
* Поток состояния
|
|
118
|
+
*/
|
|
119
|
+
readonly state$: Observable<TState>;
|
|
120
|
+
/**
|
|
121
|
+
* Создает модуль эффектов с доступом к состоянию, внешним состояниям и конфигурации
|
|
122
|
+
* @param storage Хранилище состояния
|
|
123
|
+
* @param externalStates Внешние состояния
|
|
124
|
+
* @param dispatchers Объект с диспетчерами
|
|
125
|
+
* @param services Объект с сервисами
|
|
126
|
+
* @param config Глобальная конфигурация для всех эффектов
|
|
127
|
+
*/
|
|
128
|
+
constructor(storage: IStorage<TState>, externalStates: TExternalStates | undefined, dispatchers: TDispatchers, services?: TServices, config?: TConfig);
|
|
129
|
+
/**
|
|
130
|
+
* Подписывается на действия от всех диспетчеров
|
|
131
|
+
*/
|
|
132
|
+
private subscribeToDispatchers;
|
|
133
|
+
add(effect: Effect<TState, TDispatchers, TServices, TConfig, TExternalStates>): this;
|
|
134
|
+
/**
|
|
135
|
+
* Добавляет несколько эффектов
|
|
136
|
+
* @param effects Эффекты для добавления
|
|
137
|
+
* @returns Текущий модуль
|
|
138
|
+
*/
|
|
139
|
+
addEffects(effects: Effect<TState, TDispatchers, TServices, TConfig, TExternalStates>[]): this;
|
|
140
|
+
/**
|
|
141
|
+
* Запускает все эффекты
|
|
142
|
+
* @returns Текущий модуль
|
|
143
|
+
*/
|
|
144
|
+
start(): this;
|
|
145
|
+
/**
|
|
146
|
+
* Останавливает все эффекты
|
|
147
|
+
* @returns Текущий модуль
|
|
148
|
+
*/
|
|
149
|
+
stop(): this;
|
|
150
|
+
/**
|
|
151
|
+
* Подписывается на конкретный эффект
|
|
152
|
+
* @param effect Эффект для подписки
|
|
153
|
+
*/
|
|
154
|
+
private subscribeToEffect;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Вспомогательная функция для создания типизированного эффекта без состояния
|
|
158
|
+
* @deprecated Используйте createEffect вместо этого
|
|
159
|
+
*/
|
|
160
|
+
declare function createEffectBase<TDispatchers extends Record<string, Dispatcher<any, any>>, TServices extends Record<string, any>>(effect: EffectBase<TDispatchers, TServices>): EffectBase<TDispatchers, TServices>;
|
|
161
|
+
/**
|
|
162
|
+
* Вспомогательная функция для создания типизированного эффекта с состоянием и конфигурацией
|
|
163
|
+
*/
|
|
164
|
+
declare function createEffect<TState extends Record<string, any>, TDispatchers extends Record<string, Dispatcher<any, any>>, TServices extends Record<string, any>, TConfig extends Record<string, any> = Record<string, never>, TExternalStates extends ExternalStates = Record<string, never>>(effect: Effect<TState, TDispatchers, TServices, TConfig, TExternalStates>): Effect<TState, TDispatchers, TServices, TConfig, TExternalStates>;
|
|
165
|
+
/**
|
|
166
|
+
* Объединяет несколько эффектов в один
|
|
167
|
+
* @param effects Эффекты для объединения
|
|
168
|
+
* @returns Объединенный эффект
|
|
169
|
+
*/
|
|
170
|
+
declare function combineEffects<TState extends Record<string, any>, TDispatchers extends Record<string, Dispatcher<any, any>>, TServices extends Record<string, any>, TConfig extends Record<string, any> = Record<string, never>, TExternalStates extends ExternalStates = Record<string, never>>(...effects: Effect<TState, TDispatchers, TServices, TConfig, TExternalStates>[]): Effect<TState, TDispatchers, TServices, TConfig, TExternalStates>;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Расширенное API для middleware
|
|
174
|
+
*/
|
|
175
|
+
interface EnhancedMiddlewareAPI<T extends Record<string, any>> {
|
|
176
|
+
getState: () => Promise<T>;
|
|
177
|
+
dispatch: (action: Action) => Promise<any>;
|
|
178
|
+
storage: IStorage<T>;
|
|
179
|
+
actions$: Observable<Action>;
|
|
180
|
+
actions: Record<string, DispatchFunction<any, any>>;
|
|
181
|
+
watchers: Record<string, WatcherFunction<any>>;
|
|
182
|
+
findActionByType: (actionType: string) => DispatchFunction<any, any> | undefined;
|
|
183
|
+
findWatcherByType: (actionType: string) => WatcherFunction<any> | undefined;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Расширенное определение middleware
|
|
187
|
+
*/
|
|
188
|
+
interface EnhancedMiddleware<T extends Record<string, any> = any> {
|
|
189
|
+
(api: EnhancedMiddlewareAPI<T>): (next: (action: Action) => Promise<any>) => (action: Action) => Promise<any>;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Базовая структура действия
|
|
193
|
+
*/
|
|
194
|
+
interface Action<T = unknown> {
|
|
195
|
+
type: string;
|
|
196
|
+
payload?: T;
|
|
197
|
+
meta?: Record<string, any>;
|
|
198
|
+
}
|
|
199
|
+
interface ActionExecutionOptions {
|
|
200
|
+
worker?: Worker;
|
|
201
|
+
memoize?: (currentArgs: any[], previousArgs: any[], previousResult: any) => boolean;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Параметры для создания действия
|
|
205
|
+
*/
|
|
206
|
+
interface ActionDefinition<TParams, TResult> {
|
|
207
|
+
/** Тип действия для идентификации в потоке и эффектах */
|
|
208
|
+
type: string;
|
|
209
|
+
/** Функция, выполняющая действие и возвращающая результат (payload) */
|
|
210
|
+
action: (params: TParams) => Promise<TResult> | TResult;
|
|
211
|
+
/** Дополнительные метаданные (опционально) */
|
|
212
|
+
meta?: Record<string, any>;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Определение типа для watcher'а
|
|
216
|
+
*/
|
|
217
|
+
interface WatcherDefinition<T, R> {
|
|
218
|
+
type: string;
|
|
219
|
+
selector: (state: T) => R;
|
|
220
|
+
meta?: Record<string, any>;
|
|
221
|
+
shouldTrigger?: (prev: R | undefined, current: R) => boolean;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Тип для функции watcher
|
|
225
|
+
*/
|
|
226
|
+
interface WatcherFunction<R> {
|
|
227
|
+
(): Observable<TypedAction<R>>;
|
|
228
|
+
actionType: string;
|
|
229
|
+
meta?: Record<string, any>;
|
|
230
|
+
unsubscribe: VoidFunction;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Расширенный тип для функции настройки действий с поддержкой дополнительных утилит
|
|
234
|
+
*/
|
|
235
|
+
type ActionsSetupWithUtils<T extends Record<string, unknown>> = (storage: IStorage<T>, utils: {
|
|
236
|
+
createAction: ActionCreatorFactory;
|
|
237
|
+
createWatcher: <R>(config: WatcherDefinition<T, R>) => WatcherFunction<R>;
|
|
238
|
+
}) => Record<string, DispatchFunction<any, any> | WatcherFunction<any>>;
|
|
239
|
+
/**
|
|
240
|
+
* Расширенная функция диспетчеризации
|
|
241
|
+
*/
|
|
242
|
+
interface DispatchFunction<TParams, TResult> {
|
|
243
|
+
/** Функция для вызова действия с параметрами */
|
|
244
|
+
(params: TParams): Promise<TResult>;
|
|
245
|
+
/** Тип действия для использования в эффектах */
|
|
246
|
+
actionType: string;
|
|
247
|
+
/** Метаданные действия */
|
|
248
|
+
meta?: Record<string, any>;
|
|
249
|
+
/** Внутренний тип для идентификации */
|
|
250
|
+
_type?: 'dispatch' | 'watchers';
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Тип для фабрики создателей действий
|
|
254
|
+
*/
|
|
255
|
+
type ActionCreatorFactory = <TParams, TResult>(config: ActionDefinition<TParams, TResult>, executionOptions?: ActionExecutionOptions) => DispatchFunction<TParams, TResult>;
|
|
256
|
+
/**
|
|
257
|
+
* Тип для функции настройки действий
|
|
258
|
+
*/
|
|
259
|
+
type ActionsSetup<T extends Record<string, unknown>> = (create: ActionCreatorFactory, storage: IStorage<T>) => Record<string, DispatchFunction<any, any>>;
|
|
260
|
+
/**
|
|
261
|
+
* Извлекает тип результата из функции диспетчера
|
|
262
|
+
*/
|
|
263
|
+
type ExtractResultType<T> = T extends DispatchFunction<any, infer R> ? R : never;
|
|
264
|
+
/**
|
|
265
|
+
* Извлекает типы из функции настройки действий
|
|
266
|
+
*/
|
|
267
|
+
type ActionsResult<F> = F extends (create: ActionCreatorFactory, storage: any, ...args: any[]) => infer R ? R : Record<string, DispatchFunction<any, any>>;
|
|
268
|
+
/**
|
|
269
|
+
* Типизированный объект действий
|
|
270
|
+
*/
|
|
271
|
+
type DispatchActions<T> = {
|
|
272
|
+
[K in keyof T]: T[K] extends DispatchFunction<any, any> ? T[K] : never;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Типизированный объект watchers
|
|
276
|
+
*/
|
|
277
|
+
type WatcherActions<T> = {
|
|
278
|
+
[K in keyof T]: T[K] extends WatcherFunction<any> ? T[K] : never;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Параметры для Dispatcher
|
|
282
|
+
*/
|
|
283
|
+
interface DispatcherOptions<T extends Record<string, any>> {
|
|
284
|
+
storage: IStorage<T>;
|
|
285
|
+
worker?: Worker;
|
|
286
|
+
middlewares?: EnhancedMiddleware<T>[];
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Интерфейс для API middleware
|
|
290
|
+
*/
|
|
291
|
+
interface DispatcherMiddlewareAPI<T extends Record<string, any>> {
|
|
292
|
+
getState: () => Promise<T>;
|
|
293
|
+
dispatch: (action: Action) => Promise<any>;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Интерфейс для middleware
|
|
297
|
+
*/
|
|
298
|
+
interface DispatcherMiddleware<T extends Record<string, any> = any> {
|
|
299
|
+
(api: DispatcherMiddlewareAPI<T>): (next: (action: Action) => Promise<any>) => (action: Action) => Promise<any>;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Класс Dispatcher для интеграции хранилищ с реактивной системой
|
|
303
|
+
*/
|
|
304
|
+
declare class Dispatcher<T extends Record<string, any>, TActionsFn extends ActionsSetupWithUtils<T> = ActionsSetupWithUtils<T>> {
|
|
305
|
+
private options;
|
|
306
|
+
private actions$;
|
|
307
|
+
readonly actions: Observable<Action>;
|
|
308
|
+
dispatch: Record<string, DispatchFunction<any, any>>;
|
|
309
|
+
watchers: Record<string, WatcherFunction<any>>;
|
|
310
|
+
private storage;
|
|
311
|
+
private middlewareFunctions;
|
|
312
|
+
private middlewareAPI;
|
|
313
|
+
/**
|
|
314
|
+
* Создает новый экземпляр Dispatcher
|
|
315
|
+
*/
|
|
316
|
+
constructor(options: DispatcherOptions<T>);
|
|
317
|
+
/**
|
|
318
|
+
* Добавляет middleware в цепочку обработки
|
|
319
|
+
*/
|
|
320
|
+
use(...middlewares: EnhancedMiddleware<T>[]): this;
|
|
321
|
+
/**
|
|
322
|
+
* Получает все действия с улучшенной типизацией
|
|
323
|
+
*/
|
|
324
|
+
getActions(): ActionsResult<TActionsFn>;
|
|
325
|
+
/**
|
|
326
|
+
* Получает типизированные действия диспетчера
|
|
327
|
+
*/
|
|
328
|
+
getTypedDispatch<A extends Record<string, any>>(): DispatchActions<A>;
|
|
329
|
+
/**
|
|
330
|
+
* Получает типизированные watcher'ы
|
|
331
|
+
*/
|
|
332
|
+
getTypedWatchers<A extends Record<string, any>>(): WatcherActions<A>;
|
|
333
|
+
/**
|
|
334
|
+
* Находит действие по типу
|
|
335
|
+
*/
|
|
336
|
+
findActionByType(actionType: string): DispatchFunction<any, any> | undefined;
|
|
337
|
+
/**
|
|
338
|
+
* Находит наблюдатель по типу
|
|
339
|
+
*/
|
|
340
|
+
findWatcherByType(actionType: string): WatcherFunction<any> | undefined;
|
|
341
|
+
/**
|
|
342
|
+
* Создает действие
|
|
343
|
+
*/
|
|
344
|
+
createAction<TParams, TResult>(actionConfig: ActionDefinition<TParams, TResult>, executionOptions?: ActionExecutionOptions): DispatchFunction<TParams, TResult>;
|
|
345
|
+
/**
|
|
346
|
+
* Создает watcher для отслеживания изменений в хранилище
|
|
347
|
+
*/
|
|
348
|
+
createWatcher<R>(config: WatcherDefinition<T, R>): WatcherFunction<R>;
|
|
349
|
+
/**
|
|
350
|
+
* Выполняет действие в worker
|
|
351
|
+
*/
|
|
352
|
+
private executeInWorker;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Функция для создания типизированного диспетчера
|
|
356
|
+
*/
|
|
357
|
+
declare function createDispatcher<TState extends Record<string, any>, TActions extends ActionsSetupWithUtils<TState>>(options: DispatcherOptions<TState>, actionsSetup: TActions): Dispatcher<TState, TActions> & {
|
|
358
|
+
dispatch: DispatchActions<ReturnType<TActions>>;
|
|
359
|
+
watchers: WatcherActions<ReturnType<TActions>>;
|
|
360
|
+
};
|
|
361
|
+
type CreateDispatcherType = ReturnType<typeof createDispatcher>;
|
|
362
|
+
|
|
363
|
+
export { type Action as A, combineEffects as B, type CreateDispatcherType as C, type DispatchFunction as D, type EnhancedMiddlewareAPI as E, type TypedAction as T, type ValidateConfig as V, type WatcherFunction as W, type EnhancedMiddleware as a, type ActionDefinition as b, type ActionsSetupWithUtils as c, type ActionsSetup as d, type ExtractResultType as e, type ActionsResult as f, type DispatchActions as g, type WatcherActions as h, type DispatcherMiddlewareAPI as i, type DispatcherMiddleware as j, Dispatcher as k, createDispatcher as l, type ExternalStates as m, type EffectBase as n, type Effect as o, type DispatcherActions as p, type ValidateMapRequestUtils as q, ofType as r, ofTypes as s, ofTypesWaitAll as t, selectorMap as u, selectorObject as v, validateMap as w, EffectsModule as x, createEffectBase as y, createEffect as z };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunk22J2S57D_cjs=require('./chunk-22J2S57D.cjs'),chunkFW5NGLPP_cjs=require('./chunk-FW5NGLPP.cjs'),chunkWC5TDS6C_cjs=require('./chunk-WC5TDS6C.cjs'),chunkVSIVOWZF_cjs=require('./chunk-VSIVOWZF.cjs'),chunkUFBCZ25Y_cjs=require('./chunk-UFBCZ25Y.cjs');require('./chunk-635Q6YJZ.cjs'),require('./chunk-NMDHQXMS.cjs');Object.defineProperty(exports,"ApiClient",{enumerable:true,get:function(){return chunk22J2S57D_cjs.e}});Object.defineProperty(exports,"ResponseFormat",{enumerable:true,get:function(){return chunk22J2S57D_cjs.d}});Object.defineProperty(exports,"apiLogger",{enumerable:true,get:function(){return chunk22J2S57D_cjs.a}});Object.defineProperty(exports,"createUniqueId",{enumerable:true,get:function(){return chunk22J2S57D_cjs.b}});Object.defineProperty(exports,"headersToObject",{enumerable:true,get:function(){return chunk22J2S57D_cjs.c}});Object.defineProperty(exports,"createSynapseCtx",{enumerable:true,get:function(){return chunkFW5NGLPP_cjs.c}});Object.defineProperty(exports,"useSelector",{enumerable:true,get:function(){return chunkFW5NGLPP_cjs.a}});Object.defineProperty(exports,"useStorageSubscribe",{enumerable:true,get:function(){return chunkFW5NGLPP_cjs.b}});Object.defineProperty(exports,"createSynapse",{enumerable:true,get:function(){return chunkWC5TDS6C_cjs.a}});Object.defineProperty(exports,"IndexedDBStorage",{enumerable:true,get:function(){return chunkVSIVOWZF_cjs.e}});Object.defineProperty(exports,"LocalStorage",{enumerable:true,get:function(){return chunkVSIVOWZF_cjs.f}});Object.defineProperty(exports,"MemoryStorage",{enumerable:true,get:function(){return chunkVSIVOWZF_cjs.g}});Object.defineProperty(exports,"SelectorModule",{enumerable:true,get:function(){return chunkVSIVOWZF_cjs.a}});Object.defineProperty(exports,"StorageEvents",{enumerable:true,get:function(){return chunkVSIVOWZF_cjs.c}});Object.defineProperty(exports,"StoragePluginModule",{enumerable:true,get:function(){return chunkVSIVOWZF_cjs.b}});Object.defineProperty(exports,"broadcastMiddleware",{enumerable:true,get:function(){return chunkVSIVOWZF_cjs.d}});Object.defineProperty(exports,"Dispatcher",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.a}});Object.defineProperty(exports,"EffectsModule",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.j}});Object.defineProperty(exports,"combineEffects",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.m}});Object.defineProperty(exports,"createDispatcher",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.b}});Object.defineProperty(exports,"createEffect",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.l}});Object.defineProperty(exports,"createEffectBase",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.k}});Object.defineProperty(exports,"loggerDispatcherMiddleware",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.c}});Object.defineProperty(exports,"ofType",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.d}});Object.defineProperty(exports,"ofTypes",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.e}});Object.defineProperty(exports,"ofTypesWaitAll",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.f}});Object.defineProperty(exports,"selectorMap",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.g}});Object.defineProperty(exports,"selectorObject",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.h}});Object.defineProperty(exports,"validateMap",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.i}});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { ApiClient, ResponseFormat, apiLogger, createUniqueId, headersToObject } from './api.cjs';
|
|
2
|
+
export { I as ISelectorModule, S as SelectorAPI } from './selector.interface-CA5y-kD_.cjs';
|
|
3
|
+
export { IPlugin, IPluginExecutor, IPluginManager, IStoragePlugin, IndexedDBStorage, LocalStorage, MemoryStorage, PluginContext, SelectorModule, StoragePluginModule, broadcastMiddleware } from './core.cjs';
|
|
4
|
+
export { B as BatchingMiddlewareOptions, C as ConfigureMiddlewares, D as DefaultMiddlewares, G as GetDefaultMiddleware, f as IEventEmitter, g as ILogger, I as IStorage, k as IndexedDBStorageConfig, L as LocalStorageConfig, j as MemoryStorageConfig, M as Middleware, a as MiddlewareAPI, N as NextFunction, S as ShallowCompareMiddlewareOptions, b as StorageAction, h as StorageConfig, e as StorageEvent, d as StorageEvents, c as StorageKeyType, i as StorageType } from './storage.interface-Dl8SLUd1.cjs';
|
|
5
|
+
export { A as Action, b as ActionDefinition, f as ActionsResult, d as ActionsSetup, c as ActionsSetupWithUtils, C as CreateDispatcherType, g as DispatchActions, D as DispatchFunction, k as Dispatcher, p as DispatcherActions, j as DispatcherMiddleware, i as DispatcherMiddlewareAPI, o as Effect, n as EffectBase, x as EffectsModule, a as EnhancedMiddleware, E as EnhancedMiddlewareAPI, m as ExternalStates, e as ExtractResultType, T as TypedAction, V as ValidateConfig, q as ValidateMapRequestUtils, h as WatcherActions, W as WatcherFunction, B as combineEffects, l as createDispatcher, z as createEffect, y as createEffectBase, r as ofType, s as ofTypes, t as ofTypesWaitAll, u as selectorMap, v as selectorObject, w as validateMap } from './dispatcher.module-CdpmkplA.cjs';
|
|
6
|
+
export { loggerDispatcherMiddleware } from './reactive.cjs';
|
|
7
|
+
export { AnySynapseStore, SynapseStoreBasic, SynapseStoreWithDispatcher, SynapseStoreWithEffects, createSynapse } from './utils.cjs';
|
|
8
|
+
export { createSynapseCtx, useSelector, useStorageSubscribe } from './react.cjs';
|
|
9
|
+
import 'rxjs';
|
|
10
|
+
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
export { ApiClient, ResponseFormat, apiLogger, createUniqueId, headersToObject } from './api.js';
|
|
2
|
+
export { I as ISelectorModule, S as SelectorAPI } from './selector.interface-CA5y-kD_.js';
|
|
3
|
+
export { IPlugin, IPluginExecutor, IPluginManager, IStoragePlugin, IndexedDBStorage, LocalStorage, MemoryStorage, PluginContext, SelectorModule, StoragePluginModule, broadcastMiddleware } from './core.js';
|
|
4
|
+
export { B as BatchingMiddlewareOptions, C as ConfigureMiddlewares, D as DefaultMiddlewares, G as GetDefaultMiddleware, f as IEventEmitter, g as ILogger, I as IStorage, k as IndexedDBStorageConfig, L as LocalStorageConfig, j as MemoryStorageConfig, M as Middleware, a as MiddlewareAPI, N as NextFunction, S as ShallowCompareMiddlewareOptions, b as StorageAction, h as StorageConfig, e as StorageEvent, d as StorageEvents, c as StorageKeyType, i as StorageType } from './storage.interface-Dl8SLUd1.js';
|
|
5
|
+
export { A as Action, b as ActionDefinition, f as ActionsResult, d as ActionsSetup, c as ActionsSetupWithUtils, C as CreateDispatcherType, g as DispatchActions, D as DispatchFunction, k as Dispatcher, p as DispatcherActions, j as DispatcherMiddleware, i as DispatcherMiddlewareAPI, o as Effect, n as EffectBase, x as EffectsModule, a as EnhancedMiddleware, E as EnhancedMiddlewareAPI, m as ExternalStates, e as ExtractResultType, T as TypedAction, V as ValidateConfig, q as ValidateMapRequestUtils, h as WatcherActions, W as WatcherFunction, B as combineEffects, l as createDispatcher, z as createEffect, y as createEffectBase, r as ofType, s as ofTypes, t as ofTypesWaitAll, u as selectorMap, v as selectorObject, w as validateMap } from './dispatcher.module-jd8U_ZEs.js';
|
|
6
|
+
export { loggerDispatcherMiddleware } from './reactive.js';
|
|
7
|
+
export { AnySynapseStore, SynapseStoreBasic, SynapseStoreWithDispatcher, SynapseStoreWithEffects, createSynapse } from './utils.js';
|
|
8
|
+
export { createSynapseCtx, useSelector, useStorageSubscribe } from './react.js';
|
|
9
|
+
import 'rxjs';
|
|
10
|
+
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Synapse - Библиотека управления состоянием и API-клиент
|
|
3
|
-
* @author Vlad Firsov
|
|
4
|
-
*/
|
|
5
|
-
// Основные модули
|
|
6
|
-
export * from './api/index.js';
|
|
7
|
-
export * from './core/index.js';
|
|
8
|
-
export * from './reactive/index.js';
|
|
9
|
-
export * from './utils/index.js';
|
|
10
|
-
// React-интеграция экспортируется только если установлен React
|
|
11
|
-
// Оставляем этот экспорт, он будет работать для пользователей,
|
|
12
|
-
// которые импортируют React напрямую
|
|
13
|
-
export * from './react/index.js';
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export{e as ApiClient,d as ResponseFormat,a as apiLogger,b as createUniqueId,c as headersToObject}from'./chunk-4USKKL5R.js';export{c as createSynapseCtx,a as useSelector,b as useStorageSubscribe}from'./chunk-S7X7IDBT.js';export{a as createSynapse}from'./chunk-WQNH3LVB.js';export{e as IndexedDBStorage,f as LocalStorage,g as MemoryStorage,a as SelectorModule,c as StorageEvents,b as StoragePluginModule,d as broadcastMiddleware}from'./chunk-6RNZVHSR.js';export{a as Dispatcher,j as EffectsModule,m as combineEffects,b as createDispatcher,l as createEffect,k as createEffectBase,c as loggerDispatcherMiddleware,d as ofType,e as ofTypes,f as ofTypesWaitAll,g as selectorMap,h as selectorObject,i as validateMap}from'./chunk-IPUPRMZK.js';import'./chunk-ZE2EJX2Y.js';import'./chunk-5X65PSGD.js';
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkFW5NGLPP_cjs=require('./chunk-FW5NGLPP.cjs');require('./chunk-NMDHQXMS.cjs');Object.defineProperty(exports,"createSynapseCtx",{enumerable:true,get:function(){return chunkFW5NGLPP_cjs.c}});Object.defineProperty(exports,"useSelector",{enumerable:true,get:function(){return chunkFW5NGLPP_cjs.a}});Object.defineProperty(exports,"useStorageSubscribe",{enumerable:true,get:function(){return chunkFW5NGLPP_cjs.b}});
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { S as SelectorAPI } from './selector.interface-CA5y-kD_.cjs';
|
|
2
|
+
import { I as IStorage } from './storage.interface-Dl8SLUd1.cjs';
|
|
3
|
+
import { ComponentType } from 'react';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { SynapseStoreWithEffects, SynapseStoreWithDispatcher, SynapseStoreBasic } from './utils.cjs';
|
|
6
|
+
import './dispatcher.module-CdpmkplA.cjs';
|
|
7
|
+
|
|
8
|
+
interface UseSelectorOptions<T> {
|
|
9
|
+
/** Начальное значение до загрузки данных из селектора */
|
|
10
|
+
initialValue?: T;
|
|
11
|
+
/** Функция сравнения для предотвращения лишних ререндеров */
|
|
12
|
+
equals?: (a: T, b: T) => boolean;
|
|
13
|
+
/** Включать ли статус загрузки в возвращаемый результат */
|
|
14
|
+
withLoading?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Хук для использования селекторов в компонентах React.
|
|
18
|
+
* Обеспечивает согласованность значений между всеми экземплярами хука.
|
|
19
|
+
*/
|
|
20
|
+
declare function useSelector<T>(selector: SelectorAPI<T>): T | undefined;
|
|
21
|
+
declare function useSelector<T>(selector: SelectorAPI<T>, options: UseSelectorOptions<T> & {
|
|
22
|
+
withLoading?: true;
|
|
23
|
+
}): {
|
|
24
|
+
data: T | undefined;
|
|
25
|
+
isLoading: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Хук для подписки на изменения в хранилище
|
|
30
|
+
*
|
|
31
|
+
* @template S - Тип состояния хранилища
|
|
32
|
+
* @template R - Тип возвращаемого значения
|
|
33
|
+
* @param storage - Экземпляр хранилища
|
|
34
|
+
* @param selector - Функция-селектор для выбора данных
|
|
35
|
+
* @returns Значение из хранилища
|
|
36
|
+
*/
|
|
37
|
+
declare const useStorageSubscribe: <S extends Record<string, any>, R = any>(storage: IStorage<S>, selector: (state: S) => R) => R | undefined;
|
|
38
|
+
|
|
39
|
+
interface Options<TStore extends Record<string, any>> {
|
|
40
|
+
loadingComponent?: any;
|
|
41
|
+
mergeFn?: (target: TStore, source: Record<string, any>) => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Перегрузки для createSynapseCtx в зависимости от типа хранилища
|
|
45
|
+
*/
|
|
46
|
+
declare function createSynapseCtx<TStore extends Record<string, any>, TStorage extends IStorage<TStore>, TSelectors, TActions>(synapseStorePromise: Promise<SynapseStoreWithEffects<TStore, TStorage, TSelectors, TActions>> | SynapseStoreWithEffects<TStore, TStorage, TSelectors, TActions>, options?: Options<TStore>): {
|
|
47
|
+
contextSynapse: <SelfComponentProps, PublicContextProps = Record<string, any>>(Component: ComponentType<SelfComponentProps>) => ComponentType<SelfComponentProps & {
|
|
48
|
+
contextProps?: PublicContextProps;
|
|
49
|
+
}>;
|
|
50
|
+
useSynapseStorage: () => TStorage;
|
|
51
|
+
useSynapseSelectors: () => TSelectors;
|
|
52
|
+
useSynapseActions: () => TActions;
|
|
53
|
+
useSynapseState$: () => Observable<TStore>;
|
|
54
|
+
cleanupSynapse: () => Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
declare function createSynapseCtx<TStore extends Record<string, any>, TStorage extends IStorage<TStore>, TSelectors, TActions>(synapseStorePromise: Promise<SynapseStoreWithDispatcher<TStore, TStorage, TSelectors, TActions>> | SynapseStoreWithDispatcher<TStore, TStorage, TSelectors, TActions>, options?: Options<TStore>): {
|
|
57
|
+
contextSynapse: <SelfComponentProps, PublicContextProps = Record<string, any>>(Component: ComponentType<SelfComponentProps>) => ComponentType<SelfComponentProps & {
|
|
58
|
+
contextProps?: PublicContextProps;
|
|
59
|
+
}>;
|
|
60
|
+
useSynapseStorage: () => TStorage;
|
|
61
|
+
useSynapseSelectors: () => TSelectors;
|
|
62
|
+
useSynapseActions: () => TActions;
|
|
63
|
+
cleanupSynapse: () => Promise<void>;
|
|
64
|
+
};
|
|
65
|
+
declare function createSynapseCtx<TStore extends Record<string, any>, TStorage extends IStorage<TStore>, TSelectors>(synapseStorePromise: Promise<SynapseStoreBasic<TStore, TStorage, TSelectors>> | SynapseStoreBasic<TStore, TStorage, TSelectors>, options?: Options<TStore>): {
|
|
66
|
+
contextSynapse: <SelfComponentProps, PublicContextProps = Record<string, any>>(Component: ComponentType<SelfComponentProps>) => ComponentType<SelfComponentProps & {
|
|
67
|
+
contextProps?: PublicContextProps;
|
|
68
|
+
}>;
|
|
69
|
+
useSynapseStorage: () => TStorage;
|
|
70
|
+
useSynapseSelectors: () => TSelectors;
|
|
71
|
+
cleanupSynapse: () => Promise<void>;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { createSynapseCtx, useSelector, useStorageSubscribe };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { S as SelectorAPI } from './selector.interface-CA5y-kD_.js';
|
|
2
|
+
import { I as IStorage } from './storage.interface-Dl8SLUd1.js';
|
|
3
|
+
import { ComponentType } from 'react';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { SynapseStoreWithEffects, SynapseStoreWithDispatcher, SynapseStoreBasic } from './utils.js';
|
|
6
|
+
import './dispatcher.module-jd8U_ZEs.js';
|
|
7
|
+
|
|
8
|
+
interface UseSelectorOptions<T> {
|
|
9
|
+
/** Начальное значение до загрузки данных из селектора */
|
|
10
|
+
initialValue?: T;
|
|
11
|
+
/** Функция сравнения для предотвращения лишних ререндеров */
|
|
12
|
+
equals?: (a: T, b: T) => boolean;
|
|
13
|
+
/** Включать ли статус загрузки в возвращаемый результат */
|
|
14
|
+
withLoading?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Хук для использования селекторов в компонентах React.
|
|
18
|
+
* Обеспечивает согласованность значений между всеми экземплярами хука.
|
|
19
|
+
*/
|
|
20
|
+
declare function useSelector<T>(selector: SelectorAPI<T>): T | undefined;
|
|
21
|
+
declare function useSelector<T>(selector: SelectorAPI<T>, options: UseSelectorOptions<T> & {
|
|
22
|
+
withLoading?: true;
|
|
23
|
+
}): {
|
|
24
|
+
data: T | undefined;
|
|
25
|
+
isLoading: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Хук для подписки на изменения в хранилище
|
|
30
|
+
*
|
|
31
|
+
* @template S - Тип состояния хранилища
|
|
32
|
+
* @template R - Тип возвращаемого значения
|
|
33
|
+
* @param storage - Экземпляр хранилища
|
|
34
|
+
* @param selector - Функция-селектор для выбора данных
|
|
35
|
+
* @returns Значение из хранилища
|
|
36
|
+
*/
|
|
37
|
+
declare const useStorageSubscribe: <S extends Record<string, any>, R = any>(storage: IStorage<S>, selector: (state: S) => R) => R | undefined;
|
|
38
|
+
|
|
39
|
+
interface Options<TStore extends Record<string, any>> {
|
|
40
|
+
loadingComponent?: any;
|
|
41
|
+
mergeFn?: (target: TStore, source: Record<string, any>) => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Перегрузки для createSynapseCtx в зависимости от типа хранилища
|
|
45
|
+
*/
|
|
46
|
+
declare function createSynapseCtx<TStore extends Record<string, any>, TStorage extends IStorage<TStore>, TSelectors, TActions>(synapseStorePromise: Promise<SynapseStoreWithEffects<TStore, TStorage, TSelectors, TActions>> | SynapseStoreWithEffects<TStore, TStorage, TSelectors, TActions>, options?: Options<TStore>): {
|
|
47
|
+
contextSynapse: <SelfComponentProps, PublicContextProps = Record<string, any>>(Component: ComponentType<SelfComponentProps>) => ComponentType<SelfComponentProps & {
|
|
48
|
+
contextProps?: PublicContextProps;
|
|
49
|
+
}>;
|
|
50
|
+
useSynapseStorage: () => TStorage;
|
|
51
|
+
useSynapseSelectors: () => TSelectors;
|
|
52
|
+
useSynapseActions: () => TActions;
|
|
53
|
+
useSynapseState$: () => Observable<TStore>;
|
|
54
|
+
cleanupSynapse: () => Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
declare function createSynapseCtx<TStore extends Record<string, any>, TStorage extends IStorage<TStore>, TSelectors, TActions>(synapseStorePromise: Promise<SynapseStoreWithDispatcher<TStore, TStorage, TSelectors, TActions>> | SynapseStoreWithDispatcher<TStore, TStorage, TSelectors, TActions>, options?: Options<TStore>): {
|
|
57
|
+
contextSynapse: <SelfComponentProps, PublicContextProps = Record<string, any>>(Component: ComponentType<SelfComponentProps>) => ComponentType<SelfComponentProps & {
|
|
58
|
+
contextProps?: PublicContextProps;
|
|
59
|
+
}>;
|
|
60
|
+
useSynapseStorage: () => TStorage;
|
|
61
|
+
useSynapseSelectors: () => TSelectors;
|
|
62
|
+
useSynapseActions: () => TActions;
|
|
63
|
+
cleanupSynapse: () => Promise<void>;
|
|
64
|
+
};
|
|
65
|
+
declare function createSynapseCtx<TStore extends Record<string, any>, TStorage extends IStorage<TStore>, TSelectors>(synapseStorePromise: Promise<SynapseStoreBasic<TStore, TStorage, TSelectors>> | SynapseStoreBasic<TStore, TStorage, TSelectors>, options?: Options<TStore>): {
|
|
66
|
+
contextSynapse: <SelfComponentProps, PublicContextProps = Record<string, any>>(Component: ComponentType<SelfComponentProps>) => ComponentType<SelfComponentProps & {
|
|
67
|
+
contextProps?: PublicContextProps;
|
|
68
|
+
}>;
|
|
69
|
+
useSynapseStorage: () => TStorage;
|
|
70
|
+
useSynapseSelectors: () => TSelectors;
|
|
71
|
+
cleanupSynapse: () => Promise<void>;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { createSynapseCtx, useSelector, useStorageSubscribe };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{c as createSynapseCtx,a as useSelector,b as useStorageSubscribe}from'./chunk-S7X7IDBT.js';import'./chunk-5X65PSGD.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkUFBCZ25Y_cjs=require('./chunk-UFBCZ25Y.cjs');require('./chunk-NMDHQXMS.cjs');Object.defineProperty(exports,"Dispatcher",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.a}});Object.defineProperty(exports,"EffectsModule",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.j}});Object.defineProperty(exports,"combineEffects",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.m}});Object.defineProperty(exports,"createDispatcher",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.b}});Object.defineProperty(exports,"createEffect",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.l}});Object.defineProperty(exports,"createEffectBase",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.k}});Object.defineProperty(exports,"loggerDispatcherMiddleware",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.c}});Object.defineProperty(exports,"ofType",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.d}});Object.defineProperty(exports,"ofTypes",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.e}});Object.defineProperty(exports,"ofTypesWaitAll",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.f}});Object.defineProperty(exports,"selectorMap",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.g}});Object.defineProperty(exports,"selectorObject",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.h}});Object.defineProperty(exports,"validateMap",{enumerable:true,get:function(){return chunkUFBCZ25Y_cjs.i}});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { a as EnhancedMiddleware } from './dispatcher.module-CdpmkplA.cjs';
|
|
2
|
+
export { A as Action, b as ActionDefinition, f as ActionsResult, d as ActionsSetup, c as ActionsSetupWithUtils, C as CreateDispatcherType, g as DispatchActions, D as DispatchFunction, k as Dispatcher, p as DispatcherActions, j as DispatcherMiddleware, i as DispatcherMiddlewareAPI, o as Effect, n as EffectBase, x as EffectsModule, E as EnhancedMiddlewareAPI, m as ExternalStates, e as ExtractResultType, T as TypedAction, V as ValidateConfig, q as ValidateMapRequestUtils, h as WatcherActions, W as WatcherFunction, B as combineEffects, l as createDispatcher, z as createEffect, y as createEffectBase, r as ofType, s as ofTypes, t as ofTypesWaitAll, u as selectorMap, v as selectorObject, w as validateMap } from './dispatcher.module-CdpmkplA.cjs';
|
|
3
|
+
import 'rxjs';
|
|
4
|
+
import './storage.interface-Dl8SLUd1.cjs';
|
|
5
|
+
|
|
6
|
+
interface LoggerTranslations {
|
|
7
|
+
action: string;
|
|
8
|
+
prevState: string;
|
|
9
|
+
nextState: string;
|
|
10
|
+
duration: string;
|
|
11
|
+
error: string;
|
|
12
|
+
diff: string;
|
|
13
|
+
changesCount: string;
|
|
14
|
+
showFullState: string;
|
|
15
|
+
}
|
|
16
|
+
interface LoggerColors {
|
|
17
|
+
title: string;
|
|
18
|
+
prevState: string;
|
|
19
|
+
fullState: string;
|
|
20
|
+
action: string;
|
|
21
|
+
nextState: string;
|
|
22
|
+
error: string;
|
|
23
|
+
diff: string;
|
|
24
|
+
}
|
|
25
|
+
interface LoggerOptions {
|
|
26
|
+
collapsed?: boolean;
|
|
27
|
+
duration?: boolean;
|
|
28
|
+
diff?: boolean;
|
|
29
|
+
showFullState?: boolean;
|
|
30
|
+
translations?: Partial<LoggerTranslations>;
|
|
31
|
+
colors?: Partial<LoggerColors>;
|
|
32
|
+
}
|
|
33
|
+
declare const loggerDispatcherMiddleware: <State extends Record<string, any>>(options?: LoggerOptions) => EnhancedMiddleware<State>;
|
|
34
|
+
|
|
35
|
+
export { EnhancedMiddleware, loggerDispatcherMiddleware };
|