Created
May 22, 2019 09:14
-
-
Save zerobias/136edb31206fefb66e838aa5b2088536 to your computer and use it in GitHub Desktop.
effector 0.18.10 with prettier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function e({ | |
| node: e, | |
| child: t = [], | |
| from: n = [], | |
| scope: r = {}, | |
| meta: o = {}, | |
| }) { | |
| return {from: n.map(Q), seq: e, next: t.map(Q), meta: o, scope: r} | |
| } | |
| function t(e) { | |
| return e.compositeName | |
| ? e.compositeName.fullName | |
| : e.domainName | |
| ? e.domainName.fullName | |
| : e.id | |
| } | |
| function n(e) { | |
| let n = 0 | |
| const r = Object.values(e), | |
| o = De - 1, | |
| a = r.length - 1 | |
| let i = 'combine(' | |
| for (const e of r) { | |
| const r = n === o || a === n ? '' : ', ' | |
| if ( | |
| (Ee(e) || Ie(e) || qe(e) ? (i += t(e) + r) : (i += e.toString() + r), | |
| (n += 1), | |
| '' === r) | |
| ) | |
| break | |
| } | |
| return i + ')' | |
| } | |
| function r(e, t, n) { | |
| ;(this.shortName = e), (this.fullName = t), (this.path = n) | |
| } | |
| function o(e, t) { | |
| let n, o | |
| const a = e | |
| return ( | |
| void 0 === t | |
| ? ((n = 0 === e.length ? [] : [e]), (o = e)) | |
| : 0 === e.length | |
| ? ((n = t.path), (o = t.fullName)) | |
| : ((n = t.path.concat([e])), | |
| (o = 0 === t.fullName.length ? e : t.fullName + '/' + e)), | |
| new r(a, o, n) | |
| ) | |
| } | |
| function a() { | |
| const e = this.indexOf() | |
| ;-1 !== e && (this.splice(e, 1), (this.indexOf = Fe), (this.splice = He)) | |
| } | |
| function i({name: n, parent: r, config: a = {}}) { | |
| const s = Te(), | |
| c = n || s, | |
| l = o(c, r), | |
| u = l.fullName, | |
| f = e({node: [J.emit({fullName: u})]}), | |
| d = (e, ...t) => d.create(e, u, t) | |
| return ( | |
| (d.getType = () => u), | |
| (d.create = e => (be(d, e), e)), | |
| (d.kind = A), | |
| (d[R] = () => d), | |
| (d.id = s), | |
| (d.watch = ((e, n) => | |
| Me(e, { | |
| scope: {trigger: e, handler: n}, | |
| node: [Se, J.run({fn: (e, {trigger: n, handler: r}) => r(e, t(n))})], | |
| })).bind(null, d)), | |
| (d.map = ((e, t) => { | |
| const n = i({name: e.shortName + ' → *', parent: e.domainName}) | |
| return ( | |
| Me(e, { | |
| child: [n], | |
| scope: {handler: t}, | |
| node: [J.compute({fn: (e, {handler: t}) => t(e)})], | |
| }), | |
| n | |
| ) | |
| }).bind(null, d)), | |
| (d.filter = ((e, t) => { | |
| const n = i({name: e.shortName + ' →? *', parent: e.domainName}) | |
| return ( | |
| Me(e, { | |
| scope: {handler: t}, | |
| child: [n], | |
| node: [ | |
| J.compute({fn: (e, {handler: t}) => t(e)}), | |
| J.filter({fn: (e, t) => ((t.val = e), void 0 !== e)}), | |
| J.compute({fn: (e, t) => t.val}), | |
| ], | |
| }), | |
| n | |
| ) | |
| }).bind(null, d)), | |
| (d.prepend = ((e, t) => { | |
| const n = i({name: '* → ' + e.shortName, parent: e.domainName}) | |
| return ( | |
| Me(n, { | |
| child: [e], | |
| scope: {handler: t}, | |
| node: [J.compute({fn: (e, {handler: t}) => t(e)})], | |
| }), | |
| n | |
| ) | |
| }).bind(null, d)), | |
| (d.subscribe = ((e, t) => e.watch(e => t.next(e))).bind(null, d)), | |
| (d.graphite = f), | |
| (d.shortName = c), | |
| (d.domainName = r), | |
| (d.compositeName = l), | |
| (d.defaultConfig = a), | |
| d | |
| ) | |
| } | |
| function s(e = {}) { | |
| const t = | |
| 'createStore: Second argument should be plain object, but you passed %s.' | |
| ke('object' == typeof e && null !== e, t, e), | |
| void 0 !== (null == e ? void 0 : e.ɔ) && | |
| ke('object' == typeof e.ɔ && null !== e.ɔ, t, e.ɔ) | |
| const n = Object.assign({}, e, 'object' == typeof e.ɔ ? e.ɔ : {}) | |
| return delete n.ɔ, n | |
| } | |
| function c(e, t) { | |
| const n = 'object' == typeof e ? Object.assign({}, s(t), e) : s(t) | |
| return {config: n, name: 'object' == typeof e || void 0 === e ? n.name : e} | |
| } | |
| function l(e, t = {}) { | |
| const {config: n, name: r} = c(e, t) | |
| return i({name: r, config: n}) | |
| } | |
| function u(e) { | |
| G( | |
| 'function' == typeof e || ('object' == typeof e && null !== e), | |
| 'expect observable to be object or function', | |
| ) | |
| const t = R in e ? e[R]() : e | |
| G('subscribe' in t, 'expect observable to have .subscribe') | |
| const n = l(), | |
| r = L.bind(null, n, {}) | |
| return t.subscribe({next: n, error: r, complete: r}), n | |
| } | |
| function f() {} | |
| function d() {} | |
| function p(e) { | |
| return Z(e.plainState) | |
| } | |
| function m(e, t) { | |
| const n = e.subscribers.get(t) | |
| void 0 !== n && (n(), e.subscribers.delete(t)) | |
| } | |
| function h(e, n, r) { | |
| const o = n, | |
| a = e.subscribers.get(o) | |
| return ( | |
| a && a(), | |
| e.subscribers.set( | |
| o, | |
| Me(o, { | |
| scope: {handler: r, state: e.plainState, trigger: o}, | |
| child: [e], | |
| node: [ | |
| J.compute({ | |
| fn(e, {handler: n, state: r, trigger: o}) { | |
| const a = n(Z(r), e, t(o)) | |
| if (void 0 !== a) return $(r, a) | |
| }, | |
| }), | |
| ], | |
| }), | |
| ), | |
| this | |
| ) | |
| } | |
| function b(e, n, r) { | |
| const o = 'watch requires function handler' | |
| switch (r && (null == n ? void 0 : n.kind)) { | |
| case 'store': | |
| case 'event': | |
| case 'effect': | |
| return G('function' == typeof r, o), n.watch(o => r(p(e), o, t(n))) | |
| default: | |
| return G('function' == typeof n, o), g(e, n) | |
| } | |
| } | |
| function g(e, t) { | |
| G('function' == typeof t, 'Expected the listener to be a function') | |
| let n = 'Got initial error', | |
| r = p(e) | |
| f(e, 'subscribe') | |
| try { | |
| t(r), (n = 'Initial') | |
| } catch (e) { | |
| console.error(e) | |
| } | |
| return ( | |
| d(n), | |
| Me(e, { | |
| node: [ | |
| Se, | |
| J.run({ | |
| fn(n) { | |
| let o = null | |
| if ((f(e, 'subscribe'), n !== r)) { | |
| r = n | |
| try { | |
| t(n) | |
| } catch (e) { | |
| console.error(e), (o = 'Got error') | |
| } | |
| d(o) | |
| } else d(o) | |
| }, | |
| }), | |
| ], | |
| }) | |
| ) | |
| } | |
| function v(t) { | |
| const {currentState: n, config: r, parent: a} = t, | |
| {name: i} = r, | |
| s = Y(n), | |
| c = i || s.id, | |
| u = n, | |
| y = o(c, a), | |
| N = l('update ' + c), | |
| S = { | |
| graphite: e({ | |
| scope: {state: s, oldState: n}, | |
| node: [ | |
| J.filter({fn: e => void 0 !== e}), | |
| J.update({store: s}), | |
| J.filter({ | |
| fn: (e, t) => (e === t.oldState ? 0 : ((t.oldState = e), 1)), | |
| }), | |
| ], | |
| }), | |
| kind: z, | |
| id: s.id, | |
| shortName: c, | |
| domainName: a, | |
| defaultConfig: r, | |
| defaultState: u, | |
| plainState: s, | |
| subscribers: new Map(), | |
| compositeName: y, | |
| }, | |
| w = { | |
| compositeName: S.compositeName, | |
| graphite: S.graphite, | |
| kind: z, | |
| id: s.id, | |
| shortName: c, | |
| domainName: a, | |
| setState: (e, t) => { | |
| const n = p(S), | |
| r = 'function' == typeof t ? t(n, e) : e | |
| be(w, r) | |
| }, | |
| off: m.bind(null, S), | |
| watch: b.bind(null, S), | |
| updates: N, | |
| subscribe: g.bind(null, S), | |
| getState: p.bind(null, S), | |
| stateRef: s, | |
| } | |
| return ( | |
| (w.defaultConfig = r), | |
| (w.reset = function(e, ...t) { | |
| for (const n of t) h.call(this, e, n, () => e.defaultState) | |
| return this | |
| }.bind(w, S)), | |
| (w.on = h.bind(w, S)), | |
| (w.defaultState = u), | |
| (w.map = function(e, t, n) { | |
| let r | |
| f(e, 'map') | |
| let o = 'Got initial error' | |
| try { | |
| const a = e.getState() | |
| void 0 !== a && (r = t(a, n)), (o = 'Initial') | |
| } catch (e) { | |
| console.error(e) | |
| } | |
| d(o) | |
| const a = this({ | |
| config: {name: e.shortName + ' → *'}, | |
| currentState: r, | |
| parent: e.domainName, | |
| }) | |
| return ( | |
| Me(e, { | |
| child: [a], | |
| scope: {store: e, handler: t, state: a.stateRef}, | |
| node: [ | |
| J.compute({ | |
| fn(e, {state: t, store: n, handler: r}) { | |
| f(n, 'map') | |
| let o, | |
| a = 'Got error' | |
| try { | |
| ;(o = r(e, Z(t))), (a = null) | |
| } catch (e) { | |
| console.error(e) | |
| } | |
| return d(a), o | |
| }, | |
| }), | |
| Ne, | |
| ], | |
| }), | |
| a | |
| ) | |
| }.bind(v, w)), | |
| (w.thru = function(e) { | |
| return e(this) | |
| }.bind(w)), | |
| (w.dispatch = (e => e).bind(null)), | |
| (w[R] = function(e) { | |
| const t = { | |
| subscribe: t => ( | |
| G( | |
| 'object' == typeof t && null !== t, | |
| 'Expected the observer to be an object.', | |
| ), | |
| g(e, e => { | |
| t.next && t.next(e) | |
| }) | |
| ), | |
| } | |
| return ( | |
| (t[R] = function() { | |
| return this | |
| }), | |
| t | |
| ) | |
| }.bind(null, S)), | |
| Re({from: w, to: N}), | |
| w | |
| ) | |
| } | |
| function y(e, t = {}) { | |
| return ( | |
| G( | |
| void 0 !== e, | |
| "createStore: First argument can't be undefined, use null instead.", | |
| ), | |
| v({currentState: e, config: s(t)}) | |
| ) | |
| } | |
| function N(e, t) { | |
| const n = o(t, e.domainName) | |
| ;(e.shortName = t), | |
| e.compositeName | |
| ? ((e.compositeName.path = n.path), | |
| (e.compositeName.shortName = n.shortName), | |
| (e.compositeName.fullName = n.fullName)) | |
| : (e.compositeName = n) | |
| } | |
| function S(e, t) { | |
| const n = Array.isArray(e) | |
| ? Ve(e, e => e.slice(), []) | |
| : Ve(e, e => Object.assign({}, e), {}) | |
| return t ? n.map(t) : n | |
| } | |
| function w(e, t) { | |
| let n | |
| return S((n = t('defaultShape' in e ? e.defaultShape : e.defaultState))) | |
| } | |
| function k(e, t) { | |
| const n = {} | |
| for (const r in t) { | |
| const o = t[r], | |
| a = (n[r] = l(r)) | |
| e.on(a, o) | |
| } | |
| return n | |
| } | |
| function x(e) { | |
| const t = {} | |
| for (const n in e) { | |
| const r = e[n] | |
| t[n] = Ee(r) ? r : v({currentState: r, config: {name: n}}) | |
| } | |
| return t | |
| } | |
| function j(e, t) { | |
| const n = v({ | |
| currentState: t, | |
| parent: e.domainName, | |
| config: {name: e.shortName}, | |
| }) | |
| return n.on(e.done, (e, {result: t}) => t), n | |
| } | |
| function E(e, t) { | |
| const n = v({ | |
| currentState: t, | |
| parent: e.domainName, | |
| config: {name: e.shortName}, | |
| }) | |
| return n.on(e, (e, t) => t), n | |
| } | |
| function I(e, t) { | |
| return Ee(e) ? e : Ie(e) ? E(e, t) : qe(e) ? j(e, t) : x(e) | |
| } | |
| function q(e, t) { | |
| return n => t(e.getState(), n) | |
| } | |
| function C(...e) { | |
| let t, n, r | |
| G(e.length > 0, 'at least one argument required') | |
| { | |
| const r = e[e.length - 1] | |
| 'function' == typeof r ? ((n = e.slice(0, -1)), (t = r)) : (n = e) | |
| } | |
| e: { | |
| if (1 === n.length) { | |
| const e = n[0] | |
| if (!Ee(e)) { | |
| r = e | |
| break e | |
| } | |
| } | |
| ;(r = n), t && (t = We(t)) | |
| } | |
| return S(r, t) | |
| } | |
| function O(e, t, n, r = 0) { | |
| let o | |
| void 0 === t && | |
| 'source' in e && | |
| ((t = e.clock || e.sampler), | |
| (n = e.fn), | |
| (r = e.greedy), | |
| (o = e.target), | |
| (e = e.source)), | |
| void 0 === t && (t = e) | |
| const a = Le(e), | |
| i = Le(t) | |
| return ( | |
| 'boolean' == typeof n && ((r = n), (n = void 0)), | |
| (Ee(a) ? (Ee(i) ? _e : Ue) : Je)(a, i, n, r, o) | |
| ) | |
| } | |
| function D() { | |
| const e = new Promise((e, t) => { | |
| ;(this.rs = e), (this.rj = t) | |
| }) | |
| ;(e.anyway = () => ( | |
| ke(0, '.anyway is deprecated, use .finally'), e.then(() => {}, () => {}) | |
| )), | |
| (this.req = e) | |
| } | |
| function F({name: e, parent: t, config: n}) { | |
| const {handler: r} = n, | |
| o = i({name: e, parent: t, config: n}), | |
| a = o.create, | |
| s = i({name: o.shortName + ' done', parent: t, config: n}), | |
| c = i({name: o.shortName + ' fail', parent: t, config: n}) | |
| s.graphite.seq.push(Qe), c.graphite.seq.push(Qe) | |
| let l = | |
| r || | |
| function() { | |
| return ke(0, 'no thunk used in %s', this.getType()), Promise.resolve() | |
| }.bind(o) | |
| ;(o.done = s), (o.fail = c), (o.use = e => ((l = e), o)) | |
| const u = () => l | |
| return ( | |
| (o.use.getCurrent = u), | |
| (o.kind = P), | |
| (o.graphite.scope = {done: s, fail: c, getHandler: u}), | |
| o.graphite.seq.push( | |
| J.compute({ | |
| fn: e => | |
| 'object' == typeof e && null !== e && 'ɔ' in e | |
| ? e.ɔ | |
| : {params: e, req: {rs(e) {}, rj(e) {}}}, | |
| }), | |
| J.run({ | |
| fn: ({params: e, req: t}, {getHandler: n, done: r, fail: o}) => ( | |
| ((e, t, n, r) => { | |
| let o, | |
| a, | |
| i = 0 | |
| try { | |
| a = e(t) | |
| } catch (e) { | |
| ;(i = 1), (o = e) | |
| } | |
| i | |
| ? r(o) | |
| : 'object' != typeof a || | |
| null === a || | |
| 'function' != typeof a.then | |
| ? n(a) | |
| : a.then(n, r) | |
| })( | |
| n(), | |
| e, | |
| function(e) { | |
| const {event: t, params: n, handler: r} = this | |
| ge(t, {handler: r, toHandler: e, result: {params: n, result: e}}) | |
| }.bind({event: r, params: e, handler: t.rs}), | |
| function(e) { | |
| const {event: t, params: n, handler: r} = this | |
| ge(t, {handler: r, toHandler: e, result: {params: n, error: e}}) | |
| }.bind({event: o, params: e, handler: t.rj}), | |
| ), | |
| e | |
| ), | |
| }), | |
| ), | |
| (o.create = (e, t, n) => { | |
| const r = new D() | |
| return a({ɔ: {params: e, req: r}}, o.getType(), n), r.req | |
| }), | |
| (o.pending = y(Boolean(0)) | |
| .on(o, () => Boolean(1)) | |
| .reset(s) | |
| .reset(c)), | |
| o | |
| ) | |
| } | |
| function H(e, t) { | |
| const {config: n, name: r} = c(e, t) | |
| return F({name: r, domainName: '', config: n}) | |
| } | |
| function M(e, t = {}) { | |
| const {config: n, name: r} = c(e, t) | |
| return (function e({name: t, config: n = {}, parent: r, parentHooks: a}) { | |
| const c = $e(), | |
| l = o(t || '', r), | |
| u = new Xe(), | |
| f = ((e, t, n) => { | |
| let r | |
| return ( | |
| (r = n ? Ze(n) : Ye(t)).domain.watch(t => { | |
| e.domains.add(t) | |
| }), | |
| r.event.watch(t => { | |
| e.events.add(t) | |
| }), | |
| r.store.watch(t => { | |
| e.storages.add(t) | |
| }), | |
| r.effect.watch(t => { | |
| e.effects.add(t) | |
| }), | |
| r | |
| ) | |
| })(u, l, a) | |
| return { | |
| compositeName: l, | |
| id: c, | |
| defaultConfig: n, | |
| getType: () => l.fullName, | |
| onCreateEvent: e => (u.events.forEach(e), f.event.watch(e)), | |
| onCreateEffect: e => (u.effects.forEach(e), f.effect.watch(e)), | |
| onCreateStore: e => (u.storages.forEach(e), f.store.watch(e)), | |
| onCreateDomain: e => (u.domains.forEach(e), f.domain.watch(e)), | |
| event(e, t = {}) { | |
| const n = s(t), | |
| r = i({name: e, parent: l, config: n}) | |
| return f.event(r), r | |
| }, | |
| effect(e, t = {}) { | |
| const n = s(t), | |
| r = F({name: e, domainName: l.fullName, parent: l, config: n}) | |
| return f.effect(r), r | |
| }, | |
| domain(t, n = {}) { | |
| const r = s(n), | |
| o = e({name: t, parent: l, parentHooks: f, config: r}) | |
| return f.domain(o), o | |
| }, | |
| store(e, t = {}) { | |
| const n = s(t), | |
| r = v({currentState: e, parent: l, config: n}) | |
| return f.store(r), r | |
| }, | |
| kind: V, | |
| } | |
| })({name: void 0 === r ? '' : r, config: n}) | |
| } | |
| import R from 'symbol-observable' | |
| const T = '0.18.10', | |
| B = 'production' !== process.env.NODE_ENV | |
| var G = B | |
| ? function e(t, n, ...r) { | |
| if (!t) { | |
| const t = Error() | |
| Error.captureStackTrace && Error.captureStackTrace(t, e), | |
| (t.name = 'Invariant Violation') | |
| let o = 0 | |
| throw ((t.message = n.replace(/%s/g, () => r[o++])), t) | |
| } | |
| } | |
| : e => { | |
| if (!e) throw Error('Minified exception occurred') | |
| } | |
| const z = 'store', | |
| A = 'event', | |
| P = 'effect', | |
| V = 'domain' | |
| var W = Object.freeze({store: z, event: A, effect: P, domain: V}) | |
| const K = () => { | |
| let e = 0 | |
| return () => (++e).toString(36) | |
| }, | |
| U = K(), | |
| _ = (e, t) => ({id: U(), type: e, group: 'cmd', data: t}), | |
| J = { | |
| barrier: ({barrierID: e, priority: t = 'barrier'}) => | |
| _('barrier', {barrierID: e, priority: t}), | |
| compute: _.bind(null, 'compute'), | |
| emit: _.bind(null, 'emit'), | |
| filter: _.bind(null, 'filter'), | |
| run: _.bind(null, 'run'), | |
| tap: _.bind(null, 'tap'), | |
| update: _.bind(null, 'update'), | |
| }, | |
| L = (e, {deep: t} = {}) => { | |
| const n = Q(e) | |
| t && n.next.forEach(e => L(e, {deep: t})), | |
| n.from.forEach(e => { | |
| const t = e.next.indexOf(n) | |
| ;-1 !== t && e.next.splice(t, 1) | |
| }), | |
| (n.from.length = 0), | |
| (n.next.length = 0), | |
| (n.seq.length = 0), | |
| (n.scope = null) | |
| }, | |
| Q = e => e.graphite || e, | |
| X = K(), | |
| Y = e => ({id: X(), current: e}), | |
| Z = ({current: e}) => e, | |
| $ = (e, t) => (e.current = t), | |
| ee = K(), | |
| te = e => { | |
| switch (e) { | |
| case 'child': | |
| return 0 | |
| case 'pure': | |
| return 1 | |
| case 'barrier': | |
| return 2 | |
| case 'sampler': | |
| return 3 | |
| case 'effect': | |
| return 4 | |
| default: | |
| return -1 | |
| } | |
| } | |
| class ne { | |
| constructor(e, t) { | |
| ;(this.value = {current: e}), (this.parent = t) | |
| } | |
| } | |
| class re { | |
| constructor(e, t, n, r) { | |
| ;(this.value = e), (this.rank = t), (this.left = n), (this.right = r) | |
| } | |
| } | |
| const oe = e => (e ? ae(e.left, e.right) : null), | |
| ae = (e, t) => { | |
| let n, r, o, a, i, s, c | |
| for (;;) { | |
| var l, u | |
| if (((n = t), !(r = e))) return n | |
| if (!n) return r | |
| if (((a = r.left), !se((o = r.value), n.value))) | |
| return ( | |
| (i = ae(r.right, n)), | |
| (s = (null === (l = a) || void 0 === l ? void 0 : l.rank) || 0) >= | |
| (c = (null === (u = i) || void 0 === u ? void 0 : u.rank) || 0) | |
| ? new re(o, c + 1, a, i) | |
| : new re(o, s + 1, i, a) | |
| ) | |
| ;(t = r), (e = n) | |
| } | |
| } | |
| class ie { | |
| constructor(e) { | |
| ;(this.isChanged = 1), (this.isFailed = 0), (this.scope = e) | |
| } | |
| } | |
| const se = (e, t) => (e.type === t.type ? e.id > t.id : te(e.type) > te(t.type)) | |
| let ce = 0, | |
| le = null | |
| const ue = new Set(), | |
| fe = e => { | |
| le = ((e, t) => ae(new re(e, 1, null, null), t))(e, le) | |
| }, | |
| de = ({step: e, firstIndex: t, scope: n, resetStop: r}, o) => { | |
| const a = new ie(e.scope) | |
| for (let r = t; r < e.seq.length && !o.stop; r++) { | |
| const i = e.seq[r] | |
| if (r === t) 'barrier' === i.type && ue.delete(i.data.barrierID) | |
| else | |
| switch (i.type) { | |
| case 'run': | |
| return void fe({ | |
| step: e, | |
| firstIndex: r, | |
| scope: n, | |
| resetStop: 0, | |
| type: 'effect', | |
| id: ++ce, | |
| }) | |
| case 'barrier': { | |
| const t = i.data.barrierID | |
| return void ( | |
| ue.has(t) || | |
| (ue.add(t), | |
| fe({ | |
| step: e, | |
| firstIndex: r, | |
| scope: n, | |
| resetStop: 0, | |
| type: i.data.priority, | |
| id: ++ce, | |
| })) | |
| ) | |
| } | |
| } | |
| ;(0, ve[i.type])(a, i.data, n.value), | |
| (o.stop = a.isFailed || !a.isChanged) | |
| } | |
| if (!o.stop) | |
| for (let t = 0; t < e.next.length; t++) { | |
| const r = new ne(Z(n.value), n) | |
| fe({ | |
| step: e.next[t], | |
| firstIndex: 0, | |
| scope: r, | |
| resetStop: 1, | |
| type: 'child', | |
| id: ++ce, | |
| }) | |
| } | |
| r && (o.stop = 0) | |
| } | |
| let pe = 0 | |
| const me = (e, t) => { | |
| fe({ | |
| step: Q(e), | |
| firstIndex: 0, | |
| scope: new ne(t, null), | |
| resetStop: 0, | |
| type: 'pure', | |
| id: ++ce, | |
| }) | |
| }, | |
| he = () => { | |
| const e = pe | |
| pe = 1 | |
| const t = {stop: 0} | |
| let n | |
| for (; le; ) (n = le.value), (le = oe(le)), de(n, t) | |
| pe = e | |
| }, | |
| be = (e, t) => { | |
| me(e, t), he() | |
| }, | |
| ge = (e, t) => { | |
| me(e, t), pe || he() | |
| }, | |
| ve = { | |
| barrier(e, t, n) { | |
| ;(e.isFailed = 0), (e.isChanged = 1) | |
| }, | |
| emit(e, t, n) {}, | |
| filter(e, t, n) { | |
| const r = ye({arg: Z(n), val: e.scope, fn: t.fn}) | |
| e.isChanged = !!r.result | |
| }, | |
| run(e, t, n) { | |
| const r = ye({arg: Z(n), val: e.scope, fn: t.fn}) | |
| ;(e.isFailed = r.err), $(n, r.result) | |
| }, | |
| update(e, t, n) { | |
| $(t.store, Z(n)) | |
| }, | |
| compute(e, t, n) { | |
| const r = ye({arg: Z(n), val: e.scope, fn: t.fn}) | |
| ;(e.isFailed = r.err), $(n, r.result) | |
| }, | |
| tap(e, t, n) { | |
| const r = ye({arg: Z(n), val: e.scope, fn: t.fn}) | |
| e.isFailed = r.err | |
| }, | |
| }, | |
| ye = ({fn: e, arg: t, val: n}) => { | |
| const r = {err: 0, result: null} | |
| try { | |
| r.result = e(t, n) | |
| } catch (e) { | |
| console.error(e), (r.err = 1) | |
| } | |
| return r | |
| }, | |
| Ne = J.filter({fn: (e, {state: t}) => e !== Z(t) && void 0 !== e}), | |
| Se = J.compute({fn: e => e}) | |
| var we = Object.freeze({filterChanged: Ne, noop: Se}), | |
| ke = B | |
| ? (e, t, ...n) => { | |
| e || console.error('Warning: ' + t, ...n) | |
| } | |
| : () => {} | |
| const xe = e => | |
| ('function' == typeof e || ('object' == typeof e && null !== e)) && | |
| 'kind' in e, | |
| je = e => t => xe(t) && t.kind === e, | |
| Ee = je(z), | |
| Ie = je(A), | |
| qe = je(P), | |
| Ce = je(V) | |
| var Oe = Object.freeze({unit: xe, store: Ee, event: Ie, effect: qe, domain: Ce}) | |
| const De = 25, | |
| Fe = () => -1, | |
| He = () => [], | |
| Me = (t, n) => Re({from: t, to: e(n)}), | |
| Re = e => { | |
| const t = Q(e.from), | |
| n = Q(e.to) | |
| return ( | |
| t.next.push(n), | |
| (e => { | |
| const t = e.parent.next, | |
| n = {indexOf: t.indexOf.bind(t, e.child), splice: t.splice.bind(t)}, | |
| r = a.bind(n) | |
| return (r.unsubscribe = a.bind(n)), r | |
| })({child: n, parent: t}) | |
| ) | |
| }, | |
| Te = K() | |
| let Be = null, | |
| Ge = null | |
| if (B) { | |
| const e = '☄', | |
| n = | |
| 'undefined' != typeof performance && | |
| 'function' == typeof performance.mark && | |
| 'function' == typeof performance.clearMarks && | |
| 'function' == typeof performance.measure && | |
| 'function' == typeof performance.clearMeasures | |
| function ze(t) { | |
| return e + ' ' + t | |
| } | |
| const r = (t, n) => e + ' ' + t + (n ? ' Warning: ' + n : '') | |
| function Ae(e, t) { | |
| return e + '.' + t | |
| } | |
| function Pe(e, t) { | |
| return e + ' (#' + t + ')' | |
| } | |
| const o = () => { | |
| null !== Be && | |
| null !== Ge && | |
| ((e, n) => { | |
| const r = t(e), | |
| o = e.id | |
| var a | |
| ;(a = Pe(Ae(r, n), o)), performance.clearMarks(ze(a)) | |
| })(Ge, Be), | |
| (Ge = null), | |
| (Be = null) | |
| } | |
| ;(f = (e, r) => { | |
| n && | |
| (o(), | |
| ((e, n) => { | |
| const r = t(e), | |
| o = e.id | |
| return (a = Pe(Ae(r, n), o)), performance.mark(ze(a)), 1 | |
| var a | |
| })(e, r) && ((Ge = e), (Be = r))) | |
| }), | |
| (d = e => { | |
| n && | |
| (null !== Be && | |
| null !== Ge && | |
| ((e, n, o) => { | |
| const a = t(e), | |
| i = e.id, | |
| s = Ae(a, n) | |
| ;((e, t, n) => { | |
| const o = ze(t), | |
| a = r(e, n) | |
| try { | |
| performance.measure(a, o) | |
| } catch (e) {} | |
| performance.clearMarks(o), performance.clearMeasures(a) | |
| })(s, Pe(s, i), o) | |
| })(Ge, Be, e), | |
| (Be = null), | |
| (Ge = null)) | |
| }) | |
| } | |
| const Ve = (e, t, r) => { | |
| const o = [ | |
| J.filter({ | |
| fn: (e, {target: t, key: n}) => e !== Z(t)[n] && void 0 !== e, | |
| }), | |
| J.tap({ | |
| fn(e, {isFresh: t, target: n, clone: r}) { | |
| Z(t) || ($(n, r(Z(n))), $(t, 1)) | |
| }, | |
| }), | |
| J.tap({ | |
| fn(e, {target: t, key: n}) { | |
| Z(t)[n] = e | |
| }, | |
| }), | |
| J.barrier({barrierID: ee()}), | |
| J.compute({fn: (e, {isFresh: t, target: n}) => ($(t, 0), Z(n))}), | |
| ], | |
| a = t(r), | |
| i = v({currentState: a, config: {name: n(e)}}), | |
| s = Y(0) | |
| for (const n in e) { | |
| const c = e[n] | |
| Ee(c) | |
| ? ((r[n] = c.defaultState), | |
| (a[n] = c.getState()), | |
| Me(c, { | |
| scope: {key: n, clone: t, target: i.stateRef, isFresh: s}, | |
| node: o, | |
| child: [i], | |
| })) | |
| : (a[n] = r[n] = c) | |
| } | |
| return (i.defaultShape = e), (i.defaultState = r), i | |
| }, | |
| We = e => t => e(...t), | |
| Ke = (e, t, n, r, o) => ( | |
| Me(t, { | |
| scope: {state: e.stateRef, fn: n}, | |
| child: [o], | |
| node: [ | |
| !r && Se, | |
| !r && J.barrier({barrierID: ee(), priority: 'sampler'}), | |
| J.compute({ | |
| fn: n | |
| ? (e, {state: t, fn: n}) => n(Z(t), e) | |
| : (e, {state: t}) => Z(t), | |
| }), | |
| ].filter(Boolean), | |
| }), | |
| o | |
| ), | |
| Ue = (e, t, n, r, o) => | |
| Ke(e, t, n, r, o || i({name: e.shortName, parent: e.domainName})), | |
| _e = (e, t, n, r, o) => { | |
| const a = Z(e.stateRef) | |
| return Ke( | |
| e, | |
| t, | |
| n, | |
| r, | |
| o || | |
| v({ | |
| currentState: n ? n(a, Z(t.stateRef)) : a, | |
| config: {name: e.shortName}, | |
| parent: e.domainName, | |
| }), | |
| ) | |
| }, | |
| Je = (e, t, n, r, o) => { | |
| o = o || i({name: e.shortName, parent: e.domainName}) | |
| const a = Y(0), | |
| s = Y(), | |
| c = Y() | |
| return ( | |
| Me(e, { | |
| scope: {hasSource: a}, | |
| node: [ | |
| J.update({store: s}), | |
| J.tap({ | |
| fn(e, {hasSource: t}) { | |
| $(t, 1) | |
| }, | |
| }), | |
| ], | |
| }), | |
| Me(t, { | |
| scope: {sourceState: s, clockState: c, hasSource: a, fn: n}, | |
| child: [o], | |
| node: [ | |
| J.update({store: c}), | |
| J.filter({fn: (e, {hasSource: t}) => Z(t)}), | |
| !r && J.barrier({barrierID: ee(), priority: 'sampler'}), | |
| J.compute({ | |
| fn: n | |
| ? (e, {sourceState: t, clockState: n, fn: r}) => r(Z(t), Z(n)) | |
| : (e, {sourceState: t}) => Z(t), | |
| }), | |
| ].filter(Boolean), | |
| }), | |
| o | |
| ) | |
| }, | |
| Le = e => (xe(e) ? e : S(e)), | |
| Qe = J.run({fn: ({handler: e, toHandler: t, result: n}) => (e(t), n)}) | |
| class Xe { | |
| constructor() { | |
| ;(this.events = new Set()), | |
| (this.effects = new Set()), | |
| (this.storages = new Set()), | |
| (this.domains = new Set()) | |
| } | |
| } | |
| const Ye = e => ({ | |
| event: i({name: e.fullName + ' event hook', parent: e}), | |
| effect: i({name: e.fullName + ' effect hook', parent: e}), | |
| store: i({name: e.fullName + ' store hook', parent: e}), | |
| domain: i({parent: e}), | |
| }), | |
| Ze = e => ({ | |
| event: e.event.prepend(e => e), | |
| effect: e.effect.prepend(e => e), | |
| store: e.store.prepend(e => e), | |
| domain: e.domain.prepend(e => e), | |
| }), | |
| $e = K() | |
| export { | |
| W as Kind, | |
| we as blocks, | |
| L as clearNode, | |
| C as combine, | |
| k as createApi, | |
| M as createDomain, | |
| H as createEffect, | |
| l as createEvent, | |
| e as createNode, | |
| y as createStore, | |
| C as createStoreObject, | |
| w as extract, | |
| Re as forward, | |
| u as fromObservable, | |
| G as invariant, | |
| Oe as is, | |
| Ce as isDomain, | |
| qe as isEffect, | |
| Ie as isEvent, | |
| Ee as isStore, | |
| xe as isUnit, | |
| be as launch, | |
| I as restore, | |
| j as restoreEffect, | |
| E as restoreEvent, | |
| x as restoreObject, | |
| O as sample, | |
| N as setStoreName, | |
| J as step, | |
| T as version, | |
| ke as warning, | |
| q as withProps, | |
| } | |
| //# sourceMappingURL=effector.es.js.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment