effector-storage 6.0.0 → 6.1.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 +40 -21
- package/async-storage/index.cjs.d.ts +1 -1
- package/async-storage/index.d.ts +1 -1
- package/async-storage/index.js.flow +1 -1
- package/broadcast/index.cjs +2 -0
- package/broadcast/index.cjs.d.ts +116 -0
- package/broadcast/index.cjs.map +1 -0
- package/broadcast/index.d.ts +116 -0
- package/broadcast/index.js +2 -0
- package/broadcast/index.js.flow +134 -0
- package/broadcast/index.js.map +1 -0
- package/broadcast/package.json +8 -0
- package/core/index.cjs +1 -1
- package/core/index.cjs.d.ts +1 -1
- package/core/index.cjs.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +1 -1
- package/core/index.js.flow +1 -1
- package/core/index.js.map +1 -1
- package/index.cjs +1 -1
- package/index.cjs.d.ts +3 -1
- package/index.cjs.map +1 -1
- package/index.d.ts +3 -1
- package/index.js +1 -1
- package/index.js.flow +3 -1
- package/index.js.map +1 -1
- package/local/index.cjs.d.ts +10 -5
- package/local/index.cjs.map +1 -1
- package/local/index.d.ts +10 -5
- package/local/index.js.flow +14 -5
- package/local/index.js.map +1 -1
- package/log/index.cjs.d.ts +1 -1
- package/log/index.d.ts +1 -1
- package/log/index.js.flow +1 -1
- package/memory/index.cjs.d.ts +12 -7
- package/memory/index.cjs.map +1 -1
- package/memory/index.d.ts +12 -7
- package/memory/index.js.flow +19 -10
- package/memory/index.js.map +1 -1
- package/nil/index.cjs.d.ts +1 -1
- package/nil/index.d.ts +1 -1
- package/nil/index.js.flow +1 -1
- package/package.json +33 -14
- package/query/index.cjs +1 -1
- package/query/index.cjs.d.ts +12 -5
- package/query/index.cjs.map +1 -1
- package/query/index.d.ts +12 -5
- package/query/index.js +1 -1
- package/query/index.js.flow +16 -5
- package/query/index.js.map +1 -1
- package/rn/async/index.cjs.d.ts +14 -5
- package/rn/async/index.cjs.map +1 -1
- package/rn/async/index.d.ts +14 -5
- package/rn/async/index.js.flow +14 -5
- package/rn/async/index.js.map +1 -1
- package/rn/encrypted/index.cjs.d.ts +19 -5
- package/rn/encrypted/index.cjs.map +1 -1
- package/rn/encrypted/index.d.ts +19 -5
- package/rn/encrypted/index.js.flow +19 -5
- package/rn/encrypted/index.js.map +1 -1
- package/session/index.cjs.d.ts +10 -5
- package/session/index.cjs.map +1 -1
- package/session/index.d.ts +10 -5
- package/session/index.js.flow +14 -5
- package/session/index.js.map +1 -1
- package/storage/index.cjs.d.ts +1 -1
- package/storage/index.cjs.map +1 -1
- package/storage/index.d.ts +1 -1
- package/storage/index.js.flow +1 -1
- package/storage/index.js.map +1 -1
- package/tools/index.cjs +1 -1
- package/tools/index.cjs.d.ts +1 -1
- package/tools/index.cjs.map +1 -1
- package/tools/index.d.ts +1 -1
- package/tools/index.js +1 -1
- package/tools/index.js.flow +1 -1
- package/tools/index.js.map +1 -1
package/memory/index.js.flow
CHANGED
|
@@ -11,7 +11,7 @@ declare interface StorageAdapter {
|
|
|
11
11
|
key: string,
|
|
12
12
|
update: (raw?: any) => any
|
|
13
13
|
): {
|
|
14
|
-
get(raw?: any, ctx?: any): State | Promise<State
|
|
14
|
+
get(raw?: any, ctx?: any): State | Promise<State | void> | void,
|
|
15
15
|
set(value: State, ctx?: any): void,
|
|
16
16
|
...
|
|
17
17
|
};
|
|
@@ -59,7 +59,7 @@ declare type Finally<State, Err> =
|
|
|
59
59
|
...
|
|
60
60
|
},
|
|
61
61
|
}
|
|
62
|
-
declare interface ConfigPersist {
|
|
62
|
+
declare interface ConfigPersist$1 {
|
|
63
63
|
pickup?: Unit<any>;
|
|
64
64
|
context?: Unit<any>;
|
|
65
65
|
keyPrefix?: string;
|
|
@@ -83,6 +83,16 @@ declare interface ConfigJustSourceTarget<State> {
|
|
|
83
83
|
source: Store<State> | Event<State> | Effect<State, any, any>;
|
|
84
84
|
target: Store<State> | Event<State> | Effect<State, any, any>;
|
|
85
85
|
}
|
|
86
|
+
declare type ConfigStore$1<State, Err = Error> = { ... } & ConfigCommon<
|
|
87
|
+
State,
|
|
88
|
+
Err
|
|
89
|
+
> &
|
|
90
|
+
ConfigJustStore<State>
|
|
91
|
+
declare type ConfigSourceTarget$1<State, Err = Error> = { ... } & ConfigCommon<
|
|
92
|
+
State,
|
|
93
|
+
Err
|
|
94
|
+
> &
|
|
95
|
+
ConfigJustSourceTarget<State>
|
|
86
96
|
declare interface MemoryConfig {
|
|
87
97
|
area?: Map<string, any>;
|
|
88
98
|
}
|
|
@@ -93,16 +103,14 @@ declare var npm$namespace$adapter: {|
|
|
|
93
103
|
factory: typeof adapter$factory,
|
|
94
104
|
|}
|
|
95
105
|
declare var adapter$factory: true
|
|
96
|
-
declare type
|
|
106
|
+
declare type ConfigPersist = { ... } & ConfigPersist$1
|
|
107
|
+
declare type ConfigStore<State, Err = Error> = { ... } & ConfigStore$1<
|
|
97
108
|
State,
|
|
98
109
|
Err
|
|
99
|
-
>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
Err
|
|
104
|
-
> &
|
|
105
|
-
ConfigJustSourceTarget<State>
|
|
110
|
+
>
|
|
111
|
+
declare type ConfigSourceTarget<State, Err = Error> = {
|
|
112
|
+
...
|
|
113
|
+
} & ConfigSourceTarget$1<State, Err>
|
|
106
114
|
declare interface Persist {
|
|
107
115
|
<State, Err>(config: ConfigSourceTarget<State, Err>): Subscription;
|
|
108
116
|
<State, Err>(config: ConfigStore<State, Err>): Subscription;
|
|
@@ -113,6 +121,7 @@ declare export {
|
|
|
113
121
|
ConfigPersist,
|
|
114
122
|
ConfigSourceTarget,
|
|
115
123
|
ConfigStore,
|
|
124
|
+
Contract,
|
|
116
125
|
Done,
|
|
117
126
|
Fail,
|
|
118
127
|
Finally,
|
package/memory/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/memory/adapter.ts","../../src/memory/index.ts"],"sourcesContent":["import type { StorageAdapter } from '../types'\n\nconst data = new Map<string, any>()\n\nexport interface MemoryConfig {\n area?: Map<string, any>\n}\n\n/**\n * Memory adapter\n */\nadapter.factory = true as const\nexport function adapter({ area = data }: MemoryConfig = {}): StorageAdapter {\n const adapter: StorageAdapter = <State>(key: string) => ({\n get: () => area.get(key),\n set: (value: State) => area.set(key, value),\n })\n\n adapter.keyArea = area\n return adapter\n}\n","import type { Subscription } from 'effector'\nimport type {\n ConfigPersist,\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/memory/adapter.ts","../../src/memory/index.ts"],"sourcesContent":["import type { StorageAdapter } from '../types'\n\nconst data = new Map<string, any>()\n\nexport interface MemoryConfig {\n area?: Map<string, any>\n}\n\n/**\n * Memory adapter\n */\nadapter.factory = true as const\nexport function adapter({ area = data }: MemoryConfig = {}): StorageAdapter {\n const adapter: StorageAdapter = <State>(key: string) => ({\n get: () => area.get(key),\n set: (value: State) => area.set(key, value),\n })\n\n adapter.keyArea = area\n return adapter\n}\n","import type { Subscription } from 'effector'\nimport type {\n ConfigPersist as BaseConfigPersist,\n ConfigStore as BaseConfigStore,\n ConfigSourceTarget as BaseConfigSourceTarget,\n} from '../types'\nimport { persist as base } from '../core'\nimport { adapter } from './adapter'\n\nexport type {\n Contract,\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\nexport type { MemoryConfig } from './adapter'\n\nexport interface ConfigPersist extends BaseConfigPersist {}\n\nexport interface ConfigStore<State, Err = Error>\n extends BaseConfigStore<State, Err> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends 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 * Returns memory adapter\n */\nexport { adapter as memory }\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `memory` adapter\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: adapter(),\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n */\nexport const persist = createPersist()\n"],"names":["data","Map","adapter","area","key","get","set","value","keyArea","createPersist","defaults","config","base","factory","persist"],"mappings":"2CAEA,IAAMA,EAAO,IAAIC,IAUV,SAASC,GAAQC,KAAEA,EAAOH,GAAuB,IACtD,IAAME,EAAkCE,IAAiB,CACvDC,IAAKA,IAAMF,EAAKE,IAAID,GACpBE,IAAMC,GAAiBJ,EAAKG,IAAIF,EAAKG,KAIvC,OADAL,EAAQM,QAAUL,EACXD,CACT,CCqBO,SAASO,EAAcC,GAC5B,OAAQC,GACNC,EAAK,CACHV,QAASA,OACNQ,KACAC,GAET,CDrCAT,EAAQW,SAAU,EC0CLC,IAAAA,EAAUL"}
|
package/nil/index.cjs.d.ts
CHANGED
package/nil/index.d.ts
CHANGED
package/nil/index.js.flow
CHANGED
|
@@ -10,7 +10,7 @@ declare interface StorageAdapter {
|
|
|
10
10
|
key: string,
|
|
11
11
|
update: (raw?: any) => any
|
|
12
12
|
): {
|
|
13
|
-
get(raw?: any, ctx?: any): State | Promise<State
|
|
13
|
+
get(raw?: any, ctx?: any): State | Promise<State | void> | void,
|
|
14
14
|
set(value: State, ctx?: any): void,
|
|
15
15
|
...
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effector-storage",
|
|
3
3
|
"description": "Module for Effector to sync stores with different storages",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.1.0",
|
|
5
5
|
"author": "Victor Didenko <yumaa.verdin@gmail.com> (https://yumaa.name)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -38,67 +38,86 @@
|
|
|
38
38
|
"./package.json": "./package.json",
|
|
39
39
|
".": {
|
|
40
40
|
"require": "./index.cjs",
|
|
41
|
-
"import": "./index.js"
|
|
41
|
+
"import": "./index.js",
|
|
42
|
+
"types": "./index.d.ts"
|
|
42
43
|
},
|
|
43
44
|
"./core/package.json": "./core/package.json",
|
|
44
45
|
"./core": {
|
|
45
46
|
"require": "./core/index.cjs",
|
|
46
|
-
"import": "./core/index.js"
|
|
47
|
+
"import": "./core/index.js",
|
|
48
|
+
"types": "./core/index.d.ts"
|
|
47
49
|
},
|
|
48
50
|
"./tools/package.json": "./tools/package.json",
|
|
49
51
|
"./tools": {
|
|
50
52
|
"require": "./tools/index.cjs",
|
|
51
|
-
"import": "./tools/index.js"
|
|
53
|
+
"import": "./tools/index.js",
|
|
54
|
+
"types": "./tools/index.d.ts"
|
|
52
55
|
},
|
|
53
56
|
"./nil/package.json": "./nil/package.json",
|
|
54
57
|
"./nil": {
|
|
55
58
|
"require": "./nil/index.cjs",
|
|
56
|
-
"import": "./nil/index.js"
|
|
59
|
+
"import": "./nil/index.js",
|
|
60
|
+
"types": "./nil/index.d.ts"
|
|
57
61
|
},
|
|
58
62
|
"./log/package.json": "./log/package.json",
|
|
59
63
|
"./log": {
|
|
60
64
|
"require": "./log/index.cjs",
|
|
61
|
-
"import": "./log/index.js"
|
|
65
|
+
"import": "./log/index.js",
|
|
66
|
+
"types": "./log/index.d.ts"
|
|
62
67
|
},
|
|
63
68
|
"./local/package.json": "./local/package.json",
|
|
64
69
|
"./local": {
|
|
65
70
|
"require": "./local/index.cjs",
|
|
66
|
-
"import": "./local/index.js"
|
|
71
|
+
"import": "./local/index.js",
|
|
72
|
+
"types": "./local/index.d.ts"
|
|
67
73
|
},
|
|
68
74
|
"./session/package.json": "./session/package.json",
|
|
69
75
|
"./session": {
|
|
70
76
|
"require": "./session/index.cjs",
|
|
71
|
-
"import": "./session/index.js"
|
|
77
|
+
"import": "./session/index.js",
|
|
78
|
+
"types": "./session/index.d.ts"
|
|
72
79
|
},
|
|
73
80
|
"./storage/package.json": "./storage/package.json",
|
|
74
81
|
"./storage": {
|
|
75
82
|
"require": "./storage/index.cjs",
|
|
76
|
-
"import": "./storage/index.js"
|
|
83
|
+
"import": "./storage/index.js",
|
|
84
|
+
"types": "./storage/index.d.ts"
|
|
77
85
|
},
|
|
78
86
|
"./query/package.json": "./query/package.json",
|
|
79
87
|
"./query": {
|
|
80
88
|
"require": "./query/index.cjs",
|
|
81
|
-
"import": "./query/index.js"
|
|
89
|
+
"import": "./query/index.js",
|
|
90
|
+
"types": "./query/index.d.ts"
|
|
82
91
|
},
|
|
83
92
|
"./memory/package.json": "./memory/package.json",
|
|
84
93
|
"./memory": {
|
|
85
94
|
"require": "./memory/index.cjs",
|
|
86
|
-
"import": "./memory/index.js"
|
|
95
|
+
"import": "./memory/index.js",
|
|
96
|
+
"types": "./memory/index.d.ts"
|
|
87
97
|
},
|
|
88
98
|
"./async-storage/package.json": "./async-storage/package.json",
|
|
89
99
|
"./async-storage": {
|
|
90
100
|
"require": "./async-storage/index.cjs",
|
|
91
|
-
"import": "./async-storage/index.js"
|
|
101
|
+
"import": "./async-storage/index.js",
|
|
102
|
+
"types": "./async-storage/index.d.ts"
|
|
103
|
+
},
|
|
104
|
+
"./broadcast/package.json": "./broadcast/package.json",
|
|
105
|
+
"./broadcast": {
|
|
106
|
+
"require": "./broadcast/index.cjs",
|
|
107
|
+
"import": "./broadcast/index.js",
|
|
108
|
+
"types": "./broadcast/index.d.ts"
|
|
92
109
|
},
|
|
93
110
|
"./rn/async/package.json": "./rn/async/package.json",
|
|
94
111
|
"./rn/async": {
|
|
95
112
|
"require": "./rn/async/index.cjs",
|
|
96
|
-
"import": "./rn/async/index.js"
|
|
113
|
+
"import": "./rn/async/index.js",
|
|
114
|
+
"types": "./rn/async/index.d.ts"
|
|
97
115
|
},
|
|
98
116
|
"./rn/encrypted/package.json": "./rn/encrypted/package.json",
|
|
99
117
|
"./rn/encrypted": {
|
|
100
118
|
"require": "./rn/encrypted/index.cjs",
|
|
101
|
-
"import": "./rn/encrypted/index.js"
|
|
119
|
+
"import": "./rn/encrypted/index.js",
|
|
120
|
+
"types": "./rn/encrypted/index.d.ts"
|
|
102
121
|
}
|
|
103
122
|
}
|
|
104
123
|
}
|
package/query/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e,t,r=require("../core/index.cjs"),a=require("../nil/index.cjs"),o=Symbol(),i=new Map,
|
|
1
|
+
"use strict";var e,t,r=require("../core/index.cjs"),a=require("../nil/index.cjs"),o=Symbol(),i=new Map,s=e=>location.pathname+(e+""?"?"+e:"")+(location.hash&&"#"!==location.hash?location.hash:""),n=(e,t)=>history.pushState(t?null:history.state,"",s(e));function c(e,r){if(t=void 0,i.size){var a=new URLSearchParams(location.search);for(var[o,s]of i.entries())null!=s?a.set(o,`${s}`):a.delete(o);i.clear(),e(a,"erase"===r)}}function l(r){return"undefined"!=typeof history&&"undefined"!=typeof location?function({method:r=n,state:a,serialize:s,deserialize:l,def:u=null,timeout:p}){var d=(o,n)=>("undefined"!=typeof addEventListener&&addEventListener("popstate",(()=>setTimeout(n,0))),{get(){var e=new URLSearchParams(location.search).get(o);return e?l?l(e):e:u},set(n){if(i.set(o,s?s(n):n),void 0===p)return clearTimeout(e),c(r,a);var l=Date.now()+p;(void 0===t||t>l)&&(clearTimeout(e),t=l,e=setTimeout(c,p,r,a))}});return d.keyArea=o,d}({...r}):a.nil({keyArea:"query"})}function u(e){return t=>r.persist({adapter:l,...e,...t})}l.factory=!0;var p=u();exports.createPersist=u,exports.locationAssign=e=>location.assign(s(e)),exports.locationReplace=e=>location.replace(s(e)),exports.persist=p,exports.pushState=n,exports.query=l,exports.replaceState=(e,t)=>history.replaceState(t?null:history.state,"",s(e));
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/query/index.cjs.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Unit, Store, Event, Effect, Subscription } from 'effector'
|
|
|
2
2
|
|
|
3
3
|
interface StorageAdapter {
|
|
4
4
|
<State>(key: string, update: (raw?: any) => any): {
|
|
5
|
-
get(raw?: any, ctx?: any): State | Promise<State>
|
|
5
|
+
get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
|
|
6
6
|
set(value: State, ctx?: any): void
|
|
7
7
|
}
|
|
8
8
|
keyArea?: any
|
|
@@ -62,12 +62,20 @@ interface ConfigJustSourceTarget<State> {
|
|
|
62
62
|
source: Store<State> | Event<State> | Effect<State, any, any>
|
|
63
63
|
target: Store<State> | Event<State> | Effect<State, any, any>
|
|
64
64
|
}
|
|
65
|
+
interface ConfigStore$1<State, Err = Error>
|
|
66
|
+
extends ConfigCommon<State, Err>,
|
|
67
|
+
ConfigJustStore<State> {}
|
|
68
|
+
interface ConfigSourceTarget$1<State, Err = Error>
|
|
69
|
+
extends ConfigCommon<State, Err>,
|
|
70
|
+
ConfigJustSourceTarget<State> {}
|
|
65
71
|
|
|
66
72
|
type ChangeMethod = (params: URLSearchParams | string, erase?: boolean) => void
|
|
67
73
|
type StateBehavior = 'keep' | 'erase'
|
|
68
74
|
interface QueryConfig {
|
|
69
75
|
method?: ChangeMethod
|
|
70
76
|
state?: StateBehavior
|
|
77
|
+
serialize?: (value: any) => string
|
|
78
|
+
deserialize?: (value: string) => any
|
|
71
79
|
timeout?: number
|
|
72
80
|
def?: any
|
|
73
81
|
}
|
|
@@ -83,12 +91,10 @@ interface ConfigPersist extends ConfigPersist$1 {
|
|
|
83
91
|
}
|
|
84
92
|
interface ConfigStore<State, Err = Error>
|
|
85
93
|
extends QueryConfig,
|
|
86
|
-
|
|
87
|
-
ConfigJustStore<State> {}
|
|
94
|
+
ConfigStore$1<State, Err> {}
|
|
88
95
|
interface ConfigSourceTarget<State, Err = Error>
|
|
89
96
|
extends QueryConfig,
|
|
90
|
-
|
|
91
|
-
ConfigJustSourceTarget<State> {}
|
|
97
|
+
ConfigSourceTarget$1<State, Err> {}
|
|
92
98
|
interface Persist {
|
|
93
99
|
<State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription
|
|
94
100
|
<State, Err = Error>(config: ConfigStore<State, Err>): Subscription
|
|
@@ -112,6 +118,7 @@ export {
|
|
|
112
118
|
ConfigPersist,
|
|
113
119
|
ConfigSourceTarget,
|
|
114
120
|
ConfigStore,
|
|
121
|
+
Contract,
|
|
115
122
|
Done,
|
|
116
123
|
Fail,
|
|
117
124
|
Finally,
|
package/query/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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 timeout?: number\n def?: any\n}\n\nconst keyArea = Symbol() // eslint-disable-line symbol-description\n\nconst buffer
|
|
1
|
+
{"version":3,"file":"index.cjs","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() // eslint-disable-line symbol-description\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 */\nfunction 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 function 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) => any\n ) => {\n if (typeof addEventListener !== 'undefined') {\n addEventListener('popstate', () => setTimeout(update, 0))\n }\n\n return {\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 ConfigStore as BaseConfigStore,\n ConfigSourceTarget as BaseConfigSourceTarget,\n StorageAdapter,\n} from '../types'\nimport type { ChangeMethod, StateBehavior, QueryConfig } from './adapter'\nimport { persist as base } from '../core'\nimport { nil } from '../nil'\nimport { adapter } from './adapter'\n\nexport type {\n Contract,\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\nexport type { ChangeMethod, StateBehavior, QueryConfig } 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 */\nfunction supports() {\n return typeof history !== 'undefined' && typeof location !== 'undefined'\n}\n\n/**\n * Creates query string adapter\n */\nquery.factory = true as const\nexport function query(config?: QueryConfig): StorageAdapter {\n return supports()\n ? adapter({\n ...config,\n })\n : nil({ keyArea: 'query' })\n}\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `query` adapter\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: query,\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n */\nexport const persist = createPersist()\n"],"names":["timeoutId","scheduled","keyArea","Symbol","buffer","Map","url","params","location","pathname","hash","pushState","erase","history","state","flush","method","undefined","size","URLSearchParams","search","name","value","entries","set","delete","clear","query","config","serialize","deserialize","def","timeout","adapter","key","update","addEventListener","setTimeout","get","clearTimeout","deadline","Date","now","nil","createPersist","defaults","base","factory","persist","assign","replace","replaceState"],"mappings":"iBAqBIA,EACAC,+DAJEC,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,IAc1D,SAASQ,EAAMC,EAAsBF,GAEnC,GADAb,OAAYgB,EACRb,EAAOc,KAAM,CACf,IAAMX,EAAS,IAAIY,gBAAgBX,SAASY,QAC5C,IAAK,IAAOC,EAAMC,KAAUlB,EAAOmB,UACpB,MAATD,EACFf,EAAOiB,IAAIH,EAAO,GAAEC,KAEpBf,EAAOkB,OAAOJ,GAGlBjB,EAAOsB,QACPV,EAAOT,EAAkB,UAAVO,EACjB,CACF,CCJO,SAASa,EAAMC,GACpB,MAR0B,oBAAZf,SAA+C,oBAAbL,SDgB3C,UAAiBQ,OACtBA,EAASL,EAASG,MAClBA,EAAKe,UACLA,EAASC,YACTA,EAAWC,IACXA,EAAM,KAAIC,QACVA,IAEA,IAAMC,EAA0BA,CAC9BC,EACAC,KAEgC,oBAArBC,kBACTA,iBAAiB,YAAY,IAAMC,WAAWF,EAAQ,KAGjD,CACLG,MACE,IACMhB,EADS,IAAIH,gBAAgBX,SAASY,QACvBkB,IAAIJ,GACzB,OAAOZ,EAASQ,EAAcA,EAAYR,GAASA,EAASS,CAC7D,EAEDP,IAAIF,GAGF,GAFAlB,EAAOoB,IAAIU,EAAKL,EAAYA,EAAUP,GAASA,QAE/BL,IAAZe,EAEF,OADAO,aAAavC,GACNe,EAAMC,EAAQF,GAGvB,IAAM0B,EAAWC,KAAKC,MAAQV,QACZf,IAAdhB,GAA2BA,EAAYuC,KACzCD,aAAavC,GACbC,EAAYuC,EACZxC,EAAYqC,WAAWtB,EAAOiB,EAAShB,EAAQF,GAEnD,IAKJ,OADAmB,EAAQ/B,QAAUA,EACX+B,CACT,CClDMA,CAAQ,IACHL,IAELe,EAAAA,IAAI,CAAEzC,QAAS,SACrB,CAMO,SAAS0C,EAAcC,GAC5B,OAAQjB,GACNkB,EAAAA,QAAK,CACHb,QAASN,KACNkB,KACAjB,GAET,CApBAD,EAAMoB,SAAU,EAyBHC,IAAAA,EAAUJ,mDD3CsBrC,GAC3CC,SAASyC,OAAO3C,EAAIC,4BAEwBA,GAC5CC,SAAS0C,QAAQ5C,EAAIC,+EAPmB4C,CAAC5C,EAAQK,IACjDC,QAAQsC,aAAavC,EAAQ,KAAOC,QAAQC,MAAO,GAAIR,EAAIC"}
|
package/query/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Unit, Store, Event, Effect, Subscription } from 'effector'
|
|
|
2
2
|
|
|
3
3
|
interface StorageAdapter {
|
|
4
4
|
<State>(key: string, update: (raw?: any) => any): {
|
|
5
|
-
get(raw?: any, ctx?: any): State | Promise<State>
|
|
5
|
+
get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
|
|
6
6
|
set(value: State, ctx?: any): void
|
|
7
7
|
}
|
|
8
8
|
keyArea?: any
|
|
@@ -62,12 +62,20 @@ interface ConfigJustSourceTarget<State> {
|
|
|
62
62
|
source: Store<State> | Event<State> | Effect<State, any, any>
|
|
63
63
|
target: Store<State> | Event<State> | Effect<State, any, any>
|
|
64
64
|
}
|
|
65
|
+
interface ConfigStore$1<State, Err = Error>
|
|
66
|
+
extends ConfigCommon<State, Err>,
|
|
67
|
+
ConfigJustStore<State> {}
|
|
68
|
+
interface ConfigSourceTarget$1<State, Err = Error>
|
|
69
|
+
extends ConfigCommon<State, Err>,
|
|
70
|
+
ConfigJustSourceTarget<State> {}
|
|
65
71
|
|
|
66
72
|
type ChangeMethod = (params: URLSearchParams | string, erase?: boolean) => void
|
|
67
73
|
type StateBehavior = 'keep' | 'erase'
|
|
68
74
|
interface QueryConfig {
|
|
69
75
|
method?: ChangeMethod
|
|
70
76
|
state?: StateBehavior
|
|
77
|
+
serialize?: (value: any) => string
|
|
78
|
+
deserialize?: (value: string) => any
|
|
71
79
|
timeout?: number
|
|
72
80
|
def?: any
|
|
73
81
|
}
|
|
@@ -83,12 +91,10 @@ interface ConfigPersist extends ConfigPersist$1 {
|
|
|
83
91
|
}
|
|
84
92
|
interface ConfigStore<State, Err = Error>
|
|
85
93
|
extends QueryConfig,
|
|
86
|
-
|
|
87
|
-
ConfigJustStore<State> {}
|
|
94
|
+
ConfigStore$1<State, Err> {}
|
|
88
95
|
interface ConfigSourceTarget<State, Err = Error>
|
|
89
96
|
extends QueryConfig,
|
|
90
|
-
|
|
91
|
-
ConfigJustSourceTarget<State> {}
|
|
97
|
+
ConfigSourceTarget$1<State, Err> {}
|
|
92
98
|
interface Persist {
|
|
93
99
|
<State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription
|
|
94
100
|
<State, Err = Error>(config: ConfigStore<State, Err>): Subscription
|
|
@@ -112,6 +118,7 @@ export {
|
|
|
112
118
|
ConfigPersist,
|
|
113
119
|
ConfigSourceTarget,
|
|
114
120
|
ConfigStore,
|
|
121
|
+
Contract,
|
|
115
122
|
Done,
|
|
116
123
|
Fail,
|
|
117
124
|
Finally,
|
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,o
|
|
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)),c=e=>location.assign(n(e)),u=e=>location.replace(n(e));function d(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)}}function f(e){return"undefined"!=typeof history&&"undefined"!=typeof location?function({method:e=s,state:t,serialize:n,deserialize:l,def:c=null,timeout:u}){var f=(o,s)=>("undefined"!=typeof addEventListener&&addEventListener("popstate",(()=>setTimeout(s,0))),{get(){var e=new URLSearchParams(location.search).get(o);return e?l?l(e):e:c},set(s){if(i.set(o,n?n(s):s),void 0===u)return clearTimeout(a),d(e,t);var l=Date.now()+u;(void 0===r||r>l)&&(clearTimeout(a),r=l,a=setTimeout(d,u,e,t))}});return f.keyArea=o,f}({...e}):t({keyArea:"query"})}function h(t){return a=>e({adapter:f,...t,...a})}f.factory=!0;var p=h();export{h as createPersist,c as locationAssign,u as locationReplace,p as persist,s as pushState,f as query,l as replaceState};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/query/index.js.flow
CHANGED
|
@@ -11,7 +11,7 @@ declare interface StorageAdapter {
|
|
|
11
11
|
key: string,
|
|
12
12
|
update: (raw?: any) => any
|
|
13
13
|
): {
|
|
14
|
-
get(raw?: any, ctx?: any): State | Promise<State
|
|
14
|
+
get(raw?: any, ctx?: any): State | Promise<State | void> | void,
|
|
15
15
|
set(value: State, ctx?: any): void,
|
|
16
16
|
...
|
|
17
17
|
};
|
|
@@ -83,6 +83,16 @@ declare interface ConfigJustSourceTarget<State> {
|
|
|
83
83
|
source: Store<State> | Event<State> | Effect<State, any, any>;
|
|
84
84
|
target: Store<State> | Event<State> | Effect<State, any, any>;
|
|
85
85
|
}
|
|
86
|
+
declare type ConfigStore$1<State, Err = Error> = { ... } & ConfigCommon<
|
|
87
|
+
State,
|
|
88
|
+
Err
|
|
89
|
+
> &
|
|
90
|
+
ConfigJustStore<State>
|
|
91
|
+
declare type ConfigSourceTarget$1<State, Err = Error> = { ... } & ConfigCommon<
|
|
92
|
+
State,
|
|
93
|
+
Err
|
|
94
|
+
> &
|
|
95
|
+
ConfigJustSourceTarget<State>
|
|
86
96
|
declare type ChangeMethod = (
|
|
87
97
|
params: URLSearchParams | string,
|
|
88
98
|
erase?: boolean
|
|
@@ -91,6 +101,8 @@ declare type StateBehavior = 'keep' | 'erase'
|
|
|
91
101
|
declare interface QueryConfig {
|
|
92
102
|
method?: ChangeMethod;
|
|
93
103
|
state?: StateBehavior;
|
|
104
|
+
serialize?: (value: any) => string;
|
|
105
|
+
deserialize?: (value: string) => any;
|
|
94
106
|
timeout?: number;
|
|
95
107
|
def?: any;
|
|
96
108
|
}
|
|
@@ -105,11 +117,9 @@ declare type ConfigPersist = {
|
|
|
105
117
|
...
|
|
106
118
|
} & ConfigPersist$1
|
|
107
119
|
declare type ConfigStore<State, Err = Error> = { ... } & QueryConfig &
|
|
108
|
-
|
|
109
|
-
ConfigJustStore<State>
|
|
120
|
+
ConfigStore$1<State, Err>
|
|
110
121
|
declare type ConfigSourceTarget<State, Err = Error> = { ... } & QueryConfig &
|
|
111
|
-
|
|
112
|
-
ConfigJustSourceTarget<State>
|
|
122
|
+
ConfigSourceTarget$1<State, Err>
|
|
113
123
|
declare interface Persist {
|
|
114
124
|
<State, Err>(config: ConfigSourceTarget<State, Err>): Subscription;
|
|
115
125
|
<State, Err>(config: ConfigStore<State, Err>): Subscription;
|
|
@@ -128,6 +138,7 @@ declare export {
|
|
|
128
138
|
ConfigPersist,
|
|
129
139
|
ConfigSourceTarget,
|
|
130
140
|
ConfigStore,
|
|
141
|
+
Contract,
|
|
131
142
|
Done,
|
|
132
143
|
Fail,
|
|
133
144
|
Finally,
|
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 timeout?: number\n def?: any\n}\n\nconst keyArea = Symbol() // eslint-disable-line symbol-description\n\nconst buffer
|
|
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() // eslint-disable-line symbol-description\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 */\nfunction 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 function 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) => any\n ) => {\n if (typeof addEventListener !== 'undefined') {\n addEventListener('popstate', () => setTimeout(update, 0))\n }\n\n return {\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 ConfigStore as BaseConfigStore,\n ConfigSourceTarget as BaseConfigSourceTarget,\n StorageAdapter,\n} from '../types'\nimport type { ChangeMethod, StateBehavior, QueryConfig } from './adapter'\nimport { persist as base } from '../core'\nimport { nil } from '../nil'\nimport { adapter } from './adapter'\n\nexport type {\n Contract,\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\nexport type { ChangeMethod, StateBehavior, QueryConfig } 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 */\nfunction supports() {\n return typeof history !== 'undefined' && typeof location !== 'undefined'\n}\n\n/**\n * Creates query string adapter\n */\nquery.factory = true as const\nexport function query(config?: QueryConfig): StorageAdapter {\n return supports()\n ? adapter({\n ...config,\n })\n : nil({ keyArea: 'query' })\n}\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `query` adapter\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: query,\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n */\nexport const persist = 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","serialize","deserialize","def","timeout","adapter","key","update","addEventListener","setTimeout","get","clearTimeout","deadline","Date","now","nil","createPersist","defaults","base","factory","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,IAKvB,SAASa,EAAMC,EAAsBP,GAEnC,GADAb,OAAYqB,EACRlB,EAAOmB,KAAM,CACf,IAAMhB,EAAS,IAAIiB,gBAAgBhB,SAASiB,QAC5C,IAAK,IAAOC,EAAMC,KAAUvB,EAAOwB,UACpB,MAATD,EACFpB,EAAOsB,IAAIH,EAAO,GAAEC,KAEpBpB,EAAOuB,OAAOJ,GAGlBtB,EAAO2B,QACPV,EAAOd,EAAkB,UAAVO,EACjB,CACF,CCJO,SAASkB,EAAMC,GACpB,MAR0B,oBAAZpB,SAA+C,oBAAbL,SDgB3C,UAAiBa,OACtBA,EAASV,EAASG,MAClBA,EAAKoB,UACLA,EAASC,YACTA,EAAWC,IACXA,EAAM,KAAIC,QACVA,IAEA,IAAMC,EAA0BA,CAC9BC,EACAC,KAEgC,oBAArBC,kBACTA,iBAAiB,YAAY,IAAMC,WAAWF,EAAQ,KAGjD,CACLG,MACE,IACMhB,EADS,IAAIH,gBAAgBhB,SAASiB,QACvBkB,IAAIJ,GACzB,OAAOZ,EAASQ,EAAcA,EAAYR,GAASA,EAASS,CAC7D,EAEDP,IAAIF,GAGF,GAFAvB,EAAOyB,IAAIU,EAAKL,EAAYA,EAAUP,GAASA,QAE/BL,IAAZe,EAEF,OADAO,aAAa5C,GACNoB,EAAMC,EAAQP,GAGvB,IAAM+B,EAAWC,KAAKC,MAAQV,QACZf,IAAdrB,GAA2BA,EAAY4C,KACzCD,aAAa5C,GACbC,EAAY4C,EACZ7C,EAAY0C,WAAWtB,EAAOiB,EAAShB,EAAQP,GAEnD,IAKJ,OADAwB,EAAQpC,QAAUA,EACXoC,CACT,CClDMA,CAAQ,IACHL,IAELe,EAAI,CAAE9C,QAAS,SACrB,CAMO,SAAS+C,EAAcC,GAC5B,OAAQjB,GACNkB,EAAK,CACHb,QAASN,KACNkB,KACAjB,GAET,CApBAD,EAAMoB,SAAU,EAyBHC,IAAAA,EAAUJ"}
|
package/rn/async/index.cjs.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Unit, Store, Event, Effect, Subscription } from 'effector'
|
|
|
2
2
|
|
|
3
3
|
interface StorageAdapter {
|
|
4
4
|
<State>(key: string, update: (raw?: any) => any): {
|
|
5
|
-
get(raw?: any, ctx?: any): State | Promise<State>
|
|
5
|
+
get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
|
|
6
6
|
set(value: State, ctx?: any): void
|
|
7
7
|
}
|
|
8
8
|
keyArea?: any
|
|
@@ -62,6 +62,12 @@ interface ConfigJustSourceTarget<State> {
|
|
|
62
62
|
source: Store<State> | Event<State> | Effect<State, any, any>
|
|
63
63
|
target: Store<State> | Event<State> | Effect<State, any, any>
|
|
64
64
|
}
|
|
65
|
+
interface ConfigStore$1<State, Err = Error>
|
|
66
|
+
extends ConfigCommon<State, Err>,
|
|
67
|
+
ConfigJustStore<State> {}
|
|
68
|
+
interface ConfigSourceTarget$1<State, Err = Error>
|
|
69
|
+
extends ConfigCommon<State, Err>,
|
|
70
|
+
ConfigJustSourceTarget<State> {}
|
|
65
71
|
|
|
66
72
|
interface ConfigPersist extends ConfigPersist$1 {}
|
|
67
73
|
interface AsyncStorageConfig {
|
|
@@ -70,12 +76,10 @@ interface AsyncStorageConfig {
|
|
|
70
76
|
}
|
|
71
77
|
interface ConfigStore<State, Err = Error>
|
|
72
78
|
extends AsyncStorageConfig,
|
|
73
|
-
|
|
74
|
-
ConfigJustStore<State> {}
|
|
79
|
+
ConfigStore$1<State, Err> {}
|
|
75
80
|
interface ConfigSourceTarget<State, Err = Error>
|
|
76
81
|
extends AsyncStorageConfig,
|
|
77
|
-
|
|
78
|
-
ConfigJustSourceTarget<State> {}
|
|
82
|
+
ConfigSourceTarget$1<State, Err> {}
|
|
79
83
|
interface Persist {
|
|
80
84
|
<State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription
|
|
81
85
|
<State, Err = Error>(config: ConfigStore<State, Err>): Subscription
|
|
@@ -87,10 +91,14 @@ declare namespace async {
|
|
|
87
91
|
/**
|
|
88
92
|
* Creates custom partially applied `persist`
|
|
89
93
|
* with predefined `AsyncStorage` adapter
|
|
94
|
+
*
|
|
95
|
+
* @deprecated use @effector-storage/react-native-async-storage instead
|
|
90
96
|
*/
|
|
91
97
|
declare function createPersist(defaults?: ConfigPersist): Persist
|
|
92
98
|
/**
|
|
93
99
|
* Default partially applied `persist`
|
|
100
|
+
*
|
|
101
|
+
* @deprecated use @effector-storage/react-native-async-storage instead
|
|
94
102
|
*/
|
|
95
103
|
declare const persist: Persist
|
|
96
104
|
|
|
@@ -99,6 +107,7 @@ export {
|
|
|
99
107
|
ConfigPersist,
|
|
100
108
|
ConfigSourceTarget,
|
|
101
109
|
ConfigStore,
|
|
110
|
+
Contract,
|
|
102
111
|
Done,
|
|
103
112
|
Fail,
|
|
104
113
|
Finally,
|
package/rn/async/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/rn/async/index.ts"],"sourcesContent":["import type { Subscription } from 'effector'\nimport type {\n ConfigPersist as BaseConfigPersist,\n
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/rn/async/index.ts"],"sourcesContent":["import type { Subscription } from 'effector'\nimport type {\n ConfigPersist as BaseConfigPersist,\n ConfigStore as BaseConfigStore,\n ConfigSourceTarget as BaseConfigSourceTarget,\n StorageAdapter,\n} from '../../types'\nimport { persist as base } from '../../core'\nimport { asyncStorage } from '../../async-storage'\nimport AsyncStorage from '@react-native-async-storage/async-storage'\n\nexport type {\n Contract,\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../../types'\n\nexport interface ConfigPersist extends BaseConfigPersist {}\n\nexport interface AsyncStorageConfig {\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n}\n\nexport interface ConfigStore<State, Err = Error>\n extends AsyncStorageConfig,\n BaseConfigStore<State, Err> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends AsyncStorageConfig,\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 * Creates `AsyncStorage` adapter\n *\n * @deprecated use @effector-storage/react-native-async-storage instead\n */\nasync.factory = true as const\nexport function async(config?: AsyncStorageConfig): StorageAdapter {\n return asyncStorage({\n storage: () => AsyncStorage,\n ...config,\n })\n}\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `AsyncStorage` adapter\n *\n * @deprecated use @effector-storage/react-native-async-storage instead\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: async,\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n *\n * @deprecated use @effector-storage/react-native-async-storage instead\n */\nexport const persist = createPersist()\n"],"names":["async","config","asyncStorage","storage","AsyncStorage","createPersist","defaults","base","adapter","factory","persist"],"mappings":"qJA8CO,SAASA,EAAMC,GACpB,OAAOC,eAAa,CAClBC,QAASA,IAAMC,KACZH,GAEP,CAQO,SAASI,EAAcC,GAC5B,OAAQL,GACNM,EAAAA,QAAK,CACHC,QAASR,KACNM,KACAL,GAET,CArBAD,EAAMS,SAAU,EA4BHC,IAAAA,EAAUL"}
|
package/rn/async/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Unit, Store, Event, Effect, Subscription } from 'effector'
|
|
|
2
2
|
|
|
3
3
|
interface StorageAdapter {
|
|
4
4
|
<State>(key: string, update: (raw?: any) => any): {
|
|
5
|
-
get(raw?: any, ctx?: any): State | Promise<State>
|
|
5
|
+
get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
|
|
6
6
|
set(value: State, ctx?: any): void
|
|
7
7
|
}
|
|
8
8
|
keyArea?: any
|
|
@@ -62,6 +62,12 @@ interface ConfigJustSourceTarget<State> {
|
|
|
62
62
|
source: Store<State> | Event<State> | Effect<State, any, any>
|
|
63
63
|
target: Store<State> | Event<State> | Effect<State, any, any>
|
|
64
64
|
}
|
|
65
|
+
interface ConfigStore$1<State, Err = Error>
|
|
66
|
+
extends ConfigCommon<State, Err>,
|
|
67
|
+
ConfigJustStore<State> {}
|
|
68
|
+
interface ConfigSourceTarget$1<State, Err = Error>
|
|
69
|
+
extends ConfigCommon<State, Err>,
|
|
70
|
+
ConfigJustSourceTarget<State> {}
|
|
65
71
|
|
|
66
72
|
interface ConfigPersist extends ConfigPersist$1 {}
|
|
67
73
|
interface AsyncStorageConfig {
|
|
@@ -70,12 +76,10 @@ interface AsyncStorageConfig {
|
|
|
70
76
|
}
|
|
71
77
|
interface ConfigStore<State, Err = Error>
|
|
72
78
|
extends AsyncStorageConfig,
|
|
73
|
-
|
|
74
|
-
ConfigJustStore<State> {}
|
|
79
|
+
ConfigStore$1<State, Err> {}
|
|
75
80
|
interface ConfigSourceTarget<State, Err = Error>
|
|
76
81
|
extends AsyncStorageConfig,
|
|
77
|
-
|
|
78
|
-
ConfigJustSourceTarget<State> {}
|
|
82
|
+
ConfigSourceTarget$1<State, Err> {}
|
|
79
83
|
interface Persist {
|
|
80
84
|
<State, Err = Error>(config: ConfigSourceTarget<State, Err>): Subscription
|
|
81
85
|
<State, Err = Error>(config: ConfigStore<State, Err>): Subscription
|
|
@@ -87,10 +91,14 @@ declare namespace async {
|
|
|
87
91
|
/**
|
|
88
92
|
* Creates custom partially applied `persist`
|
|
89
93
|
* with predefined `AsyncStorage` adapter
|
|
94
|
+
*
|
|
95
|
+
* @deprecated use @effector-storage/react-native-async-storage instead
|
|
90
96
|
*/
|
|
91
97
|
declare function createPersist(defaults?: ConfigPersist): Persist
|
|
92
98
|
/**
|
|
93
99
|
* Default partially applied `persist`
|
|
100
|
+
*
|
|
101
|
+
* @deprecated use @effector-storage/react-native-async-storage instead
|
|
94
102
|
*/
|
|
95
103
|
declare const persist: Persist
|
|
96
104
|
|
|
@@ -99,6 +107,7 @@ export {
|
|
|
99
107
|
ConfigPersist,
|
|
100
108
|
ConfigSourceTarget,
|
|
101
109
|
ConfigStore,
|
|
110
|
+
Contract,
|
|
102
111
|
Done,
|
|
103
112
|
Fail,
|
|
104
113
|
Finally,
|