Comparing version 2.0.0 to 2.1.0
@@ -20,2 +20,3 @@ { | ||
"patronum/pending", | ||
"patronum/previous", | ||
"patronum/reset", | ||
@@ -48,2 +49,3 @@ "patronum/reshape", | ||
"pending": "pending", | ||
"previous": "previous", | ||
"reset": "reset", | ||
@@ -50,0 +52,0 @@ "reshape": "reshape", |
@@ -17,2 +17,3 @@ import { Effect, Event, EventAsReturnType, Store, Unit, UnitTargetable } from 'effector'; | ||
}): ReturnTarget<P, T>; | ||
export declare function combineEvents<P extends Shape>(events: Events<P>): EventAsReturnType<P>; | ||
export {}; |
@@ -7,3 +7,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
import { createEvent, createStore, is, sample, withRegion } from 'effector'; | ||
export function combineEvents(_ref) { | ||
export function combineEvents(args) { | ||
var argsShape = isEventsShape(args) ? { | ||
events: args | ||
} : args; | ||
var { | ||
@@ -14,8 +17,5 @@ events, | ||
name: "target", | ||
sid: "aip3nf" | ||
}, { | ||
name: "target", | ||
sid: "aip3nf" | ||
sid: "p73fff" | ||
}) | ||
} = _ref; | ||
} = argsShape; | ||
if (!(is.unit(target) && is.targetable(target))) throwError('target should be a targetable unit'); | ||
@@ -31,3 +31,3 @@ if (reset && !is.unit(reset)) throwError('reset should be a unit'); | ||
name: "$counter", | ||
sid: "-cuwegw" | ||
sid: "-ahoahx" | ||
}); | ||
@@ -39,22 +39,24 @@ var $results = createStore(defaultShape, { | ||
name: "$results", | ||
sid: "cn2cpl" | ||
sid: "oy8iyn" | ||
}); | ||
$counter.reset(sample({ | ||
sample({ | ||
and: [{ | ||
source: target | ||
source: target, | ||
target: $counter.reinit | ||
}], | ||
or: { | ||
sid: "-80w3us" | ||
sid: "blex0c" | ||
} | ||
})); | ||
}); | ||
$results.reset(target); | ||
if (reset) { | ||
$counter.reset(sample({ | ||
sample({ | ||
and: [{ | ||
source: reset | ||
source: reset, | ||
target: $counter.reinit | ||
}], | ||
or: { | ||
sid: "3t8gjw" | ||
sid: "bnm3fi" | ||
} | ||
})); | ||
}); | ||
$results.reset(reset); | ||
@@ -68,3 +70,3 @@ } | ||
name: "$isDone", | ||
sid: "vavgfq" | ||
sid: "-rf2fac" | ||
}).on(events[key], () => true).reset(target); | ||
@@ -91,3 +93,3 @@ if (reset) { | ||
name: "eventsTrriggered", | ||
sid: "-o4wcap" | ||
sid: "-lro8bq" | ||
} | ||
@@ -104,3 +106,3 @@ }); | ||
or: { | ||
sid: "cm94rj" | ||
sid: "-dlkr2s" | ||
} | ||
@@ -111,4 +113,7 @@ }); | ||
} | ||
function isEventsShape(args) { | ||
return Object.keys(args).some(key => !['events', 'reset', 'target'].includes(key) && is.unit(args[key])); | ||
} | ||
function throwError(message) { | ||
throw new Error(message); | ||
} |
import { Store, Unit, UnitTargetable, EventAsReturnType } from 'effector'; | ||
export declare function debounce<T>(source: Unit<T>, timeout: number | Store<number>): EventAsReturnType<T>; | ||
export declare function debounce<T>(_: { | ||
@@ -3,0 +4,0 @@ source: Unit<T>; |
import { createEvent, createStore, is, sample, attach, merge } from 'effector'; | ||
export function debounce(_ref) { | ||
var _ref2; | ||
export function debounce() { | ||
var _ref; | ||
var argsShape = arguments.length === 2 ? { | ||
source: arguments.length <= 0 ? undefined : arguments[0], | ||
timeout: arguments.length <= 1 ? undefined : arguments[1] | ||
} : arguments.length <= 0 ? undefined : arguments[0]; | ||
var { | ||
@@ -9,6 +13,6 @@ source, | ||
name | ||
} = _ref; | ||
} = argsShape; | ||
if (!is.unit(source)) throw new TypeError('source must be unit from effector'); | ||
if (is.domain(source, { | ||
sid: "johnmj" | ||
sid: "jsc7s2" | ||
})) throw new TypeError('source cannot be domain'); | ||
@@ -18,3 +22,3 @@ var $timeout = toStoreNumber(timeout); | ||
name: "saveCancel", | ||
sid: "-xnlfoj" | ||
sid: "-kec0n3" | ||
}); | ||
@@ -26,7 +30,7 @@ var $canceller = createStore([], { | ||
name: "$canceller", | ||
sid: "sc8di8" | ||
sid: "-tfm9fg" | ||
}).on(saveCancel, (_, payload) => payload); | ||
var tick = (_ref2 = target) !== null && _ref2 !== void 0 ? _ref2 : createEvent({ | ||
var tick = (_ref = target) !== null && _ref !== void 0 ? _ref : createEvent({ | ||
name: "tick", | ||
sid: "-8sr1x7" | ||
sid: "-50e2rn" | ||
}); | ||
@@ -37,4 +41,4 @@ var timerFx = attach({ | ||
source: $canceller, | ||
effect(_ref3, timeout) { | ||
var [timeoutId, rejectPromise] = _ref3; | ||
effect(_ref2, timeout) { | ||
var [timeoutId, rejectPromise] = _ref2; | ||
if (timeoutId) clearTimeout(timeoutId); | ||
@@ -49,3 +53,3 @@ if (rejectPromise) rejectPromise(); | ||
name: "timerFx", | ||
sid: "-xn3pk6" | ||
sid: "-jwso4j" | ||
} | ||
@@ -62,3 +66,3 @@ }); | ||
name: "$payload", | ||
sid: "pgla4m" | ||
sid: "-x9cllg" | ||
}).on(source, (_, payload) => [payload]); | ||
@@ -70,7 +74,7 @@ var $canTick = createStore(true, { | ||
name: "$canTick", | ||
sid: "6du563" | ||
sid: "8r2952" | ||
}); | ||
var triggerTick = createEvent({ | ||
name: "triggerTick", | ||
sid: "-jj7t7n" | ||
sid: "-781myl" | ||
}); | ||
@@ -91,7 +95,7 @@ $canTick.on(triggerTick, () => false).on([tick, | ||
name: "requestTick", | ||
sid: "-kkiowi" | ||
sid: "-khrpxp" | ||
} | ||
})], { | ||
name: "requestTick", | ||
sid: "6s463" | ||
sid: "2k0852" | ||
}); | ||
@@ -105,3 +109,3 @@ sample({ | ||
or: { | ||
sid: "m4gqgv" | ||
sid: "-31h8q8" | ||
} | ||
@@ -116,3 +120,3 @@ }); | ||
or: { | ||
sid: "-30xg4v" | ||
sid: "-2y6h62" | ||
} | ||
@@ -124,4 +128,4 @@ }); | ||
clock: timerFx.done, | ||
fn: _ref4 => { | ||
var [payload] = _ref4; | ||
fn: _ref3 => { | ||
var [payload] = _ref3; | ||
return payload; | ||
@@ -132,3 +136,3 @@ }, | ||
or: { | ||
sid: "-2xmokp" | ||
sid: "-2jc15b" | ||
} | ||
@@ -140,3 +144,3 @@ }); | ||
if (is.store(value, { | ||
sid: "-24hl14" | ||
sid: "-21qm2b" | ||
})) return value; | ||
@@ -149,3 +153,3 @@ if (typeof value === 'number') { | ||
}, | ||
sid: "808jp2" | ||
sid: "kbepy4" | ||
}); | ||
@@ -152,0 +156,0 @@ } |
import { Unit, Store, EventAsReturnType, Target as TargetType, MultiTarget, UnitValue } from 'effector'; | ||
type TimeoutType<Payload> = ((payload: Payload) => number) | Store<number> | number; | ||
export declare function delay<Source extends Unit<any>>(source: Source, timeout: TimeoutType<UnitValue<Source>>): EventAsReturnType<UnitValue<Source>>; | ||
export declare function delay<Source extends Unit<any>, Target extends TargetType>(config: { | ||
@@ -4,0 +5,0 @@ source: Source; |
import { createEffect, createEvent, is, sample, combine } from 'effector'; | ||
export function delay(_ref) { | ||
export function delay() { | ||
var argsShape = arguments.length === 2 ? { | ||
source: arguments.length <= 0 ? undefined : arguments[0], | ||
timeout: arguments.length <= 1 ? undefined : arguments[1] | ||
} : arguments.length <= 0 ? undefined : arguments[0]; | ||
var { | ||
@@ -8,8 +12,5 @@ source, | ||
name: "target", | ||
sid: "-7m9t8m" | ||
}, { | ||
name: "target", | ||
sid: "-7m9t8m" | ||
sid: "jucb8d" | ||
}) | ||
} = _ref; | ||
} = argsShape; | ||
var targets = Array.isArray(target) ? target : [target]; | ||
@@ -19,7 +20,7 @@ if (!is.unit(source)) throw new TypeError('source must be a unit from effector'); | ||
var ms = validateTimeout(timeout); | ||
var timerFx = createEffect(_ref2 => { | ||
var timerFx = createEffect(_ref => { | ||
var { | ||
payload, | ||
milliseconds | ||
} = _ref2; | ||
} = _ref; | ||
return new Promise(resolve => { | ||
@@ -30,3 +31,3 @@ setTimeout(resolve, milliseconds, payload); | ||
name: "timerFx", | ||
sid: "d8ml62" | ||
sid: "-wp3hwr" | ||
}); | ||
@@ -43,10 +44,10 @@ sample({ | ||
name: "source", | ||
sid: "-vfyhl7" | ||
sid: "-gaikyz" | ||
} | ||
}), | ||
clock: source, | ||
fn: (_ref3, payload) => { | ||
fn: (_ref2, payload) => { | ||
var { | ||
milliseconds | ||
} = _ref3; | ||
} = _ref2; | ||
return { | ||
@@ -60,3 +61,3 @@ payload, | ||
or: { | ||
sid: "-vnw0w1" | ||
sid: "-uuqxfw" | ||
} | ||
@@ -70,3 +71,3 @@ }); | ||
or: { | ||
sid: "-utnc96" | ||
sid: "-uc1x9m" | ||
} | ||
@@ -78,3 +79,3 @@ }); | ||
if (is.store(timeout, { | ||
sid: "-ud5iem" | ||
sid: "-tvk3f2" | ||
}) || typeof timeout === 'function' || typeof timeout === 'number') { | ||
@@ -81,0 +82,0 @@ return timeout; |
import { Domain, Effect, Store } from 'effector'; | ||
export declare function inFlight(effects: Array<Effect<any, any, any>>): Store<number>; | ||
export declare function inFlight(_: { | ||
@@ -3,0 +4,0 @@ effects: Array<Effect<any, any, any>>; |
import { combine } from 'effector'; | ||
export function inFlight(_ref) { | ||
export function inFlight(args) { | ||
var argsShape = Array.isArray(args) ? { | ||
effects: args | ||
} : args; | ||
var { | ||
effects, | ||
domain | ||
} = _ref; | ||
} = argsShape; | ||
if (domain) { | ||
var $inFlight = domain.createStore(0, { | ||
name: "$inFlight", | ||
sid: "-y7vg7t" | ||
sid: "-wboyn1" | ||
}); | ||
@@ -22,5 +25,5 @@ domain.onCreateEffect(fx => { | ||
or: { | ||
sid: "ubqxa7" | ||
sid: "udy3nn" | ||
} | ||
}); | ||
} |
@@ -18,2 +18,3 @@ export { and } from './and'; | ||
export { pending } from './pending'; | ||
export { previous } from './previous'; | ||
export { reset } from './reset'; | ||
@@ -20,0 +21,0 @@ export { reshape } from './reshape'; |
@@ -18,2 +18,3 @@ export { and } from './and/index.js' | ||
export { pending } from './pending/index.js' | ||
export { previous } from './previous/index.js' | ||
export { reset } from './reset/index.js' | ||
@@ -20,0 +21,0 @@ export { reshape } from './reshape/index.js' |
{ | ||
"name": "patronum", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "☄️ Effector utility library delivering modularity and convenience", | ||
@@ -29,3 +29,3 @@ "type": "module", | ||
}, | ||
"homepage": "https://github.com/effector/patronum#readme", | ||
"homepage": "https://patronum.effector.dev", | ||
"peerDependencies": { | ||
@@ -132,2 +132,7 @@ "effector": "^23" | ||
}, | ||
"./previous/package.json": "./previous/package.json", | ||
"./previous": { | ||
"require": "./previous/index.cjs", | ||
"import": "./previous/index.js" | ||
}, | ||
"./reset/package.json": "./reset/package.json", | ||
@@ -134,0 +139,0 @@ "./reset": { |
@@ -1,2 +0,2 @@ | ||
import{combine as e,createEvent as r,is as n,withRegion as t,createStore as o,sample as a,split as i,attach as c,merge as u,createNode as s,step as d,clearNode as f,createEffect as l,restore as m}from"effector";function p(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];return e({and:[n,e=>{for(var r of e)if(!r)return!1;return!0},{skipVoid:!1}],or:{sid:"-rbm5ks"}})}function v(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function g(e,r,n){return(r=function(e){var r=function(e,r){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var t=n.call(e,r||"default");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==typeof r?r:String(r)}(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function y(e){var{events:i,reset:c,target:u=r({name:"target",sid:"aip3nf"},{name:"target",sid:"aip3nf"})}=e;return n.unit(u)&&n.targetable(u)||h("target should be a targetable unit"),c&&!n.unit(c)&&h("reset should be a unit"),t(u,(()=>{var e=Object.keys(i),r=Array.isArray(i)?[...e].fill(""):{},n=o(e.length,{and:{serialize:"ignore"},name:"$counter",sid:"-cuwegw"}),t=o(r,{and:{serialize:"ignore"},name:"$results",sid:"cn2cpl"});n.reset(a({and:[{source:u}],or:{sid:"-80w3us"}})),t.reset(u),c&&(n.reset(a({and:[{source:c}],or:{sid:"3t8gjw"}})),t.reset(c));var s=function(e){var r=o(!1,{and:{serialize:"ignore"},name:"$isDone",sid:"vavgfq"}).on(i[e],(()=>!0)).reset(u);c&&r.reset(c),n.on(r,(e=>e-1)),t.on(i[e],((r,n)=>{var t=Array.isArray(r)?[...r]:function(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?v(Object(n),!0).forEach((function(r){g(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}({},r);return t[e]=n,t}))};for(var d of e)s(d);var f=a({and:[{source:t,clock:[...Object.values(i)]}],or:{name:"eventsTrriggered",sid:"-o4wcap"}});a({and:[{source:f,filter:n.map((e=>0===e),{skipVoid:!1}),target:u}],or:{sid:"cm94rj"}})})),u}function h(e){throw new Error(e)}function b(e){var{if:t,then:o,else:c,source:u=r({name:"source",sid:"tdyoa4"},{name:"source",sid:"tdyoa4"})}=e,s=n.unit(t)||"function"==typeof t?t:e=>e===t;return o&&c?i({and:[{source:u,match:{then:s,else:w(s)},cases:{then:o,else:c}}],or:{sid:"aaw2hr"}}):o?a({and:[{source:u,filter:s,target:o}],or:{sid:"-dwrmbb"}}):c&&a({and:[{source:u,filter:w(s),target:c}],or:{sid:"-dsx25s"}}),u}function w(e){return n.unit(e)?e.map((e=>!e),{skipVoid:!1}):r=>!e(r)}function k(e){var t,{source:i,timeout:s,target:d,name:f}=e;if(!n.unit(i))throw new TypeError("source must be unit from effector");if(n.domain(i,{sid:"johnmj"}))throw new TypeError("source cannot be domain");var l=function(e){if(n.store(e,{sid:"-24hl14"}))return e;if("number"==typeof e){if(e<0||!Number.isFinite(e))throw new Error('timeout must be positive number or zero. Received: "'.concat(e,'"'));return o(e,{and:{name:"$timeout"},sid:"808jp2"})}throw new TypeError('timeout parameter in interval method should be number or Store. "'.concat(typeof e,'" was passed'))}(s),m=r({name:"saveCancel",sid:"-xnlfoj"}),p=o([],{and:{serialize:"ignore"},name:"$canceller",sid:"sc8di8"}).on(m,((e,r)=>r)),v=null!==(t=d)&&void 0!==t?t:r({name:"tick",sid:"-8sr1x7"}),g=c({and:{name:f||"debounce(".concat((null==i?void 0:i.shortName)||i.kind,") effect"),source:p,effect(e,r){var[n,t]=e;return n&&clearTimeout(n),t&&t(),new Promise(((e,n)=>{m([setTimeout(e,r),n])}))}},or:{name:"timerFx",sid:"-xn3pk6"}});p.reset(g.done);var y=o([],{and:{serialize:"ignore",skipVoid:!1},name:"$payload",sid:"pgla4m"}).on(i,((e,r)=>[r])),h=o(!0,{and:{serialize:"ignore"},name:"$canTick",sid:"6du563"}),b=r({name:"triggerTick",sid:"-jj7t7n"});h.on(b,(()=>!1)).on([v,l,g],(()=>!0));var w=u([i,a({and:[{clock:l,filter:g.pending}],or:{name:"requestTick",sid:"-kkiowi"}})],{name:"requestTick",sid:"6s463"});return a({and:[{clock:w,filter:h,target:b}],or:{sid:"m4gqgv"}}),a({and:[{source:l,clock:b,target:g}],or:{sid:"-30xg4v"}}),a({and:[{source:y,clock:g.done,fn:e=>{var[r]=e;return r},target:v}],or:{sid:"-2xmokp"}}),v}function j(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function O(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?j(Object(n),!0).forEach((function(r){E(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function E(e,r,n){return(r=function(e){var r=function(e,r){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var t=n.call(e,r||"default");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==typeof r?r:String(r)}(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var T={trace:!1,handler:e=>{if(!R(e.node)||"finally"!==e.node.meta.named){var{scope:r,scopeName:n,name:t,kind:o,value:a,loc:i,trace:c,node:u,logType:s}=e,d=r?" (scope: ".concat(n,")"):"",f=null!=t?t:i?"".concat(i.file,":").concat(i.line,":").concat(i.column):"",l="initial"===s?" [getState]":"";console.info("[".concat(o,"]").concat(d," ").concat(f).concat(l),a),c&&c.length>0&&!R(u)&&(console.groupCollapsed("[".concat(o,"]").concat(d," ").concat(f," trace")),c.forEach((e=>{var{name:r,kind:n,value:t,loc:o}=e,a=null!=r?r:o?"".concat(o.file,":").concat(o.line,":").concat(o.column):"";console.info("<- [".concat(n,"] ").concat(a),t)})),console.groupEnd())}}};function P(){var{config:e,units:r}=V(...arguments);r.forEach((r=>{n.store(r,{sid:"-foynff"})||n.event(r,{sid:"apy28p"})||n.effect(r,{sid:"apy3od"})?A(r,e):n.domain(r,{sid:"-rsqe9t"})&&S(r,e)}))}function S(e,r){e.onCreateStore((e=>A(e,r))),e.onCreateEvent((e=>A(e,r))),e.onCreateEffect((e=>A(e,r))),e.onCreateDomain((e=>S(e,r)))}function A(e,r){n.store(e,{sid:"w7ds2s"})?(!function(e,r){if(!r.handler)throw Error("patronum/debug must have the handler");var n={logType:"initial",scope:null,scopeName:null,node:L(e),kind:_(e),value:e.getState(),name:G(e),loc:J(e),trace:[],stackMeta:{}};r.handler(n),I.forEach((n=>$(e,r,n))),D((n=>$(e,r,n)))}(e,r),x(e,r)):n.event(e,{sid:"fretyd"})?x(e,r):n.effect(e,{sid:"gpi2qr"})&&(x(e,r),x(e.finally,r),x(e.done,r),x(e.fail,r))}function x(e,r){var n=s({parent:[e],meta:{op:"watch"},family:{owners:e},regional:!0,node:[d.run({fn(n,t,o){var a,i=null!==(a=null==o?void 0:o.scope)&&void 0!==a?a:null,c={logType:"update",scope:i,scopeName:M(i),node:L(e),kind:_(e),value:n,name:G(e),loc:J(e),stackMeta:Q(o.parent),trace:r.trace?z(o):[]};if(!r.handler)throw Error("patronum/debug must have the handler");r.handler(c)}})]});return()=>f(n)}function z(e){for(var r=[],n=null==e?void 0:e.parent;n;){var{node:t,value:o}=n,a={node:t,value:o,name:G(t),loc:J(t),kind:_(t),stackMeta:Q(n)};r.push(a),n=n.parent}return r}function $(e,r,n){if(!r.handler)throw Error("patronum/debug must have the handler");var t=L(e),o={logType:"initial",scope:n,scopeName:M(n),node:t,kind:_(e),value:n.getState(e),name:G(e),loc:J(e),trace:[],stackMeta:{}};r.handler(o)}function V(){for(var e=T,r=arguments.length,t=new Array(r),o=0;o<r;o++)t[o]=arguments[o];var[a,...i]=t,c=[];if(q(a))e=O(O({},T),a);else if(n.unit(a))c.push(a);else for(var[u,s]of Object.entries(a))K.set(B(s).id,u),c.push(s);for(var d of i)if(n.unit(d))c.push(d);else for(var[f,l]of Object.entries(d))K.set(B(l).id,f),c.push(l);return{config:e,units:c}}function q(e){return!n.unit(e)&&!Object.values(e).every(n.unit)}var N=new Set,D=e=>(N.add(e),()=>{N.delete(e)});var F=0;var C=new Map,I={save(e,r){I.get(e)||C.set(e,r)},get(e){var r;return e&&null!==(r=C.get(e))&&void 0!==r?r:null},delete(e){C.delete(e)},forEach(e){C.forEach(((r,n)=>e(n,r)))},clear(){C.clear()}};function M(e){if(!e)return null;var r=I.get(e);return r?r.name:e._debugId||(e._debugId="unknown_".concat(F+=1))}function R(e){var r=L(e),{sid:n,named:t}=r.meta;return Boolean(!n&&("finally"===t||"done"===t||"doneData"===t||"fail"===t||"failData"===t||"inFlight"===t||"pending"===t))}function _(e){if(n.store(e,{sid:"4o7s04"}))return"store";if(n.effect(e,{sid:"4pv5s7"})||R(e))return"effect";if(n.event(e,{sid:"4rijka"}))return"event";if(n.domain(e,{sid:"54plsy"}))return"domain";if(n.unit(e))return"unit";var r=L(e);return r.meta.op?r.meta.op:"unknown"}P.registerScope=function(e,r){return I.save(e,{name:r.name}),N.forEach((r=>r(e))),()=>{I.delete(e)}},P.unregisterAllScopes=function(){I.clear()};var B=e=>e.graphite||e,K=new Map;function G(e){var r,t,o=K.get(B(e).id);if(o)return o;if(R(e)){var a=L(e),i=a.family.owners.find((e=>"effect"===e.meta.op));if(i){var c=H(i),u=c?"".concat(c,"/"):"";return"".concat(u).concat(G(i),".").concat(a.meta.named)}return a.meta.named}if(function(e){var r=L(e),{op:n}=r.meta;return"on"===n}(e)){var s=L(e),d=G(s.next[0]),f=G(s.family.owners[0]);return"".concat(d,".on(").concat(f,")")}if(n.unit(e)){var l;if(null!=e&&null!==(l=e.compositeName)&&void 0!==l&&l.fullName)return e.compositeName.fullName;var m=H(e),p=m?"".concat(m,"/"):"";if(null!=e&&e.shortName)return"".concat(p).concat(e.shortName);if(null!=e&&e.name)return"".concat(p).concat(e.name)}return null!==(r=L(e))&&void 0!==r&&null!==(t=r.meta)&&void 0!==t&&t.name?L(e).meta.name:null}function H(e){var r=L(e).family.owners.find((e=>"domain"===e.meta.op));return r?G(r):null}function J(e){var r=function(e){var{meta:r}=e;return"config"in r?r.config.loc:r.loc}(L(e));if(r)return r}function L(e){return"graphite"in e?e.graphite:e}function Q(e){return e&&e.meta||{}}function U(t){var{source:o,timeout:i,target:c=r({name:"target",sid:"-7m9t8m"},{name:"target",sid:"-7m9t8m"})}=t,u=Array.isArray(c)?c:[c];if(!n.unit(o))throw new TypeError("source must be a unit from effector");if(!u.every((e=>n.unit(e))))throw new TypeError("target must be a unit from effector");var s=function(e){if(n.store(e,{sid:"-ud5iem"})||"function"==typeof e||"number"==typeof e)return e;throw new TypeError("'timeout' argument must be a function, Store, or a number. Passed \"".concat(typeof e,'"'))}(i),d=l((e=>{var{payload:r,milliseconds:n}=e;return new Promise((e=>{setTimeout(e,n,r)}))}),{name:"timerFx",sid:"d8ml62"});return a({and:[{source:e({and:[{milliseconds:s}],or:{name:"source",sid:"-vfyhl7"}}),clock:o,fn:(e,r)=>{var{milliseconds:n}=e;return{payload:r,milliseconds:"function"==typeof n?n(r):n}},target:d}],or:{sid:"-vnw0w1"}}),a({and:[{clock:d.doneData,target:u}],or:{sid:"-utnc96"}}),c}function W(r,t,o){if(n.store(r,{sid:"ozzvoc"}))return e({and:[r,t,o,(e,r,n)=>e?r:n,{skipVoid:!1}],or:{sid:"-5vau2h"}});var a=r;return W(a.filter,a.then,a.other)}function X(e){return e.map((e=>null==e),{skipVoid:!1})}function Y(r,n){return e({and:[r,n,(e,r)=>e===r,{skipVoid:!1}],or:{sid:"-pqjlti"}})}function Z(r,t){var o,a=[],i=()=>!1;Array.isArray(r)?(a=r,i=t):Array.isArray(r.stores)&&(a=r.stores,i=r.predicate),o="function"==typeof i?i:n.store(i,{sid:"sid3ut"})?i.map((e=>r=>e===r),{skipVoid:!1}):e=>e===i;var c=e({and:[a],or:{name:"$values",sid:"rwb5jx"}});return e({and:[o,c,(e,r)=>r.every(e),{skipVoid:!1}],or:{sid:"hgnz2z"}})}function ee(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),o=1;o<n;o++)t[o-1]=arguments[o];return e({and:[t,e=>r.reduce(((n,t,o)=>n.concat(ne(r,o)?t:"".concat(t).concat(re(e[o])))),""),{skipVoid:!1}],or:{sid:"-yrbthp"}})}function re(e){return Array.isArray(e)?e.map((e=>String(e))).join(", "):String(e)}function ne(e,r){return r===e.length-1}function te(r){var{effects:n,domain:t}=r;if(t){var o=t.createStore(0,{name:"$inFlight",sid:"-y7vg7t"});return t.onCreateEffect((e=>{o.on(e,(e=>e+1)).on(e.finally,(e=>e-1))})),o}return e({and:[n.map((e=>e.inFlight)),e=>e.reduce(((e,r)=>e+r),0),{skipVoid:!1}],or:{sid:"ubqxa7"}})}function oe(e){var{timeout:t,start:i,stop:u,leading:s=!1,trailing:d=!1}=e,f=null!=i?i:r({name:"setup",sid:"-essz1d"}),l=null!=u?u:r({name:"teardown",sid:"sv95oj"}),m=r({name:"tick",sid:"-r3kxtw"}),p=o(!1,{name:"$isRunning",sid:"-jo5dgs"}),v=function(e){if(n.store(e,{sid:"81l3dz"}))return e;if("number"==typeof e)return o(e,{and:{name:"$timeout"},sid:"-xt76rp"});throw new TypeError('timeout parameter in interval method should be number or Store. "'.concat(typeof e,'" was passed'))}(t),g=p.map((e=>!e),{skipVoid:!1}),y=r({name:"saveTimeout",sid:"e3gpcx"}),h=o(null,{name:"$timeoutId",sid:"3759wd"}).on(y,((e,r)=>{var{timeoutId:n}=r;return n})),b=o((()=>{}),{name:"$rejecter",sid:"shnzo1"}).on(y,((e,r)=>{var{reject:n}=r;return n})),w=c({and:{source:{timeout:v,running:p},effect:e=>{var{timeout:r,running:n}=e;return n?new Promise(((e,n)=>{var t=setTimeout(e,r);y({timeoutId:t,reject:n})})):Promise.reject()}},or:{name:"timeoutFx",sid:"n7tmmy"}}),k=c({and:{source:{timeoutId:h,rejecter:b},effect:e=>{var{timeoutId:r,rejecter:n}=e;n(),r&&clearTimeout(r)}},or:{name:"cleanupFx",sid:"-h9rkrq"}});if(a({and:[{clock:f,source:v,filter:g,target:w}],or:{sid:"-v8qzb1"}}),s){var j=a({and:[{clock:f,filter:g}],or:{name:"onReady",sid:"13etu6"}});a({and:[{clock:j,target:m}],or:{sid:"-us95gh"}})}return a({and:[{clock:f,fn:()=>!0,target:p}],or:{sid:"-uqlrq4"}}),a({and:[{clock:w.done,source:v,filter:p,target:w}],or:{sid:"-ubrbpd"}}),a({and:[{clock:w.done,filter:p,target:m.prepend((()=>{}))}],or:{sid:"6k91qi"}}),d&&a({and:[{clock:l,target:m}],or:{sid:"6p774h"}}),p.on(l,(()=>!1)),a({and:[{clock:l,target:k}],or:{sid:"7558a8"}}),{tick:m,isRunning:p,"@@trigger":()=>({setup:f,teardown:l,fired:m})}}function ae(e){return e.map((e=>!e),{skipVoid:!1})}function ie(e){var r,t;n.unit(e)?r=e:({source:r,reset:t}=e);var i=o(!0,{name:"$canTrigger",sid:"ys2jl0"}),c=a({and:[{source:r,filter:i}],or:{name:"trigger",sid:"e3xto3"}});return i.on(c,(()=>!1)),t&&i.reset(t),c}function ce(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];return e({and:[n,e=>{for(var r of e)if(r)return!0;return!1},{skipVoid:!1}],or:{sid:"-44722k"}})}var ue={some:e=>e.some(Boolean),every:e=>e.every(Boolean)};function se(r){var{effects:t,domain:o,of:a="some"}=r;if(!n.domain(o,{sid:"97b92c"})&&!t)throw new TypeError("domain or effects should be passed");if("some"!==a&&"every"!==a)throw new TypeError('strategy parameter "of" can be "every" or "some". Passed: "'.concat(a,'"'));var i=null!=t?t:[],c=ue[a];return o&&(i=[],o.onCreateEffect((e=>i.push(e)))),e({and:[i.map((e=>e.pending)),c,{skipVoid:!1}],or:{sid:"a37bj0"}})}function de(e){var{clock:n,target:t}=e,o=Array.isArray(t)?t:[t],a=Array.isArray(n)?n:[null!=n?n:r({name:"clocks",sid:"bqmea5"})];return o.forEach((e=>{e.reset(a)})),void 0===n?a[0]:void 0}function fe(e){var{source:r,shape:n}=e,t={},o=function(e){if(!Object.prototype.hasOwnProperty.call(n,e))return"continue";var o=n[e];t[e]=r.map((e=>{var r=o(e);return void 0===r?null:r}),{skipVoid:!1})};for(var a in n)o(a);return t}function le(e){var{source:r,clock:n,fn:t=(e=>e)}=e,i=t(r.defaultState),c=a(n?{and:[{source:r,clock:n,fn:t}],or:{name:"onSnapshot",sid:"-imuiws"}}:{and:[{source:r,fn:t}],or:{name:"onSnapshot",sid:"-imaqbf"}}),u=o(i,{name:"$snapshot",sid:"-63s6pn"});return u.on(c,((e,r)=>r)),u}function me(r,t){var o,a=[],i=()=>!1;Array.isArray(r)?(a=r,i=t):Array.isArray(r.stores)&&(a=r.stores,i=r.predicate),o="function"==typeof i?i:n.store(i,{sid:"zbwu0l"})?i.map((e=>r=>e===r),{skipVoid:!1}):e=>e===i;var c=e({and:[a],or:{name:"$values",sid:"-kx24vm"}});return e({and:[o,c,(e,r)=>r.some(e),{skipVoid:!1}],or:{sid:"-ee8kph"}})}function pe(e){var{source:r,cases:t}=e,o={},a=n.store(r,{name:"current",sid:"-htjkz7"})?r.updates:r;for(var i in t)i in t&&function(){var e=t[i];o[i]=a.filterMap(e),a=a.filter({fn:r=>!e(r)})}();return o.__=a,o}var ve={}.hasOwnProperty;function ge(e){var{targets:n,source:t=r({name:"source",sid:"-fkbi3c"},{name:"source",sid:"-fkbi3c"})}=e,o=function(e){if(i=n,c=e,ve.call(i,c)){var r=n[e],o=a({and:[{source:t,batch:!1,filter:r=>"object"==typeof r&&null!==r&&e in r}],or:{name:"hasTargetKey",sid:"-cov4g4"}});a({and:[{batch:!1,clock:o,fn:r=>r[e],target:r}],or:{sid:"lpn34j"}})}var i,c};for(var i in n)o(i);return t}function ye(e){var{effect:r,defaultValue:n="initial"}=e,t=o(n,{name:"$status",sid:"abrgim"});return t.on(r,(()=>"pending")).on(r.done,(()=>"done")).on(r.fail,(()=>"fail")),t}function he(e){var{source:t,timeout:i,target:c=r({name:"target",sid:"r328r6"},{name:"target",sid:"r328r6"})}=e;if(!n.unit(t))throw new TypeError("source must be unit from effector");var u=function(e){if(n.store(e,{sid:"-gzqwle"}))return e;if("number"==typeof e){if(e<0||!Number.isFinite(e))throw new Error('timeout must be positive number or zero. Received: "'.concat(e,'"'));return o(e,{and:{name:"$timeout"},sid:"-gs60mt"})}throw new TypeError('timeout parameter should be number or Store. "'.concat(typeof e,'" was passed'))}(i),s=l({name:"throttle(".concat(t.shortName||t.kind,") effect"),handler:e=>new Promise((r=>setTimeout(r,e)))},{name:"timerFx",sid:"-pyjx8k"}),d=o(null,{and:{serialize:"ignore",skipVoid:!1},name:"$payload",sid:"hzp5u0"}).on(t,((e,r)=>r)),f=r({name:"triggerTick",sid:"-ry76an"}),m=o(!0,{and:{serialize:"ignore"},name:"$canTick",sid:"-4yqc5"}).on(f,(()=>!1)).on(c,(()=>!0));return a({and:[{clock:t,filter:m,target:f}],or:{sid:"-hyxqny"}}),a({and:[{source:u,clock:f,target:s}],or:{sid:"-hk3an7"}}),a({and:[{source:d,clock:s.done,target:c}],or:{sid:"-hgsj31"}}),c}var be=()=>Date.now();function we(e){var{clock:r,getNow:n,initial:t}=e,o=null!=n?n:be,i=l(o,{name:"readNowFx",sid:"53d7kp"}),c=m(i,null!=t?t:o(),{name:"$time",sid:"-xu6mk0"});return a({and:[{clock:r,target:i}],or:{sid:"remzgl"}}),c}export{p as and,y as combineEvents,b as condition,k as debounce,P as debug,U as delay,W as either,X as empty,Y as equals,Z as every,ee as format,te as inFlight,oe as interval,ae as not,ie as once,ce as or,se as pending,de as reset,fe as reshape,le as snapshot,me as some,pe as splitMap,ge as spread,ye as status,he as throttle,we as time}; | ||
import{combine as e,createEvent as r,is as t,withRegion as n,createStore as o,sample as i,split as a,attach as c,merge as u,createNode as s,step as d,clearNode as f,createEffect as l,launch as m,restore as p}from"effector";function v(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return e({and:[t,e=>{for(var r of e)if(!r)return!1;return!0},{skipVoid:!1}],or:{sid:"-rbm5ks"}})}function g(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function y(e,r,t){return(r=function(e){var r=function(e,r){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==typeof r?r:String(r)}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function h(e){var a=function(e){return Object.keys(e).some((r=>!["events","reset","target"].includes(r)&&t.unit(e[r])))}(e)?{events:e}:e,{events:c,reset:u,target:s=r({name:"target",sid:"p73fff"})}=a;return t.unit(s)&&t.targetable(s)||b("target should be a targetable unit"),u&&!t.unit(u)&&b("reset should be a unit"),n(s,(()=>{var e=Object.keys(c),r=Array.isArray(c)?[...e].fill(""):{},t=o(e.length,{and:{serialize:"ignore"},name:"$counter",sid:"-ahoahx"}),n=o(r,{and:{serialize:"ignore"},name:"$results",sid:"oy8iyn"});i({and:[{source:s,target:t.reinit}],or:{sid:"blex0c"}}),n.reset(s),u&&(i({and:[{source:u,target:t.reinit}],or:{sid:"bnm3fi"}}),n.reset(u));var a=function(e){var r=o(!1,{and:{serialize:"ignore"},name:"$isDone",sid:"-rf2fac"}).on(c[e],(()=>!0)).reset(s);u&&r.reset(u),t.on(r,(e=>e-1)),n.on(c[e],((r,t)=>{var n=Array.isArray(r)?[...r]:function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?g(Object(t),!0).forEach((function(r){y(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):g(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}({},r);return n[e]=t,n}))};for(var d of e)a(d);var f=i({and:[{source:n,clock:[...Object.values(c)]}],or:{name:"eventsTrriggered",sid:"-lro8bq"}});i({and:[{source:f,filter:t.map((e=>0===e),{skipVoid:!1}),target:s}],or:{sid:"-dlkr2s"}})})),s}function b(e){throw new Error(e)}function w(e){var{if:n,then:o,else:c,source:u=r({name:"source",sid:"tdyoa4"},{name:"source",sid:"tdyoa4"})}=e,s=t.unit(n)||"function"==typeof n?n:e=>e===n;return o&&c?a({and:[{source:u,match:{then:s,else:k(s)},cases:{then:o,else:c}}],or:{sid:"aaw2hr"}}):o?i({and:[{source:u,filter:s,target:o}],or:{sid:"-dwrmbb"}}):c&&i({and:[{source:u,filter:k(s),target:c}],or:{sid:"-dsx25s"}}),u}function k(e){return t.unit(e)?e.map((e=>!e),{skipVoid:!1}):r=>!e(r)}function j(){var e,n=2===arguments.length?{source:arguments.length<=0?void 0:arguments[0],timeout:arguments.length<=1?void 0:arguments[1]}:arguments.length<=0?void 0:arguments[0],{source:a,timeout:s,target:d,name:f}=n;if(!t.unit(a))throw new TypeError("source must be unit from effector");if(t.domain(a,{sid:"jsc7s2"}))throw new TypeError("source cannot be domain");var l=O(s),m=r({name:"saveCancel",sid:"-kec0n3"}),p=o([],{and:{serialize:"ignore"},name:"$canceller",sid:"-tfm9fg"}).on(m,((e,r)=>r)),v=null!==(e=d)&&void 0!==e?e:r({name:"tick",sid:"-50e2rn"}),g=c({and:{name:f||"debounce(".concat((null==a?void 0:a.shortName)||a.kind,") effect"),source:p,effect(e,r){var[t,n]=e;return t&&clearTimeout(t),n&&n(),new Promise(((e,t)=>{m([setTimeout(e,r),t])}))}},or:{name:"timerFx",sid:"-jwso4j"}});p.reset(g.done);var y=o([],{and:{serialize:"ignore",skipVoid:!1},name:"$payload",sid:"-x9cllg"}).on(a,((e,r)=>[r])),h=o(!0,{and:{serialize:"ignore"},name:"$canTick",sid:"8r2952"}),b=r({name:"triggerTick",sid:"-781myl"});h.on(b,(()=>!1)).on([v,l,g],(()=>!0));var w=u([a,i({and:[{clock:l,filter:g.pending}],or:{name:"requestTick",sid:"-khrpxp"}})],{name:"requestTick",sid:"2k0852"});return i({and:[{clock:w,filter:h,target:b}],or:{sid:"-31h8q8"}}),i({and:[{source:l,clock:b,target:g}],or:{sid:"-2y6h62"}}),i({and:[{source:y,clock:g.done,fn:e=>{var[r]=e;return r},target:v}],or:{sid:"-2jc15b"}}),v}function O(e){if(t.store(e,{sid:"-21qm2b"}))return e;if("number"==typeof e){if(e<0||!Number.isFinite(e))throw new Error('timeout must be positive number or zero. Received: "'.concat(e,'"'));return o(e,{and:{name:"$timeout"},sid:"kbepy4"})}throw new TypeError('timeout parameter in interval method should be number or Store. "'.concat(typeof e,'" was passed'))}function E(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function T(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?E(Object(t),!0).forEach((function(r){P(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):E(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function P(e,r,t){return(r=function(e){var r=function(e,r){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==typeof r?r:String(r)}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var A={trace:!1,handler:e=>{if(!B(e.node)||"finally"!==e.node.meta.named){var{scope:r,scopeName:t,name:n,kind:o,value:i,loc:a,trace:c,node:u,logType:s}=e,d=r?" (scope: ".concat(t,")"):"",f=null!=n?n:a?"".concat(a.file,":").concat(a.line,":").concat(a.column):"",l="initial"===s?" [getState]":"";console.info("[".concat(o,"]").concat(d," ").concat(f).concat(l),i),c&&c.length>0&&!B(u)&&(console.groupCollapsed("[".concat(o,"]").concat(d," ").concat(f," trace")),c.forEach((e=>{var{name:r,kind:t,value:n,loc:o}=e,i=null!=r?r:o?"".concat(o.file,":").concat(o.line,":").concat(o.column):"";console.info("<- [".concat(t,"] ").concat(i),n)})),console.groupEnd())}}};function S(){var{config:e,units:r}=N(...arguments);r.forEach((r=>{t.store(r,{sid:"-foynff"})||t.event(r,{sid:"apy28p"})||t.effect(r,{sid:"apy3od"})?x(r,e):t.domain(r,{sid:"-rsqe9t"})&&z(r,e)}))}function z(e,r){e.onCreateStore((e=>x(e,r))),e.onCreateEvent((e=>x(e,r))),e.onCreateEffect((e=>x(e,r))),e.onCreateDomain((e=>z(e,r)))}function x(e,r){t.store(e,{sid:"w7ds2s"})?(!function(e,r){if(!r.handler)throw Error("patronum/debug must have the handler");var t={logType:"initial",scope:null,scopeName:null,node:U(e),kind:K(e),value:e.getState(),name:J(e),loc:Q(e),trace:[],stackMeta:{}};r.handler(t),R.forEach((t=>q(e,r,t))),C((t=>q(e,r,t)))}(e,r),V(e,r)):t.event(e,{sid:"fretyd"})?V(e,r):t.effect(e,{sid:"gpi2qr"})&&(V(e,r),V(e.finally,r),V(e.done,r),V(e.fail,r))}function V(e,r){var t=s({parent:[e],meta:{op:"watch"},family:{owners:e},regional:!0,node:[d.run({fn(t,n,o){var i,a=null!==(i=null==o?void 0:o.scope)&&void 0!==i?i:null,c={logType:"update",scope:a,scopeName:_(a),node:U(e),kind:K(e),value:t,name:J(e),loc:Q(e),stackMeta:W(o.parent),trace:r.trace?$(o):[]};if(!r.handler)throw Error("patronum/debug must have the handler");r.handler(c)}})]});return()=>f(t)}function $(e){for(var r=[],t=null==e?void 0:e.parent;t;){var{node:n,value:o}=t,i={node:n,value:o,name:J(n),loc:Q(n),kind:K(n),stackMeta:W(t)};r.push(i),t=t.parent}return r}function q(e,r,t){if(!r.handler)throw Error("patronum/debug must have the handler");var n=U(e),o={logType:"initial",scope:t,scopeName:_(t),node:n,kind:K(e),value:t.getState(e),name:J(e),loc:Q(e),trace:[],stackMeta:{}};r.handler(o)}function N(){for(var e=A,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];var[i,...a]=n,c=[];if(D(i))e=T(T({},A),i);else if(t.unit(i))c.push(i);else for(var[u,s]of Object.entries(i))H.set(G(s).id,u),c.push(s);for(var d of a)if(t.unit(d))c.push(d);else for(var[f,l]of Object.entries(d))H.set(G(l).id,f),c.push(l);return{config:e,units:c}}function D(e){return!t.unit(e)&&!Object.values(e).every(t.unit)}var F=new Set,C=e=>(F.add(e),()=>{F.delete(e)});var I=0;var M=new Map,R={save(e,r){R.get(e)||M.set(e,r)},get(e){var r;return e&&null!==(r=M.get(e))&&void 0!==r?r:null},delete(e){M.delete(e)},forEach(e){M.forEach(((r,t)=>e(t,r)))},clear(){M.clear()}};function _(e){if(!e)return null;var r=R.get(e);return r?r.name:e._debugId||(e._debugId="unknown_".concat(I+=1))}function B(e){var r=U(e),{sid:t,named:n}=r.meta;return Boolean(!t&&("finally"===n||"done"===n||"doneData"===n||"fail"===n||"failData"===n||"inFlight"===n||"pending"===n))}function K(e){if(t.store(e,{sid:"4o7s04"}))return"store";if(t.effect(e,{sid:"4pv5s7"})||B(e))return"effect";if(t.event(e,{sid:"4rijka"}))return"event";if(t.domain(e,{sid:"54plsy"}))return"domain";if(t.unit(e))return"unit";var r=U(e);return r.meta.op?r.meta.op:"unknown"}S.registerScope=function(e,r){return R.save(e,{name:r.name}),F.forEach((r=>r(e))),()=>{R.delete(e)}},S.unregisterAllScopes=function(){R.clear()};var G=e=>e.graphite||e,H=new Map;function J(e){var r,n,o=H.get(G(e).id);if(o)return o;if(B(e)){var i=U(e),a=i.family.owners.find((e=>"effect"===e.meta.op));if(a){var c=L(a),u=c?"".concat(c,"/"):"";return"".concat(u).concat(J(a),".").concat(i.meta.named)}return i.meta.named}if(function(e){var r=U(e),{op:t}=r.meta;return"on"===t}(e)){var s=U(e),d=J(s.next[0]),f=J(s.family.owners[0]);return"".concat(d,".on(").concat(f,")")}if(t.unit(e)){var l;if(null!=e&&null!==(l=e.compositeName)&&void 0!==l&&l.fullName)return e.compositeName.fullName;var m=L(e),p=m?"".concat(m,"/"):"";if(null!=e&&e.shortName)return"".concat(p).concat(e.shortName);if(null!=e&&e.name)return"".concat(p).concat(e.name)}return null!==(r=U(e))&&void 0!==r&&null!==(n=r.meta)&&void 0!==n&&n.name?U(e).meta.name:null}function L(e){var r=U(e).family.owners.find((e=>"domain"===e.meta.op));return r?J(r):null}function Q(e){var r=function(e){var{meta:r}=e;return"config"in r?r.config.loc:r.loc}(U(e));if(r)return r}function U(e){return"graphite"in e?e.graphite:e}function W(e){return e&&e.meta||{}}function X(){var n=2===arguments.length?{source:arguments.length<=0?void 0:arguments[0],timeout:arguments.length<=1?void 0:arguments[1]}:arguments.length<=0?void 0:arguments[0],{source:o,timeout:a,target:c=r({name:"target",sid:"jucb8d"})}=n,u=Array.isArray(c)?c:[c];if(!t.unit(o))throw new TypeError("source must be a unit from effector");if(!u.every((e=>t.unit(e))))throw new TypeError("target must be a unit from effector");var s=Y(a),d=l((e=>{var{payload:r,milliseconds:t}=e;return new Promise((e=>{setTimeout(e,t,r)}))}),{name:"timerFx",sid:"-wp3hwr"});return i({and:[{source:e({and:[{milliseconds:s}],or:{name:"source",sid:"-gaikyz"}}),clock:o,fn:(e,r)=>{var{milliseconds:t}=e;return{payload:r,milliseconds:"function"==typeof t?t(r):t}},target:d}],or:{sid:"-uuqxfw"}}),i({and:[{clock:d.doneData,target:u}],or:{sid:"-uc1x9m"}}),c}function Y(e){if(t.store(e,{sid:"-tvk3f2"})||"function"==typeof e||"number"==typeof e)return e;throw new TypeError("'timeout' argument must be a function, Store, or a number. Passed \"".concat(typeof e,'"'))}function Z(r,n,o){if(t.store(r,{sid:"ozzvoc"}))return e({and:[r,n,o,(e,r,t)=>e?r:t,{skipVoid:!1}],or:{sid:"-5vau2h"}});var i=r;return Z(i.filter,i.then,i.other)}function ee(e){return e.map((e=>null==e),{skipVoid:!1})}function re(r,t){return e({and:[r,t,(e,r)=>e===r,{skipVoid:!1}],or:{sid:"-pqjlti"}})}function te(r,n){var o,i=[],a=()=>!1;Array.isArray(r)?(i=r,a=n):Array.isArray(r.stores)&&(i=r.stores,a=r.predicate),o="function"==typeof a?a:t.store(a,{sid:"sid3ut"})?a.map((e=>r=>e===r),{skipVoid:!1}):e=>e===a;var c=e({and:[i],or:{name:"$values",sid:"rwb5jx"}});return e({and:[o,c,(e,r)=>r.every(e),{skipVoid:!1}],or:{sid:"hgnz2z"}})}function ne(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return e({and:[n,e=>r.reduce(((t,n,o)=>t.concat(ie(r,o)?n:"".concat(n).concat(oe(e[o])))),""),{skipVoid:!1}],or:{sid:"-yrbthp"}})}function oe(e){return Array.isArray(e)?e.map((e=>String(e))).join(", "):String(e)}function ie(e,r){return r===e.length-1}function ae(r){var t=Array.isArray(r)?{effects:r}:r,{effects:n,domain:o}=t;if(o){var i=o.createStore(0,{name:"$inFlight",sid:"-wboyn1"});return o.onCreateEffect((e=>{i.on(e,(e=>e+1)).on(e.finally,(e=>e-1))})),i}return e({and:[n.map((e=>e.inFlight)),e=>e.reduce(((e,r)=>e+r),0),{skipVoid:!1}],or:{sid:"udy3nn"}})}function ce(e){var{timeout:n,start:a,stop:u,leading:s=!1,trailing:d=!1}=e,f=null!=a?a:r({name:"setup",sid:"-essz1d"}),l=null!=u?u:r({name:"teardown",sid:"sv95oj"}),m=r({name:"tick",sid:"-r3kxtw"}),p=o(!1,{name:"$isRunning",sid:"-jo5dgs"}),v=function(e){if(t.store(e,{sid:"81l3dz"}))return e;if("number"==typeof e)return o(e,{and:{name:"$timeout"},sid:"-xt76rp"});throw new TypeError('timeout parameter in interval method should be number or Store. "'.concat(typeof e,'" was passed'))}(n),g=p.map((e=>!e),{skipVoid:!1}),y=r({name:"saveTimeout",sid:"e3gpcx"}),h=o(null,{name:"$timeoutId",sid:"3759wd"}).on(y,((e,r)=>{var{timeoutId:t}=r;return t})),b=o((()=>{}),{name:"$rejecter",sid:"shnzo1"}).on(y,((e,r)=>{var{reject:t}=r;return t})),w=c({and:{source:{timeout:v,running:p},effect:e=>{var{timeout:r,running:t}=e;return t?new Promise(((e,t)=>{var n=setTimeout(e,r);y({timeoutId:n,reject:t})})):Promise.reject()}},or:{name:"timeoutFx",sid:"n7tmmy"}}),k=c({and:{source:{timeoutId:h,rejecter:b},effect:e=>{var{timeoutId:r,rejecter:t}=e;t(),r&&clearTimeout(r)}},or:{name:"cleanupFx",sid:"-h9rkrq"}});if(i({and:[{clock:f,source:v,filter:g,target:w}],or:{sid:"-v8qzb1"}}),s){var j=i({and:[{clock:f,filter:g}],or:{name:"onReady",sid:"13etu6"}});i({and:[{clock:j,target:m}],or:{sid:"-us95gh"}})}return i({and:[{clock:f,fn:()=>!0,target:p}],or:{sid:"-uqlrq4"}}),i({and:[{clock:w.done,source:v,filter:p,target:w}],or:{sid:"-ubrbpd"}}),i({and:[{clock:w.done,filter:p,target:m.prepend((()=>{}))}],or:{sid:"6k91qi"}}),d&&i({and:[{clock:l,target:m}],or:{sid:"6p774h"}}),p.on(l,(()=>!1)),i({and:[{clock:l,target:k}],or:{sid:"7558a8"}}),{tick:m,isRunning:p,"@@trigger":()=>({setup:f,teardown:l,fired:m})}}function ue(e){return e.map((e=>!e),{skipVoid:!1})}function se(e){var r,n;t.unit(e)?r=e:({source:r,reset:n}=e);var a=o(!0,{name:"$canTrigger",sid:"ys2jl0"}),c=i({and:[{source:r,filter:a}],or:{name:"trigger",sid:"e3xto3"}});return a.on(c,(()=>!1)),n&&a.reset(n),c}function de(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return e({and:[t,e=>{for(var r of e)if(r)return!0;return!1},{skipVoid:!1}],or:{sid:"-44722k"}})}var fe={some:e=>e.some(Boolean),every:e=>e.every(Boolean)};function le(r){var n=Array.isArray(r)?{effects:r}:r,{effects:o,domain:i,of:a="some"}=n;if(!t.domain(i,{sid:"98ymuf"})&&!o)throw new TypeError("domain or effects should be passed");if("some"!==a&&"every"!==a)throw new TypeError('strategy parameter "of" can be "every" or "some". Passed: "'.concat(a,'"'));var c=null!=o?o:[],u=fe[a];return i&&(c=[],i.onCreateEffect((e=>c.push(e)))),e({and:[c.map((e=>e.pending)),u,{skipVoid:!1}],or:{sid:"a4upb3"}})}function me(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var[i]=r,a=r.length<2?null:r[1];if(!t.store(i,{sid:"mzq5dc"}))throw Error("previous first argument should be a store");var c=o(a,{and:{serialize:"ignore",skipVoid:!1},name:"$prevValue",sid:"e05yob"}),u=i.graphite;return u.seq.push(d.compute({fn:(e,r,t)=>(m({target:c,params:t.a,defer:!0}),e)})),c}function pe(e){var{clock:t,target:n}=e,o=Array.isArray(n)?n:[n],i=Array.isArray(t)?t:[null!=t?t:r({name:"clocks",sid:"bqmea5"})];return o.forEach((e=>{e.reset(i)})),void 0===t?i[0]:void 0}function ve(e){var{source:r,shape:t}=e,n={},o=function(e){if(!Object.prototype.hasOwnProperty.call(t,e))return"continue";var o=t[e];n[e]=r.map((e=>{var r=o(e);return void 0===r?null:r}),{skipVoid:!1})};for(var i in t)o(i);return n}function ge(e){var{source:r,clock:t,fn:n=(e=>e)}=e,a=n(r.defaultState),c=i(t?{and:[{source:r,clock:t,fn:n}],or:{name:"onSnapshot",sid:"-imuiws"}}:{and:[{source:r,fn:n}],or:{name:"onSnapshot",sid:"-imaqbf"}}),u=o(a,{name:"$snapshot",sid:"-63s6pn"});return u.on(c,((e,r)=>r)),u}function ye(r,n){var o,i=[],a=()=>!1;Array.isArray(r)?(i=r,a=n):Array.isArray(r.stores)&&(i=r.stores,a=r.predicate),o="function"==typeof a?a:t.store(a,{sid:"zbwu0l"})?a.map((e=>r=>e===r),{skipVoid:!1}):e=>e===a;var c=e({and:[i],or:{name:"$values",sid:"-kx24vm"}});return e({and:[o,c,(e,r)=>r.some(e),{skipVoid:!1}],or:{sid:"-ee8kph"}})}function he(e){var{source:r,cases:n}=e,o={},i=t.store(r,{name:"current",sid:"-htjkz7"})?r.updates:r;for(var a in n)a in n&&function(){var e=n[a];o[a]=i.filterMap(e),i=i.filter({fn:r=>!e(r)})}();return o.__=i,o}var be={}.hasOwnProperty;function we(e){var n=function(e){return Object.keys(e).some((r=>!["targets","source"].includes(r)&&t.unit(e[r])))}(e)?{targets:e}:e,{targets:o,source:a=r({name:"source",sid:"e9ipnn"})}=n,c=function(e){if(n=o,c=e,be.call(n,c)){var r=o[e],t=i({and:[{source:a,batch:!1,filter:r=>"object"==typeof r&&null!==r&&e in r}],or:{name:"hasTargetKey",sid:"eapc0z"}});i({and:[{batch:!1,clock:t,fn:r=>r[e],target:r}],or:{sid:"mkzcy4"}})}var n,c};for(var u in o)c(u);return a}function ke(e){var{effect:r,defaultValue:n="initial"}=t.effect(e,{sid:"cn6w5b"})?{effect:e}:e,i=o(n,{name:"$status",sid:"ph7d4u"});if(!t.effect(r,{sid:"-kp39vu"}))throw TypeError('status: "effect" property is not an effect');return i.on(r,(()=>"pending")).on(r.done,(()=>"done")).on(r.fail,(()=>"fail")),i}function je(){var e=2===arguments.length?{source:arguments.length<=0?void 0:arguments[0],timeout:arguments.length<=1?void 0:arguments[1]}:arguments.length<=0?void 0:arguments[0],{source:n,timeout:a,target:c=r({name:"target",sid:"-gyhb56"})}=e;if(!t.unit(n))throw new TypeError("source must be unit from effector");var u=Oe(a),s=l({name:"throttle(".concat(n.shortName||n.kind,") effect"),handler:e=>new Promise((r=>setTimeout(r,e)))},{name:"timerFx",sid:"-lp5bot"}),d=o(null,{and:{serialize:"ignore",skipVoid:!1},name:"$payload",sid:"w71tnu"}).on(n,((e,r)=>r)),f=r({name:"triggerTick",sid:"-dquigt"}),m=o(!0,{and:{serialize:"ignore"},name:"$canTick",sid:"e2dxhp"}).on(f,(()=>!1)).on(c,(()=>!0));return i({and:[{clock:n,filter:m,target:f}],or:{sid:"-hifwv4"}}),i({and:[{source:u,clock:f,target:s}],or:{sid:"-h3lgud"}}),i({and:[{source:d,clock:s.done,target:c}],or:{sid:"-h0apa7"}}),c}function Oe(e){if(t.store(e,{sid:"-gj92sk"}))return e;if("number"==typeof e){if(e<0||!Number.isFinite(e))throw new Error('timeout must be positive number or zero. Received: "'.concat(e,'"'));return o(e,{and:{name:"$timeout"},sid:"-2ktcsz"})}throw new TypeError('timeout parameter should be number or Store. "'.concat(typeof e,'" was passed'))}var Ee=()=>Date.now();function Te(e){var r=t.unit(e)?{clock:e}:e,{clock:n,getNow:o,initial:a}=r,c=null!=o?o:Ee,u=l(c,{name:"readNowFx",sid:"ito90c"}),s=p(u,null!=a?a:c(),{name:"$time",sid:"-k3vl4d"});return i({and:[{clock:n,target:u}],or:{sid:"rul0o2"}}),s}export{v as and,h as combineEvents,w as condition,j as debounce,S as debug,X as delay,Z as either,ee as empty,re as equals,te as every,ne as format,ae as inFlight,ce as interval,ue as not,se as once,de as or,le as pending,me as previous,pe as reset,ve as reshape,ge as snapshot,ye as some,he as splitMap,we as spread,ke as status,je as throttle,Te as time}; | ||
//# sourceMappingURL=patronum.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("effector")):"function"==typeof define&&define.amd?define(["exports","effector"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).patronum={},e.effector)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(t);function o(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}var a=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.and=function(...e){return(0,r.default.combine)({and:[e,e=>{for(const t of e)if(!t)return!1;return!0},{skipVoid:!1}],or:{sid:"-rbm5ks"}})}})),i=o((function(e,t){function n(e){throw new Error(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.combineEvents=function({events:e,reset:t,target:o=(0,r.default.createEvent)({name:"target",sid:"aip3nf"})}){r.default.is.unit(o)&&r.default.is.targetable(o)||n("target should be a targetable unit");t&&!r.default.is.unit(t)&&n("reset should be a unit");return(0,r.default.withRegion)(o,(()=>{const n=Object.keys(e),a=Array.isArray(e)?[...n].fill(""):{},i=(0,r.default.createStore)(n.length,{and:{serialize:"ignore"},name:"$counter",sid:"-cuwegw"}),s=(0,r.default.createStore)(a,{and:{serialize:"ignore"},name:"$results",sid:"cn2cpl"});i.reset((0,r.default.sample)({and:[{source:o}],or:{sid:"-80w3us"}})),s.reset(o),t&&(i.reset((0,r.default.sample)({and:[{source:t}],or:{sid:"3t8gjw"}})),s.reset(t));for(const a of n){const n=(0,r.default.createStore)(!1,{and:{serialize:"ignore"},name:"$isDone",sid:"vavgfq"}).on(e[a],(()=>!0)).reset(o);t&&n.reset(t),i.on(n,(e=>e-1)),s.on(e[a],((e,t)=>{const n=Array.isArray(e)?[...e]:{...e};return n[a]=t,n}))}const u=(0,r.default.sample)({and:[{source:s,clock:[...Object.values(e)]}],or:{name:"eventsTrriggered",sid:"-o4wcap"}});(0,r.default.sample)({and:[{source:u,filter:i.map((e=>0===e),{skipVoid:!1}),target:o}],or:{sid:"cm94rj"}})})),o}})),s=o((function(e,t){function n(e){return r.default.is.unit(e)?e.map((e=>!e),{skipVoid:!1}):t=>!e(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.condition=function({if:e,then:t,else:o,source:a=(0,r.default.createEvent)({name:"source",sid:"tdyoa4"})}){const i=r.default.is.unit(e)||(s=e,"function"==typeof s)?e:t=>t===e;var s;t&&o?(0,r.default.split)({and:[{source:a,match:{then:i,else:n(i)},cases:{then:t,else:o}}],or:{sid:"aaw2hr"}}):t?(0,r.default.sample)({and:[{source:a,filter:i,target:t}],or:{sid:"-dwrmbb"}}):o&&(0,r.default.sample)({and:[{source:a,filter:n(i),target:o}],or:{sid:"-dsx25s"}});return a}})),u=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=function({source:e,timeout:t,target:n,name:o}){var a;if(!r.default.is.unit(e))throw new TypeError("source must be unit from effector");if(r.default.is.domain(e,{sid:"johnmj"}))throw new TypeError("source cannot be domain");const i=function(e){if(r.default.is.store(e,{sid:"-24hl14"}))return e;if("number"==typeof e){if(e<0||!Number.isFinite(e))throw new Error(`timeout must be positive number or zero. Received: "${e}"`);return(0,r.default.createStore)(e,{and:{name:"$timeout"},sid:"808jp2"})}throw new TypeError(`timeout parameter in interval method should be number or Store. "${typeof e}" was passed`)}(t),s=(0,r.default.createEvent)({name:"saveCancel",sid:"-xnlfoj"}),u=(0,r.default.createStore)([],{and:{serialize:"ignore"},name:"$canceller",sid:"sc8di8"}).on(s,((e,t)=>t)),d=null!==(a=n)&&void 0!==a?a:(0,r.default.createEvent)({name:"tick",sid:"-8sr1x7"}),l=(0,r.default.attach)({and:{name:o||`debounce(${e?.shortName||e.kind}) effect`,source:u,effect:([e,t],n)=>(e&&clearTimeout(e),t&&t(),new Promise(((e,t)=>{s([setTimeout(e,n),t])})))},or:{name:"timerFx",sid:"-xn3pk6"}});u.reset(l.done);const c=(0,r.default.createStore)([],{and:{serialize:"ignore",skipVoid:!1},name:"$payload",sid:"pgla4m"}).on(e,((e,t)=>[t])),f=(0,r.default.createStore)(!0,{and:{serialize:"ignore"},name:"$canTick",sid:"6du563"}),m=(0,r.default.createEvent)({name:"triggerTick",sid:"-jj7t7n"});f.on(m,(()=>!1)).on([d,i,l],(()=>!0));const p=(0,r.default.merge)([e,(0,r.default.sample)({and:[{clock:i,filter:l.pending}],or:{name:"requestTick",sid:"-kkiowi"}})],{name:"requestTick",sid:"6s463"});return(0,r.default.sample)({and:[{clock:p,filter:f,target:m}],or:{sid:"m4gqgv"}}),(0,r.default.sample)({and:[{source:i,clock:m,target:l}],or:{sid:"-30xg4v"}}),(0,r.default.sample)({and:[{source:c,clock:l.done,fn:([e])=>e,target:d}],or:{sid:"-2xmokp"}}),d}})),d=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.debug=o;const n={trace:!1,handler:e=>{if(y(e.node)&&"finally"===e.node.meta.named)return;const{scope:t,scopeName:n,name:r,kind:o,value:a,loc:i,trace:s,node:u,logType:d}=e,l=t?` (scope: ${n})`:"",c=null!=r?r:i?`${i.file}:${i.line}:${i.column}`:"",f="initial"===d?" [getState]":"";console.info(`[${o}]${l} ${c}${f}`,a),s&&s.length>0&&!y(u)&&(console.groupCollapsed(`[${o}]${l} ${c} trace`),s.forEach((e=>{const{name:t,kind:n,value:r,loc:o}=e,a=null!=t?t:o?`${o.file}:${o.line}:${o.column}`:"";console.info(`<- [${n}] ${a}`,r)})),console.groupEnd())}};function o(...e){const{config:t,units:o}=function(...e){let t=n;const[o,...a]=e,i=[];if(function(e){if(!r.default.is.unit(e))return!Object.values(e).every(r.default.is.unit);return!1}(o))t={...n,...o};else if(r.default.is.unit(o))i.push(o);else for(const[e,t]of Object.entries(o))b.set(v(t).id,e),i.push(t);for(const e of a)if(r.default.is.unit(e))i.push(e);else for(const[t,n]of Object.entries(e))b.set(v(n).id,t),i.push(n);return{config:t,units:i}}(...e);o.forEach((e=>{r.default.is.store(e,{sid:"-foynff"})||r.default.is.event(e,{sid:"apy28p"})||r.default.is.effect(e,{sid:"apy3od"})?i(e,t):r.default.is.domain(e,{sid:"-rsqe9t"})&&a(e,t)}))}function a(e,t){e.onCreateStore((e=>i(e,t))),e.onCreateEvent((e=>i(e,t))),e.onCreateEffect((e=>i(e,t))),e.onCreateDomain((e=>a(e,t)))}function i(e,t){r.default.is.store(e,{sid:"w7ds2s"})?(!function(e,t){if(!t.handler)throw Error("patronum/debug must have the handler");const n={logType:"initial",scope:null,scopeName:null,node:$(e),kind:h(e),value:e.getState(),name:k(e),loc:j(e),trace:[],stackMeta:{}};t.handler(n),p.forEach((n=>d(e,t,n))),c((n=>d(e,t,n)))}(e,t),s(e,t)):r.default.is.event(e,{sid:"fretyd"})?s(e,t):r.default.is.effect(e,{sid:"gpi2qr"})&&(s(e,t),s(e.finally,t),s(e.done,t),s(e.fail,t))}function s(e,t){const n=(0,r.default.createNode)({parent:[e],meta:{op:"watch"},family:{owners:e},regional:!0,node:[r.default.step.run({fn(n,r,o){var a;const i=null!==(a=o?.scope)&&void 0!==a?a:null,s={logType:"update",scope:i,scopeName:g(i),node:$(e),kind:h(e),value:n,name:k(e),loc:j(e),stackMeta:_(o.parent),trace:t.trace?u(o):[]};if(!t.handler)throw Error("patronum/debug must have the handler");t.handler(s)}})]});return()=>(0,r.default.clearNode)(n)}function u(e){const t=[];let n=e?.parent;for(;n;){const{node:e,value:r}=n,o={node:e,value:r,name:k(e),loc:j(e),kind:h(e),stackMeta:_(n)};t.push(o),n=n.parent}return t}function d(e,t,n){if(!t.handler)throw Error("patronum/debug must have the handler");const r=$(e),o={logType:"initial",scope:n,scopeName:g(n),node:r,kind:h(e),value:n.getState(e),name:k(e),loc:j(e),trace:[],stackMeta:{}};t.handler(o)}const l=new Set,c=e=>(l.add(e),()=>{l.delete(e)});let f=0;const m=new Map,p={save(e,t){p.get(e)||m.set(e,t)},get(e){var t;return e&&null!==(t=m.get(e))&&void 0!==t?t:null},delete(e){m.delete(e)},forEach(e){m.forEach(((t,n)=>e(n,t)))},clear(){m.clear()}};function g(e){if(!e)return null;const t=p.get(e);if(!t){return e._debugId||(e._debugId=(f+=1,`unknown_${f}`))}return t.name}function y(e){const t=$(e),{sid:n,named:r}=t.meta;return Boolean(!n&&("finally"===r||"done"===r||"doneData"===r||"fail"===r||"failData"===r||"inFlight"===r||"pending"===r))}function h(e){if(r.default.is.store(e,{sid:"4o7s04"}))return"store";if(r.default.is.effect(e,{sid:"4pv5s7"})||y(e))return"effect";if(r.default.is.event(e,{sid:"4rijka"}))return"event";if(r.default.is.domain(e,{sid:"54plsy"}))return"domain";if(r.default.is.unit(e))return"unit";const t=$(e);return t.meta.op?t.meta.op:"unknown"}o.registerScope=function(e,t){return p.save(e,{name:t.name}),l.forEach((t=>t(e))),()=>{p.delete(e)}},o.unregisterAllScopes=function(){p.clear()};const v=e=>e.graphite||e,b=new Map;function k(e){const t=b.get(v(e).id);if(t)return t;if(y(e)){const t=$(e),n=t.family.owners.find((e=>"effect"===e.meta.op));if(n){const e=w(n);return`${e?`${e}/`:""}${k(n)}.${t.meta.named}`}return t.meta.named}if(function(e){const t=$(e),{op:n}=t.meta;return"on"===n}(e)){const t=$(e);return`${k(t.next[0])}.on(${k(t.family.owners[0])})`}if(r.default.is.unit(e)){if(e?.compositeName?.fullName)return e.compositeName.fullName;const t=w(e),n=t?`${t}/`:"";if(e?.shortName)return`${n}${e.shortName}`;if(e?.name)return`${n}${e.name}`}return $(e)?.meta?.name?$(e).meta.name:null}function w(e){const t=$(e).family.owners.find((e=>"domain"===e.meta.op));return t?k(t):null}function j(e){const t=function({meta:e}){return"config"in e?e.config.loc:e.loc}($(e));if(t)return t}function $(e){return"graphite"in e?e.graphite:e}function _(e){if(!e)return{};return e.meta||{}}})),l=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.delay=function({source:e,timeout:t,target:n=(0,r.default.createEvent)({name:"target",sid:"-7m9t8m"})}){const o=Array.isArray(n)?n:[n];if(!r.default.is.unit(e))throw new TypeError("source must be a unit from effector");if(!o.every((e=>r.default.is.unit(e))))throw new TypeError("target must be a unit from effector");const a=function(e){if(r.default.is.store(e,{sid:"-ud5iem"})||"function"==typeof e||"number"==typeof e)return e;throw new TypeError(`'timeout' argument must be a function, Store, or a number. Passed "${typeof e}"`)}(t),i=(0,r.default.createEffect)((({payload:e,milliseconds:t})=>new Promise((n=>{setTimeout(n,t,e)}))),{name:"timerFx",sid:"d8ml62"});return(0,r.default.sample)({and:[{source:(0,r.default.combine)({and:[{milliseconds:a}],or:{name:"source",sid:"-vfyhl7"}}),clock:e,fn:({milliseconds:e},t)=>({payload:t,milliseconds:"function"==typeof e?e(t):e}),target:i}],or:{sid:"-vnw0w1"}}),(0,r.default.sample)({and:[{clock:i.doneData,target:o}],or:{sid:"-utnc96"}}),n}})),c=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.either=function e(t,n,o){if(r.default.is.store(t,{sid:"ozzvoc"}))return(0,r.default.combine)({and:[t,n,o,(e,t,n)=>e?t:n,{skipVoid:!1}],or:{sid:"-5vau2h"}});const a=t;return e(a.filter,a.then,a.other)}})),f=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.empty=function(e){return e.map((e=>null==e),{skipVoid:!1})}})),m=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.equals=function(e,t){return(0,r.default.combine)({and:[e,t,(e,t)=>e===t,{skipVoid:!1}],or:{sid:"-pqjlti"}})}})),p=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.every=function(e,t){let n,o=[],a=()=>!1;Array.isArray(e)?(o=e,a=t):Array.isArray(e.stores)&&(o=e.stores,a=e.predicate);i=a,n="function"==typeof i?a:r.default.is.store(a,{sid:"sid3ut"})?a.map((e=>t=>e===t),{skipVoid:!1}):e=>e===a;var i;const s=(0,r.default.combine)({and:[o],or:{name:"$values",sid:"rwb5jx"}}),u=n;return(0,r.default.combine)({and:[u,s,(e,t)=>t.every(e),{skipVoid:!1}],or:{sid:"hgnz2z"}})}})),g=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.format=function(e,...t){return(0,r.default.combine)({and:[t,t=>e.reduce(((n,r,o)=>n.concat(function(e,t){return t===e.length-1}(e,o)?r:`${r}${function(e){if(Array.isArray(e))return e.map((e=>String(e))).join(", ");return String(e)}(t[o])}`)),""),{skipVoid:!1}],or:{sid:"-yrbthp"}})}})),y=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.inFlight=function({effects:e,domain:t}){if(t){const e=t.createStore(0,{name:"$inFlight",sid:"-y7vg7t"});return t.onCreateEffect((t=>{e.on(t,(e=>e+1)).on(t.finally,(e=>e-1))})),e}return(0,r.default.combine)({and:[e.map((e=>e.inFlight)),e=>e.reduce(((e,t)=>e+t),0),{skipVoid:!1}],or:{sid:"ubqxa7"}})}})),h=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.interval=function({timeout:e,start:t,stop:n,leading:o=!1,trailing:a=!1}){const i=null!=t?t:(0,r.default.createEvent)({name:"setup",sid:"-essz1d"}),s=null!=n?n:(0,r.default.createEvent)({name:"teardown",sid:"sv95oj"}),u=(0,r.default.createEvent)({name:"tick",sid:"-r3kxtw"}),d=(0,r.default.createStore)(!1,{name:"$isRunning",sid:"-jo5dgs"}),l=function(e){if(r.default.is.store(e,{sid:"81l3dz"}))return e;if("number"==typeof e)return(0,r.default.createStore)(e,{and:{name:"$timeout"},sid:"-xt76rp"});throw new TypeError(`timeout parameter in interval method should be number or Store. "${typeof e}" was passed`)}(e),c=d.map((e=>!e),{skipVoid:!1}),f=(0,r.default.createEvent)({name:"saveTimeout",sid:"e3gpcx"}),m=(0,r.default.createStore)(null,{name:"$timeoutId",sid:"3759wd"}).on(f,((e,{timeoutId:t})=>t)),p=(0,r.default.createStore)((()=>{}),{name:"$rejecter",sid:"shnzo1"}).on(f,((e,{reject:t})=>t)),g=(0,r.default.attach)({and:{source:{timeout:l,running:d},effect:({timeout:e,running:t})=>t?new Promise(((t,n)=>{const r=setTimeout(t,e);f({timeoutId:r,reject:n})})):Promise.reject()},or:{name:"timeoutFx",sid:"n7tmmy"}}),y=(0,r.default.attach)({and:{source:{timeoutId:m,rejecter:p},effect:({timeoutId:e,rejecter:t})=>{t(),e&&clearTimeout(e)}},or:{name:"cleanupFx",sid:"-h9rkrq"}});if((0,r.default.sample)({and:[{clock:i,source:l,filter:c,target:g}],or:{sid:"-v8qzb1"}}),o){const e=(0,r.default.sample)({and:[{clock:i,filter:c}],or:{name:"onReady",sid:"13etu6"}});(0,r.default.sample)({and:[{clock:e,target:u}],or:{sid:"-us95gh"}})}(0,r.default.sample)({and:[{clock:i,fn:()=>!0,target:d}],or:{sid:"-uqlrq4"}}),(0,r.default.sample)({and:[{clock:g.done,source:l,filter:d,target:g}],or:{sid:"-ubrbpd"}}),(0,r.default.sample)({and:[{clock:g.done,filter:d,target:u.prepend((()=>{}))}],or:{sid:"6k91qi"}}),a&&(0,r.default.sample)({and:[{clock:s,target:u}],or:{sid:"6p774h"}});return d.on(s,(()=>!1)),(0,r.default.sample)({and:[{clock:s,target:y}],or:{sid:"7558a8"}}),{tick:u,isRunning:d,"@@trigger":()=>({setup:i,teardown:s,fired:u})}}})),v=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.not=function(e){return e.map((e=>!e),{skipVoid:!1})}})),b=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.once=function(e){let t,n;r.default.is.unit(e)?t=e:({source:t,reset:n}=e);const o=(0,r.default.createStore)(!0,{name:"$canTrigger",sid:"ys2jl0"}),a=(0,r.default.sample)({and:[{source:t,filter:o}],or:{name:"trigger",sid:"e3xto3"}});o.on(a,(()=>!1)),n&&o.reset(n);return a}})),k=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=function(...e){return(0,r.default.combine)({and:[e,e=>{for(const t of e)if(t)return!0;return!1},{skipVoid:!1}],or:{sid:"-44722k"}})}})),w=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.pending=function({effects:e,domain:t,of:o="some"}){if(!r.default.is.domain(t,{sid:"97b92c"})&&!e)throw new TypeError("domain or effects should be passed");if("some"!==o&&"every"!==o)throw new TypeError(`strategy parameter "of" can be "every" or "some". Passed: "${o}"`);let a=null!=e?e:[];const i=n[o];t&&(a=[],t.onCreateEffect((e=>a.push(e))));return(0,r.default.combine)({and:[a.map((e=>e.pending)),i,{skipVoid:!1}],or:{sid:"a37bj0"}})};const n={some:e=>e.some(Boolean),every:e=>e.every(Boolean)}})),j=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reset=function({clock:e,target:t}){const n=Array.isArray(t)?t:[t],o=Array.isArray(e)?e:[null!=e?e:(0,r.default.createEvent)({name:"clocks",sid:"bqmea5"})];return n.forEach((e=>{e.reset(o)})),void 0===e?o[0]:void 0}})),$=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=function({source:e,shape:t}){const n={};for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;const o=t[r];n[r]=e.map((e=>{const t=o(e);return void 0===t?null:t}),{skipVoid:!1})}return n}})),_=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.snapshot=function({source:e,clock:t,fn:n=(e=>e)}){const o=n(e.defaultState),a=t?(0,r.default.sample)({and:[{source:e,clock:t,fn:n}],or:{name:"onSnapshot",sid:"-imuiws"}}):(0,r.default.sample)({and:[{source:e,fn:n}],or:{name:"onSnapshot",sid:"-imaqbf"}}),i=(0,r.default.createStore)(o,{name:"$snapshot",sid:"-63s6pn"});return i.on(a,((e,t)=>t)),i}})),E=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.some=function(e,t){let n,o=[],a=()=>!1;Array.isArray(e)?(o=e,a=t):Array.isArray(e.stores)&&(o=e.stores,a=e.predicate);i=a,n="function"==typeof i?a:r.default.is.store(a,{sid:"zbwu0l"})?a.map((e=>t=>e===t),{skipVoid:!1}):e=>e===a;var i;const s=(0,r.default.combine)({and:[o],or:{name:"$values",sid:"-kx24vm"}}),u=n;return(0,r.default.combine)({and:[u,s,(e,t)=>t.some(e),{skipVoid:!1}],or:{sid:"-ee8kph"}})}})),M=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.splitMap=function({source:e,cases:t}){const n={};let o=r.default.is.store(e,{name:"current",sid:"-htjkz7"})?e.updates:e;for(const e in t)if(e in t){const r=t[e];n[e]=o.filterMap(r),o=o.filter({fn:e=>!r(e)})}return n.__=o,n}})),P=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.spread=function({targets:e,source:t=(0,r.default.createEvent)({name:"source",sid:"-fkbi3c"})}){for(const i in e)if(o=e,a=i,n.call(o,a)){const n=e[i],o=(0,r.default.sample)({and:[{source:t,batch:!1,filter:e=>"object"==typeof e&&null!==e&&i in e}],or:{name:"hasTargetKey",sid:"-cov4g4"}});(0,r.default.sample)({and:[{batch:!1,clock:o,fn:e=>e[i],target:n}],or:{sid:"lpn34j"}})}var o,a;return t};const n={}.hasOwnProperty})),O=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.status=function({effect:e,defaultValue:t="initial"}){const n=(0,r.default.createStore)(t,{name:"$status",sid:"abrgim"});return n.on(e,(()=>"pending")).on(e.done,(()=>"done")).on(e.fail,(()=>"fail")),n}})),S=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.throttle=function({source:e,timeout:t,target:n=(0,r.default.createEvent)({name:"target",sid:"r328r6"})}){if(!r.default.is.unit(e))throw new TypeError("source must be unit from effector");const o=function(e){if(r.default.is.store(e,{sid:"-gzqwle"}))return e;if("number"==typeof e){if(e<0||!Number.isFinite(e))throw new Error(`timeout must be positive number or zero. Received: "${e}"`);return(0,r.default.createStore)(e,{and:{name:"$timeout"},sid:"-gs60mt"})}throw new TypeError(`timeout parameter should be number or Store. "${typeof e}" was passed`)}(t),a=(0,r.default.createEffect)({name:`throttle(${e.shortName||e.kind}) effect`,handler:e=>new Promise((t=>setTimeout(t,e)))},{name:"timerFx",sid:"-pyjx8k"}),i=(0,r.default.createStore)(null,{and:{serialize:"ignore",skipVoid:!1},name:"$payload",sid:"hzp5u0"}).on(e,((e,t)=>t)),s=(0,r.default.createEvent)({name:"triggerTick",sid:"-ry76an"}),u=(0,r.default.createStore)(!0,{and:{serialize:"ignore"},name:"$canTick",sid:"-4yqc5"}).on(s,(()=>!1)).on(n,(()=>!0));return(0,r.default.sample)({and:[{clock:e,filter:u,target:s}],or:{sid:"-hyxqny"}}),(0,r.default.sample)({and:[{source:o,clock:s,target:a}],or:{sid:"-hk3an7"}}),(0,r.default.sample)({and:[{source:i,clock:a.done,target:n}],or:{sid:"-hgsj31"}}),n}})),T=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.time=function({clock:e,getNow:t,initial:o}){const a=null!=t?t:n,i=(0,r.default.createEffect)(a,{name:"readNowFx",sid:"53d7kp"}),s=(0,r.default.restore)(i,null!=o?o:a(),{name:"$time",sid:"-xu6mk0"});return(0,r.default.sample)({and:[{clock:e,target:i}],or:{sid:"remzgl"}}),s};const n=()=>Date.now()})),x=a.and,q=i.combineEvents,z=s.condition,A=u.debounce,V=d.debug,N=l.delay,F=c.either,C=f.empty,D=m.equals,I=p.every,R=g.format,B=y.inFlight,K=h.interval,G=v.not,H=b.once,J=k.or,L=w.pending,Q=j.reset,U=$.reshape,W=_.snapshot,X=E.some,Y=M.splitMap,Z=P.spread,ee=O.status,te=S.throttle,ne=T.time,re={and:x,combineEvents:q,condition:z,debounce:A,debug:V,delay:N,either:F,empty:C,equals:D,every:I,format:R,inFlight:B,interval:K,not:G,once:H,or:J,pending:L,reset:Q,reshape:U,snapshot:W,some:X,splitMap:Y,spread:Z,status:ee,throttle:te,time:ne};e.and=x,e.combineEvents=q,e.condition=z,e.debounce=A,e.debug=V,e.default=re,e.delay=N,e.either=F,e.empty=C,e.equals=D,e.every=I,e.format=R,e.inFlight=B,e.interval=K,e.not=G,e.once=H,e.or=J,e.pending=L,e.reset=Q,e.reshape=U,e.snapshot=W,e.some=X,e.splitMap=Y,e.spread=Z,e.status=ee,e.throttle=te,e.time=ne,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("effector")):"function"==typeof define&&define.amd?define(["exports","effector"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).patronum={},e.effector)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(t);function o(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}var a=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.and=function(...e){return(0,r.default.combine)({and:[e,e=>{for(const t of e)if(!t)return!1;return!0},{skipVoid:!1}],or:{sid:"-rbm5ks"}})}})),i=o((function(e,t){function n(e){throw new Error(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.combineEvents=function(e){const t=function(e){return Object.keys(e).some((t=>!["events","reset","target"].includes(t)&&r.default.is.unit(e[t])))}(e)?{events:e}:e,{events:o,reset:a,target:i=(0,r.default.createEvent)({name:"target",sid:"p73fff"})}=t;r.default.is.unit(i)&&r.default.is.targetable(i)||n("target should be a targetable unit");a&&!r.default.is.unit(a)&&n("reset should be a unit");return(0,r.default.withRegion)(i,(()=>{const e=Object.keys(o),t=Array.isArray(o)?[...e].fill(""):{},n=(0,r.default.createStore)(e.length,{and:{serialize:"ignore"},name:"$counter",sid:"-ahoahx"}),s=(0,r.default.createStore)(t,{and:{serialize:"ignore"},name:"$results",sid:"oy8iyn"});(0,r.default.sample)({and:[{source:i,target:n.reinit}],or:{sid:"blex0c"}}),s.reset(i),a&&((0,r.default.sample)({and:[{source:a,target:n.reinit}],or:{sid:"bnm3fi"}}),s.reset(a));for(const t of e){const e=(0,r.default.createStore)(!1,{and:{serialize:"ignore"},name:"$isDone",sid:"-rf2fac"}).on(o[t],(()=>!0)).reset(i);a&&e.reset(a),n.on(e,(e=>e-1)),s.on(o[t],((e,n)=>{const r=Array.isArray(e)?[...e]:{...e};return r[t]=n,r}))}const u=(0,r.default.sample)({and:[{source:s,clock:[...Object.values(o)]}],or:{name:"eventsTrriggered",sid:"-lro8bq"}});(0,r.default.sample)({and:[{source:u,filter:n.map((e=>0===e),{skipVoid:!1}),target:i}],or:{sid:"-dlkr2s"}})})),i}})),s=o((function(e,t){function n(e){return r.default.is.unit(e)?e.map((e=>!e),{skipVoid:!1}):t=>!e(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.condition=function({if:e,then:t,else:o,source:a=(0,r.default.createEvent)({name:"source",sid:"tdyoa4"})}){const i=r.default.is.unit(e)||(s=e,"function"==typeof s)?e:t=>t===e;var s;t&&o?(0,r.default.split)({and:[{source:a,match:{then:i,else:n(i)},cases:{then:t,else:o}}],or:{sid:"aaw2hr"}}):t?(0,r.default.sample)({and:[{source:a,filter:i,target:t}],or:{sid:"-dwrmbb"}}):o&&(0,r.default.sample)({and:[{source:a,filter:n(i),target:o}],or:{sid:"-dsx25s"}});return a}})),u=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=function(...e){var t;const n=2===e.length?{source:e[0],timeout:e[1]}:e[0],{source:o,timeout:a,target:i,name:s}=n;if(!r.default.is.unit(o))throw new TypeError("source must be unit from effector");if(r.default.is.domain(o,{sid:"jsc7s2"}))throw new TypeError("source cannot be domain");const u=function(e){if(r.default.is.store(e,{sid:"-21qm2b"}))return e;if("number"==typeof e){if(e<0||!Number.isFinite(e))throw new Error(`timeout must be positive number or zero. Received: "${e}"`);return(0,r.default.createStore)(e,{and:{name:"$timeout"},sid:"kbepy4"})}throw new TypeError(`timeout parameter in interval method should be number or Store. "${typeof e}" was passed`)}(a),d=(0,r.default.createEvent)({name:"saveCancel",sid:"-kec0n3"}),c=(0,r.default.createStore)([],{and:{serialize:"ignore"},name:"$canceller",sid:"-tfm9fg"}).on(d,((e,t)=>t)),l=null!==(t=i)&&void 0!==t?t:(0,r.default.createEvent)({name:"tick",sid:"-50e2rn"}),f=(0,r.default.attach)({and:{name:s||`debounce(${o?.shortName||o.kind}) effect`,source:c,effect:([e,t],n)=>(e&&clearTimeout(e),t&&t(),new Promise(((e,t)=>{d([setTimeout(e,n),t])})))},or:{name:"timerFx",sid:"-jwso4j"}});c.reset(f.done);const m=(0,r.default.createStore)([],{and:{serialize:"ignore",skipVoid:!1},name:"$payload",sid:"-x9cllg"}).on(o,((e,t)=>[t])),p=(0,r.default.createStore)(!0,{and:{serialize:"ignore"},name:"$canTick",sid:"8r2952"}),y=(0,r.default.createEvent)({name:"triggerTick",sid:"-781myl"});p.on(y,(()=>!1)).on([l,u,f],(()=>!0));const h=(0,r.default.merge)([o,(0,r.default.sample)({and:[{clock:u,filter:f.pending}],or:{name:"requestTick",sid:"-khrpxp"}})],{name:"requestTick",sid:"2k0852"});return(0,r.default.sample)({and:[{clock:h,filter:p,target:y}],or:{sid:"-31h8q8"}}),(0,r.default.sample)({and:[{source:u,clock:y,target:f}],or:{sid:"-2y6h62"}}),(0,r.default.sample)({and:[{source:m,clock:f.done,fn:([e])=>e,target:l}],or:{sid:"-2jc15b"}}),l}})),d=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.debug=o;const n={trace:!1,handler:e=>{if(h(e.node)&&"finally"===e.node.meta.named)return;const{scope:t,scopeName:n,name:r,kind:o,value:a,loc:i,trace:s,node:u,logType:d}=e,c=t?` (scope: ${n})`:"",l=null!=r?r:i?`${i.file}:${i.line}:${i.column}`:"",f="initial"===d?" [getState]":"";console.info(`[${o}]${c} ${l}${f}`,a),s&&s.length>0&&!h(u)&&(console.groupCollapsed(`[${o}]${c} ${l} trace`),s.forEach((e=>{const{name:t,kind:n,value:r,loc:o}=e,a=null!=t?t:o?`${o.file}:${o.line}:${o.column}`:"";console.info(`<- [${n}] ${a}`,r)})),console.groupEnd())}};function o(...e){const{config:t,units:o}=function(...e){let t=n;const[o,...a]=e,i=[];if(function(e){if(!r.default.is.unit(e))return!Object.values(e).every(r.default.is.unit);return!1}(o))t={...n,...o};else if(r.default.is.unit(o))i.push(o);else for(const[e,t]of Object.entries(o))v.set(b(t).id,e),i.push(t);for(const e of a)if(r.default.is.unit(e))i.push(e);else for(const[t,n]of Object.entries(e))v.set(b(n).id,t),i.push(n);return{config:t,units:i}}(...e);o.forEach((e=>{r.default.is.store(e,{sid:"-foynff"})||r.default.is.event(e,{sid:"apy28p"})||r.default.is.effect(e,{sid:"apy3od"})?i(e,t):r.default.is.domain(e,{sid:"-rsqe9t"})&&a(e,t)}))}function a(e,t){e.onCreateStore((e=>i(e,t))),e.onCreateEvent((e=>i(e,t))),e.onCreateEffect((e=>i(e,t))),e.onCreateDomain((e=>a(e,t)))}function i(e,t){r.default.is.store(e,{sid:"w7ds2s"})?(!function(e,t){if(!t.handler)throw Error("patronum/debug must have the handler");const n={logType:"initial",scope:null,scopeName:null,node:_(e),kind:g(e),value:e.getState(),name:k(e),loc:$(e),trace:[],stackMeta:{}};t.handler(n),p.forEach((n=>d(e,t,n))),l((n=>d(e,t,n)))}(e,t),s(e,t)):r.default.is.event(e,{sid:"fretyd"})?s(e,t):r.default.is.effect(e,{sid:"gpi2qr"})&&(s(e,t),s(e.finally,t),s(e.done,t),s(e.fail,t))}function s(e,t){const n=(0,r.default.createNode)({parent:[e],meta:{op:"watch"},family:{owners:e},regional:!0,node:[r.default.step.run({fn(n,r,o){var a;const i=null!==(a=o?.scope)&&void 0!==a?a:null,s={logType:"update",scope:i,scopeName:y(i),node:_(e),kind:g(e),value:n,name:k(e),loc:$(e),stackMeta:j(o.parent),trace:t.trace?u(o):[]};if(!t.handler)throw Error("patronum/debug must have the handler");t.handler(s)}})]});return()=>(0,r.default.clearNode)(n)}function u(e){const t=[];let n=e?.parent;for(;n;){const{node:e,value:r}=n,o={node:e,value:r,name:k(e),loc:$(e),kind:g(e),stackMeta:j(n)};t.push(o),n=n.parent}return t}function d(e,t,n){if(!t.handler)throw Error("patronum/debug must have the handler");const r=_(e),o={logType:"initial",scope:n,scopeName:y(n),node:r,kind:g(e),value:n.getState(e),name:k(e),loc:$(e),trace:[],stackMeta:{}};t.handler(o)}const c=new Set,l=e=>(c.add(e),()=>{c.delete(e)});let f=0;const m=new Map,p={save(e,t){p.get(e)||m.set(e,t)},get(e){var t;return e&&null!==(t=m.get(e))&&void 0!==t?t:null},delete(e){m.delete(e)},forEach(e){m.forEach(((t,n)=>e(n,t)))},clear(){m.clear()}};function y(e){if(!e)return null;const t=p.get(e);if(!t){return e._debugId||(e._debugId=(f+=1,`unknown_${f}`))}return t.name}function h(e){const t=_(e),{sid:n,named:r}=t.meta;return Boolean(!n&&("finally"===r||"done"===r||"doneData"===r||"fail"===r||"failData"===r||"inFlight"===r||"pending"===r))}function g(e){if(r.default.is.store(e,{sid:"4o7s04"}))return"store";if(r.default.is.effect(e,{sid:"4pv5s7"})||h(e))return"effect";if(r.default.is.event(e,{sid:"4rijka"}))return"event";if(r.default.is.domain(e,{sid:"54plsy"}))return"domain";if(r.default.is.unit(e))return"unit";const t=_(e);return t.meta.op?t.meta.op:"unknown"}o.registerScope=function(e,t){return p.save(e,{name:t.name}),c.forEach((t=>t(e))),()=>{p.delete(e)}},o.unregisterAllScopes=function(){p.clear()};const b=e=>e.graphite||e,v=new Map;function k(e){const t=v.get(b(e).id);if(t)return t;if(h(e)){const t=_(e),n=t.family.owners.find((e=>"effect"===e.meta.op));if(n){const e=w(n);return`${e?`${e}/`:""}${k(n)}.${t.meta.named}`}return t.meta.named}if(function(e){const t=_(e),{op:n}=t.meta;return"on"===n}(e)){const t=_(e);return`${k(t.next[0])}.on(${k(t.family.owners[0])})`}if(r.default.is.unit(e)){if(e?.compositeName?.fullName)return e.compositeName.fullName;const t=w(e),n=t?`${t}/`:"";if(e?.shortName)return`${n}${e.shortName}`;if(e?.name)return`${n}${e.name}`}return _(e)?.meta?.name?_(e).meta.name:null}function w(e){const t=_(e).family.owners.find((e=>"domain"===e.meta.op));return t?k(t):null}function $(e){const t=function({meta:e}){return"config"in e?e.config.loc:e.loc}(_(e));if(t)return t}function _(e){return"graphite"in e?e.graphite:e}function j(e){if(!e)return{};return e.meta||{}}})),c=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.delay=function(...e){const t=2===e.length?{source:e[0],timeout:e[1]}:e[0],{source:n,timeout:o,target:a=(0,r.default.createEvent)({name:"target",sid:"jucb8d"})}=t,i=Array.isArray(a)?a:[a];if(!r.default.is.unit(n))throw new TypeError("source must be a unit from effector");if(!i.every((e=>r.default.is.unit(e))))throw new TypeError("target must be a unit from effector");const s=function(e){if(r.default.is.store(e,{sid:"-tvk3f2"})||"function"==typeof e||"number"==typeof e)return e;throw new TypeError(`'timeout' argument must be a function, Store, or a number. Passed "${typeof e}"`)}(o),u=(0,r.default.createEffect)((({payload:e,milliseconds:t})=>new Promise((n=>{setTimeout(n,t,e)}))),{name:"timerFx",sid:"-wp3hwr"});return(0,r.default.sample)({and:[{source:(0,r.default.combine)({and:[{milliseconds:s}],or:{name:"source",sid:"-gaikyz"}}),clock:n,fn:({milliseconds:e},t)=>({payload:t,milliseconds:"function"==typeof e?e(t):e}),target:u}],or:{sid:"-uuqxfw"}}),(0,r.default.sample)({and:[{clock:u.doneData,target:i}],or:{sid:"-uc1x9m"}}),a}})),l=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.either=function e(t,n,o){if(r.default.is.store(t,{sid:"ozzvoc"}))return(0,r.default.combine)({and:[t,n,o,(e,t,n)=>e?t:n,{skipVoid:!1}],or:{sid:"-5vau2h"}});const a=t;return e(a.filter,a.then,a.other)}})),f=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.empty=function(e){return e.map((e=>null==e),{skipVoid:!1})}})),m=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.equals=function(e,t){return(0,r.default.combine)({and:[e,t,(e,t)=>e===t,{skipVoid:!1}],or:{sid:"-pqjlti"}})}})),p=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.every=function(e,t){let n,o=[],a=()=>!1;Array.isArray(e)?(o=e,a=t):Array.isArray(e.stores)&&(o=e.stores,a=e.predicate);i=a,n="function"==typeof i?a:r.default.is.store(a,{sid:"sid3ut"})?a.map((e=>t=>e===t),{skipVoid:!1}):e=>e===a;var i;const s=(0,r.default.combine)({and:[o],or:{name:"$values",sid:"rwb5jx"}}),u=n;return(0,r.default.combine)({and:[u,s,(e,t)=>t.every(e),{skipVoid:!1}],or:{sid:"hgnz2z"}})}})),y=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.format=function(e,...t){return(0,r.default.combine)({and:[t,t=>e.reduce(((n,r,o)=>n.concat(function(e,t){return t===e.length-1}(e,o)?r:`${r}${function(e){if(Array.isArray(e))return e.map((e=>String(e))).join(", ");return String(e)}(t[o])}`)),""),{skipVoid:!1}],or:{sid:"-yrbthp"}})}})),h=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.inFlight=function(e){const t=Array.isArray(e)?{effects:e}:e,{effects:n,domain:o}=t;if(o){const e=o.createStore(0,{name:"$inFlight",sid:"-wboyn1"});return o.onCreateEffect((t=>{e.on(t,(e=>e+1)).on(t.finally,(e=>e-1))})),e}return(0,r.default.combine)({and:[n.map((e=>e.inFlight)),e=>e.reduce(((e,t)=>e+t),0),{skipVoid:!1}],or:{sid:"udy3nn"}})}})),g=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.interval=function({timeout:e,start:t,stop:n,leading:o=!1,trailing:a=!1}){const i=null!=t?t:(0,r.default.createEvent)({name:"setup",sid:"-essz1d"}),s=null!=n?n:(0,r.default.createEvent)({name:"teardown",sid:"sv95oj"}),u=(0,r.default.createEvent)({name:"tick",sid:"-r3kxtw"}),d=(0,r.default.createStore)(!1,{name:"$isRunning",sid:"-jo5dgs"}),c=function(e){if(r.default.is.store(e,{sid:"81l3dz"}))return e;if("number"==typeof e)return(0,r.default.createStore)(e,{and:{name:"$timeout"},sid:"-xt76rp"});throw new TypeError(`timeout parameter in interval method should be number or Store. "${typeof e}" was passed`)}(e),l=d.map((e=>!e),{skipVoid:!1}),f=(0,r.default.createEvent)({name:"saveTimeout",sid:"e3gpcx"}),m=(0,r.default.createStore)(null,{name:"$timeoutId",sid:"3759wd"}).on(f,((e,{timeoutId:t})=>t)),p=(0,r.default.createStore)((()=>{}),{name:"$rejecter",sid:"shnzo1"}).on(f,((e,{reject:t})=>t)),y=(0,r.default.attach)({and:{source:{timeout:c,running:d},effect:({timeout:e,running:t})=>t?new Promise(((t,n)=>{const r=setTimeout(t,e);f({timeoutId:r,reject:n})})):Promise.reject()},or:{name:"timeoutFx",sid:"n7tmmy"}}),h=(0,r.default.attach)({and:{source:{timeoutId:m,rejecter:p},effect:({timeoutId:e,rejecter:t})=>{t(),e&&clearTimeout(e)}},or:{name:"cleanupFx",sid:"-h9rkrq"}});if((0,r.default.sample)({and:[{clock:i,source:c,filter:l,target:y}],or:{sid:"-v8qzb1"}}),o){const e=(0,r.default.sample)({and:[{clock:i,filter:l}],or:{name:"onReady",sid:"13etu6"}});(0,r.default.sample)({and:[{clock:e,target:u}],or:{sid:"-us95gh"}})}(0,r.default.sample)({and:[{clock:i,fn:()=>!0,target:d}],or:{sid:"-uqlrq4"}}),(0,r.default.sample)({and:[{clock:y.done,source:c,filter:d,target:y}],or:{sid:"-ubrbpd"}}),(0,r.default.sample)({and:[{clock:y.done,filter:d,target:u.prepend((()=>{}))}],or:{sid:"6k91qi"}}),a&&(0,r.default.sample)({and:[{clock:s,target:u}],or:{sid:"6p774h"}});return d.on(s,(()=>!1)),(0,r.default.sample)({and:[{clock:s,target:h}],or:{sid:"7558a8"}}),{tick:u,isRunning:d,"@@trigger":()=>({setup:i,teardown:s,fired:u})}}})),b=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.not=function(e){return e.map((e=>!e),{skipVoid:!1})}})),v=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.once=function(e){let t,n;r.default.is.unit(e)?t=e:({source:t,reset:n}=e);const o=(0,r.default.createStore)(!0,{name:"$canTrigger",sid:"ys2jl0"}),a=(0,r.default.sample)({and:[{source:t,filter:o}],or:{name:"trigger",sid:"e3xto3"}});o.on(a,(()=>!1)),n&&o.reset(n);return a}})),k=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=function(...e){return(0,r.default.combine)({and:[e,e=>{for(const t of e)if(t)return!0;return!1},{skipVoid:!1}],or:{sid:"-44722k"}})}})),w=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.pending=function(e){const t=Array.isArray(e)?{effects:e}:e,{effects:o,domain:a,of:i="some"}=t;if(!r.default.is.domain(a,{sid:"98ymuf"})&&!o)throw new TypeError("domain or effects should be passed");if("some"!==i&&"every"!==i)throw new TypeError(`strategy parameter "of" can be "every" or "some". Passed: "${i}"`);let s=null!=o?o:[];const u=n[i];a&&(s=[],a.onCreateEffect((e=>s.push(e))));return(0,r.default.combine)({and:[s.map((e=>e.pending)),u,{skipVoid:!1}],or:{sid:"a4upb3"}})};const n={some:e=>e.some(Boolean),every:e=>e.every(Boolean)}})),$=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.previous=function(...e){const[t]=e,n=e.length<2?null:e[1];if(!r.default.is.store(t,{sid:"mzq5dc"}))throw Error("previous first argument should be a store");const o=(0,r.default.createStore)(n,{and:{serialize:"ignore",skipVoid:!1},name:"$prevValue",sid:"e05yob"});return t.graphite.seq.push(r.default.step.compute({fn:(e,t,n)=>((0,r.default.launch)({target:o,params:n.a,defer:!0}),e)})),o}})),_=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reset=function({clock:e,target:t}){const n=Array.isArray(t)?t:[t],o=Array.isArray(e)?e:[null!=e?e:(0,r.default.createEvent)({name:"clocks",sid:"bqmea5"})];return n.forEach((e=>{e.reset(o)})),void 0===e?o[0]:void 0}})),j=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=function({source:e,shape:t}){const n={};for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;const o=t[r];n[r]=e.map((e=>{const t=o(e);return void 0===t?null:t}),{skipVoid:!1})}return n}})),E=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.snapshot=function({source:e,clock:t,fn:n=(e=>e)}){const o=n(e.defaultState),a=t?(0,r.default.sample)({and:[{source:e,clock:t,fn:n}],or:{name:"onSnapshot",sid:"-imuiws"}}):(0,r.default.sample)({and:[{source:e,fn:n}],or:{name:"onSnapshot",sid:"-imaqbf"}}),i=(0,r.default.createStore)(o,{name:"$snapshot",sid:"-63s6pn"});return i.on(a,((e,t)=>t)),i}})),M=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.some=function(e,t){let n,o=[],a=()=>!1;Array.isArray(e)?(o=e,a=t):Array.isArray(e.stores)&&(o=e.stores,a=e.predicate);i=a,n="function"==typeof i?a:r.default.is.store(a,{sid:"zbwu0l"})?a.map((e=>t=>e===t),{skipVoid:!1}):e=>e===a;var i;const s=(0,r.default.combine)({and:[o],or:{name:"$values",sid:"-kx24vm"}}),u=n;return(0,r.default.combine)({and:[u,s,(e,t)=>t.some(e),{skipVoid:!1}],or:{sid:"-ee8kph"}})}})),O=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.splitMap=function({source:e,cases:t}){const n={};let o=r.default.is.store(e,{name:"current",sid:"-htjkz7"})?e.updates:e;for(const e in t)if(e in t){const r=t[e];n[e]=o.filterMap(r),o=o.filter({fn:e=>!r(e)})}return n.__=o,n}})),P=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.spread=function(e){const t=function(e){return Object.keys(e).some((t=>!["targets","source"].includes(t)&&r.default.is.unit(e[t])))}(e)?{targets:e}:e,{targets:o,source:a=(0,r.default.createEvent)({name:"source",sid:"e9ipnn"})}=t;for(const e in o)if(i=o,s=e,n.call(i,s)){const t=o[e],n=(0,r.default.sample)({and:[{source:a,batch:!1,filter:t=>"object"==typeof t&&null!==t&&e in t}],or:{name:"hasTargetKey",sid:"eapc0z"}});(0,r.default.sample)({and:[{batch:!1,clock:n,fn:t=>t[e],target:t}],or:{sid:"mkzcy4"}})}var i,s;return a};const n={}.hasOwnProperty})),S=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.status=function(e){const{effect:t,defaultValue:n="initial"}=r.default.is.effect(e,{sid:"cn6w5b"})?{effect:e}:e,o=(0,r.default.createStore)(n,{name:"$status",sid:"ph7d4u"});if(!r.default.is.effect(t,{sid:"-kp39vu"}))throw TypeError('status: "effect" property is not an effect');return o.on(t,(()=>"pending")).on(t.done,(()=>"done")).on(t.fail,(()=>"fail")),o}})),T=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.throttle=function(...e){const t=2===e.length?{source:e[0],timeout:e[1]}:e[0],{source:n,timeout:o,target:a=(0,r.default.createEvent)({name:"target",sid:"-gyhb56"})}=t;if(!r.default.is.unit(n))throw new TypeError("source must be unit from effector");const i=function(e){if(r.default.is.store(e,{sid:"-gj92sk"}))return e;if("number"==typeof e){if(e<0||!Number.isFinite(e))throw new Error(`timeout must be positive number or zero. Received: "${e}"`);return(0,r.default.createStore)(e,{and:{name:"$timeout"},sid:"-2ktcsz"})}throw new TypeError(`timeout parameter should be number or Store. "${typeof e}" was passed`)}(o),s=(0,r.default.createEffect)({name:`throttle(${n.shortName||n.kind}) effect`,handler:e=>new Promise((t=>setTimeout(t,e)))},{name:"timerFx",sid:"-lp5bot"}),u=(0,r.default.createStore)(null,{and:{serialize:"ignore",skipVoid:!1},name:"$payload",sid:"w71tnu"}).on(n,((e,t)=>t)),d=(0,r.default.createEvent)({name:"triggerTick",sid:"-dquigt"}),c=(0,r.default.createStore)(!0,{and:{serialize:"ignore"},name:"$canTick",sid:"e2dxhp"}).on(d,(()=>!1)).on(a,(()=>!0));return(0,r.default.sample)({and:[{clock:n,filter:c,target:d}],or:{sid:"-hifwv4"}}),(0,r.default.sample)({and:[{source:i,clock:d,target:s}],or:{sid:"-h3lgud"}}),(0,r.default.sample)({and:[{source:u,clock:s.done,target:a}],or:{sid:"-h0apa7"}}),a}})),x=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.time=function(e){const t=r.default.is.unit(e)?{clock:e}:e,{clock:o,getNow:a,initial:i}=t,s=null!=a?a:n,u=(0,r.default.createEffect)(s,{name:"readNowFx",sid:"ito90c"}),d=(0,r.default.restore)(u,null!=i?i:s(),{name:"$time",sid:"-k3vl4d"});return(0,r.default.sample)({and:[{clock:o,target:u}],or:{sid:"rul0o2"}}),d};const n=()=>Date.now()})),q=a.and,z=i.combineEvents,A=s.condition,V=u.debounce,N=d.debug,F=c.delay,C=l.either,D=f.empty,I=m.equals,R=p.every,B=y.format,K=h.inFlight,G=g.interval,H=b.not,J=v.once,L=k.or,Q=w.pending,U=$.previous,W=_.reset,X=j.reshape,Y=E.snapshot,Z=M.some,ee=O.splitMap,te=P.spread,ne=S.status,re=T.throttle,oe=x.time,ae={and:q,combineEvents:z,condition:A,debounce:V,debug:N,delay:F,either:C,empty:D,equals:I,every:R,format:B,inFlight:K,interval:G,not:H,once:J,or:L,pending:Q,previous:U,reset:W,reshape:X,snapshot:Y,some:Z,splitMap:ee,spread:te,status:ne,throttle:re,time:oe};e.and=q,e.combineEvents=z,e.condition=A,e.debounce=V,e.debug=N,e.default=ae,e.delay=F,e.either=C,e.empty=D,e.equals=I,e.every=R,e.format=B,e.inFlight=K,e.interval=G,e.not=H,e.once=J,e.or=L,e.pending=Q,e.previous=U,e.reset=W,e.reshape=X,e.snapshot=Y,e.some=Z,e.splitMap=ee,e.spread=te,e.status=ne,e.throttle=re,e.time=oe,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=patronum.umd.js.map |
import { Domain, Effect, Store } from 'effector'; | ||
export type Strategy = 'some' | 'every'; | ||
export declare function pending(effects: Array<Effect<any, any, any>>): Store<boolean>; | ||
export declare function pending(config: { | ||
@@ -4,0 +5,0 @@ effects: Array<Effect<any, any, any>>; |
@@ -6,3 +6,6 @@ import { combine, is } from 'effector'; | ||
}; | ||
export function pending(_ref) { | ||
export function pending(args) { | ||
var argsShape = Array.isArray(args) ? { | ||
effects: args | ||
} : args; | ||
var { | ||
@@ -12,5 +15,5 @@ effects: rawEffects, | ||
of = 'some' | ||
} = _ref; | ||
} = argsShape; | ||
if (!is.domain(domain, { | ||
sid: "97b92c" | ||
sid: "98ymuf" | ||
}) && !rawEffects) throw new TypeError('domain or effects should be passed'); | ||
@@ -29,5 +32,5 @@ if (of !== 'some' && of !== 'every') throw new TypeError("strategy parameter \"of\" can be \"every\" or \"some\". Passed: \"".concat(of, "\"")); | ||
or: { | ||
sid: "a37bj0" | ||
sid: "a4upb3" | ||
} | ||
}); | ||
} |
@@ -14,2 +14,5 @@ import { EventCallable, Unit, UnitTargetable } from 'effector'; | ||
}): Source; | ||
export declare function spread<Payload>(targets: { | ||
[Key in keyof Payload]?: UnitTargetable<Payload[Key]>; | ||
}): EventCallable<Partial<Payload>>; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { createEvent, sample } from 'effector'; | ||
import { createEvent, is, sample } from 'effector'; | ||
var hasPropBase = {}.hasOwnProperty; | ||
@@ -11,3 +11,6 @@ var hasOwnProp = (object, key) => hasPropBase.call(object, key); | ||
*/ | ||
export function spread(_ref) { | ||
export function spread(args) { | ||
var argsShape = isTargets(args) ? { | ||
targets: args | ||
} : args; | ||
var { | ||
@@ -17,8 +20,5 @@ targets, | ||
name: "source", | ||
sid: "-fkbi3c" | ||
}, { | ||
name: "source", | ||
sid: "-fkbi3c" | ||
sid: "e9ipnn" | ||
}) | ||
} = _ref; | ||
} = argsShape; | ||
var _loop = function _loop(targetKey) { | ||
@@ -35,3 +35,3 @@ if (hasOwnProp(targets, targetKey)) { | ||
name: "hasTargetKey", | ||
sid: "-cov4g4" | ||
sid: "eapc0z" | ||
} | ||
@@ -47,3 +47,3 @@ }); | ||
or: { | ||
sid: "lpn34j" | ||
sid: "mkzcy4" | ||
} | ||
@@ -57,2 +57,5 @@ }); | ||
return source; | ||
} | ||
function isTargets(args) { | ||
return Object.keys(args).some(key => !['targets', 'source'].includes(key) && is.unit(args[key])); | ||
} |
import { Effect, Store } from 'effector'; | ||
export type EffectState = 'initial' | 'pending' | 'done' | 'fail'; | ||
export declare function status<Params, Done, Fail = Error>({ effect, defaultValue, }: { | ||
export declare function status<Params, Done, Fail = Error>(effect: Effect<Params, Done, Fail>): Store<EffectState>; | ||
export declare function status<Params, Done, Fail = Error>(params: { | ||
effect: Effect<Params, Done, Fail>; | ||
defaultValue?: EffectState; | ||
}): Store<EffectState>; |
@@ -1,13 +0,22 @@ | ||
import { createStore } from 'effector'; | ||
export function status(_ref) { | ||
import { createStore, is } from 'effector'; | ||
export function status(params) { | ||
var { | ||
effect, | ||
defaultValue = 'initial' | ||
} = _ref; | ||
} = is.effect(params, { | ||
sid: "cn6w5b" | ||
}) ? { | ||
effect: params | ||
} : params; | ||
var $status = createStore(defaultValue, { | ||
name: "$status", | ||
sid: "abrgim" | ||
sid: "ph7d4u" | ||
}); | ||
if (!is.effect(effect, { | ||
sid: "-kp39vu" | ||
})) { | ||
throw TypeError("status: \"effect\" property is not an effect"); | ||
} | ||
$status.on(effect, () => 'pending').on(effect.done, () => 'done').on(effect.fail, () => 'fail'); | ||
return $status; | ||
} |
import { Event, Store, Unit, UnitTargetable } from 'effector'; | ||
type EventAsReturnType<Payload> = any extends Payload ? Event<Payload> : never; | ||
export declare function throttle<T>(source: Unit<T>, timeout: number | Store<number>): EventAsReturnType<T>; | ||
export declare function throttle<T>(_: { | ||
@@ -4,0 +5,0 @@ source: Unit<T>; |
import { createEffect, createEvent, createStore, is, sample } from 'effector'; | ||
export function throttle(_ref) { | ||
export function throttle() { | ||
var argsShape = arguments.length === 2 ? { | ||
source: arguments.length <= 0 ? undefined : arguments[0], | ||
timeout: arguments.length <= 1 ? undefined : arguments[1] | ||
} : arguments.length <= 0 ? undefined : arguments[0]; | ||
var { | ||
@@ -8,8 +12,5 @@ source, | ||
name: "target", | ||
sid: "r328r6" | ||
}, { | ||
name: "target", | ||
sid: "r328r6" | ||
sid: "-gyhb56" | ||
}) | ||
} = _ref; | ||
} = argsShape; | ||
if (!is.unit(source)) throw new TypeError('source must be unit from effector'); | ||
@@ -22,3 +23,3 @@ var $timeout = toStoreNumber(timeout); | ||
name: "timerFx", | ||
sid: "-pyjx8k" | ||
sid: "-lp5bot" | ||
}); | ||
@@ -33,7 +34,7 @@ | ||
name: "$payload", | ||
sid: "hzp5u0" | ||
sid: "w71tnu" | ||
}).on(source, (_, payload) => payload); | ||
var triggerTick = createEvent({ | ||
name: "triggerTick", | ||
sid: "-ry76an" | ||
sid: "-dquigt" | ||
}); | ||
@@ -45,3 +46,3 @@ var $canTick = createStore(true, { | ||
name: "$canTick", | ||
sid: "-4yqc5" | ||
sid: "e2dxhp" | ||
}).on(triggerTick, () => false).on(target, () => true); | ||
@@ -55,3 +56,3 @@ sample({ | ||
or: { | ||
sid: "-hyxqny" | ||
sid: "-hifwv4" | ||
} | ||
@@ -66,3 +67,3 @@ }); | ||
or: { | ||
sid: "-hk3an7" | ||
sid: "-h3lgud" | ||
} | ||
@@ -77,3 +78,3 @@ }); | ||
or: { | ||
sid: "-hgsj31" | ||
sid: "-h0apa7" | ||
} | ||
@@ -85,3 +86,3 @@ }); | ||
if (is.store(value, { | ||
sid: "-gzqwle" | ||
sid: "-gj92sk" | ||
})) return value; | ||
@@ -94,3 +95,3 @@ if (typeof value === 'number') { | ||
}, | ||
sid: "-gs60mt" | ||
sid: "-2ktcsz" | ||
}); | ||
@@ -97,0 +98,0 @@ } |
import { Unit, Store } from 'effector'; | ||
type NoInfer<T> = [T][T extends any ? 0 : never]; | ||
export declare function time<Time = number>({ clock, getNow, initial, }: { | ||
export declare function time(clock: Unit<any>): Store<number>; | ||
export declare function time<Time = number>(config: { | ||
clock: Unit<any>; | ||
@@ -5,0 +6,0 @@ getNow?: () => Time; |
@@ -1,4 +0,7 @@ | ||
import { createEffect, restore, sample } from 'effector'; | ||
import { createEffect, restore, sample, is } from 'effector'; | ||
var defaultNow = () => Date.now(); | ||
export function time(_ref) { | ||
export function time(args) { | ||
var argsShape = is.unit(args) ? { | ||
clock: args | ||
} : args; | ||
var { | ||
@@ -8,11 +11,11 @@ clock, | ||
initial | ||
} = _ref; | ||
} = argsShape; | ||
var timeReader = getNow !== null && getNow !== void 0 ? getNow : defaultNow; | ||
var readNowFx = createEffect(timeReader, { | ||
name: "readNowFx", | ||
sid: "53d7kp" | ||
sid: "ito90c" | ||
}); | ||
var $time = restore(readNowFx, initial !== null && initial !== void 0 ? initial : timeReader(), { | ||
name: "$time", | ||
sid: "-xu6mk0" | ||
sid: "-k3vl4d" | ||
}); | ||
@@ -25,3 +28,3 @@ sample({ | ||
or: { | ||
sid: "remzgl" | ||
sid: "rul0o2" | ||
} | ||
@@ -28,0 +31,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
184122
124
4176