effector-storage 6.0.1 → 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 +20 -10
- 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.map +1 -1
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/index.cjs +1 -1
- package/index.cjs.d.ts +1 -0
- package/index.cjs.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/index.js.flow +1 -0
- package/index.js.map +1 -1
- package/package.json +33 -14
- package/query/index.cjs +1 -1
- package/query/index.cjs.d.ts +2 -0
- package/query/index.cjs.map +1 -1
- package/query/index.d.ts +2 -0
- package/query/index.js +1 -1
- package/query/index.js.flow +2 -0
- package/query/index.js.map +1 -1
- package/rn/async/index.cjs.d.ts +4 -0
- package/rn/async/index.cjs.map +1 -1
- package/rn/async/index.d.ts +4 -0
- package/rn/async/index.js.map +1 -1
- package/rn/encrypted/index.cjs.d.ts +4 -0
- package/rn/encrypted/index.cjs.map +1 -1
- package/rn/encrypted/index.d.ts +4 -0
- package/rn/encrypted/index.js.map +1 -1
- package/storage/index.cjs.map +1 -1
- package/storage/index.js.map +1 -1
- package/tools/index.cjs +1 -1
- package/tools/index.cjs.map +1 -1
- package/tools/index.js +1 -1
- package/tools/index.js.map +1 -1
package/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/core/area.ts","../../src/core/index.ts"],"sourcesContent":["import type { Store } from 'effector'\nimport { createStore } from 'effector'\n\n/**\n * Keys areas / namespaces cache\n */\nconst areas = new Map<any, Map<string, Store<any>>>()\n\n/**\n * Get store, responsible for the key in key area / namespace\n */\nexport function getAreaStorage<State>(keyArea: any, key: string): Store<State> {\n let area = areas.get(keyArea)\n if (area === undefined) {\n area = new Map()\n areas.set(keyArea, area)\n }\n\n let store = area.get(key)\n if (store !== undefined) {\n return store\n }\n\n store = createStore(null, { serialize: 'ignore' })\n area.set(key, store)\n\n return store\n}\n","import type { Effect, Subscription } from 'effector'\nimport type {\n ConfigAdapter,\n ConfigAdapterFactory,\n ConfigPersist,\n ConfigSourceTarget,\n ConfigStore,\n Contract,\n Done,\n Fail,\n Finally,\n} from '../types'\nimport {\n attach,\n clearNode,\n createEvent,\n createEffect,\n createNode,\n createStore,\n forward,\n guard,\n is,\n merge,\n sample,\n scopeBind,\n withRegion,\n} from 'effector'\nimport { getAreaStorage } from './area'\n\n// helper function to swap two function arguments\n// end extract current context from ref-box\nconst contextual =\n <T, C, R>(fn: (value: T, ctx?: C) => R) =>\n (ctx: { ref?: C }, value: T) =>\n fn(value, ctx.ref)\n\n// helper function to validate data with contract\nconst contracted =\n <T>(contract?: Contract<T>) =>\n (raw: unknown) =>\n !contract || // no contract -> data is valid\n raw === undefined || // `undefined` is always valid\n ('isData' in contract ? contract.isData(raw) : contract(raw))\n ? (raw as T)\n : (() => {\n throw 'getErrorMessages' in contract\n ? contract.getErrorMessages(raw)\n : undefined\n })()\n\n// helper function for safe bind effects to scope\n// since version 22.4.0 there is `safe` option in `scopeBind`,\n// but as long as effector-storage supports 22.0 this helper is required\nconst safeBind = (fx: Effect<any, any, any>) => {\n try {\n // @ts-expect-error due to old typings in import\n return scopeBind(fx, { safe: true })\n } catch (e) {\n return fx\n }\n}\n\n/**\n * Default sink for unhandled errors\n */\nconst sink = createEvent<Fail<any>>()\nsink.watch((payload) => console.error(payload.error))\n\n/**\n * Main `persist` function\n */\nexport function persist<State, Err = Error>(\n config: Partial<\n (ConfigAdapter | ConfigAdapterFactory<any>) &\n ConfigPersist &\n ConfigStore<State, Err> &\n ConfigSourceTarget<State, Err>\n >\n): Subscription {\n const {\n adapter: adapterOrFactory,\n store,\n source = store,\n target = store,\n clock = source,\n done,\n fail = sink,\n finally: anyway,\n pickup,\n context,\n key: keyName,\n keyPrefix = '',\n contract,\n } = config\n\n if (!adapterOrFactory) {\n throw Error('Adapter is not defined')\n }\n if (!source) {\n throw Error('Store or source is not defined')\n }\n if (!target) {\n throw Error('Target is not defined')\n }\n if (!keyName && source.shortName === (source as any).id) {\n throw Error('Key or name is not defined')\n }\n if (source === target && !is.store(source)) {\n throw Error('Source must be different from target')\n }\n\n // get default value from store, if given\n // this is used in adapter factory\n if ((config as any).def === undefined && is.store(source)) {\n ;(config as any).def = source.defaultState\n }\n\n const adapter =\n 'factory' in adapterOrFactory ? adapterOrFactory(config) : adapterOrFactory\n\n const key = keyName || source.shortName\n const storage = getAreaStorage<State>(\n adapter.keyArea || adapter,\n keyPrefix + key\n )\n const region = createNode()\n const desist = () => clearNode(region)\n\n const op =\n (operation: 'get' | 'set' | 'validate') =>\n ({ status = 'fail', params, result, error }: any): any =>\n status === 'done'\n ? {\n status,\n key,\n keyPrefix,\n operation,\n value: operation === 'get' ? result : params,\n }\n : {\n status,\n key,\n keyPrefix,\n operation,\n value: params,\n error,\n }\n\n // create all auxiliary units and nodes within the region,\n // to be able to remove them all at once on unsubscription\n withRegion(region, () => {\n const ctx = createStore<{ ref: any }>(\n { ref: undefined },\n { serialize: 'ignore' }\n )\n\n const value = adapter<State>(keyPrefix + key, (x) => bindedGet(x))\n\n const getFx = attach({\n source: ctx,\n effect: contextual(value.get),\n }) as any as Effect<void, State, Err>\n\n const setFx = attach({\n source: ctx,\n effect: contextual(value.set),\n }) as any as Effect<State, void, Err>\n\n const validateFx = createEffect<unknown, State>(contracted(contract))\n\n const localAnyway = createEvent<Finally<State, Err>>()\n const localDone = localAnyway.filterMap<Done<State>>(\n ({ status, key, keyPrefix, operation, value }) =>\n status === 'done' ? { key, keyPrefix, operation, value } : undefined\n )\n const localFail = localAnyway.filterMap<Fail<Err>>(\n ({ status, key, keyPrefix, operation, error, value }: any) =>\n status === 'fail'\n ? { key, keyPrefix, operation, error, value }\n : undefined\n )\n\n const trigger = createEvent<State>()\n\n let bindedGet: (raw?: any) => any = getFx\n ctx.updates.watch(() => {\n bindedGet = safeBind(getFx)\n })\n\n sample({\n source,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n clock: clock!, // `clock` is always defined, as long as `source` is defined\n target: trigger,\n })\n\n guard({\n source: sample(storage, trigger, (current, proposed) => [\n proposed,\n current,\n ]),\n filter: ([proposed, current]) => proposed !== current,\n target: setFx.prepend(([proposed]: State[]) => proposed),\n })\n forward({ from: [getFx.doneData, setFx], to: storage })\n sample({\n source: merge([getFx.doneData, storage]),\n target: validateFx as any,\n })\n forward({ from: validateFx.doneData, to: target })\n\n forward({\n from: [\n getFx.finally.map(op('get')),\n setFx.finally.map(op('set')),\n validateFx.fail.map(op('validate')),\n ],\n to: localAnyway,\n })\n\n forward({ from: localFail, to: fail })\n if (done) forward({ from: localDone, to: done })\n if (anyway) forward({ from: localAnyway, to: anyway })\n\n if (context) {\n ctx.on(context, ({ ref }, payload) => ({\n ref: payload === undefined ? ref : payload,\n }))\n }\n\n if (pickup) {\n // pick up value from storage ONLY on `pickup` update\n forward({ from: pickup, to: getFx.prepend(() => undefined) })\n ctx.on(pickup, ({ ref }, payload) => ({\n ref: payload === undefined ? ref : payload,\n }))\n } else {\n // kick getter to pick up initial value from storage\n getFx()\n }\n })\n\n return (desist.unsubscribe = desist)\n}\n"],"names":["areas","Map","contextual","fn","ctx","value","ref","sink","createEvent","persist","config","adapter","adapterOrFactory","store","source","target","clock","done","fail","finally","anyway","pickup","context","key","keyName","keyPrefix","contract","Error","shortName","id","is","undefined","def","defaultState","storage","keyArea","area","get","set","createStore","serialize","getAreaStorage","region","createNode","desist","clearNode","op","operation","status","params","result","error","withRegion","x","bindedGet","getFx","attach","effect","setFx","validateFx","createEffect","raw","isData","getErrorMessages","contracted","localAnyway","localDone","filterMap","localFail","trigger","updates","watch","fx","scopeBind","safe","e","safeBind","sample","guard","current","proposed","filter","prepend","forward","from","doneData","to","merge","map","on","payload","unsubscribe","console"],"mappings":"2MAMA,IAAMA,EAAQ,IAAIC,ICyBZC,EACMC,GACV,CAACC,EAAkBC,IACjBF,EAAGE,EAAOD,EAAIE,KA+BZC,EAAOC,IAMN,SAASC,EACdC,GAOA,IACEC,QAASC,EAAgBC,MACzBA,EAAKC,OACLA,EAASD,EAAKE,OACdA,EAASF,EAAKG,MACdA,EAAQF,EAAMG,KACdA,EAAIC,KACJA,EAAOX,EACPY,QAASC,EAAMC,OACfA,EAAMC,QACNA,EACAC,IAAKC,EAAOC,UACZA,EAAY,GAAEC,SACdA,GACEhB,EAEJ,IAAKE,EACH,MAAMe,MAAM,0BAEd,IAAKb,EACH,MAAMa,MAAM,kCAEd,IAAKZ,EACH,MAAMY,MAAM,yBAEd,IAAKH,GAAWV,EAAOc,YAAed,EAAee,GACnD,MAAMF,MAAM,8BAEd,GAAIb,IAAWC,IAAWe,EAAGjB,MAAMC,GACjC,MAAMa,MAAM,6CAKcI,IAAvBrB,EAAesB,KAAqBF,EAAGjB,MAAMC,KAC9CJ,EAAesB,IAAMlB,EAAOmB,cAGhC,IAAMtB,EACJ,YAAaC,EAAmBA,EAAiBF,GAAUE,EAEvDW,EAAMC,GAAWV,EAAOc,UACxBM,ED9GD,SAA+BC,EAAcZ,GAClD,IAAIa,EAAOpC,EAAMqC,IAAIF,QACRJ,IAATK,IACFA,EAAO,IAAInC,IACXD,EAAMsC,IAAIH,EAASC,IAGrB,IAAIvB,EAAQuB,EAAKC,IAAId,GACrB,YAAcQ,IAAVlB,IAIJA,EAAQ0B,EAAY,KAAM,CAAEC,UAAW,WACvCJ,EAAKE,IAAIf,EAAKV,IAJLA,CAOX,CC8FkB4B,CACd9B,EAAQwB,SAAWxB,EACnBc,EAAYF,GAERmB,EAASC,IACTC,EAASA,IAAMC,EAAUH,GAEzBI,EACHC,GACD,EAAGC,SAAS,OAAQC,SAA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Aa,CACtDA,EACAD,KAEFE,OAAQA,EAAED,EAAUD,KAAaC,IAAaD,EAC9ChE,OAAQ2C,EAAMwB,SAAQ,EAAEF,KAAuBA,MAEjDG,EAAQ,CAAEC,KAAM,CAAC7B,EAAM8B,SAAU3B,GAAQ4B,GAAIpD,IAC7C2C,EAAO,CACL/D,OAAQyE,EAAM,CAAChC,EAAM8B,SAAUnD,IAC/BnB,OAAQ4C,IAEVwB,EAAQ,CAAEC,KAAMzB,EAAW0B,SAAUC,GAAIvE,IAEzCoE,EAAQ,CACNC,KAAM,CACJ7B,EAAMpC,QAAQqE,IAAI1C,EAAG,QACrBY,EAAMvC,QAAQqE,IAAI1C,EAAG,QACrBa,EAAWzC,KAAKsE,IAAI1C,EAAG,cAEzBwC,GAAIrB,IAGNkB,EAAQ,CAAEC,KAAMhB,EAAWkB,GAAIpE,IAC3BD,GAAMkE,EAAQ,CAAEC,KAAMlB,EAAWoB,GAAIrE,IACrCG,GAAQ+D,EAAQ,CAAEC,KAAMnB,EAAaqB,GAAIlE,IAEzCE,GACFlB,EAAIqF,GAAGnE,GAAS,EAAGhB,OAAOoF,KAAa,CACrCpF,SAAiByB,IAAZ2D,EAAwBpF,EAAMoF,MAInCrE,GAEF8D,EAAQ,CAAEC,KAAM/D,EAAQiE,GAAI/B,EAAM2B,SAAQ,KAAe,MACzD9E,EAAIqF,GAAGpE,GAAQ,EAAGf,OAAOoF,KAAa,CACpCpF,SAAiByB,IAAZ2D,EAAwBpF,EAAMoF,OAIrCnC,GACF,IAGMX,EAAO+C,YAAc/C,CAC/B,CAjLArC,EAAKgE,OAAOmB,GAAYE,QAAQzC,MAAMuC,EAAQvC"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/core/area.ts","../../src/core/index.ts"],"sourcesContent":["import type { Store } from 'effector'\nimport { createStore } from 'effector'\n\n/**\n * Keys areas / namespaces cache\n */\nconst areas = new Map<any, Map<string, Store<any>>>()\n\n/**\n * Get store, responsible for the key in key area / namespace\n */\nexport function getAreaStorage<State>(keyArea: any, key: string): Store<State> {\n let area = areas.get(keyArea)\n if (area === undefined) {\n area = new Map()\n areas.set(keyArea, area)\n }\n\n let store = area.get(key)\n if (store !== undefined) {\n return store\n }\n\n store = createStore(null, { serialize: 'ignore' })\n area.set(key, store)\n\n return store\n}\n","import type { Effect, Subscription } from 'effector'\nimport type {\n ConfigAdapter,\n ConfigAdapterFactory,\n ConfigPersist,\n ConfigSourceTarget,\n ConfigStore,\n Contract,\n Done,\n Fail,\n Finally,\n} from '../types'\nimport {\n attach,\n clearNode,\n createEvent,\n createEffect,\n createNode,\n createStore,\n guard,\n is,\n sample,\n scopeBind,\n withRegion,\n} from 'effector'\nimport { getAreaStorage } from './area'\n\n// helper function to swap two function arguments\n// end extract current context from ref-box\nconst contextual =\n <T, C, R>(fn: (value: T, ctx?: C) => R) =>\n ([ref]: [C?], value: T) =>\n fn(value, ref)\n\n// helper function to validate data with contract\nconst contracted =\n <T>(contract?: Contract<T>) =>\n (raw: unknown) =>\n !contract || // no contract -> data is valid\n raw === undefined || // `undefined` is always valid\n ('isData' in contract ? contract.isData(raw) : contract(raw))\n ? (raw as T)\n : (() => {\n throw 'getErrorMessages' in contract\n ? contract.getErrorMessages(raw)\n : undefined\n })()\n\n// helper function for safe bind effects to scope\n// since version 22.4.0 there is `safe` option in `scopeBind`,\n// but as long as effector-storage supports 22.0 this helper is required\nconst safeBind = (fx: Effect<any, any, any>) => {\n try {\n // @ts-expect-error due to old typings in import\n return scopeBind(fx, { safe: true })\n } catch (e) {\n return fx\n }\n}\n\n/**\n * Default sink for unhandled errors\n */\nconst sink = createEvent<Fail<any>>()\nsink.watch((payload) => console.error(payload.error))\n\n/**\n * Main `persist` function\n */\nexport function persist<State, Err = Error>(\n config: Partial<\n (ConfigAdapter | ConfigAdapterFactory<any>) &\n ConfigPersist &\n ConfigStore<State, Err> &\n ConfigSourceTarget<State, Err>\n >\n): Subscription {\n const {\n adapter: adapterOrFactory,\n store,\n source = store,\n target = store,\n clock = source,\n done,\n fail = sink,\n finally: anyway,\n pickup,\n context,\n key: keyName,\n keyPrefix = '',\n contract,\n } = config\n\n if (!adapterOrFactory) {\n throw Error('Adapter is not defined')\n }\n if (!source) {\n throw Error('Store or source is not defined')\n }\n if (!target) {\n throw Error('Target is not defined')\n }\n if (!keyName && source.shortName === (source as any).id) {\n throw Error('Key or name is not defined')\n }\n if (source === target && !is.store(source)) {\n throw Error('Source must be different from target')\n }\n\n // get default value from store, if given\n // this is used in adapter factory\n if ((config as any).def === undefined && is.store(source)) {\n ;(config as any).def = source.defaultState\n }\n\n const adapter =\n 'factory' in adapterOrFactory ? adapterOrFactory(config) : adapterOrFactory\n\n const key = keyName || source.shortName\n const storage = getAreaStorage<State>(\n adapter.keyArea || adapter,\n keyPrefix + key\n )\n const region = createNode()\n const desist = () => clearNode(region)\n\n const op =\n (operation: 'get' | 'set' | 'validate') =>\n ({ status = 'fail', params, result, error }: any): any =>\n status === 'done'\n ? {\n status,\n key,\n keyPrefix,\n operation,\n value: operation === 'get' ? result : params,\n }\n : {\n status,\n key,\n keyPrefix,\n operation,\n value: typeof params === 'function' ? undefined : params, // hide internal \"box\" implementation\n error,\n }\n\n // create all auxiliary units and nodes within the region,\n // to be able to remove them all at once on unsubscription\n withRegion(region, () => {\n const ctx = createStore<[any?]>([], { serialize: 'ignore' })\n\n const value = adapter<State>(keyPrefix + key, (x) => bindedGet(x))\n\n const getFx = attach({\n source: ctx,\n effect: contextual(value.get),\n }) as any as Effect<void, State, Err>\n\n const setFx = attach({\n source: ctx,\n effect: contextual(value.set),\n }) as any as Effect<State, void, Err>\n\n const validateFx = createEffect<unknown, State>(contracted(contract))\n\n const localAnyway = createEvent<Finally<State, Err>>()\n const localDone = localAnyway.filterMap<Done<State>>(\n ({ status, key, keyPrefix, operation, value }) =>\n status === 'done' ? { key, keyPrefix, operation, value } : undefined\n )\n const localFail = localAnyway.filterMap<Fail<Err>>(\n ({ status, key, keyPrefix, operation, error, value }: any) =>\n status === 'fail'\n ? { key, keyPrefix, operation, error, value }\n : undefined\n )\n\n const trigger = createEvent<State>()\n\n let bindedGet: (raw?: any) => any = getFx\n ctx.updates.watch(() => {\n bindedGet = safeBind(getFx)\n })\n\n sample({\n source,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n clock: clock!, // `clock` is always defined, as long as `source` is defined\n target: trigger,\n })\n\n guard({\n source: sample(storage, trigger, (current, proposed) => [\n proposed,\n current,\n ]),\n filter: ([proposed, current]) => proposed !== current,\n target: setFx.prepend(([proposed]: State[]) => proposed),\n })\n sample({ clock: [getFx.doneData, setFx], target: storage as any })\n sample({ clock: [getFx.doneData, storage], target: validateFx as any })\n sample({ clock: validateFx.doneData, target })\n\n sample({\n clock: [\n getFx.finally.map(op('get')),\n setFx.finally.map(op('set')),\n validateFx.fail.map(op('validate')),\n ],\n target: localAnyway,\n })\n\n if (anyway) sample({ clock: localAnyway, target: anyway })\n if (done) sample({ clock: localDone, target: done })\n sample({ clock: localFail, target: fail })\n\n if (context) {\n ctx.on(context, ([ref], payload) => [\n payload === undefined ? ref : payload,\n ])\n }\n\n if (pickup) {\n // pick up value from storage ONLY on `pickup` update\n sample({ clock: pickup, fn: () => undefined, target: getFx })\n ctx.on(pickup, ([ref], payload) => [\n payload === undefined ? ref : payload,\n ])\n } else {\n // kick getter to pick up initial value from storage\n getFx()\n }\n })\n\n return (desist.unsubscribe = desist)\n}\n"],"names":["areas","Map","contextual","fn","ref","value","sink","createEvent","persist","config","adapter","adapterOrFactory","store","source","target","clock","done","fail","finally","anyway","pickup","context","key","keyName","keyPrefix","contract","Error","shortName","id","is","undefined","def","defaultState","storage","keyArea","area","get","set","createStore","serialize","getAreaStorage","region","createNode","desist","clearNode","op","operation","status","params","result","error","withRegion","ctx","x","bindedGet","getFx","attach","effect","setFx","validateFx","createEffect","raw","isData","getErrorMessages","contracted","localAnyway","localDone","filterMap","localFail","trigger","updates","watch","fx","scopeBind","safe","e","safeBind","sample","guard","current","proposed","filter","pr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,IAAaD,EAC9CjE,OAAQ4C,EAAMwB,SAAQ,EAAEF,KAAuBA,MAEjDH,EAAO,CAAE9D,MAAO,CAACwC,EAAM4B,SAAUzB,GAAQ5C,OAAQmB,IACjD4C,EAAO,CAAE9D,MAAO,CAACwC,EAAM4B,SAAUlD,GAAUnB,OAAQ6C,IACnDkB,EAAO,CAAE9D,MAAO4C,EAAWwB,SAAUrE,WAErC+D,EAAO,CACL9D,MAAO,CACLwC,EAAMrC,QAAQkE,IAAIvC,EAAG,QACrBa,EAAMxC,QAAQkE,IAAIvC,EAAG,QACrBc,EAAW1C,KAAKmE,IAAIvC,EAAG,cAEzB/B,OAAQmD,IAGN9C,GAAQ0D,EAAO,CAAE9D,MAAOkD,EAAanD,OAAQK,IAC7CH,GAAM6D,EAAO,CAAE9D,MAAOmD,EAAWpD,OAAQE,IAC7C6D,EAAO,CAAE9D,MAAOqD,EAAWtD,OAAQG,IAE/BI,GACF+B,EAAIiC,GAAGhE,GAAS,EAAEjB,GAAMkF,IAAY,MACtBxD,IAAZwD,EAAwBlF,EAAMkF,KAI9BlE,GAEFyD,EAAO,CAAE9D,MAAOK,EAAQjB,GAAIA,KAAe,EAAEW,OAAQyC,IACrDH,EAAIiC,GAAGjE,GAAQ,EAAEhB,GAAMkF,IAAY,MACrBxD,IAAZwD,EAAwBlF,EAAMkF,MAIhC/B,GACF,IAGMZ,EAAO4C,YAAc5C,CAC/B,CA3KArC,EAAKiE,OAAOe,GAAYE,QAAQtC,MAAMoC,EAAQpC"}
|
package/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("./core/index.cjs"),r=require("./async-storage/index.cjs"),s=require("./
|
|
1
|
+
"use strict";var e=require("./core/index.cjs"),r=require("./async-storage/index.cjs"),s=require("./broadcast/index.cjs"),o=require("./local/index.cjs"),i=require("./log/index.cjs"),t=require("./memory/index.cjs"),c=require("./nil/index.cjs"),a=require("./query/index.cjs"),n=require("./session/index.cjs"),x=require("./storage/index.cjs"),p=require("./tools/index.cjs"),u=e.persist;exports.asyncStorage=r.asyncStorage,exports.broadcast=s.broadcast,exports.local=o.local,exports.log=i.log,exports.memory=t.memory,exports.nil=c.nil,exports.query=a.query,exports.session=n.session,exports.storage=x.storage,exports.async=p.async,exports.either=p.either,exports.farcached=p.farcached,exports.createPersist=function(r){return s=>e.persist({...r,...s})},exports.persist=u;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Unit, Subscription, Store, Event, Effect } from 'effector'
|
|
2
2
|
export { AsyncStorageConfig, asyncStorage } from './async-storage'
|
|
3
|
+
export { BroadcastConfig, broadcast } from './broadcast'
|
|
3
4
|
export { LocalStorageConfig, local } from './local'
|
|
4
5
|
export { LogConfig, log } from './log'
|
|
5
6
|
export { MemoryConfig, memory } from './memory'
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { ConfigPersist, Persist } from './types'\nimport { persist as base } from './core'\n\nexport type {\n ConfigPersist,\n ConfigSourceTarget,\n ConfigStore,\n Contract,\n Done,\n Fail,\n Finally,\n Persist,\n StorageAdapter,\n StorageAdapterFactory,\n} from './types'\n\n//\n// reexport adapters\n//\n\nexport type { AsyncStorageConfig } from './async-storage'\nexport type { LocalStorageConfig } from './local'\nexport type { LogConfig } from './log'\nexport type { MemoryConfig } from './memory'\nexport type { NilConfig } from './nil'\nexport type { QueryConfig } from './query'\nexport type { SessionStorageConfig } from './session'\nexport type { StorageConfig } from './storage'\n\nexport { asyncStorage } from './async-storage'\nexport { local } from './local'\nexport { log } from './log'\nexport { memory } from './memory'\nexport { nil } from './nil'\nexport { query } from './query'\nexport { session } from './session'\nexport { storage } from './storage'\n\n//\n// reexport tools\n//\n\nexport { async, either, farcached } from './tools'\n\n/**\n * Creates custom `persist`\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config: any) =>\n base({\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default `persist`\n */\nexport const persist: Persist = base\n"],"names":["persist","base","defaults","config"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { ConfigPersist, Persist } from './types'\nimport { persist as base } from './core'\n\nexport type {\n ConfigPersist,\n ConfigSourceTarget,\n ConfigStore,\n Contract,\n Done,\n Fail,\n Finally,\n Persist,\n StorageAdapter,\n StorageAdapterFactory,\n} from './types'\n\n//\n// reexport adapters\n//\n\nexport type { AsyncStorageConfig } from './async-storage'\nexport type { BroadcastConfig } from './broadcast'\nexport type { LocalStorageConfig } from './local'\nexport type { LogConfig } from './log'\nexport type { MemoryConfig } from './memory'\nexport type { NilConfig } from './nil'\nexport type { QueryConfig } from './query'\nexport type { SessionStorageConfig } from './session'\nexport type { StorageConfig } from './storage'\n\nexport { asyncStorage } from './async-storage'\nexport { broadcast } from './broadcast'\nexport { local } from './local'\nexport { log } from './log'\nexport { memory } from './memory'\nexport { nil } from './nil'\nexport { query } from './query'\nexport { session } from './session'\nexport { storage } from './storage'\n\n//\n// reexport tools\n//\n\nexport { async, either, farcached } from './tools'\n\n/**\n * Creates custom `persist`\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config: any) =>\n base({\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default `persist`\n */\nexport const persist: Persist = base\n"],"names":["persist","base","defaults","config"],"mappings":"kXA4DaA,EAAmBC,EAAAA,wUAXzB,SAAuBC,GAC5B,OAAQC,GACNF,EAAAA,QAAK,IACAC,KACAC,GAET"}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Unit, Subscription, Store, Event, Effect } from 'effector'
|
|
2
2
|
export { AsyncStorageConfig, asyncStorage } from './async-storage'
|
|
3
|
+
export { BroadcastConfig, broadcast } from './broadcast'
|
|
3
4
|
export { LocalStorageConfig, local } from './local'
|
|
4
5
|
export { LogConfig, log } from './log'
|
|
5
6
|
export { MemoryConfig, memory } from './memory'
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{persist as o}from"./core/index.js";export{asyncStorage}from"./async-storage/index.js";export{local}from"./local/index.js";export{log}from"./log/index.js";export{memory}from"./memory/index.js";export{nil}from"./nil/index.js";export{query}from"./query/index.js";export{session}from"./session/index.js";export{storage}from"./storage/index.js";export{async,either,farcached}from"./tools/index.js";function
|
|
1
|
+
import{persist as o}from"./core/index.js";export{asyncStorage}from"./async-storage/index.js";export{broadcast}from"./broadcast/index.js";export{local}from"./local/index.js";export{log}from"./log/index.js";export{memory}from"./memory/index.js";export{nil}from"./nil/index.js";export{query}from"./query/index.js";export{session}from"./session/index.js";export{storage}from"./storage/index.js";export{async,either,farcached}from"./tools/index.js";function r(r){return e=>o({...r,...e})}var e=o;export{r as createPersist,e as persist};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/index.js.flow
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { Unit, Subscription, Store, Event, Effect } from 'effector'
|
|
9
9
|
declare export { AsyncStorageConfig, asyncStorage } from './async-storage'
|
|
10
|
+
declare export { BroadcastConfig, broadcast } from './broadcast'
|
|
10
11
|
declare export { LocalStorageConfig, local } from './local'
|
|
11
12
|
declare export { LogConfig, log } from './log'
|
|
12
13
|
declare export { MemoryConfig, memory } from './memory'
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { ConfigPersist, Persist } from './types'\nimport { persist as base } from './core'\n\nexport type {\n ConfigPersist,\n ConfigSourceTarget,\n ConfigStore,\n Contract,\n Done,\n Fail,\n Finally,\n Persist,\n StorageAdapter,\n StorageAdapterFactory,\n} from './types'\n\n//\n// reexport adapters\n//\n\nexport type { AsyncStorageConfig } from './async-storage'\nexport type { LocalStorageConfig } from './local'\nexport type { LogConfig } from './log'\nexport type { MemoryConfig } from './memory'\nexport type { NilConfig } from './nil'\nexport type { QueryConfig } from './query'\nexport type { SessionStorageConfig } from './session'\nexport type { StorageConfig } from './storage'\n\nexport { asyncStorage } from './async-storage'\nexport { local } from './local'\nexport { log } from './log'\nexport { memory } from './memory'\nexport { nil } from './nil'\nexport { query } from './query'\nexport { session } from './session'\nexport { storage } from './storage'\n\n//\n// reexport tools\n//\n\nexport { async, either, farcached } from './tools'\n\n/**\n * Creates custom `persist`\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config: any) =>\n base({\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default `persist`\n */\nexport const persist: Persist = base\n"],"names":["createPersist","defaults","config","base","persist"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { ConfigPersist, Persist } from './types'\nimport { persist as base } from './core'\n\nexport type {\n ConfigPersist,\n ConfigSourceTarget,\n ConfigStore,\n Contract,\n Done,\n Fail,\n Finally,\n Persist,\n StorageAdapter,\n StorageAdapterFactory,\n} from './types'\n\n//\n// reexport adapters\n//\n\nexport type { AsyncStorageConfig } from './async-storage'\nexport type { BroadcastConfig } from './broadcast'\nexport type { LocalStorageConfig } from './local'\nexport type { LogConfig } from './log'\nexport type { MemoryConfig } from './memory'\nexport type { NilConfig } from './nil'\nexport type { QueryConfig } from './query'\nexport type { SessionStorageConfig } from './session'\nexport type { StorageConfig } from './storage'\n\nexport { asyncStorage } from './async-storage'\nexport { broadcast } from './broadcast'\nexport { local } from './local'\nexport { log } from './log'\nexport { memory } from './memory'\nexport { nil } from './nil'\nexport { query } from './query'\nexport { session } from './session'\nexport { storage } from './storage'\n\n//\n// reexport tools\n//\n\nexport { async, either, farcached } from './tools'\n\n/**\n * Creates custom `persist`\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config: any) =>\n base({\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default `persist`\n */\nexport const persist: Persist = base\n"],"names":["createPersist","defaults","config","base","persist"],"mappings":"4bAiDO,SAASA,EAAcC,GAC5B,OAAQC,GACNC,EAAK,IACAF,KACAC,GAET,CAKO,IAAME,EAAmBD"}
|
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
|
|
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
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,QAA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,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
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
|
@@ -101,6 +101,8 @@ declare type StateBehavior = 'keep' | 'erase'
|
|
|
101
101
|
declare interface QueryConfig {
|
|
102
102
|
method?: ChangeMethod;
|
|
103
103
|
state?: StateBehavior;
|
|
104
|
+
serialize?: (value: any) => string;
|
|
105
|
+
deserialize?: (value: string) => any;
|
|
104
106
|
timeout?: number;
|
|
105
107
|
def?: any;
|
|
106
108
|
}
|
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,E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"}
|
package/rn/async/index.cjs.d.ts
CHANGED
|
@@ -91,10 +91,14 @@ declare namespace async {
|
|
|
91
91
|
/**
|
|
92
92
|
* Creates custom partially applied `persist`
|
|
93
93
|
* with predefined `AsyncStorage` adapter
|
|
94
|
+
*
|
|
95
|
+
* @deprecated use @effector-storage/react-native-async-storage instead
|
|
94
96
|
*/
|
|
95
97
|
declare function createPersist(defaults?: ConfigPersist): Persist
|
|
96
98
|
/**
|
|
97
99
|
* Default partially applied `persist`
|
|
100
|
+
*
|
|
101
|
+
* @deprecated use @effector-storage/react-native-async-storage instead
|
|
98
102
|
*/
|
|
99
103
|
declare const persist: Persist
|
|
100
104
|
|
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 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 */\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":"
|
|
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
|
@@ -91,10 +91,14 @@ declare namespace async {
|
|
|
91
91
|
/**
|
|
92
92
|
* Creates custom partially applied `persist`
|
|
93
93
|
* with predefined `AsyncStorage` adapter
|
|
94
|
+
*
|
|
95
|
+
* @deprecated use @effector-storage/react-native-async-storage instead
|
|
94
96
|
*/
|
|
95
97
|
declare function createPersist(defaults?: ConfigPersist): Persist
|
|
96
98
|
/**
|
|
97
99
|
* Default partially applied `persist`
|
|
100
|
+
*
|
|
101
|
+
* @deprecated use @effector-storage/react-native-async-storage instead
|
|
98
102
|
*/
|
|
99
103
|
declare const persist: Persist
|
|
100
104
|
|
package/rn/async/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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 */\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":"
|
|
1
|
+
{"version":3,"file":"index.js","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":"mKA8CO,SAASA,EAAMC,GACpB,OAAOC,EAAa,CAClBC,QAASA,IAAMC,KACZH,GAEP,CAQO,SAASI,EAAcC,GAC5B,OAAQL,GACNM,EAAK,CACHC,QAASR,KACNM,KACAL,GAET,CArBAD,EAAMS,SAAU,EA4BHC,IAAAA,EAAUL"}
|
|
@@ -91,10 +91,14 @@ declare namespace encrypted {
|
|
|
91
91
|
/**
|
|
92
92
|
* Creates custom partially applied `persist`
|
|
93
93
|
* with predefined `EncryptedStorage` adapter
|
|
94
|
+
*
|
|
95
|
+
* @deprecated use @effector-storage/react-native-encrypted-storage instead
|
|
94
96
|
*/
|
|
95
97
|
declare function createPersist(defaults?: ConfigPersist): Persist
|
|
96
98
|
/**
|
|
97
99
|
* Default partially applied `persist`
|
|
100
|
+
*
|
|
101
|
+
* @deprecated use @effector-storage/react-native-encrypted-storage instead
|
|
98
102
|
*/
|
|
99
103
|
declare const persist: Persist
|
|
100
104
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/rn/encrypted/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 EncryptedStorage from 'react-native-encrypted-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 EncryptedStorageConfig {\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n}\n\nexport interface ConfigStore<State, Err = Error>\n extends EncryptedStorageConfig,\n BaseConfigStore<State, Err> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends EncryptedStorageConfig,\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 `EncryptedStorage` adapter\n */\nencrypted.factory = true as const\nexport function encrypted(config?: EncryptedStorageConfig): StorageAdapter {\n return asyncStorage({\n storage: () => EncryptedStorage,\n ...config,\n })\n}\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `EncryptedStorage` adapter\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: encrypted,\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n */\nexport const persist = createPersist()\n"],"names":["encrypted","config","asyncStorage","storage","EncryptedStorage","createPersist","defaults","base","adapter","factory","persist"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/rn/encrypted/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 EncryptedStorage from 'react-native-encrypted-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 EncryptedStorageConfig {\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n}\n\nexport interface ConfigStore<State, Err = Error>\n extends EncryptedStorageConfig,\n BaseConfigStore<State, Err> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends EncryptedStorageConfig,\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 `EncryptedStorage` adapter\n *\n * @deprecated use @effector-storage/react-native-encrypted-storage instead\n */\nencrypted.factory = true as const\nexport function encrypted(config?: EncryptedStorageConfig): StorageAdapter {\n return asyncStorage({\n storage: () => EncryptedStorage,\n ...config,\n })\n}\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `EncryptedStorage` adapter\n *\n * @deprecated use @effector-storage/react-native-encrypted-storage instead\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: encrypted,\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n *\n * @deprecated use @effector-storage/react-native-encrypted-storage instead\n */\nexport const persist = createPersist()\n"],"names":["encrypted","config","asyncStorage","storage","EncryptedStorage","createPersist","defaults","base","adapter","factory","persist"],"mappings":"0IA8CO,SAASA,EAAUC,GACxB,OAAOC,eAAa,CAClBC,QAASA,IAAMC,KACZH,GAEP,CAQO,SAASI,EAAcC,GAC5B,OAAQL,GACNM,EAAAA,QAAK,CACHC,QAASR,KACNM,KACAL,GAET,CArBAD,EAAUS,SAAU,EA4BPC,IAAAA,EAAUL"}
|
package/rn/encrypted/index.d.ts
CHANGED
|
@@ -91,10 +91,14 @@ declare namespace encrypted {
|
|
|
91
91
|
/**
|
|
92
92
|
* Creates custom partially applied `persist`
|
|
93
93
|
* with predefined `EncryptedStorage` adapter
|
|
94
|
+
*
|
|
95
|
+
* @deprecated use @effector-storage/react-native-encrypted-storage instead
|
|
94
96
|
*/
|
|
95
97
|
declare function createPersist(defaults?: ConfigPersist): Persist
|
|
96
98
|
/**
|
|
97
99
|
* Default partially applied `persist`
|
|
100
|
+
*
|
|
101
|
+
* @deprecated use @effector-storage/react-native-encrypted-storage instead
|
|
98
102
|
*/
|
|
99
103
|
declare const persist: Persist
|
|
100
104
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/rn/encrypted/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 EncryptedStorage from 'react-native-encrypted-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 EncryptedStorageConfig {\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n}\n\nexport interface ConfigStore<State, Err = Error>\n extends EncryptedStorageConfig,\n BaseConfigStore<State, Err> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends EncryptedStorageConfig,\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 `EncryptedStorage` adapter\n */\nencrypted.factory = true as const\nexport function encrypted(config?: EncryptedStorageConfig): StorageAdapter {\n return asyncStorage({\n storage: () => EncryptedStorage,\n ...config,\n })\n}\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `EncryptedStorage` adapter\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: encrypted,\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n */\nexport const persist = createPersist()\n"],"names":["encrypted","config","asyncStorage","storage","EncryptedStorage","createPersist","defaults","base","adapter","factory","persist"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/rn/encrypted/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 EncryptedStorage from 'react-native-encrypted-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 EncryptedStorageConfig {\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n}\n\nexport interface ConfigStore<State, Err = Error>\n extends EncryptedStorageConfig,\n BaseConfigStore<State, Err> {}\n\nexport interface ConfigSourceTarget<State, Err = Error>\n extends EncryptedStorageConfig,\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 `EncryptedStorage` adapter\n *\n * @deprecated use @effector-storage/react-native-encrypted-storage instead\n */\nencrypted.factory = true as const\nexport function encrypted(config?: EncryptedStorageConfig): StorageAdapter {\n return asyncStorage({\n storage: () => EncryptedStorage,\n ...config,\n })\n}\n\n/**\n * Creates custom partially applied `persist`\n * with predefined `EncryptedStorage` adapter\n *\n * @deprecated use @effector-storage/react-native-encrypted-storage instead\n */\nexport function createPersist(defaults?: ConfigPersist): Persist {\n return (config) =>\n base({\n adapter: encrypted,\n ...defaults,\n ...config,\n })\n}\n\n/**\n * Default partially applied `persist`\n *\n * @deprecated use @effector-storage/react-native-encrypted-storage instead\n */\nexport const persist = createPersist()\n"],"names":["encrypted","config","asyncStorage","storage","EncryptedStorage","createPersist","defaults","base","adapter","factory","persist"],"mappings":"wJA8CO,SAASA,EAAUC,GACxB,OAAOC,EAAa,CAClBC,QAASA,IAAMC,KACZH,GAEP,CAQO,SAASI,EAAcC,GAC5B,OAAQL,GACNM,EAAK,CACHC,QAASR,KACNM,KACAL,GAET,CArBAD,EAAUS,SAAU,EA4BPC,IAAAA,EAAUL"}
|
package/storage/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/storage/index.ts"],"sourcesContent":["import type { StorageAdapter } from '../types'\n\nexport interface StorageConfig {\n storage: () => Storage\n sync?: boolean | 'force'\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n timeout?: number\n def?: any\n}\n\n/**\n * Creates generic `Storage` adapter\n */\nstorage.factory = true as const\nexport function storage({\n storage,\n sync = false,\n serialize = JSON.stringify,\n deserialize = JSON.parse,\n timeout,\n def,\n}: StorageConfig): StorageAdapter {\n const adapter: StorageAdapter = <State>(\n key: string,\n update: (raw?: any) => any\n ) => {\n let scheduled:
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/storage/index.ts"],"sourcesContent":["import type { StorageAdapter } from '../types'\n\nexport interface StorageConfig {\n storage: () => Storage\n sync?: boolean | 'force'\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n timeout?: number\n def?: any\n}\n\n/**\n * Creates generic `Storage` adapter\n */\nstorage.factory = true as const\nexport function storage({\n storage,\n sync = false,\n serialize = JSON.stringify,\n deserialize = JSON.parse,\n timeout,\n def,\n}: StorageConfig): StorageAdapter {\n const adapter: StorageAdapter = <State>(\n key: string,\n update: (raw?: any) => any\n ) => {\n let scheduled: ReturnType<typeof setTimeout> | undefined\n let unsaved: State\n let to: Storage\n\n // flush unsaved changes to Storage\n const flush = () => to.setItem(key, serialize(unsaved))\n\n // postponed flush unsaved changes to Storage\n const postponed = (e?: BeforeUnloadEvent | 1) => {\n scheduled = clearTimeout(scheduled) as undefined\n if (e) flush()\n\n // according to documentation, it is recommended to remove 'beforeunload' listener\n // as soon as possible to minimize the effect on performance\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event\n if (typeof removeEventListener !== 'undefined') {\n removeEventListener('beforeunload', postponed)\n }\n }\n\n // schedule postponed flush unsaved changes to Storage\n const schedule = () => {\n scheduled = setTimeout(postponed, timeout, 1)\n\n // according to documentation, it is recommended to add 'beforeunload' listener\n // ONLY when it is necessary, when there are actually unsaved changes\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event\n if (typeof addEventListener !== 'undefined') {\n addEventListener('beforeunload', postponed)\n }\n }\n\n if (sync && typeof addEventListener !== 'undefined') {\n addEventListener('storage', (e) => {\n // I hope storage is accessible in case 'storage' event is happening\n // so calling `storage()` should not throw security exception here\n if (e.storageArea === storage()) {\n // call `get` function with new value or undefined in case of force update\n if (e.key === key) update(sync === 'force' ? undefined : e.newValue)\n\n // `key` attribute is `null` when the change is caused by the storage `clear()` method\n if (e.key === null) update(null)\n }\n })\n }\n\n return {\n get(raw?: string | null) {\n postponed() // cancel postponed flush\n const item = raw !== undefined ? raw : storage().getItem(key)\n return item === null\n ? def !== undefined\n ? def\n : raw // 'undefined' when pickup, 'null' when clear\n : deserialize(item)\n },\n\n set(value: State) {\n unsaved = value\n to = storage()\n if (timeout === undefined) {\n flush()\n } else if (!scheduled) {\n schedule()\n }\n },\n }\n }\n\n try {\n adapter.keyArea = storage()\n } catch (error) {\n // do nothing\n }\n\n return adapter\n}\n"],"names":["storage","sync","serialize","JSON","stringify","deserialize","parse","timeout","def","adapter","key","update","scheduled","unsaved","to","flush","setItem","postponed","e","clearTimeout","removeEventListener","addEventListener","storageArea","undefined","newValue","get","raw","item","getItem","set","value","setTimeout","keyArea","error","factory"],"mappings":"aAeO,SAASA,GAAQA,QACtBA,EAAOC,KACPA,GAAO,EAAKC,UACZA,EAAYC,KAAKC,UAASC,YAC1BA,EAAcF,KAAKG,MAAKC,QACxBA,EAAOC,IACPA,IAEA,IAAMC,EAA0BA,CAC9BC,EACAC,KAEA,IAAIC,EACAC,EACAC,EAGEC,EAAQA,IAAMD,EAAGE,QAAQN,EAAKR,EAAUW,IAGxCI,EAAaC,IACjBN,EAAYO,aAAaP,GACrBM,GAAGH,IAK4B,oBAAxBK,qBACTA,oBAAoB,eAAgBH,EACtC,EA6BF,OAdIhB,GAAoC,oBAArBoB,kBACjBA,iBAAiB,WAAYH,IAGvBA,EAAEI,cAAgBtB,MAEhBkB,EAAER,MAAQA,GAAKC,EAAgB,UAATV,OAAmBsB,EAAYL,EAAEM,UAG7C,OAAVN,EAAER,KAAcC,EAAO,MAC7B,IAIG,CACLc,IAAIC,GACFT,IACA,IAAMU,OAAeJ,IAARG,EAAoBA,EAAM1B,IAAU4B,QAAQlB,GACzD,OAAgB,OAATiB,OACKJ,IAARf,EACEA,EACAkB,EACFrB,EAAYsB,EACjB,EAEDE,IAAIC,GACFjB,EAAUiB,EACVhB,EAAKd,SACWuB,IAAZhB,EACFQ,IACUH,IAxCdA,EAAYmB,WAAWd,EAAWV,EAAS,GAKX,oBAArBc,kBACTA,iBAAiB,eAAgBJ,GAqCnC,EACD,EAGH,IACER,EAAQuB,QAAUhC,GACnB,CAAC,MAAOiC,GACP,CAGF,OAAOxB,CACT,CAzFAT,EAAQkC,SAAU"}
|
package/storage/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/storage/index.ts"],"sourcesContent":["import type { StorageAdapter } from '../types'\n\nexport interface StorageConfig {\n storage: () => Storage\n sync?: boolean | 'force'\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n timeout?: number\n def?: any\n}\n\n/**\n * Creates generic `Storage` adapter\n */\nstorage.factory = true as const\nexport function storage({\n storage,\n sync = false,\n serialize = JSON.stringify,\n deserialize = JSON.parse,\n timeout,\n def,\n}: StorageConfig): StorageAdapter {\n const adapter: StorageAdapter = <State>(\n key: string,\n update: (raw?: any) => any\n ) => {\n let scheduled:
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/storage/index.ts"],"sourcesContent":["import type { StorageAdapter } from '../types'\n\nexport interface StorageConfig {\n storage: () => Storage\n sync?: boolean | 'force'\n serialize?: (value: any) => string\n deserialize?: (value: string) => any\n timeout?: number\n def?: any\n}\n\n/**\n * Creates generic `Storage` adapter\n */\nstorage.factory = true as const\nexport function storage({\n storage,\n sync = false,\n serialize = JSON.stringify,\n deserialize = JSON.parse,\n timeout,\n def,\n}: StorageConfig): StorageAdapter {\n const adapter: StorageAdapter = <State>(\n key: string,\n update: (raw?: any) => any\n ) => {\n let scheduled: ReturnType<typeof setTimeout> | undefined\n let unsaved: State\n let to: Storage\n\n // flush unsaved changes to Storage\n const flush = () => to.setItem(key, serialize(unsaved))\n\n // postponed flush unsaved changes to Storage\n const postponed = (e?: BeforeUnloadEvent | 1) => {\n scheduled = clearTimeout(scheduled) as undefined\n if (e) flush()\n\n // according to documentation, it is recommended to remove 'beforeunload' listener\n // as soon as possible to minimize the effect on performance\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event\n if (typeof removeEventListener !== 'undefined') {\n removeEventListener('beforeunload', postponed)\n }\n }\n\n // schedule postponed flush unsaved changes to Storage\n const schedule = () => {\n scheduled = setTimeout(postponed, timeout, 1)\n\n // according to documentation, it is recommended to add 'beforeunload' listener\n // ONLY when it is necessary, when there are actually unsaved changes\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event\n if (typeof addEventListener !== 'undefined') {\n addEventListener('beforeunload', postponed)\n }\n }\n\n if (sync && typeof addEventListener !== 'undefined') {\n addEventListener('storage', (e) => {\n // I hope storage is accessible in case 'storage' event is happening\n // so calling `storage()` should not throw security exception here\n if (e.storageArea === storage()) {\n // call `get` function with new value or undefined in case of force update\n if (e.key === key) update(sync === 'force' ? undefined : e.newValue)\n\n // `key` attribute is `null` when the change is caused by the storage `clear()` method\n if (e.key === null) update(null)\n }\n })\n }\n\n return {\n get(raw?: string | null) {\n postponed() // cancel postponed flush\n const item = raw !== undefined ? raw : storage().getItem(key)\n return item === null\n ? def !== undefined\n ? def\n : raw // 'undefined' when pickup, 'null' when clear\n : deserialize(item)\n },\n\n set(value: State) {\n unsaved = value\n to = storage()\n if (timeout === undefined) {\n flush()\n } else if (!scheduled) {\n schedule()\n }\n },\n }\n }\n\n try {\n adapter.keyArea = storage()\n } catch (error) {\n // do nothing\n }\n\n return adapter\n}\n"],"names":["storage","sync","serialize","JSON","stringify","deserialize","parse","timeout","def","adapter","key","update","scheduled","unsaved","to","flush","setItem","postponed","e","clearTimeout","removeEventListener","addEventListener","storageArea","undefined","newValue","get","raw","item","getItem","set","value","setTimeout","keyArea","error","factory"],"mappings":"AAeO,SAASA,GAAQA,QACtBA,EAAOC,KACPA,GAAO,EAAKC,UACZA,EAAYC,KAAKC,UAASC,YAC1BA,EAAcF,KAAKG,MAAKC,QACxBA,EAAOC,IACPA,IAEA,IAAMC,EAA0BA,CAC9BC,EACAC,KAEA,IAAIC,EACAC,EACAC,EAGEC,EAAQA,IAAMD,EAAGE,QAAQN,EAAKR,EAAUW,IAGxCI,EAAaC,IACjBN,EAAYO,aAAaP,GACrBM,GAAGH,IAK4B,oBAAxBK,qBACTA,oBAAoB,eAAgBH,EACtC,EA6BF,OAdIhB,GAAoC,oBAArBoB,kBACjBA,iBAAiB,WAAYH,IAGvBA,EAAEI,cAAgBtB,MAEhBkB,EAAER,MAAQA,GAAKC,EAAgB,UAATV,OAAmBsB,EAAYL,EAAEM,UAG7C,OAAVN,EAAER,KAAcC,EAAO,MAC7B,IAIG,CACLc,IAAIC,GACFT,IACA,IAAMU,OAAeJ,IAARG,EAAoBA,EAAM1B,IAAU4B,QAAQlB,GACzD,OAAgB,OAATiB,OACKJ,IAARf,EACEA,EACAkB,EACFrB,EAAYsB,EACjB,EAEDE,IAAIC,GACFjB,EAAUiB,EACVhB,EAAKd,SACWuB,IAAZhB,EACFQ,IACUH,IAxCdA,EAAYmB,WAAWd,EAAWV,EAAS,GAKX,oBAArBc,kBACTA,iBAAiB,eAAgBJ,GAqCnC,EACD,EAGH,IACER,EAAQuB,QAAUhC,GACnB,CAAC,MAAOiC,GACP,CAGF,OAAOxB,CACT,CAzFAT,EAAQkC,SAAU"}
|
package/tools/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("effector");exports.async=function(e){var
|
|
1
|
+
"use strict";var e=require("effector");exports.async=function(e){var t="factory"in e;function r(r){var a=t?e(r):e,n=(e,t)=>{var{get:r,set:n}=a(e,t);return{get:async(e,t)=>r(await e,t),set:async(e,t)=>n(await e,t)}};return n.keyArea=a.keyArea,n.noop=a.noop,n}return r.factory=!0,t?r:r()},exports.either=function(e,t){var r="factory"in e,a="factory"in t;function n(n){var c=r?e(n):e,o=a?t(n):t;return c.noop?o:c}return n.factory=!0,r||a?n:n()},exports.farcached=function(t,r){var a=r=>({get:e.attach({source:t.__.$instance,async effect(e){var t=await e.get({key:r});return t?.value}}),set:e.attach({source:t.__.$instance,effect:async(e,t)=>e.set({key:r,value:t})})});return a.keyArea=r??t,a};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|