effector-storage 7.1.0 → 8.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 +12 -9
- package/async-storage/index.cjs +1 -1
- package/async-storage/index.cjs.map +1 -1
- package/async-storage/index.d.cts +20 -9
- package/async-storage/index.d.ts +20 -9
- package/async-storage/index.js +1 -1
- package/async-storage/index.js.map +1 -1
- package/broadcast/index.cjs +1 -1
- package/broadcast/index.cjs.map +1 -1
- package/broadcast/index.d.cts +105 -26
- package/broadcast/index.d.ts +105 -26
- package/broadcast/index.js +1 -1
- package/broadcast/index.js.map +1 -1
- package/core/index.cjs +1 -1
- package/core/index.cjs.map +1 -1
- package/core/index.d.cts +99 -21
- package/core/index.d.ts +99 -21
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/core/package.json +3 -0
- package/index.cjs +1 -1
- package/index.cjs.map +1 -1
- package/index.d.cts +101 -22
- package/index.d.ts +101 -22
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/local/index.cjs +1 -1
- package/local/index.cjs.map +1 -1
- package/local/index.d.cts +105 -26
- package/local/index.d.ts +105 -26
- package/local/index.js +1 -1
- package/local/index.js.map +1 -1
- package/log/index.cjs +1 -1
- package/log/index.cjs.map +1 -1
- package/log/index.d.cts +21 -9
- package/log/index.d.ts +21 -9
- package/log/index.js +1 -1
- package/log/index.js.map +1 -1
- package/memory/index.cjs +1 -1
- package/memory/index.cjs.map +1 -1
- package/memory/index.d.cts +105 -26
- package/memory/index.d.ts +105 -26
- package/memory/index.js +1 -1
- package/memory/index.js.map +1 -1
- package/nil/index.cjs +1 -1
- package/nil/index.cjs.map +1 -1
- package/nil/index.d.cts +20 -9
- package/nil/index.d.ts +20 -9
- package/nil/index.js +1 -1
- package/nil/index.js.map +1 -1
- package/package.json +3 -3
- package/query/index.cjs +1 -1
- package/query/index.cjs.map +1 -1
- package/query/index.d.cts +105 -26
- package/query/index.d.ts +105 -26
- package/query/index.js +1 -1
- package/query/index.js.map +1 -1
- package/session/index.cjs +1 -1
- package/session/index.cjs.map +1 -1
- package/session/index.d.cts +105 -26
- package/session/index.d.ts +105 -26
- package/session/index.js +1 -1
- package/session/index.js.map +1 -1
- package/storage/index.cjs +1 -1
- package/storage/index.cjs.map +1 -1
- package/storage/index.d.cts +20 -9
- package/storage/index.d.ts +20 -9
- package/storage/index.js +1 -1
- package/storage/index.js.map +1 -1
- package/tools/index.cjs +1 -1
- package/tools/index.cjs.map +1 -1
- package/tools/index.d.cts +18 -9
- package/tools/index.d.ts +18 -9
- package/tools/index.js +1 -1
- package/tools/index.js.map +1 -1
- package/tools/package.json +3 -0
- package/async-storage/index.js.flow +0 -37
- package/broadcast/index.js.flow +0 -132
- package/core/index.js.flow +0 -113
- package/index.js.flow +0 -146
- package/local/index.js.flow +0 -140
- package/log/index.js.flow +0 -32
- package/memory/index.js.flow +0 -133
- package/nil/index.js.flow +0 -31
- package/query/index.js.flow +0 -159
- package/session/index.js.flow +0 -140
- package/storage/index.js.flow +0 -36
- package/tools/index.js.flow +0 -104
package/query/index.d.ts
CHANGED
|
@@ -1,21 +1,97 @@
|
|
|
1
|
-
import { Unit, Store, Event, Effect, Subscription } from 'effector';
|
|
1
|
+
import { Unit, UnitTargetable, Store, Event, Effect, StoreWritable, EventCallable, Subscription } from 'effector';
|
|
2
2
|
|
|
3
|
+
/** The Contract interface. */
|
|
4
|
+
interface Contract$1<Raw, Data extends Raw> {
|
|
5
|
+
/**
|
|
6
|
+
* Checks if Raw is Data
|
|
7
|
+
*/
|
|
8
|
+
isData: (prepared: Raw) => prepared is Data;
|
|
9
|
+
/**
|
|
10
|
+
* - empty array is dedicated for valid response
|
|
11
|
+
* - array of string with validation erorrs for invalidDataError
|
|
12
|
+
*/
|
|
13
|
+
getErrorMessages: (prepared: Raw) => string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The Standard Schema interface. */
|
|
17
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
18
|
+
/** The Standard Schema properties. */
|
|
19
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
20
|
+
}
|
|
21
|
+
declare namespace StandardSchemaV1 {
|
|
22
|
+
/** The Standard Schema properties interface. */
|
|
23
|
+
interface Props<Input = unknown, Output = Input> {
|
|
24
|
+
/** The version number of the standard. */
|
|
25
|
+
readonly version: 1;
|
|
26
|
+
/** The vendor name of the schema library. */
|
|
27
|
+
readonly vendor: string;
|
|
28
|
+
/** Validates unknown input values. */
|
|
29
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
30
|
+
/** Inferred types associated with the schema. */
|
|
31
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
32
|
+
}
|
|
33
|
+
/** The result interface of the validate function. */
|
|
34
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
35
|
+
/** The result interface if validation succeeds. */
|
|
36
|
+
interface SuccessResult<Output> {
|
|
37
|
+
/** The typed output value. */
|
|
38
|
+
readonly value: Output;
|
|
39
|
+
/** A falsy value for `issues` indicates success. */
|
|
40
|
+
readonly issues?: undefined;
|
|
41
|
+
}
|
|
42
|
+
interface Options {
|
|
43
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
44
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
45
|
+
}
|
|
46
|
+
/** The result interface if validation fails. */
|
|
47
|
+
interface FailureResult {
|
|
48
|
+
/** The issues of failed validation. */
|
|
49
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
50
|
+
}
|
|
51
|
+
/** The issue interface of the failure output. */
|
|
52
|
+
interface Issue {
|
|
53
|
+
/** The error message of the issue. */
|
|
54
|
+
readonly message: string;
|
|
55
|
+
/** The path of the issue, if any. */
|
|
56
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
57
|
+
}
|
|
58
|
+
/** The path segment interface of the issue. */
|
|
59
|
+
interface PathSegment {
|
|
60
|
+
/** The key representing a path segment. */
|
|
61
|
+
readonly key: PropertyKey;
|
|
62
|
+
}
|
|
63
|
+
/** The Standard Schema types interface. */
|
|
64
|
+
interface Types<Input = unknown, Output = Input> {
|
|
65
|
+
/** The input type of the schema. */
|
|
66
|
+
readonly input: Input;
|
|
67
|
+
/** The output type of the schema. */
|
|
68
|
+
readonly output: Output;
|
|
69
|
+
}
|
|
70
|
+
/** Infers the input type of a Standard Schema. */
|
|
71
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
72
|
+
/** Infers the output type of a Standard Schema. */
|
|
73
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface Adapter<State> {
|
|
77
|
+
get(this: void, //
|
|
78
|
+
raw?: any, ctx?: any): State | undefined | Promise<State | undefined>;
|
|
79
|
+
set(this: void, //
|
|
80
|
+
value: State, ctx?: any): void | Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
interface DisposableAdapter<State> extends Adapter<State> {
|
|
83
|
+
(): void;
|
|
84
|
+
}
|
|
3
85
|
interface StorageAdapter {
|
|
4
|
-
<State>(key: string, update: (raw?: any) => void):
|
|
5
|
-
get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined;
|
|
6
|
-
set(value: State, ctx?: any): void;
|
|
7
|
-
};
|
|
86
|
+
<State>(key: string, update: (raw?: any) => void): Adapter<State> | DisposableAdapter<State>;
|
|
8
87
|
keyArea?: any;
|
|
9
88
|
noop?: boolean;
|
|
10
89
|
}
|
|
11
90
|
interface StorageAdapterFactory<AdapterConfig> {
|
|
12
|
-
(config
|
|
91
|
+
(config: AdapterConfig): StorageAdapter;
|
|
13
92
|
factory: true;
|
|
14
93
|
}
|
|
15
|
-
type Contract<Data> = ((raw: unknown) => raw is Data) |
|
|
16
|
-
isData: (raw: unknown) => raw is Data;
|
|
17
|
-
getErrorMessages: (raw: unknown) => string[];
|
|
18
|
-
};
|
|
94
|
+
type Contract<Data> = ((raw: unknown) => raw is Data) | StandardSchemaV1<unknown, Data> | Contract$1<unknown, Data>;
|
|
19
95
|
type Done<State> = {
|
|
20
96
|
key: string;
|
|
21
97
|
keyPrefix: string;
|
|
@@ -29,34 +105,36 @@ type Fail<Err> = {
|
|
|
29
105
|
error: Err;
|
|
30
106
|
value?: any;
|
|
31
107
|
};
|
|
32
|
-
type
|
|
108
|
+
type FinallyDone<State> = Done<State> & {
|
|
33
109
|
status: 'done';
|
|
34
|
-
}
|
|
110
|
+
};
|
|
111
|
+
type FinallyFail<Err> = Fail<Err> & {
|
|
35
112
|
status: 'fail';
|
|
36
|
-
}
|
|
113
|
+
};
|
|
114
|
+
type Finally<State, Err> = FinallyDone<State> | FinallyFail<Err>;
|
|
37
115
|
interface ConfigPersist$1 {
|
|
38
|
-
pickup?: Unit<any
|
|
116
|
+
pickup?: Unit<any> | Unit<any>[];
|
|
39
117
|
context?: Unit<any>;
|
|
40
118
|
keyPrefix?: string;
|
|
41
119
|
contract?: Contract<any>;
|
|
42
120
|
}
|
|
43
121
|
interface ConfigCommon<State, Err = Error> {
|
|
44
122
|
clock?: Unit<any>;
|
|
45
|
-
done?:
|
|
46
|
-
fail?:
|
|
47
|
-
finally?:
|
|
48
|
-
pickup?: Unit<any
|
|
123
|
+
done?: UnitTargetable<Done<State>>;
|
|
124
|
+
fail?: UnitTargetable<Fail<Err>>;
|
|
125
|
+
finally?: UnitTargetable<Finally<State, Err>>;
|
|
126
|
+
pickup?: Unit<any> | Unit<any>[];
|
|
49
127
|
context?: Unit<any>;
|
|
50
128
|
key?: string;
|
|
51
129
|
keyPrefix?: string;
|
|
52
130
|
contract?: Contract<State | undefined>;
|
|
53
131
|
}
|
|
54
132
|
interface ConfigJustStore<State> {
|
|
55
|
-
store:
|
|
133
|
+
store: StoreWritable<State>;
|
|
56
134
|
}
|
|
57
135
|
interface ConfigJustSourceTarget<State> {
|
|
58
136
|
source: Store<State> | Event<State> | Effect<State, any, any>;
|
|
59
|
-
target:
|
|
137
|
+
target: StoreWritable<State> | EventCallable<State> | Effect<State, any, any>;
|
|
60
138
|
}
|
|
61
139
|
interface ConfigStore$1<State, Err = Error> extends ConfigCommon<State, Err>, ConfigJustStore<State> {
|
|
62
140
|
}
|
|
@@ -91,18 +169,19 @@ interface Persist {
|
|
|
91
169
|
<State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription;
|
|
92
170
|
<State, Err = Error>(config: ConfigStore<State, Err>): Subscription;
|
|
93
171
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Creates query string adapter
|
|
174
|
+
*/
|
|
175
|
+
declare const query: StorageAdapterFactory<QueryConfig | undefined | void>;
|
|
98
176
|
/**
|
|
99
177
|
* Creates custom partially applied `persist`
|
|
100
178
|
* with predefined `query` adapter
|
|
101
179
|
*/
|
|
102
|
-
declare
|
|
180
|
+
declare const createPersist: (defaults?: ConfigPersist) => Persist;
|
|
103
181
|
/**
|
|
104
182
|
* Default partially applied `persist`
|
|
105
183
|
*/
|
|
106
184
|
declare const persist: Persist;
|
|
107
185
|
|
|
108
|
-
export {
|
|
186
|
+
export { createPersist, locationAssign, locationReplace, persist, pushState, query, replaceState };
|
|
187
|
+
export type { Adapter, ChangeMethod, ConfigPersist, ConfigSourceTarget, ConfigStore, Contract, DisposableAdapter, Done, Fail, Finally, Persist, QueryConfig, StateBehavior, StorageAdapter, StorageAdapterFactory };
|
package/query/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{persist as e}from"../core/index.js";import{nil as t}from"../nil/index.js";var a,r,o=Symbol(),i=new Map,n=e=>location.pathname+(e+""?"?"+e:"")+(location.hash&&"#"!==location.hash?location.hash:""),s=(e,t)=>history.pushState(t?null:history.state,"",n(e)),l=(e,t)=>history.replaceState(t?null:history.state,"",n(e)),
|
|
1
|
+
import{persist as e}from"../core/index.js";import{nil as t}from"../nil/index.js";var a,r,o=Symbol(),i=new Map,n=e=>location.pathname+(e+""?"?"+e:"")+(location.hash&&"#"!==location.hash?location.hash:""),s=(e,t)=>history.pushState(t?null:history.state,"",n(e)),l=(e,t)=>history.replaceState(t?null:history.state,"",n(e)),d=e=>location.assign(n(e)),c=e=>location.replace(n(e)),u=(e,t)=>{if(r=void 0,i.size){var a=new URLSearchParams(location.search);for(var[o,n]of i.entries())null!=n?a.set(o,`${n}`):a.delete(o);i.clear(),e(a,"erase"===t)}},h=e=>"undefined"!=typeof history&&"undefined"!=typeof location?(({method:e=s,state:t,serialize:n,deserialize:l,def:d=null,timeout:c})=>{var h=(o,s)=>{var h=()=>setTimeout(s,0);return"undefined"!=typeof addEventListener&&addEventListener("popstate",h),Object.assign(()=>{"undefined"!=typeof removeEventListener&&removeEventListener("popstate",h)},{get(){var e=new URLSearchParams(location.search).get(o);return e?l?l(e):e:d},set(s){if(i.set(o,n?n(s):s),void 0===c)return clearTimeout(a),u(e,t);var l=Date.now()+c;(void 0===r||r>l)&&(clearTimeout(a),r=l,a=setTimeout(u,c,e,t))}})};return h.keyArea=o,h})({...e}):t({keyArea:"query"});h.factory=!0;var p=t=>a=>e({adapter:h,...t,...a}),v=/*#__PURE__*/p();export{p as createPersist,d as locationAssign,c as locationReplace,v as persist,s as pushState,h as query,l as replaceState};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/query/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/query/adapter.ts","../../src/query/index.ts"],"sourcesContent":["import type { StorageAdapter } from '../types'\n\nexport type ChangeMethod = (\n params: URLSearchParams | string,\n erase?: boolean\n) => void\n\nexport type StateBehavior = 'keep' | 'erase'\n\nexport interface QueryConfig {\n method?: ChangeMethod\n state?: StateBehavior\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n timeout?: number\n def?: any\n}\n\nconst keyArea = Symbol()
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/query/adapter.ts","../../src/query/index.ts"],"sourcesContent":["import type { StorageAdapter } from '../types'\n\nexport type ChangeMethod = (\n params: URLSearchParams | string,\n erase?: boolean\n) => void\n\nexport type StateBehavior = 'keep' | 'erase'\n\nexport interface QueryConfig {\n method?: ChangeMethod\n state?: StateBehavior\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n timeout?: number\n def?: any\n}\n\nconst keyArea = Symbol()\n\nconst buffer = new Map<string, any>()\nlet timeoutId: ReturnType<typeof setTimeout> | undefined\nlet scheduled: number | undefined\n\n/*\n * Location change methods list\n */\n\nconst url = (params: URLSearchParams | string) =>\n location.pathname +\n (params + '' ? '?' + params : '') +\n (location.hash && location.hash !== '#' ? location.hash : '')\n\nexport const pushState: ChangeMethod = (params, erase): void =>\n history.pushState(erase ? null : history.state, '', url(params))\n\nexport const replaceState: ChangeMethod = (params, erase): void =>\n history.replaceState(erase ? null : history.state, '', url(params))\n\nexport const locationAssign: ChangeMethod = (params): void =>\n location.assign(url(params))\n\nexport const locationReplace: ChangeMethod = (params): void =>\n location.replace(url(params))\n\n/**\n * Flush buffer to actual location search params\n */\nconst flush = (method: ChangeMethod, state?: StateBehavior) => {\n scheduled = undefined\n if (buffer.size) {\n const params = new URLSearchParams(location.search)\n for (const [name, value] of buffer.entries()) {\n if (value != null) {\n params.set(name, `${value}`)\n } else {\n params.delete(name)\n }\n }\n buffer.clear()\n method(params, state === 'erase')\n }\n}\n\n/**\n * Query string adapter factory\n */\nexport const adapter = ({\n method = pushState,\n state,\n serialize,\n deserialize,\n def = null,\n timeout,\n}: QueryConfig): StorageAdapter => {\n const adapter: StorageAdapter = <State>(\n key: string,\n update: (raw?: any) => void\n ) => {\n const updated = () => setTimeout(update, 0)\n\n if (typeof addEventListener !== 'undefined') {\n addEventListener('popstate', updated)\n }\n\n const dispose = () => {\n if (typeof removeEventListener !== 'undefined') {\n removeEventListener('popstate', updated)\n }\n }\n\n return Object.assign(dispose, {\n get() {\n const params = new URLSearchParams(location.search)\n const value = params.get(key)\n return value ? (deserialize ? deserialize(value) : value) : def\n },\n\n set(value: State) {\n buffer.set(key, serialize ? serialize(value) : value)\n\n if (timeout === undefined) {\n clearTimeout(timeoutId)\n return flush(method, state)\n }\n\n const deadline = Date.now() + timeout\n if (scheduled === undefined || scheduled > deadline) {\n clearTimeout(timeoutId)\n scheduled = deadline\n timeoutId = setTimeout(flush, timeout, method, state)\n }\n },\n })\n }\n\n adapter.keyArea = keyArea\n return adapter\n}\n","import type { Subscription } from 'effector'\nimport type {\n ConfigPersist as BaseConfigPersist,\n ConfigSourceTarget as BaseConfigSourceTarget,\n ConfigStore as BaseConfigStore,\n StorageAdapterFactory,\n} from '../types'\nimport type { ChangeMethod, QueryConfig, StateBehavior } from './adapter'\nimport { persist as base } from '../core'\nimport { nil } from '../nil'\nimport { adapter } from './adapter'\n\nexport type {\n Adapter,\n Contract,\n DisposableAdapter,\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\nexport type { ChangeMethod, QueryConfig, StateBehavior } from './adapter'\nexport {\n locationAssign,\n locationReplace,\n pushState,\n replaceState,\n} from './adapter'\n\nexport interface ConfigPersist extends BaseConfigPersist {\n method?: ChangeMethod\n state?: StateBehavior\n timeout?: number\n}\n\nexport interface ConfigStore<State, Err = Error>\n extends QueryConfig,\n BaseConfigStore<State, Err> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends QueryConfig,\n BaseConfigSourceTarget<State, Err> {}\n\nexport interface Persist {\n <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription\n <State, Err = Error>(config: ConfigStore<State, Err>): Subscription\n}\n\n/**\n * Function, checking if `history` and `location` exists and accessible\n */\nconst supports = () =>\n typeof history !== 'undefined' && typeof location !== 'undefined'\n\n/**\n * Creates query string adapter\n */\nexport const query: StorageAdapterFactory<QueryConfig | undefined | void> = (\n config\n) => {\n return supports()\n ? adapter({\n ...config,\n })\n : nil({ keyArea: 'query' })\n}\n\n// mark as factory\nquery.factory = true\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `query` adapter\n */\nexport const createPersist =\n (defaults?: ConfigPersist): Persist =>\n (config) =>\n base({\n adapter: query,\n ...defaults,\n ...config,\n })\n\n/**\n * Default partially applied `persist`\n */\nexport const persist: Persist = /*#__PURE__*/ createPersist()\n"],"names":["timeoutId","scheduled","keyArea","Symbol","buffer","Map","url","params","location","pathname","hash","pushState","erase","history","state","replaceState","locationAssign","assign","locationReplace","replace","flush","method","undefined","size","URLSearchParams","search","name","value","entries","set","delete","clear","query","config","adapter","serialize","deserialize","def","timeout","key","update","updated","setTimeout","addEventListener","Object","dispose","removeEventListener","get","clearTimeout","deadline","Date","now","nil","factory","createPersist","defaults","base","persist"],"mappings":"iFAkBA,IAGIA,EACAC,EAJEC,EAAUC,SAEVC,EAAS,IAAIC,IAQbC,EAAOC,GACXC,SAASC,UACRF,EAAS,GAAK,IAAMA,EAAS,KAC7BC,SAASE,MAA0B,MAAlBF,SAASE,KAAeF,SAASE,KAAO,IAE/CC,EAA0BA,CAACJ,EAAQK,IAC9CC,QAAQF,UAAUC,EAAQ,KAAOC,QAAQC,MAAO,GAAIR,EAAIC,IAE7CQ,EAA6BA,CAACR,EAAQK,IACjDC,QAAQE,aAAaH,EAAQ,KAAOC,QAAQC,MAAO,GAAIR,EAAIC,IAEhDS,EAAgCT,GAC3CC,SAASS,OAAOX,EAAIC,IAETW,EAAiCX,GAC5CC,SAASW,QAAQb,EAAIC,IAKjBa,EAAQA,CAACC,EAAsBP,KAEnC,GADAb,OAAYqB,EACRlB,EAAOmB,KAAM,CACf,IAAMhB,EAAS,IAAIiB,gBAAgBhB,SAASiB,QAC5C,IAAK,IAAOC,EAAMC,KAAUvB,EAAOwB,UACpB,MAATD,EACFpB,EAAOsB,IAAIH,EAAM,GAAGC,KAEpBpB,EAAOuB,OAAOJ,GAGlBtB,EAAO2B,QACPV,EAAOd,EAAkB,UAAVO,EACjB,GCHWkB,EACXC,GANmB,oBAAZpB,SAA+C,oBAAbL,SDcpB0B,GACrBb,SAASV,EACTG,QACAqB,YACAC,cACAC,MAAM,KACNC,cAEA,IAAMJ,EAA0BA,CAC9BK,EACAC,KAEA,IAAMC,EAAUA,IAAMC,WAAWF,EAAQ,GAYzC,MAVgC,oBAArBG,kBACTA,iBAAiB,WAAYF,GASxBG,OAAO3B,OANE4B,KACqB,oBAAxBC,qBACTA,oBAAoB,WAAYL,IAIN,CAC5BM,GAAAA,GACE,IACMpB,EADS,IAAIH,gBAAgBhB,SAASiB,QACvBsB,IAAIR,GACzB,OAAOZ,EAASS,EAAcA,EAAYT,GAASA,EAASU,CAC9D,EAEAR,GAAAA,CAAIF,GAGF,GAFAvB,EAAOyB,IAAIU,EAAKJ,EAAYA,EAAUR,GAASA,QAE/BL,IAAZgB,EAEF,OADAU,aAAahD,GACNoB,EAAMC,EAAQP,GAGvB,IAAMmC,EAAWC,KAAKC,MAAQb,QACZhB,IAAdrB,GAA2BA,EAAYgD,KACzCD,aAAahD,GACbC,EAAYgD,EACZjD,EAAY0C,WAAWtB,EAAOkB,EAASjB,EAAQP,GAEnD,KAKJ,OADAoB,EAAQhC,QAAUA,EACXgC,GCvDHA,CAAQ,IACHD,IAELmB,EAAI,CAAElD,QAAS,UAIrB8B,EAAMqB,SAAU,EAMT,IAAMC,EACVC,GACAtB,GACCuB,EAAK,CACHtB,QAASF,KACNuB,KACAtB,IAMIwB,eAAiCH"}
|
package/session/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../core/index.cjs"),r=require("../nil/index.cjs"),s=require("../storage/index.cjs")
|
|
1
|
+
"use strict";var e=require("../core/index.cjs"),r=require("../nil/index.cjs"),s=require("../storage/index.cjs"),t=e=>(()=>{try{return"undefined"!=typeof sessionStorage}catch(e){return!0}})()?s.storage({storage:()=>sessionStorage,...e}):r.nil({keyArea:"session"});t.factory=!0;var i=r=>s=>e.persist({adapter:t,...r,...s}),o=/*#__PURE__*/i();exports.createPersist=i,exports.persist=o,exports.session=t;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/session/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/session/index.ts"],"sourcesContent":["import type { Subscription } from 'effector'\nimport type {\n ConfigPersist as BaseConfigPersist,\n
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/session/index.ts"],"sourcesContent":["import type { Subscription } from 'effector'\nimport type {\n ConfigPersist as BaseConfigPersist,\n ConfigSourceTarget as BaseConfigSourceTarget,\n ConfigStore as BaseConfigStore,\n StorageAdapterFactory,\n} from '../types'\nimport { persist as base } from '../core'\nimport { nil } from '../nil'\nimport { storage } from '../storage'\n\nexport type {\n Adapter,\n Contract,\n DisposableAdapter,\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\n\nexport interface ConfigPersist extends BaseConfigPersist {\n sync?: boolean | 'force'\n timeout?: number\n}\n\nexport interface SessionStorageConfig {\n sync?: boolean | 'force'\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n timeout?: number\n def?: any\n}\n\nexport interface ConfigStore<State, Err = Error>\n extends SessionStorageConfig,\n BaseConfigStore<State, Err> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends SessionStorageConfig,\n BaseConfigSourceTarget<State, Err> {}\n\nexport interface Persist {\n <State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription\n <State, Err = Error>(config: ConfigStore<State, Err>): Subscription\n}\n\n/**\n * Function, checking if `sessionStorage` exists\n */\nconst supports = () => {\n try {\n return typeof sessionStorage !== 'undefined'\n } catch (_error) {\n // accessing `sessionStorage` could throw an exception only in one case -\n // when `sessionStorage` IS supported, but blocked by security policies\n return true\n }\n}\n\n/**\n * Creates `sessionStorage` adapter\n */\nexport const session: StorageAdapterFactory<\n SessionStorageConfig | undefined | void\n> = (config) => {\n return supports()\n ? storage({\n storage: () => sessionStorage,\n ...config,\n })\n : nil({ keyArea: 'session' })\n}\n\n// mark as factory\nsession.factory = true\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `sessionStorage` adapter\n */\nexport const createPersist =\n (defaults?: ConfigPersist): Persist =>\n (config) =>\n base({\n adapter: session,\n ...defaults,\n ...config,\n })\n\n/**\n * Default partially applied `persist`\n */\nexport const persist: Persist = /*#__PURE__*/ createPersist()\n"],"names":["session","config","supports","sessionStorage","_error","storage","nil","keyArea","factory","createPersist","defaults","base","adapter","persist"],"mappings":"gHAgEaA,EAERC,GAfYC,MACf,IACE,MAAiC,oBAAnBC,cAChB,CAAE,MAAOC,GAGP,OAAO,CACT,GASOF,GACHG,UAAQ,CACNA,QAASA,IAAMF,kBACZF,IAELK,EAAAA,IAAI,CAAEC,QAAS,YAIrBP,EAAQQ,SAAU,EAMX,IAAMC,EACVC,GACAT,GACCU,UAAK,CACHC,QAASZ,KACNU,KACAT,IAMIY,eAAiCJ"}
|
package/session/index.d.cts
CHANGED
|
@@ -1,21 +1,97 @@
|
|
|
1
|
-
import { Unit, Store, Event, Effect, Subscription } from 'effector';
|
|
1
|
+
import { Unit, UnitTargetable, Store, Event, Effect, StoreWritable, EventCallable, Subscription } from 'effector';
|
|
2
2
|
|
|
3
|
+
/** The Contract interface. */
|
|
4
|
+
interface Contract$1<Raw, Data extends Raw> {
|
|
5
|
+
/**
|
|
6
|
+
* Checks if Raw is Data
|
|
7
|
+
*/
|
|
8
|
+
isData: (prepared: Raw) => prepared is Data;
|
|
9
|
+
/**
|
|
10
|
+
* - empty array is dedicated for valid response
|
|
11
|
+
* - array of string with validation erorrs for invalidDataError
|
|
12
|
+
*/
|
|
13
|
+
getErrorMessages: (prepared: Raw) => string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The Standard Schema interface. */
|
|
17
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
18
|
+
/** The Standard Schema properties. */
|
|
19
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
20
|
+
}
|
|
21
|
+
declare namespace StandardSchemaV1 {
|
|
22
|
+
/** The Standard Schema properties interface. */
|
|
23
|
+
interface Props<Input = unknown, Output = Input> {
|
|
24
|
+
/** The version number of the standard. */
|
|
25
|
+
readonly version: 1;
|
|
26
|
+
/** The vendor name of the schema library. */
|
|
27
|
+
readonly vendor: string;
|
|
28
|
+
/** Validates unknown input values. */
|
|
29
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
30
|
+
/** Inferred types associated with the schema. */
|
|
31
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
32
|
+
}
|
|
33
|
+
/** The result interface of the validate function. */
|
|
34
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
35
|
+
/** The result interface if validation succeeds. */
|
|
36
|
+
interface SuccessResult<Output> {
|
|
37
|
+
/** The typed output value. */
|
|
38
|
+
readonly value: Output;
|
|
39
|
+
/** A falsy value for `issues` indicates success. */
|
|
40
|
+
readonly issues?: undefined;
|
|
41
|
+
}
|
|
42
|
+
interface Options {
|
|
43
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
44
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
45
|
+
}
|
|
46
|
+
/** The result interface if validation fails. */
|
|
47
|
+
interface FailureResult {
|
|
48
|
+
/** The issues of failed validation. */
|
|
49
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
50
|
+
}
|
|
51
|
+
/** The issue interface of the failure output. */
|
|
52
|
+
interface Issue {
|
|
53
|
+
/** The error message of the issue. */
|
|
54
|
+
readonly message: string;
|
|
55
|
+
/** The path of the issue, if any. */
|
|
56
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
57
|
+
}
|
|
58
|
+
/** The path segment interface of the issue. */
|
|
59
|
+
interface PathSegment {
|
|
60
|
+
/** The key representing a path segment. */
|
|
61
|
+
readonly key: PropertyKey;
|
|
62
|
+
}
|
|
63
|
+
/** The Standard Schema types interface. */
|
|
64
|
+
interface Types<Input = unknown, Output = Input> {
|
|
65
|
+
/** The input type of the schema. */
|
|
66
|
+
readonly input: Input;
|
|
67
|
+
/** The output type of the schema. */
|
|
68
|
+
readonly output: Output;
|
|
69
|
+
}
|
|
70
|
+
/** Infers the input type of a Standard Schema. */
|
|
71
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
72
|
+
/** Infers the output type of a Standard Schema. */
|
|
73
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface Adapter<State> {
|
|
77
|
+
get(this: void, //
|
|
78
|
+
raw?: any, ctx?: any): State | undefined | Promise<State | undefined>;
|
|
79
|
+
set(this: void, //
|
|
80
|
+
value: State, ctx?: any): void | Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
interface DisposableAdapter<State> extends Adapter<State> {
|
|
83
|
+
(): void;
|
|
84
|
+
}
|
|
3
85
|
interface StorageAdapter {
|
|
4
|
-
<State>(key: string, update: (raw?: any) => void):
|
|
5
|
-
get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined;
|
|
6
|
-
set(value: State, ctx?: any): void;
|
|
7
|
-
};
|
|
86
|
+
<State>(key: string, update: (raw?: any) => void): Adapter<State> | DisposableAdapter<State>;
|
|
8
87
|
keyArea?: any;
|
|
9
88
|
noop?: boolean;
|
|
10
89
|
}
|
|
11
90
|
interface StorageAdapterFactory<AdapterConfig> {
|
|
12
|
-
(config
|
|
91
|
+
(config: AdapterConfig): StorageAdapter;
|
|
13
92
|
factory: true;
|
|
14
93
|
}
|
|
15
|
-
type Contract<Data> = ((raw: unknown) => raw is Data) |
|
|
16
|
-
isData: (raw: unknown) => raw is Data;
|
|
17
|
-
getErrorMessages: (raw: unknown) => string[];
|
|
18
|
-
};
|
|
94
|
+
type Contract<Data> = ((raw: unknown) => raw is Data) | StandardSchemaV1<unknown, Data> | Contract$1<unknown, Data>;
|
|
19
95
|
type Done<State> = {
|
|
20
96
|
key: string;
|
|
21
97
|
keyPrefix: string;
|
|
@@ -29,34 +105,36 @@ type Fail<Err> = {
|
|
|
29
105
|
error: Err;
|
|
30
106
|
value?: any;
|
|
31
107
|
};
|
|
32
|
-
type
|
|
108
|
+
type FinallyDone<State> = Done<State> & {
|
|
33
109
|
status: 'done';
|
|
34
|
-
}
|
|
110
|
+
};
|
|
111
|
+
type FinallyFail<Err> = Fail<Err> & {
|
|
35
112
|
status: 'fail';
|
|
36
|
-
}
|
|
113
|
+
};
|
|
114
|
+
type Finally<State, Err> = FinallyDone<State> | FinallyFail<Err>;
|
|
37
115
|
interface ConfigPersist$1 {
|
|
38
|
-
pickup?: Unit<any
|
|
116
|
+
pickup?: Unit<any> | Unit<any>[];
|
|
39
117
|
context?: Unit<any>;
|
|
40
118
|
keyPrefix?: string;
|
|
41
119
|
contract?: Contract<any>;
|
|
42
120
|
}
|
|
43
121
|
interface ConfigCommon<State, Err = Error> {
|
|
44
122
|
clock?: Unit<any>;
|
|
45
|
-
done?:
|
|
46
|
-
fail?:
|
|
47
|
-
finally?:
|
|
48
|
-
pickup?: Unit<any
|
|
123
|
+
done?: UnitTargetable<Done<State>>;
|
|
124
|
+
fail?: UnitTargetable<Fail<Err>>;
|
|
125
|
+
finally?: UnitTargetable<Finally<State, Err>>;
|
|
126
|
+
pickup?: Unit<any> | Unit<any>[];
|
|
49
127
|
context?: Unit<any>;
|
|
50
128
|
key?: string;
|
|
51
129
|
keyPrefix?: string;
|
|
52
130
|
contract?: Contract<State | undefined>;
|
|
53
131
|
}
|
|
54
132
|
interface ConfigJustStore<State> {
|
|
55
|
-
store:
|
|
133
|
+
store: StoreWritable<State>;
|
|
56
134
|
}
|
|
57
135
|
interface ConfigJustSourceTarget<State> {
|
|
58
136
|
source: Store<State> | Event<State> | Effect<State, any, any>;
|
|
59
|
-
target:
|
|
137
|
+
target: StoreWritable<State> | EventCallable<State> | Effect<State, any, any>;
|
|
60
138
|
}
|
|
61
139
|
interface ConfigStore$1<State, Err = Error> extends ConfigCommon<State, Err>, ConfigJustStore<State> {
|
|
62
140
|
}
|
|
@@ -82,18 +160,19 @@ interface Persist {
|
|
|
82
160
|
<State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription;
|
|
83
161
|
<State, Err = Error>(config: ConfigStore<State, Err>): Subscription;
|
|
84
162
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Creates `sessionStorage` adapter
|
|
165
|
+
*/
|
|
166
|
+
declare const session: StorageAdapterFactory<SessionStorageConfig | undefined | void>;
|
|
89
167
|
/**
|
|
90
168
|
* Creates custom partially applied `persist`
|
|
91
169
|
* with predefined `sessionStorage` adapter
|
|
92
170
|
*/
|
|
93
|
-
declare
|
|
171
|
+
declare const createPersist: (defaults?: ConfigPersist) => Persist;
|
|
94
172
|
/**
|
|
95
173
|
* Default partially applied `persist`
|
|
96
174
|
*/
|
|
97
175
|
declare const persist: Persist;
|
|
98
176
|
|
|
99
|
-
export {
|
|
177
|
+
export { createPersist, persist, session };
|
|
178
|
+
export type { Adapter, ConfigPersist, ConfigSourceTarget, ConfigStore, Contract, DisposableAdapter, Done, Fail, Finally, Persist, SessionStorageConfig, StorageAdapter, StorageAdapterFactory };
|
package/session/index.d.ts
CHANGED
|
@@ -1,21 +1,97 @@
|
|
|
1
|
-
import { Unit, Store, Event, Effect, Subscription } from 'effector';
|
|
1
|
+
import { Unit, UnitTargetable, Store, Event, Effect, StoreWritable, EventCallable, Subscription } from 'effector';
|
|
2
2
|
|
|
3
|
+
/** The Contract interface. */
|
|
4
|
+
interface Contract$1<Raw, Data extends Raw> {
|
|
5
|
+
/**
|
|
6
|
+
* Checks if Raw is Data
|
|
7
|
+
*/
|
|
8
|
+
isData: (prepared: Raw) => prepared is Data;
|
|
9
|
+
/**
|
|
10
|
+
* - empty array is dedicated for valid response
|
|
11
|
+
* - array of string with validation erorrs for invalidDataError
|
|
12
|
+
*/
|
|
13
|
+
getErrorMessages: (prepared: Raw) => string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The Standard Schema interface. */
|
|
17
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
18
|
+
/** The Standard Schema properties. */
|
|
19
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
20
|
+
}
|
|
21
|
+
declare namespace StandardSchemaV1 {
|
|
22
|
+
/** The Standard Schema properties interface. */
|
|
23
|
+
interface Props<Input = unknown, Output = Input> {
|
|
24
|
+
/** The version number of the standard. */
|
|
25
|
+
readonly version: 1;
|
|
26
|
+
/** The vendor name of the schema library. */
|
|
27
|
+
readonly vendor: string;
|
|
28
|
+
/** Validates unknown input values. */
|
|
29
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
30
|
+
/** Inferred types associated with the schema. */
|
|
31
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
32
|
+
}
|
|
33
|
+
/** The result interface of the validate function. */
|
|
34
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
35
|
+
/** The result interface if validation succeeds. */
|
|
36
|
+
interface SuccessResult<Output> {
|
|
37
|
+
/** The typed output value. */
|
|
38
|
+
readonly value: Output;
|
|
39
|
+
/** A falsy value for `issues` indicates success. */
|
|
40
|
+
readonly issues?: undefined;
|
|
41
|
+
}
|
|
42
|
+
interface Options {
|
|
43
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
44
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
45
|
+
}
|
|
46
|
+
/** The result interface if validation fails. */
|
|
47
|
+
interface FailureResult {
|
|
48
|
+
/** The issues of failed validation. */
|
|
49
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
50
|
+
}
|
|
51
|
+
/** The issue interface of the failure output. */
|
|
52
|
+
interface Issue {
|
|
53
|
+
/** The error message of the issue. */
|
|
54
|
+
readonly message: string;
|
|
55
|
+
/** The path of the issue, if any. */
|
|
56
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
57
|
+
}
|
|
58
|
+
/** The path segment interface of the issue. */
|
|
59
|
+
interface PathSegment {
|
|
60
|
+
/** The key representing a path segment. */
|
|
61
|
+
readonly key: PropertyKey;
|
|
62
|
+
}
|
|
63
|
+
/** The Standard Schema types interface. */
|
|
64
|
+
interface Types<Input = unknown, Output = Input> {
|
|
65
|
+
/** The input type of the schema. */
|
|
66
|
+
readonly input: Input;
|
|
67
|
+
/** The output type of the schema. */
|
|
68
|
+
readonly output: Output;
|
|
69
|
+
}
|
|
70
|
+
/** Infers the input type of a Standard Schema. */
|
|
71
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
72
|
+
/** Infers the output type of a Standard Schema. */
|
|
73
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface Adapter<State> {
|
|
77
|
+
get(this: void, //
|
|
78
|
+
raw?: any, ctx?: any): State | undefined | Promise<State | undefined>;
|
|
79
|
+
set(this: void, //
|
|
80
|
+
value: State, ctx?: any): void | Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
interface DisposableAdapter<State> extends Adapter<State> {
|
|
83
|
+
(): void;
|
|
84
|
+
}
|
|
3
85
|
interface StorageAdapter {
|
|
4
|
-
<State>(key: string, update: (raw?: any) => void):
|
|
5
|
-
get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined;
|
|
6
|
-
set(value: State, ctx?: any): void;
|
|
7
|
-
};
|
|
86
|
+
<State>(key: string, update: (raw?: any) => void): Adapter<State> | DisposableAdapter<State>;
|
|
8
87
|
keyArea?: any;
|
|
9
88
|
noop?: boolean;
|
|
10
89
|
}
|
|
11
90
|
interface StorageAdapterFactory<AdapterConfig> {
|
|
12
|
-
(config
|
|
91
|
+
(config: AdapterConfig): StorageAdapter;
|
|
13
92
|
factory: true;
|
|
14
93
|
}
|
|
15
|
-
type Contract<Data> = ((raw: unknown) => raw is Data) |
|
|
16
|
-
isData: (raw: unknown) => raw is Data;
|
|
17
|
-
getErrorMessages: (raw: unknown) => string[];
|
|
18
|
-
};
|
|
94
|
+
type Contract<Data> = ((raw: unknown) => raw is Data) | StandardSchemaV1<unknown, Data> | Contract$1<unknown, Data>;
|
|
19
95
|
type Done<State> = {
|
|
20
96
|
key: string;
|
|
21
97
|
keyPrefix: string;
|
|
@@ -29,34 +105,36 @@ type Fail<Err> = {
|
|
|
29
105
|
error: Err;
|
|
30
106
|
value?: any;
|
|
31
107
|
};
|
|
32
|
-
type
|
|
108
|
+
type FinallyDone<State> = Done<State> & {
|
|
33
109
|
status: 'done';
|
|
34
|
-
}
|
|
110
|
+
};
|
|
111
|
+
type FinallyFail<Err> = Fail<Err> & {
|
|
35
112
|
status: 'fail';
|
|
36
|
-
}
|
|
113
|
+
};
|
|
114
|
+
type Finally<State, Err> = FinallyDone<State> | FinallyFail<Err>;
|
|
37
115
|
interface ConfigPersist$1 {
|
|
38
|
-
pickup?: Unit<any
|
|
116
|
+
pickup?: Unit<any> | Unit<any>[];
|
|
39
117
|
context?: Unit<any>;
|
|
40
118
|
keyPrefix?: string;
|
|
41
119
|
contract?: Contract<any>;
|
|
42
120
|
}
|
|
43
121
|
interface ConfigCommon<State, Err = Error> {
|
|
44
122
|
clock?: Unit<any>;
|
|
45
|
-
done?:
|
|
46
|
-
fail?:
|
|
47
|
-
finally?:
|
|
48
|
-
pickup?: Unit<any
|
|
123
|
+
done?: UnitTargetable<Done<State>>;
|
|
124
|
+
fail?: UnitTargetable<Fail<Err>>;
|
|
125
|
+
finally?: UnitTargetable<Finally<State, Err>>;
|
|
126
|
+
pickup?: Unit<any> | Unit<any>[];
|
|
49
127
|
context?: Unit<any>;
|
|
50
128
|
key?: string;
|
|
51
129
|
keyPrefix?: string;
|
|
52
130
|
contract?: Contract<State | undefined>;
|
|
53
131
|
}
|
|
54
132
|
interface ConfigJustStore<State> {
|
|
55
|
-
store:
|
|
133
|
+
store: StoreWritable<State>;
|
|
56
134
|
}
|
|
57
135
|
interface ConfigJustSourceTarget<State> {
|
|
58
136
|
source: Store<State> | Event<State> | Effect<State, any, any>;
|
|
59
|
-
target:
|
|
137
|
+
target: StoreWritable<State> | EventCallable<State> | Effect<State, any, any>;
|
|
60
138
|
}
|
|
61
139
|
interface ConfigStore$1<State, Err = Error> extends ConfigCommon<State, Err>, ConfigJustStore<State> {
|
|
62
140
|
}
|
|
@@ -82,18 +160,19 @@ interface Persist {
|
|
|
82
160
|
<State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription;
|
|
83
161
|
<State, Err = Error>(config: ConfigStore<State, Err>): Subscription;
|
|
84
162
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Creates `sessionStorage` adapter
|
|
165
|
+
*/
|
|
166
|
+
declare const session: StorageAdapterFactory<SessionStorageConfig | undefined | void>;
|
|
89
167
|
/**
|
|
90
168
|
* Creates custom partially applied `persist`
|
|
91
169
|
* with predefined `sessionStorage` adapter
|
|
92
170
|
*/
|
|
93
|
-
declare
|
|
171
|
+
declare const createPersist: (defaults?: ConfigPersist) => Persist;
|
|
94
172
|
/**
|
|
95
173
|
* Default partially applied `persist`
|
|
96
174
|
*/
|
|
97
175
|
declare const persist: Persist;
|
|
98
176
|
|
|
99
|
-
export {
|
|
177
|
+
export { createPersist, persist, session };
|
|
178
|
+
export type { Adapter, ConfigPersist, ConfigSourceTarget, ConfigStore, Contract, DisposableAdapter, Done, Fail, Finally, Persist, SessionStorageConfig, StorageAdapter, StorageAdapterFactory };
|
package/session/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{persist as r}from"../core/index.js";import{nil as e}from"../nil/index.js";import{storage as
|
|
1
|
+
import{persist as r}from"../core/index.js";import{nil as e}from"../nil/index.js";import{storage as o}from"../storage/index.js";var s=r=>(()=>{try{return"undefined"!=typeof sessionStorage}catch(r){return!0}})()?o({storage:()=>sessionStorage,...r}):e({keyArea:"session"});s.factory=!0;var t=e=>o=>r({adapter:s,...e,...o}),a=/*#__PURE__*/t();export{t as createPersist,a as persist,s as session};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|