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.
Files changed (77) hide show
  1. package/README.md +40 -21
  2. package/async-storage/index.cjs.d.ts +1 -1
  3. package/async-storage/index.d.ts +1 -1
  4. package/async-storage/index.js.flow +1 -1
  5. package/broadcast/index.cjs +2 -0
  6. package/broadcast/index.cjs.d.ts +116 -0
  7. package/broadcast/index.cjs.map +1 -0
  8. package/broadcast/index.d.ts +116 -0
  9. package/broadcast/index.js +2 -0
  10. package/broadcast/index.js.flow +134 -0
  11. package/broadcast/index.js.map +1 -0
  12. package/broadcast/package.json +8 -0
  13. package/core/index.cjs +1 -1
  14. package/core/index.cjs.d.ts +1 -1
  15. package/core/index.cjs.map +1 -1
  16. package/core/index.d.ts +1 -1
  17. package/core/index.js +1 -1
  18. package/core/index.js.flow +1 -1
  19. package/core/index.js.map +1 -1
  20. package/index.cjs +1 -1
  21. package/index.cjs.d.ts +3 -1
  22. package/index.cjs.map +1 -1
  23. package/index.d.ts +3 -1
  24. package/index.js +1 -1
  25. package/index.js.flow +3 -1
  26. package/index.js.map +1 -1
  27. package/local/index.cjs.d.ts +10 -5
  28. package/local/index.cjs.map +1 -1
  29. package/local/index.d.ts +10 -5
  30. package/local/index.js.flow +14 -5
  31. package/local/index.js.map +1 -1
  32. package/log/index.cjs.d.ts +1 -1
  33. package/log/index.d.ts +1 -1
  34. package/log/index.js.flow +1 -1
  35. package/memory/index.cjs.d.ts +12 -7
  36. package/memory/index.cjs.map +1 -1
  37. package/memory/index.d.ts +12 -7
  38. package/memory/index.js.flow +19 -10
  39. package/memory/index.js.map +1 -1
  40. package/nil/index.cjs.d.ts +1 -1
  41. package/nil/index.d.ts +1 -1
  42. package/nil/index.js.flow +1 -1
  43. package/package.json +33 -14
  44. package/query/index.cjs +1 -1
  45. package/query/index.cjs.d.ts +12 -5
  46. package/query/index.cjs.map +1 -1
  47. package/query/index.d.ts +12 -5
  48. package/query/index.js +1 -1
  49. package/query/index.js.flow +16 -5
  50. package/query/index.js.map +1 -1
  51. package/rn/async/index.cjs.d.ts +14 -5
  52. package/rn/async/index.cjs.map +1 -1
  53. package/rn/async/index.d.ts +14 -5
  54. package/rn/async/index.js.flow +14 -5
  55. package/rn/async/index.js.map +1 -1
  56. package/rn/encrypted/index.cjs.d.ts +19 -5
  57. package/rn/encrypted/index.cjs.map +1 -1
  58. package/rn/encrypted/index.d.ts +19 -5
  59. package/rn/encrypted/index.js.flow +19 -5
  60. package/rn/encrypted/index.js.map +1 -1
  61. package/session/index.cjs.d.ts +10 -5
  62. package/session/index.cjs.map +1 -1
  63. package/session/index.d.ts +10 -5
  64. package/session/index.js.flow +14 -5
  65. package/session/index.js.map +1 -1
  66. package/storage/index.cjs.d.ts +1 -1
  67. package/storage/index.cjs.map +1 -1
  68. package/storage/index.d.ts +1 -1
  69. package/storage/index.js.flow +1 -1
  70. package/storage/index.js.map +1 -1
  71. package/tools/index.cjs +1 -1
  72. package/tools/index.cjs.d.ts +1 -1
  73. package/tools/index.cjs.map +1 -1
  74. package/tools/index.d.ts +1 -1
  75. package/tools/index.js +1 -1
  76. package/tools/index.js.flow +1 -1
  77. package/tools/index.js.map +1 -1
@@ -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 ConfigStore<State, Err = Error> = { ... } & ConfigCommon<
106
+ declare type ConfigPersist = { ... } & ConfigPersist$1
107
+ declare type ConfigStore<State, Err = Error> = { ... } & ConfigStore$1<
97
108
  State,
98
109
  Err
99
- > &
100
- ConfigJustStore<State>
101
- declare type ConfigSourceTarget<State, Err = Error> = { ... } & ConfigCommon<
102
- State,
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,
@@ -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 ConfigCommon,\n ConfigJustStore,\n ConfigJustSourceTarget,\n} from '../types'\nimport { persist as base } from '../core'\nimport { adapter } from './adapter'\n\nexport type {\n ConfigPersist,\n Done,\n Fail,\n Finally,\n StorageAdapter,\n StorageAdapterFactory,\n} from '../types'\nexport type { MemoryConfig } from './adapter'\n\nexport interface ConfigStore<State, Err = Error>\n extends ConfigCommon<State, Err>,\n ConfigJustStore<State> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends ConfigCommon<State, Err>,\n ConfigJustSourceTarget<State> {}\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,CCsBO,SAASO,EAAcC,GAC5B,OAAQC,GACNC,EAAK,CACHV,QAASA,OACNQ,KACAC,GAET,CDtCAT,EAAQW,SAAU,EC2CLC,IAAAA,EAAUL"}
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"}
@@ -1,6 +1,6 @@
1
1
  interface StorageAdapter {
2
2
  <State>(key: string, update: (raw?: any) => any): {
3
- get(raw?: any, ctx?: any): State | Promise<State>
3
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
4
4
  set(value: State, ctx?: any): void
5
5
  }
6
6
  keyArea?: any
package/nil/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  interface StorageAdapter {
2
2
  <State>(key: string, update: (raw?: any) => any): {
3
- get(raw?: any, ctx?: any): State | Promise<State>
3
+ get(raw?: any, ctx?: any): State | Promise<State | undefined> | undefined
4
4
  set(value: State, ctx?: any): void
5
5
  }
6
6
  keyArea?: any
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.0.0",
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,n=e=>location.pathname+(e+""?"?"+e:"")+(location.hash&&"#"!==location.hash?location.hash:""),s=(e,t)=>history.pushState(t?null:history.state,"",n(e));function c(e,r){if(t=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"===r)}}function l(r){return"undefined"!=typeof history&&"undefined"!=typeof location?function({method:r=s,state:a,def:n=null,timeout:l}){var u=(o,s)=>("undefined"!=typeof addEventListener&&addEventListener("popstate",(()=>setTimeout(s,0))),{get:()=>new URLSearchParams(location.search).get(o)||n,set(n){if(i.set(o,n),void 0===l)return clearTimeout(e),c(r,a);var s=Date.now()+l;(void 0===t||t>s)&&(clearTimeout(e),t=s,e=setTimeout(c,l,r,a))}});return u.keyArea=o,u}({...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(n(e)),exports.locationReplace=e=>location.replace(n(e)),exports.persist=p,exports.pushState=s,exports.query=l,exports.replaceState=(e,t)=>history.replaceState(t?null:history.state,"",n(e));
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
@@ -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
- ConfigCommon<State, Err>,
87
- ConfigJustStore<State> {}
94
+ ConfigStore$1<State, Err> {}
88
95
  interface ConfigSourceTarget<State, Err = Error>
89
96
  extends QueryConfig,
90
- ConfigCommon<State, Err>,
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,
@@ -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: Map<string, any> = new Map()\nlet timeoutId: number | 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 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 return params.get(key) || def\n },\n\n set(value: State) {\n buffer.set(key, 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 ConfigCommon,\n ConfigJustStore,\n ConfigJustSourceTarget,\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 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 ConfigCommon<State, Err>,\n ConfigJustStore<State> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends QueryConfig,\n ConfigCommon<State, Err>,\n ConfigJustSourceTarget<State> {}\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","def","timeout","adapter","key","update","addEventListener","setTimeout","get","clearTimeout","deadline","Date","now","nil","createPersist","defaults","base","factory","persist","assign","replace","replaceState"],"mappings":"iBAmBIA,EACAC,+DAJEC,EAAUC,SAEVC,EAA2B,IAAIC,IAQ/BC,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,CCAO,SAASa,EAAMC,GACpB,MAR0B,oBAAZf,SAA+C,oBAAbL,SDY3C,UAAiBQ,OACtBA,EAASL,EAASG,MAClBA,EAAKe,IACLA,EAAM,KAAIC,QACVA,IAEA,IAAMC,EAA0BA,CAC9BC,EACAC,KAEgC,oBAArBC,kBACTA,iBAAiB,YAAY,IAAMC,WAAWF,EAAQ,KAGjD,CACLG,IAAGA,IACc,IAAIjB,gBAAgBX,SAASY,QAC9BgB,IAAIJ,IAAQH,EAG5BL,IAAIF,GAGF,GAFAlB,EAAOoB,IAAIQ,EAAKV,QAEAL,IAAZa,EAEF,OADAO,aAAarC,GACNe,EAAMC,EAAQF,GAGvB,IAAMwB,EAAWC,KAAKC,MAAQV,QACZb,IAAdhB,GAA2BA,EAAYqC,KACzCD,aAAarC,GACbC,EAAYqC,EACZtC,EAAYmC,WAAWpB,EAAOe,EAASd,EAAQF,GAEnD,IAKJ,OADAiB,EAAQ7B,QAAUA,EACX6B,CACT,CC3CMA,CAAQ,IACHH,IAELa,EAAAA,IAAI,CAAEvC,QAAS,SACrB,CAMO,SAASwC,EAAcC,GAC5B,OAAQf,GACNgB,EAAAA,QAAK,CACHb,QAASJ,KACNgB,KACAf,GAET,CApBAD,EAAMkB,SAAU,EAyBHC,IAAAA,EAAUJ,mDD/CsBnC,GAC3CC,SAASuC,OAAOzC,EAAIC,4BAEwBA,GAC5CC,SAASwC,QAAQ1C,EAAIC,+EAPmB0C,CAAC1C,EAAQK,IACjDC,QAAQoC,aAAarC,EAAQ,KAAOC,QAAQC,MAAO,GAAIR,EAAIC"}
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
- ConfigCommon<State, Err>,
87
- ConfigJustStore<State> {}
94
+ ConfigStore$1<State, Err> {}
88
95
  interface ConfigSourceTarget<State, Err = Error>
89
96
  extends QueryConfig,
90
- ConfigCommon<State, Err>,
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,r=Symbol(),n=new Map,i=e=>location.pathname+(e+""?"?"+e:"")+(location.hash&&"#"!==location.hash?location.hash:""),s=(e,t)=>history.pushState(t?null:history.state,"",i(e)),l=(e,t)=>history.replaceState(t?null:history.state,"",i(e)),c=e=>location.assign(i(e)),u=e=>location.replace(i(e));function d(e,t){if(o=void 0,n.size){var a=new URLSearchParams(location.search);for(var[r,i]of n.entries())null!=i?a.set(r,`${i}`):a.delete(r);n.clear(),e(a,"erase"===t)}}function f(e){return"undefined"!=typeof history&&"undefined"!=typeof location?function({method:e=s,state:t,def:i=null,timeout:l}){var c=(r,s)=>("undefined"!=typeof addEventListener&&addEventListener("popstate",(()=>setTimeout(s,0))),{get:()=>new URLSearchParams(location.search).get(r)||i,set(i){if(n.set(r,i),void 0===l)return clearTimeout(a),d(e,t);var s=Date.now()+l;(void 0===o||o>s)&&(clearTimeout(a),o=s,a=setTimeout(d,l,e,t))}});return c.keyArea=r,c}({...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};
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
@@ -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
- ConfigCommon<State, Err> &
109
- ConfigJustStore<State>
120
+ ConfigStore$1<State, Err>
110
121
  declare type ConfigSourceTarget<State, Err = Error> = { ... } & QueryConfig &
111
- ConfigCommon<State, Err> &
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,
@@ -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: Map<string, any> = new Map()\nlet timeoutId: number | 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 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 return params.get(key) || def\n },\n\n set(value: State) {\n buffer.set(key, 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 ConfigCommon,\n ConfigJustStore,\n ConfigJustSourceTarget,\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 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 ConfigCommon<State, Err>,\n ConfigJustStore<State> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends QueryConfig,\n ConfigCommon<State, Err>,\n ConfigJustSourceTarget<State> {}\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","def","timeout","adapter","key","update","addEventListener","setTimeout","get","clearTimeout","deadline","Date","now","nil","createPersist","defaults","base","factory","persist"],"mappings":"iFAgBA,IAGIA,EACAC,EAJEC,EAAUC,SAEVC,EAA2B,IAAIC,IAQ/BC,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,CCAO,SAASkB,EAAMC,GACpB,MAR0B,oBAAZpB,SAA+C,oBAAbL,SDY3C,UAAiBa,OACtBA,EAASV,EAASG,MAClBA,EAAKoB,IACLA,EAAM,KAAIC,QACVA,IAEA,IAAMC,EAA0BA,CAC9BC,EACAC,KAEgC,oBAArBC,kBACTA,iBAAiB,YAAY,IAAMC,WAAWF,EAAQ,KAGjD,CACLG,IAAGA,IACc,IAAIjB,gBAAgBhB,SAASiB,QAC9BgB,IAAIJ,IAAQH,EAG5BL,IAAIF,GAGF,GAFAvB,EAAOyB,IAAIQ,EAAKV,QAEAL,IAAZa,EAEF,OADAO,aAAa1C,GACNoB,EAAMC,EAAQP,GAGvB,IAAM6B,EAAWC,KAAKC,MAAQV,QACZb,IAAdrB,GAA2BA,EAAY0C,KACzCD,aAAa1C,GACbC,EAAY0C,EACZ3C,EAAYwC,WAAWpB,EAAOe,EAASd,EAAQP,GAEnD,IAKJ,OADAsB,EAAQlC,QAAUA,EACXkC,CACT,CC3CMA,CAAQ,IACHH,IAELa,EAAI,CAAE5C,QAAS,SACrB,CAMO,SAAS6C,EAAcC,GAC5B,OAAQf,GACNgB,EAAK,CACHb,QAASJ,KACNgB,KACAf,GAET,CApBAD,EAAMkB,SAAU,EAyBHC,IAAAA,EAAUJ"}
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"}
@@ -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
- ConfigCommon<State, Err>,
74
- ConfigJustStore<State> {}
79
+ ConfigStore$1<State, Err> {}
75
80
  interface ConfigSourceTarget<State, Err = Error>
76
81
  extends AsyncStorageConfig,
77
- ConfigCommon<State, Err>,
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,
@@ -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 ConfigCommon,\n ConfigJustStore,\n ConfigJustSourceTarget,\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 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 ConfigCommon<State, Err>,\n ConfigJustStore<State> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends AsyncStorageConfig,\n ConfigCommon<State, Err>,\n ConfigJustSourceTarget<State> {}\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 */\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 */\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 */\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,CAMO,SAASI,EAAcC,GAC5B,OAAQL,GACNM,EAAAA,QAAK,CACHC,QAASR,KACNM,KACAL,GAET,CAnBAD,EAAMS,SAAU,EAwBHC,IAAAA,EAAUL"}
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"}
@@ -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
- ConfigCommon<State, Err>,
74
- ConfigJustStore<State> {}
79
+ ConfigStore$1<State, Err> {}
75
80
  interface ConfigSourceTarget<State, Err = Error>
76
81
  extends AsyncStorageConfig,
77
- ConfigCommon<State, Err>,
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,