rx-tiny-flux 1.0.23 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,129 @@
1
+ import { OperatorFunction, Subscription, Observable } from 'rxjs';
2
+ export * from 'rxjs';
3
+
4
+ /**
5
+ * Represents a Flux Standard Action.
6
+ */
7
+ interface Action<T = any> {
8
+ type: string;
9
+ payload?: T;
10
+ context?: any;
11
+ }
12
+
13
+ /**
14
+ * Describes a ZeppOS Page enhanced by the `storePlugin`.
15
+ */
16
+ interface StorePage {
17
+ /**
18
+ * Dispatches an action to the store.
19
+ */
20
+ dispatch(action: Action): void;
21
+
22
+ /**
23
+ * Subscribes to a slice of the store's state. The subscription is auto-managed.
24
+ */
25
+ subscribe<T, A = T, B = A, C = B, D = C, E = D, F = E>(
26
+ selector: (state: object) => T,
27
+ op1?: OperatorFunction<T, A>,
28
+ op2?: OperatorFunction<A, B>,
29
+ op3?: OperatorFunction<B, C>,
30
+ op4?: OperatorFunction<C, D>,
31
+ op5?: OperatorFunction<D, E>,
32
+ op6?: OperatorFunction<E, F>,
33
+ callback: (value: F) => void
34
+ ): Subscription;
35
+
36
+ /**
37
+ * Subscribes to specific store actions to trigger side-effects.
38
+ */
39
+ listen(
40
+ actionTypes: (string | { type: string }) | Array<string | { type: string }>,
41
+ callback: (action: Action) => void
42
+ ): void;
43
+
44
+ /**
45
+ * Handler for actions received via the messaging system.
46
+ */
47
+ onAction(action: Action): void;
48
+ }
49
+
50
+ /**
51
+ * The central state container.
52
+ */
53
+ declare class Store {
54
+ constructor(initialState?: object);
55
+ get actions$(): Observable<Action>;
56
+ registerReducers(...reducers: any[]): void;
57
+ setContext(context: object): void;
58
+ registerEffects(...effects: ((actions: Observable<Action>) => Observable<Action>)[]): void;
59
+ dispatch(action: Action): void;
60
+ select<T>(selectorFn: (state: object) => T): Observable<T>;
61
+ }
62
+
63
+ /**
64
+ * Factory function to create an action creator.
65
+ */
66
+ declare function createAction(type: string): ((payload?: any) => Action) & { type: string };
67
+
68
+ /**
69
+ * A token to be used with `on` to catch any action.
70
+ */
71
+ declare function anyAction(): void;
72
+
73
+ /**
74
+ * Associates action creators with a reducer function.
75
+ */
76
+ declare function on(...args: (Function | ((state: any, action: Action) => any))[]): { types: string[], reducerFn: Function };
77
+
78
+ /**
79
+ * Factory function to create a reducer.
80
+ */
81
+ declare function createReducer(featureKey: string, initialState: any, ...ons: any[]): { path: string, initialState: any, reducerFn: Function };
82
+
83
+ /**
84
+ * Factory function to create an effect.
85
+ */
86
+ declare function createEffect(effectFn: (actions: Observable<Action>) => Observable<Action>, config?: { dispatch?: boolean }): Function;
87
+
88
+ /**
89
+ * Custom RxJS operator to filter actions by type.
90
+ */
91
+ declare function ofType(...actionCreators: Function[]): OperatorFunction<Action, Action>;
92
+
93
+ /**
94
+ * Creates a selector for a top-level state slice.
95
+ */
96
+ declare function createFeatureSelector<T>(featureKey: string, projectionFn?: (featureState: any) => T): (state: object) => T;
97
+
98
+ /**
99
+ * Creates a memoized selector that composes other selectors.
100
+ */
101
+ declare function createSelector(...args: Function[]): (state: object) => any;
102
+
103
+ /**
104
+ * The store plugin for ZeppOS App/Page/Service.
105
+ */
106
+ declare function storePlugin(instance: object, store?: Store): object;
107
+
108
+ /**
109
+ * RxJS operator to combine an action with the latest value from the store.
110
+ */
111
+ declare function withLatestFromStore<T>(selector: (state: object) => T): OperatorFunction<Action, [Action, T]>;
112
+
113
+ /**
114
+ * RxJS operator that filters for the Side Service environment.
115
+ */
116
+ declare const isSideService: () => OperatorFunction<any, any>;
117
+
118
+ /**
119
+ * RxJS operator that filters for the App/Page environment.
120
+ */
121
+ declare const isApp: () => OperatorFunction<any, any>;
122
+
123
+ /**
124
+ * RxJS operator to propagate an action to another ZeppOS context.
125
+ */
126
+ declare const propagateAction: () => OperatorFunction<Action, Action>;
127
+
128
+ export { Store, anyAction, createAction, createEffect, createFeatureSelector, createReducer, createSelector, isApp, isSideService, ofType, on, propagateAction, storePlugin, withLatestFromStore };
129
+ export type { Action, StorePage };
@@ -1913,7 +1913,7 @@ function withLatestFrom() {
1913
1913
  }
1914
1914
 
1915
1915
  /**
1916
- * @typedef {import('./actions').Action} Action
1916
+ * @typedef {import('./types').Action} Action
1917
1917
  */
1918
1918
 
1919
1919
  class Store {
@@ -1963,26 +1963,26 @@ class Store {
1963
1963
 
1964
1964
  const state$ = dispatcher$.pipe(
1965
1965
  scan((currentState, action) => {
1966
- // Clones the state to ensure immutability.
1967
- // For larger apps, a library like `lodash.cloneDeep` would be more robust.
1968
- const nextState = JSON.parse(JSON.stringify(currentState));
1966
+ // Create a shallow copy of the state. This is key to preserving references
1967
+ // for unchanged state slices, which allows memoized selectors to work.
1968
+ let nextState = { ...currentState };
1969
+ let hasChanged = false;
1969
1970
 
1970
1971
  this._reducers.forEach(({ path: featureKey, reducerFn }) => {
1971
1972
  // Gets the current state slice.
1972
- const stateSlice = nextState[featureKey];
1973
+ const stateSlice = currentState[featureKey];
1973
1974
 
1974
1975
  // Executes the reducer to get the new slice.
1975
1976
  const nextStateSlice = reducerFn(stateSlice, action);
1976
1977
 
1977
- // If the reducer returned a new value (not undefined) and it's different from the previous one,
1978
- // apply the change to the state object.
1979
- if (nextStateSlice !== undefined && stateSlice !== nextStateSlice) {
1980
- // Directly assign the new slice to the corresponding key in the state.
1978
+ // If the reducer returned a new object reference, the slice has changed.
1979
+ if (stateSlice !== nextStateSlice) {
1981
1980
  nextState[featureKey] = nextStateSlice;
1981
+ hasChanged = true;
1982
1982
  }
1983
1983
  });
1984
1984
 
1985
- return nextState;
1985
+ return hasChanged ? nextState : currentState;
1986
1986
  }, initialStoreState),
1987
1987
  startWith(initialState),
1988
1988
  // Ensures new subscribers receive the last emitted state and shares the execution.
@@ -2000,19 +2000,23 @@ class Store {
2000
2000
  registerReducers(...reducers) {
2001
2001
  this._reducers.push(...reducers);
2002
2002
 
2003
- // Builds the initial state from the registered reducers
2003
+ // Get the current state and prepare a shallow copy.
2004
2004
  const currentState = this._state$.getValue();
2005
- const nextState = JSON.parse(JSON.stringify(currentState));
2005
+ const nextState = { ...currentState };
2006
+ let hasChanged = false;
2006
2007
 
2007
2008
  reducers.forEach(({ path: featureKey, initialState }) => {
2008
2009
  // If the state slice has not been defined yet, apply the reducer's initial state.
2009
2010
  if (nextState[featureKey] === undefined) {
2010
2011
  nextState[featureKey] = initialState;
2012
+ hasChanged = true;
2011
2013
  }
2012
2014
  });
2013
2015
 
2014
- // Emits the new constructed state
2015
- this._state$.next(nextState);
2016
+ // Only emit a new state if a new feature slice was actually added.
2017
+ if (hasChanged) {
2018
+ this._state$.next(nextState);
2019
+ }
2016
2020
  }
2017
2021
 
2018
2022
  /**
@@ -2072,12 +2076,6 @@ class Store {
2072
2076
  }
2073
2077
  }
2074
2078
 
2075
- /**
2076
- * @typedef {Object} Action
2077
- * @property {string} type - The action type, a unique string describing it.
2078
- * @property {any} [payload] - The data associated with the action.
2079
- */
2080
-
2081
2079
  /**
2082
2080
  * Factory function to create an action.
2083
2081
  * @param {string} type - The action type.
@@ -2090,7 +2088,7 @@ function createAction(type) {
2090
2088
  }
2091
2089
 
2092
2090
  /**
2093
- * @typedef {import('./actions').Action} Action
2091
+ * @typedef {import('./types').Action} Action
2094
2092
  */
2095
2093
 
2096
2094
  /**
@@ -2158,7 +2156,7 @@ function createReducer(featureKey, initialState, ...ons) {
2158
2156
  }
2159
2157
 
2160
2158
  /**
2161
- * @typedef {import('./actions').Action} Action
2159
+ * @typedef {import('./types').Action} Action
2162
2160
  * @typedef {import('rxjs').Observable<Action>} ActionStream
2163
2161
  */
2164
2162
 
@@ -2225,14 +2223,47 @@ function createSelector(...args) {
2225
2223
  // All previous arguments are the input selectors.
2226
2224
  const inputSelectors = args;
2227
2225
 
2228
- if (typeof projectionFn !== 'function') {
2229
- throw new Error('The last argument to createSelector must be a projection function.');
2230
- }
2226
+ // Memoization state
2227
+ let lastResult;
2228
+ let lastArgs;
2229
+ let hasRun = false;
2231
2230
 
2232
- return (state) => {
2233
- const inputs = inputSelectors.map(selector => selector(state));
2234
- return projectionFn(...inputs);
2231
+ /**
2232
+ * Checks if two arrays of arguments are shallowly equal.
2233
+ * @param {any[]} a - First array of arguments.
2234
+ * @param {any[]} b - Second array of arguments.
2235
+ * @returns {boolean} - True if the arrays are equal.
2236
+ */
2237
+ function areArgsEqual(a, b) {
2238
+ if (!b || a.length !== b.length) {
2239
+ return false;
2240
+ }
2241
+ for (let i = 0; i < a.length; i++) {
2242
+ // Strict equality check for each argument. This works because our improved
2243
+ // store logic preserves references for unchanged state slices.
2244
+ if (a[i] !== b[i]) {
2245
+ return false;
2246
+ }
2247
+ }
2248
+ return true;
2235
2249
  }
2250
+
2251
+ return (state) => {
2252
+ const newArgs = inputSelectors.map(selector => selector(state));
2253
+
2254
+ if (hasRun && areArgsEqual(newArgs, lastArgs)) {
2255
+ // If the inputs from selectors are the same as last time, return the cached result.
2256
+ // This preserves reference equality for derived data.
2257
+ return lastResult;
2258
+ }
2259
+
2260
+ // Otherwise, compute the new result, cache it, and return it.
2261
+ lastArgs = newArgs;
2262
+ lastResult = projectionFn(...newArgs);
2263
+ hasRun = true;
2264
+
2265
+ return lastResult;
2266
+ };
2236
2267
  }
2237
2268
 
2238
2269
  /**
@@ -2271,8 +2302,10 @@ function storePlugin(instance, store) {
2271
2302
  this.debug('Attach the store and a dispatch method to the App instance.');
2272
2303
  this._store = store;
2273
2304
  this.dispatch = (action) => {
2274
- const actionWithContext = { ...action, context: this };
2275
- this._store.dispatch(actionWithContext);
2305
+ setTimeout(() => {
2306
+ const actionWithContext = { ...action, context: this };
2307
+ this._store.dispatch(actionWithContext);
2308
+ }, 50);
2276
2309
  };
2277
2310
 
2278
2311
  this.onAction = (action) => {
@@ -2363,8 +2396,10 @@ function storePlugin(instance, store) {
2363
2396
 
2364
2397
  this.debug(`Attaching store methods to the ${isSideServiceContext ? 'SideService' : 'Page'} instance.`);
2365
2398
  this.dispatch = (action) => {
2366
- const actionWithContext = { ...action, context: this };
2367
- this._store.dispatch(actionWithContext);
2399
+ setTimeout(() => {
2400
+ const actionWithContext = { ...action, context: this };
2401
+ this._store.dispatch(actionWithContext);
2402
+ }, 50);
2368
2403
  };
2369
2404
 
2370
2405
  /**
@@ -2435,7 +2470,7 @@ function storePlugin(instance, store) {
2435
2470
  }
2436
2471
 
2437
2472
  /**
2438
- * @typedef {import('./actions').Action} Action
2473
+ * @typedef {import('./types').Action} Action
2439
2474
  */
2440
2475
 
2441
2476
  /**
@@ -1 +1 @@
1
- var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};function n(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function e(t,n,e,r){return new(e||(e=Promise))(function(o,i){function u(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(u,s)}c((r=r.apply(t,n||[])).next())})}function r(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=s(0),u.throw=s(1),u.return=s(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function s(s){return function(c){return function(s){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,s[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=n.call(t,i)}catch(t){s=[6,t],r=0}finally{e=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function o(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u}function u(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}function s(t){return this instanceof s?(this.v=t,this):new s(t)}function c(t,n,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=e.apply(t,n||[]),i=[];return r=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",function(t){return function(n){return Promise.resolve(n).then(t,l)}}),r[Symbol.asyncIterator]=function(){return this},r;function u(t,n){o[t]&&(r[t]=function(n){return new Promise(function(e,r){i.push([t,n,e,r])>1||c(t,n)})},n&&(r[t]=n(r[t])))}function c(t,n){try{(e=o[t](n)).value instanceof s?Promise.resolve(e.value.v).then(a,l):f(i[0][2],e)}catch(t){f(i[0][3],t)}var e}function a(t){c("next",t)}function l(t){c("throw",t)}function f(t,n){t(n),i.shift(),i.length&&c(i[0][0],i[0][1])}}function a(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,e=t[Symbol.asyncIterator];return e?e.call(t):(t=o(t),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(e){n[e]=t[e]&&function(n){return new Promise(function(r,o){(function(t,n,e,r){Promise.resolve(r).then(function(n){t({value:n,done:e})},n)})(r,o,(n=t[e](n)).done,n.value)})}}}function l(t){return"function"==typeof t}function f(t){var n=t(function(t){Error.call(t),t.stack=(new Error).stack});return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}"function"==typeof SuppressedError&&SuppressedError;var h=f(function(t){return function(n){t(this),this.message=n?n.length+" errors occurred during unsubscription:\n"+n.map(function(t,n){return n+1+") "+t.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=n}});function p(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var d=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var n;return t.prototype.unsubscribe=function(){var t,n,e,r,s;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var a=o(c),f=a.next();!f.done;f=a.next()){f.value.remove(this)}}catch(n){t={error:n}}finally{try{f&&!f.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else c.remove(this);var p=this.initialTeardown;if(l(p))try{p()}catch(t){s=t instanceof h?t.errors:[t]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var b=o(d),v=b.next();!v.done;v=b.next()){var m=v.value;try{y(m)}catch(t){s=null!=s?s:[],t instanceof h?s=u(u([],i(s)),i(t.errors)):s.push(t)}}}catch(t){e={error:t}}finally{try{v&&!v.done&&(r=b.return)&&r.call(b)}finally{if(e)throw e.error}}}if(s)throw new h(s)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)y(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=null!==(e=this._finalizers)&&void 0!==e?e:[]).push(n)}},t.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},t.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},t.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&p(n,t)},t.prototype.remove=function(n){var e=this._finalizers;e&&p(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=((n=new t).closed=!0,n),t}(),b=d.EMPTY;function v(t){return t instanceof d||t&&"closed"in t&&l(t.remove)&&l(t.add)&&l(t.unsubscribe)}function y(t){l(t)?t():t.unsubscribe()}var m={Promise:void 0},w=function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,u([t,n],i(e)))};function _(t){w(function(){throw t})}function g(){}function x(t){t()}var S=function(t){function e(n){var e=t.call(this)||this;return e.isStopped=!1,n?(e.destination=n,v(n)&&n.add(e)):e.destination=P,e}return n(e,t),e.create=function(t,n,e){return new E(t,n,e)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(d),A=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(t){O(t)}},t.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(t){O(t)}else O(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){O(t)}},t}(),E=function(t){function e(n,e,r){var o,i=t.call(this)||this;return o=l(n)||!n?{next:null!=n?n:void 0,error:null!=e?e:void 0,complete:null!=r?r:void 0}:n,i.destination=new A(o),i}return n(e,t),e}(S);function O(t){_(t)}var P={closed:!0,next:g,error:function(t){throw t},complete:g},I="function"==typeof Symbol&&Symbol.observable||"@@observable";function C(t){return t}function T(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return j(t)}function j(t){return 0===t.length?C:1===t.length?t[0]:function(n){return t.reduce(function(t,n){return n(t)},n)}}var $=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(n){var e=new t;return e.source=this,e.operator=n,e},t.prototype.subscribe=function(t,n,e){var r,o=this,i=(r=t)&&r instanceof S||function(t){return t&&l(t.next)&&l(t.error)&&l(t.complete)}(r)&&v(r)?t:new E(t,n,e);return x(function(){var t=o,n=t.operator,e=t.source;i.add(n?n.call(i,e):e?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},t.prototype.forEach=function(t,n){var e=this;return new(n=z(n))(function(n,r){var o=new E({next:function(n){try{t(n)}catch(t){r(t),o.unsubscribe()}},error:r,complete:n});e.subscribe(o)})},t.prototype._subscribe=function(t){var n;return null===(n=this.source)||void 0===n?void 0:n.subscribe(t)},t.prototype[I]=function(){return this},t.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return j(t)(this)},t.prototype.toPromise=function(t){var n=this;return new(t=z(t))(function(t,e){var r;n.subscribe(function(t){return r=t},function(t){return e(t)},function(){return t(r)})})},t.create=function(n){return new t(n)},t}();function z(t){var n;return null!==(n=null!=t?t:m.Promise)&&void 0!==n?n:Promise}function k(t){return function(n){if(function(t){return l(null==t?void 0:t.lift)}(n))return n.lift(function(n){try{return t(n,this)}catch(t){this.error(t)}});throw new TypeError("Unable to lift unknown Observable type")}}function F(t,n,e,r,o){return new N(t,n,e,r,o)}var N=function(t){function e(n,e,r,o,i,u){var s=t.call(this,n)||this;return s.onFinalize=i,s.shouldUnsubscribe=u,s._next=e?function(t){try{e(t)}catch(t){n.error(t)}}:t.prototype._next,s._error=o?function(t){try{o(t)}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._error,s._complete=r?function(){try{r()}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,s}return n(e,t),e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var e=this.closed;t.prototype.unsubscribe.call(this),!e&&(null===(n=this.onFinalize)||void 0===n||n.call(this))}},e}(S),R=f(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),B=function(t){function e(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return n(e,t),e.prototype.lift=function(t){var n=new D(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new R},e.prototype.next=function(t){var n=this;x(function(){var e,r;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var i=o(n.currentObservers),u=i.next();!u.done;u=i.next()){u.value.next(t)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}}})},e.prototype.error=function(t){var n=this;x(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var e=n.observers;e.length;)e.shift().error(t)}})},e.prototype.complete=function(){var t=this;x(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,e=this,r=e.hasError,o=e.isStopped,i=e.observers;return r||o?b:(this.currentObservers=null,i.push(t),new d(function(){n.currentObservers=null,p(i,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,e=n.hasError,r=n.thrownError,o=n.isStopped;e?t.error(r):o&&t.complete()},e.prototype.asObservable=function(){var t=new $;return t.source=this,t},e.create=function(t,n){return new D(t,n)},e}($),D=function(t){function e(n,e){var r=t.call(this)||this;return r.destination=n,r.source=e,r}return n(e,t),e.prototype.next=function(t){var n,e;null===(e=null===(n=this.destination)||void 0===n?void 0:n.next)||void 0===e||e.call(n,t)},e.prototype.error=function(t){var n,e;null===(e=null===(n=this.destination)||void 0===n?void 0:n.error)||void 0===e||e.call(n,t)},e.prototype.complete=function(){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===n||n.call(t)},e.prototype._subscribe=function(t){var n,e;return null!==(e=null===(n=this.source)||void 0===n?void 0:n.subscribe(t))&&void 0!==e?e:b},e}(B),J=function(t){function e(n){var e=t.call(this)||this;return e._value=n,e}return n(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(n){var e=t.prototype._subscribe.call(this,n);return!e.closed&&n.next(this._value),e},e.prototype.getValue=function(){var t=this,n=t.hasError,e=t.thrownError,r=t._value;if(n)throw e;return this._throwIfClosed(),r},e.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},e}(B),U={now:function(){return(U.delegate||Date).now()},delegate:void 0},W=function(t){function e(n,e,r){void 0===n&&(n=1/0),void 0===e&&(e=1/0),void 0===r&&(r=U);var o=t.call(this)||this;return o._bufferSize=n,o._windowTime=e,o._timestampProvider=r,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=e===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,e),o}return n(e,t),e.prototype.next=function(n){var e=this,r=e.isStopped,o=e._buffer,i=e._infiniteTimeWindow,u=e._timestampProvider,s=e._windowTime;r||(o.push(n),!i&&o.push(u.now()+s)),this._trimBuffer(),t.prototype.next.call(this,n)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),e=this._infiniteTimeWindow,r=this._buffer.slice(),o=0;o<r.length&&!t.closed;o+=e?1:2)t.next(r[o]);return this._checkFinalizedStatuses(t),n},e.prototype._trimBuffer=function(){var t=this,n=t._bufferSize,e=t._timestampProvider,r=t._buffer,o=t._infiniteTimeWindow,i=(o?1:2)*n;if(n<1/0&&i<r.length&&r.splice(0,r.length-i),!o){for(var u=e.now(),s=0,c=1;c<r.length&&r[c]<=u;c+=2)s=c;s&&r.splice(0,s+1)}},e}(B),M=function(t){function e(n,e){return t.call(this)||this}return n(e,t),e.prototype.schedule=function(t,n){return this},e}(d),V=function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,u([t,n],i(e)))},Y=function(t){return clearInterval(t)},q=function(t){function e(n,e){var r=t.call(this,n,e)||this;return r.scheduler=n,r.work=e,r.pending=!1,r}return n(e,t),e.prototype.schedule=function(t,n){var e;if(void 0===n&&(n=0),this.closed)return this;this.state=t;var r=this.id,o=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(o,r,n)),this.pending=!0,this.delay=n,this.id=null!==(e=this.id)&&void 0!==e?e:this.requestAsyncId(o,this.id,n),this},e.prototype.requestAsyncId=function(t,n,e){return void 0===e&&(e=0),V(t.flush.bind(t,this),e)},e.prototype.recycleAsyncId=function(t,n,e){if(void 0===e&&(e=0),null!=e&&this.delay===e&&!1===this.pending)return n;null!=n&&Y(n)},e.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var e=this._execute(t,n);if(e)return e;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,n){var e,r=!1;try{this.work(t)}catch(t){r=!0,e=t||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),e},e.prototype.unsubscribe=function(){if(!this.closed){var n=this.id,e=this.scheduler,r=e.actions;this.work=this.state=this.scheduler=null,this.pending=!1,p(r,this),null!=n&&(this.id=this.recycleAsyncId(e,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(M),L=function(){function t(n,e){void 0===e&&(e=t.now),this.schedulerActionCtor=n,this.now=e}return t.prototype.schedule=function(t,n,e){return void 0===n&&(n=0),new this.schedulerActionCtor(this,t).schedule(e,n)},t.now=U.now,t}(),Z=new(function(t){function e(n,e){void 0===e&&(e=L.now);var r=t.call(this,n,e)||this;return r.actions=[],r._active=!1,r}return n(e,t),e.prototype.flush=function(t){var n=this.actions;if(this._active)n.push(t);else{var e;this._active=!0;do{if(e=t.execute(t.state,t.delay))break}while(t=n.shift());if(this._active=!1,e){for(;t=n.shift();)t.unsubscribe();throw e}}},e}(L))(q),G=Z,K=new $(function(t){return t.complete()});function H(t){return t&&l(t.schedule)}function Q(t){return t[t.length-1]}function X(t){return H(Q(t))?t.pop():void 0}var tt=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function nt(t){return l(null==t?void 0:t.then)}function et(t){return l(t[I])}function rt(t){return Symbol.asyncIterator&&l(null==t?void 0:t[Symbol.asyncIterator])}function ot(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var it="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function ut(t){return l(null==t?void 0:t[it])}function st(t){return c(this,arguments,function(){var n,e,o;return r(this,function(r){switch(r.label){case 0:n=t.getReader(),r.label=1;case 1:r.trys.push([1,,9,10]),r.label=2;case 2:return[4,s(n.read())];case 3:return e=r.sent(),o=e.value,e.done?[4,s(void 0)]:[3,5];case 4:return[2,r.sent()];case 5:return[4,s(o)];case 6:return[4,r.sent()];case 7:return r.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function ct(t){return l(null==t?void 0:t.getReader)}function at(t){if(t instanceof $)return t;if(null!=t){if(et(t))return i=t,new $(function(t){var n=i[I]();if(l(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(tt(t))return r=t,new $(function(t){for(var n=0;n<r.length&&!t.closed;n++)t.next(r[n]);t.complete()});if(nt(t))return e=t,new $(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,_)});if(rt(t))return lt(t);if(ut(t))return n=t,new $(function(t){var e,r;try{for(var i=o(n),u=i.next();!u.done;u=i.next()){var s=u.value;if(t.next(s),t.closed)return}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}t.complete()});if(ct(t))return lt(st(t))}var n,e,r,i;throw ot(t)}function lt(t){return new $(function(n){(function(t,n){var o,i,u,s;return e(this,void 0,void 0,function(){var e,c;return r(this,function(r){switch(r.label){case 0:r.trys.push([0,5,6,11]),o=a(t),r.label=1;case 1:return[4,o.next()];case 2:if((i=r.sent()).done)return[3,4];if(e=i.value,n.next(e),n.closed)return[2];r.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=r.sent(),u={error:c},[3,11];case 6:return r.trys.push([6,,9,10]),i&&!i.done&&(s=o.return)?[4,s.call(o)]:[3,8];case 7:r.sent(),r.label=8;case 8:return[3,10];case 9:if(u)throw u.error;return[7];case 10:return[7];case 11:return n.complete(),[2]}})})})(t,n).catch(function(t){return n.error(t)})})}function ft(t,n,e,r,o){void 0===r&&(r=0),void 0===o&&(o=!1);var i=n.schedule(function(){e(),o?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(i),!o)return i}function ht(t,n){return void 0===n&&(n=0),k(function(e,r){e.subscribe(F(r,function(e){return ft(r,t,function(){return r.next(e)},n)},function(){return ft(r,t,function(){return r.complete()},n)},function(e){return ft(r,t,function(){return r.error(e)},n)}))})}function pt(t,n){return void 0===n&&(n=0),k(function(e,r){r.add(t.schedule(function(){return e.subscribe(r)},n))})}function dt(t,n){if(!t)throw new Error("Iterable cannot be null");return new $(function(e){ft(e,n,function(){var r=t[Symbol.asyncIterator]();ft(e,n,function(){r.next().then(function(t){t.done?e.complete():e.next(t.value)})},0,!0)})})}function bt(t,n){if(null!=t){if(et(t))return function(t,n){return at(t).pipe(pt(n),ht(n))}(t,n);if(tt(t))return function(t,n){return new $(function(e){var r=0;return n.schedule(function(){r===t.length?e.complete():(e.next(t[r++]),e.closed||this.schedule())})})}(t,n);if(nt(t))return function(t,n){return at(t).pipe(pt(n),ht(n))}(t,n);if(rt(t))return dt(t,n);if(ut(t))return function(t,n){return new $(function(e){var r;return ft(e,n,function(){r=t[it](),ft(e,n,function(){var t,n,o;try{n=(t=r.next()).value,o=t.done}catch(t){return void e.error(t)}o?e.complete():e.next(n)},0,!0)}),function(){return l(null==r?void 0:r.return)&&r.return()}})}(t,n);if(ct(t))return function(t,n){return dt(st(t),n)}(t,n)}throw ot(t)}function vt(t,n){return n?bt(t,n):at(t)}function yt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return vt(t,X(t))}function mt(t,n){return k(function(e,r){var o=0;e.subscribe(F(r,function(e){r.next(t.call(n,e,o++))}))})}function wt(t,n,e){return void 0===e&&(e=1/0),l(n)?wt(function(e,r){return mt(function(t,o){return n(e,t,r,o)})(at(t(e,r)))},e):("number"==typeof n&&(e=n),k(function(n,r){return function(t,n,e,r,o,i,u){var s=[],c=0,a=0,l=!1,f=function(){!l||s.length||c||n.complete()},h=function(t){c++;var o=!1;at(e(t,a++)).subscribe(F(n,function(t){n.next(t)},function(){o=!0},void 0,function(){if(o)try{c--;for(var t=function(){var t=s.shift();u||h(t)};s.length&&c<r;)t();f()}catch(t){n.error(t)}}))};return t.subscribe(F(n,function(t){return c<r?h(t):s.push(t)},function(){l=!0,f()})),function(){}}(n,r,t,e)}))}function _t(){return wt(C,1)}function gt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _t()(vt(t,X(t)))}function xt(t){return new $(function(n){at(t()).subscribe(n)})}function St(t,n,e){void 0===t&&(t=0),void 0===e&&(e=G);var r=-1;return null!=n&&(H(n)?e=n:r=n),new $(function(n){var o,i=(o=t)instanceof Date&&!isNaN(o)?+t-e.now():t;i<0&&(i=0);var u=0;return e.schedule(function(){n.closed||(n.next(u++),0<=r?this.schedule(void 0,r):n.complete())},i)})}function At(t,n){return k(function(e,r){var o=0;e.subscribe(F(r,function(e){return t.call(n,e,o++)&&r.next(e)}))})}function Et(t){return k(function(n,e){var r,o=null,i=!1;o=n.subscribe(F(e,void 0,void 0,function(u){r=at(t(u,Et(t)(n))),o?(o.unsubscribe(),o=null,r.subscribe(e)):i=!0})),i&&(o.unsubscribe(),o=null,r.subscribe(e))})}function Ot(t,n){return l(n)?wt(t,n,1):wt(t,1)}function Pt(t){return t<=0?function(){return K}:k(function(n,e){var r=0;n.subscribe(F(e,function(n){++r<=t&&(e.next(n),t<=r&&e.complete())}))})}function It(t,n){return wt(function(n,e){return at(t(n,e)).pipe(Pt(1),function(t){return mt(function(){return t})}(n))})}function Ct(t,n){void 0===n&&(n=Z);var e=St(t,n);return It(function(){return e})}function Tt(t,n){return t===n}function jt(t,n){return n?function(e){return e.pipe(jt(function(e,r){return at(t(e,r)).pipe(mt(function(t,o){return n(e,t,r,o)}))}))}:k(function(n,e){var r=0,o=null,i=!1;n.subscribe(F(e,function(n){o||(o=F(e,void 0,function(){o=null,i&&e.complete()}),at(t(n,r++)).subscribe(o))},function(){i=!0,!o&&e.complete()}))})}function $t(t,n){return k(function(t,n,e,r,o){return function(r,i){var u=e,s=n,c=0;r.subscribe(F(i,function(n){var e=c++;s=u?t(s,n,e):(u=!0,n),i.next(s)},o))}}(t,n,arguments.length>=2))}function zt(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];if(!0!==n){if(!1!==n){var o=new E({next:function(){o.unsubscribe(),t()}});return at(n.apply(void 0,u([],i(e)))).subscribe(o)}}else t()}function kt(t,n,e){var r;return r=t,function(t){void 0===t&&(t={});var n=t.connector,e=void 0===n?function(){return new B}:n,r=t.resetOnError,o=void 0===r||r,i=t.resetOnComplete,u=void 0===i||i,s=t.resetOnRefCountZero,c=void 0===s||s;return function(t){var n,r,i,s=0,a=!1,l=!1,f=function(){null==r||r.unsubscribe(),r=void 0},h=function(){f(),n=i=void 0,a=l=!1},p=function(){var t=n;h(),null==t||t.unsubscribe()};return k(function(t,d){s++,l||a||f();var b=i=null!=i?i:e();d.add(function(){0!==--s||l||a||(r=zt(p,c))}),b.subscribe(d),!n&&s>0&&(n=new E({next:function(t){return b.next(t)},error:function(t){l=!0,f(),r=zt(h,o,t),b.error(t)},complete:function(){a=!0,f(),r=zt(h,u),b.complete()}}),at(t).subscribe(n))})(t)}}({connector:function(){return new W(r,n,e)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})}function Ft(t,n){return k(function(e,r){var o=null,i=0,u=!1,s=function(){return u&&!o&&r.complete()};e.subscribe(F(r,function(e){null==o||o.unsubscribe();var u=0,c=i++;at(t(e,c)).subscribe(o=F(r,function(t){return r.next(n?n(e,t,c,u++):t)},function(){o=null,s()}))},function(){u=!0,s()}))})}function Nt(t,n,e){var r=l(t)||n||e?{next:t,error:n,complete:e}:t;return r?k(function(t,n){var e;null===(e=r.subscribe)||void 0===e||e.call(r);var o=!0;t.subscribe(F(n,function(t){var e;null===(e=r.next)||void 0===e||e.call(r,t),n.next(t)},function(){var t;o=!1,null===(t=r.complete)||void 0===t||t.call(r),n.complete()},function(t){var e;o=!1,null===(e=r.error)||void 0===e||e.call(r,t),n.error(t)},function(){var t,n;o&&(null===(t=r.unsubscribe)||void 0===t||t.call(r)),null===(n=r.finalize)||void 0===n||n.call(r)}))}):C}function Rt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e,r=l(Q(e=t))?e.pop():void 0;return k(function(n,e){for(var o=t.length,s=new Array(o),c=t.map(function(){return!1}),a=!1,l=function(n){at(t[n]).subscribe(F(e,function(t){s[n]=t,a||c[n]||(c[n]=!0,(a=c.every(C))&&(c=null))},g))},f=0;f<o;f++)l(f);n.subscribe(F(e,function(t){if(a){var n=u([t],i(s));e.next(r?r.apply(void 0,u([],i(n))):n)}}))})}class Bt{_state$;_actions$=new B;get actions$(){return this._actions$.asObservable()}_reducers=[];_context=null;constructor(t={}){const n="function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t));this._state$=new J(n);const e=this._actions$.pipe($t((t,n)=>{const e=JSON.parse(JSON.stringify(t));return this._reducers.forEach(({path:t,reducerFn:r})=>{const o=e[t],i=r(o,n);void 0!==i&&o!==i&&(e[t]=i)}),e},n),function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=X(t);return k(function(n,r){(e?gt(t,n,e):gt(t,n)).subscribe(r)})}(t),kt(1));e.subscribe(this._state$)}registerReducers(...t){this._reducers.push(...t);const n=this._state$.getValue(),e=JSON.parse(JSON.stringify(n));t.forEach(({path:t,initialState:n})=>{void 0===e[t]&&(e[t]=n)}),this._state$.next(e)}setContext(t){this._context=t}registerEffects(...t){t.forEach(t=>{const n=t._rxEffect||{dispatch:!0};let e=t(this._actions$);n.dispatch?e.pipe(mt(t=>this._context&&!t.context?{...t,context:this._context}:t)).subscribe(t=>this.dispatch(t)):e.subscribe()})}dispatch(t){this._actions$.next(t)}select(t){return this._state$.pipe(mt(n=>t(n)),(void 0===e&&(e=C),n=null!=n?n:Tt,k(function(t,r){var o,i=!0;t.subscribe(F(r,function(t){var u=e(t);!i&&n(o,u)||(i=!1,o=u,r.next(t))}))})));var n,e}}function Dt(t){const n=n=>({type:t,...n});return n.type=t,n}function Jt(){}function Ut(...t){const n=t.pop(),e=t,r=e.includes(Jt);if(r&&e.length>1)throw new Error("The `anyAction` token cannot be mixed with other action creators in a single `on` handler.");return{types:e.map(t=>t.type),reducerFn:n,isCatchAll:r}}function Wt(t,n,...e){if(!t||"string"!=typeof t)throw new Error("Reducer featureKey must be a non-empty string.");const r=e.filter(t=>!t.isCatchAll),o=e.find(t=>t.isCatchAll);return{path:t,initialState:n,reducerFn:(t=n,e)=>{for(const n of r)if(n.types.includes(e.type))return n.reducerFn(t,e);return o?o.reducerFn(t,e):t}}}function Mt(...t){const n=t.map(t=>t.type);return At(t=>n.includes(t.type))}function Vt(t,n={dispatch:!0}){if("function"!=typeof t)throw new Error("Effect must be a function.");return Object.defineProperty(t,"_rxEffect",{value:{dispatch:!1!==n.dispatch},enumerable:!1}),t}function Yt(t,n){return e=>{const r=e[t];return n?n(r):r}}function qt(...t){const n=t.pop(),e=t;if("function"!=typeof n)throw new Error("The last argument to createSelector must be a projection function.");return t=>{const r=e.map(n=>n(t));return n(...r)}}function Lt(t,n){return{onCreate(){n?(n.setContext(this),this.debug("Attach the store and a dispatch method to the App instance."),this._store=n,this.dispatch=t=>{const n={...t,context:this};this._store.dispatch(n)},this.onAction=t=>{t&&"string"==typeof t.type?(this.debug(`Dispatching action ${t.type} from App.onAction.`),this.dispatch(t)):this.debug("Not an Action, discarding the message on App.onAction.")},this.messaging.onCall(this.onAction),this.subscribe=(t,...n)=>{this._subscriptions||(this._subscriptions=[]);const e=n.pop(),r=n,o=this._store.select(t),i=(r.length>0?o.pipe(...r):o).subscribe(e);return this._subscriptions.push(i),i}):console.error("[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseApp.use(storePlugin, store)`.")},onInit(){let t;const e="undefined"!=typeof messaging;if(e)n?(n.setContext(this),t=n,this.onAction=t=>{t&&"string"==typeof t.type?(this.debug(`Dispatching action ${t.type} from SideService.onAction.`),this.dispatch(t)):this.debug("Not an Action, discarding the message on SideService.onAction.")}):console.error("[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseSideService.use(storePlugin, store)`.");else{const n=getApp();n&&n._store?t=n._store:console.error("[rx-tiny-flux] Store not found on global App object. Ensure the plugin is registered on BaseApp."),this.onAction=()=>{}}if(!t)return this.onAction=()=>console.error("[rx-tiny-flux] OnAction failed: store not initialized."),this.messaging.onCall(this.onAction),this.dispatch=()=>console.error("[rx-tiny-flux] Dispatch failed: store not initialized."),void(this.subscribe=()=>console.error("[rx-tiny-flux] Subscribe failed: store not initialized."));this._store=t,this.messaging.onCall(this.onAction),this.debug(`Attaching store methods to the ${e?"SideService":"Page"} instance.`),this.dispatch=t=>{const n={...t,context:this};this._store.dispatch(n)},this.subscribe=(t,...n)=>{this._subscriptions||(this._subscriptions=[]);const e=n.pop(),r=n,o=this._store.select(t),i=(r.length>0?o.pipe(...r):o).subscribe(e);return this._subscriptions.push(i),i},e||(this.listen=(t,n)=>{const e=(Array.isArray(t)?t:[t]).map(t=>"function"==typeof t?t.type:t);if(e.some(t=>"string"!=typeof t))throw new Error("[rx-tiny-flux] listen: actionTypes must be strings or action creators with a `type` property.");this._subscriptions||(this._subscriptions=[]);const r=this._store.actions$.pipe(At(t=>e.includes(t.type))).subscribe(n);this._subscriptions.push(r)})},onDestroy(){this.messaging.offOnCall(this.onAction),this._subscriptions&&this._subscriptions.length>0&&(this._subscriptions.forEach(t=>t.unsubscribe()),this._subscriptions=[])}}}const Zt=t=>n=>n.pipe(Nt(t=>{if(!t.context||!t.context._store||!t.context._store._state$)throw new Error("[rx-tiny-flux] `withLatestFromStore` could not find a valid store on `action.context._store`. Ensure the `storePlugin` is correctly configured.")}),mt(n=>{const e=n.context._store._state$.getValue();return[n,t(e)]})),Gt=()=>At(()=>"undefined"!=typeof messaging),Kt=()=>At(()=>"undefined"==typeof messaging),Ht=()=>Nt(t=>{if(t.context&&"function"==typeof t.context.call){t.context.debug(`Propagation action '${t.type}' through messaging.call(action).`);const{context:n,...e}=t;t.context.call(e)}else console.debug(`No context: Action '${t.type}' not propagated through messaging.call(action).`)});export{K as EMPTY,Bt as Store,Jt as anyAction,Et as catchError,Ot as concatMap,Dt as createAction,Vt as createEffect,Yt as createFeatureSelector,Wt as createReducer,qt as createSelector,xt as defer,Ct as delay,jt as exhaustMap,At as filter,vt as from,Kt as isApp,Gt as isSideService,mt as map,wt as mergeMap,yt as of,Mt as ofType,Ut as on,T as pipe,Ht as propagateAction,Lt as storePlugin,Ft as switchMap,Pt as take,Nt as tap,Rt as withLatestFrom,Zt as withLatestFromStore};
1
+ var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};function n(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function e(t,n,e,r){return new(e||(e=Promise))(function(o,i){function u(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(u,s)}c((r=r.apply(t,n||[])).next())})}function r(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=s(0),u.throw=s(1),u.return=s(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function s(s){return function(c){return function(s){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,s[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=n.call(t,i)}catch(t){s=[6,t],r=0}finally{e=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function o(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u}function u(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}function s(t){return this instanceof s?(this.v=t,this):new s(t)}function c(t,n,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=e.apply(t,n||[]),i=[];return r=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",function(t){return function(n){return Promise.resolve(n).then(t,l)}}),r[Symbol.asyncIterator]=function(){return this},r;function u(t,n){o[t]&&(r[t]=function(n){return new Promise(function(e,r){i.push([t,n,e,r])>1||c(t,n)})},n&&(r[t]=n(r[t])))}function c(t,n){try{(e=o[t](n)).value instanceof s?Promise.resolve(e.value.v).then(a,l):f(i[0][2],e)}catch(t){f(i[0][3],t)}var e}function a(t){c("next",t)}function l(t){c("throw",t)}function f(t,n){t(n),i.shift(),i.length&&c(i[0][0],i[0][1])}}function a(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,e=t[Symbol.asyncIterator];return e?e.call(t):(t=o(t),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(e){n[e]=t[e]&&function(n){return new Promise(function(r,o){(function(t,n,e,r){Promise.resolve(r).then(function(n){t({value:n,done:e})},n)})(r,o,(n=t[e](n)).done,n.value)})}}}function l(t){return"function"==typeof t}function f(t){var n=t(function(t){Error.call(t),t.stack=(new Error).stack});return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}"function"==typeof SuppressedError&&SuppressedError;var h=f(function(t){return function(n){t(this),this.message=n?n.length+" errors occurred during unsubscription:\n"+n.map(function(t,n){return n+1+") "+t.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=n}});function p(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var d=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var n;return t.prototype.unsubscribe=function(){var t,n,e,r,s;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var a=o(c),f=a.next();!f.done;f=a.next()){f.value.remove(this)}}catch(n){t={error:n}}finally{try{f&&!f.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else c.remove(this);var p=this.initialTeardown;if(l(p))try{p()}catch(t){s=t instanceof h?t.errors:[t]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var b=o(d),v=b.next();!v.done;v=b.next()){var m=v.value;try{y(m)}catch(t){s=null!=s?s:[],t instanceof h?s=u(u([],i(s)),i(t.errors)):s.push(t)}}}catch(t){e={error:t}}finally{try{v&&!v.done&&(r=b.return)&&r.call(b)}finally{if(e)throw e.error}}}if(s)throw new h(s)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)y(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=null!==(e=this._finalizers)&&void 0!==e?e:[]).push(n)}},t.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},t.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},t.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&p(n,t)},t.prototype.remove=function(n){var e=this._finalizers;e&&p(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=((n=new t).closed=!0,n),t}(),b=d.EMPTY;function v(t){return t instanceof d||t&&"closed"in t&&l(t.remove)&&l(t.add)&&l(t.unsubscribe)}function y(t){l(t)?t():t.unsubscribe()}var m={Promise:void 0},_=function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,u([t,n],i(e)))};function w(t){_(function(){throw t})}function g(){}function x(t){t()}var S=function(t){function e(n){var e=t.call(this)||this;return e.isStopped=!1,n?(e.destination=n,v(n)&&n.add(e)):e.destination=P,e}return n(e,t),e.create=function(t,n,e){return new E(t,n,e)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(d),A=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(t){O(t)}},t.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(t){O(t)}else O(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){O(t)}},t}(),E=function(t){function e(n,e,r){var o,i=t.call(this)||this;return o=l(n)||!n?{next:null!=n?n:void 0,error:null!=e?e:void 0,complete:null!=r?r:void 0}:n,i.destination=new A(o),i}return n(e,t),e}(S);function O(t){w(t)}var P={closed:!0,next:g,error:function(t){throw t},complete:g},I="function"==typeof Symbol&&Symbol.observable||"@@observable";function C(t){return t}function T(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return $(t)}function $(t){return 0===t.length?C:1===t.length?t[0]:function(n){return t.reduce(function(t,n){return n(t)},n)}}var j=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(n){var e=new t;return e.source=this,e.operator=n,e},t.prototype.subscribe=function(t,n,e){var r,o=this,i=(r=t)&&r instanceof S||function(t){return t&&l(t.next)&&l(t.error)&&l(t.complete)}(r)&&v(r)?t:new E(t,n,e);return x(function(){var t=o,n=t.operator,e=t.source;i.add(n?n.call(i,e):e?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},t.prototype.forEach=function(t,n){var e=this;return new(n=z(n))(function(n,r){var o=new E({next:function(n){try{t(n)}catch(t){r(t),o.unsubscribe()}},error:r,complete:n});e.subscribe(o)})},t.prototype._subscribe=function(t){var n;return null===(n=this.source)||void 0===n?void 0:n.subscribe(t)},t.prototype[I]=function(){return this},t.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return $(t)(this)},t.prototype.toPromise=function(t){var n=this;return new(t=z(t))(function(t,e){var r;n.subscribe(function(t){return r=t},function(t){return e(t)},function(){return t(r)})})},t.create=function(n){return new t(n)},t}();function z(t){var n;return null!==(n=null!=t?t:m.Promise)&&void 0!==n?n:Promise}function k(t){return function(n){if(function(t){return l(null==t?void 0:t.lift)}(n))return n.lift(function(n){try{return t(n,this)}catch(t){this.error(t)}});throw new TypeError("Unable to lift unknown Observable type")}}function F(t,n,e,r,o){return new N(t,n,e,r,o)}var N=function(t){function e(n,e,r,o,i,u){var s=t.call(this,n)||this;return s.onFinalize=i,s.shouldUnsubscribe=u,s._next=e?function(t){try{e(t)}catch(t){n.error(t)}}:t.prototype._next,s._error=o?function(t){try{o(t)}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._error,s._complete=r?function(){try{r()}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,s}return n(e,t),e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var e=this.closed;t.prototype.unsubscribe.call(this),!e&&(null===(n=this.onFinalize)||void 0===n||n.call(this))}},e}(S),R=f(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),B=function(t){function e(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return n(e,t),e.prototype.lift=function(t){var n=new D(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new R},e.prototype.next=function(t){var n=this;x(function(){var e,r;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var i=o(n.currentObservers),u=i.next();!u.done;u=i.next()){u.value.next(t)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}}})},e.prototype.error=function(t){var n=this;x(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var e=n.observers;e.length;)e.shift().error(t)}})},e.prototype.complete=function(){var t=this;x(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,e=this,r=e.hasError,o=e.isStopped,i=e.observers;return r||o?b:(this.currentObservers=null,i.push(t),new d(function(){n.currentObservers=null,p(i,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,e=n.hasError,r=n.thrownError,o=n.isStopped;e?t.error(r):o&&t.complete()},e.prototype.asObservable=function(){var t=new j;return t.source=this,t},e.create=function(t,n){return new D(t,n)},e}(j),D=function(t){function e(n,e){var r=t.call(this)||this;return r.destination=n,r.source=e,r}return n(e,t),e.prototype.next=function(t){var n,e;null===(e=null===(n=this.destination)||void 0===n?void 0:n.next)||void 0===e||e.call(n,t)},e.prototype.error=function(t){var n,e;null===(e=null===(n=this.destination)||void 0===n?void 0:n.error)||void 0===e||e.call(n,t)},e.prototype.complete=function(){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===n||n.call(t)},e.prototype._subscribe=function(t){var n,e;return null!==(e=null===(n=this.source)||void 0===n?void 0:n.subscribe(t))&&void 0!==e?e:b},e}(B),U=function(t){function e(n){var e=t.call(this)||this;return e._value=n,e}return n(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(n){var e=t.prototype._subscribe.call(this,n);return!e.closed&&n.next(this._value),e},e.prototype.getValue=function(){var t=this,n=t.hasError,e=t.thrownError,r=t._value;if(n)throw e;return this._throwIfClosed(),r},e.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},e}(B),W={now:function(){return(W.delegate||Date).now()},delegate:void 0},M=function(t){function e(n,e,r){void 0===n&&(n=1/0),void 0===e&&(e=1/0),void 0===r&&(r=W);var o=t.call(this)||this;return o._bufferSize=n,o._windowTime=e,o._timestampProvider=r,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=e===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,e),o}return n(e,t),e.prototype.next=function(n){var e=this,r=e.isStopped,o=e._buffer,i=e._infiniteTimeWindow,u=e._timestampProvider,s=e._windowTime;r||(o.push(n),!i&&o.push(u.now()+s)),this._trimBuffer(),t.prototype.next.call(this,n)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),e=this._infiniteTimeWindow,r=this._buffer.slice(),o=0;o<r.length&&!t.closed;o+=e?1:2)t.next(r[o]);return this._checkFinalizedStatuses(t),n},e.prototype._trimBuffer=function(){var t=this,n=t._bufferSize,e=t._timestampProvider,r=t._buffer,o=t._infiniteTimeWindow,i=(o?1:2)*n;if(n<1/0&&i<r.length&&r.splice(0,r.length-i),!o){for(var u=e.now(),s=0,c=1;c<r.length&&r[c]<=u;c+=2)s=c;s&&r.splice(0,s+1)}},e}(B),V=function(t){function e(n,e){return t.call(this)||this}return n(e,t),e.prototype.schedule=function(t,n){return this},e}(d),Y=function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,u([t,n],i(e)))},q=function(t){return clearInterval(t)},J=function(t){function e(n,e){var r=t.call(this,n,e)||this;return r.scheduler=n,r.work=e,r.pending=!1,r}return n(e,t),e.prototype.schedule=function(t,n){var e;if(void 0===n&&(n=0),this.closed)return this;this.state=t;var r=this.id,o=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(o,r,n)),this.pending=!0,this.delay=n,this.id=null!==(e=this.id)&&void 0!==e?e:this.requestAsyncId(o,this.id,n),this},e.prototype.requestAsyncId=function(t,n,e){return void 0===e&&(e=0),Y(t.flush.bind(t,this),e)},e.prototype.recycleAsyncId=function(t,n,e){if(void 0===e&&(e=0),null!=e&&this.delay===e&&!1===this.pending)return n;null!=n&&q(n)},e.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var e=this._execute(t,n);if(e)return e;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,n){var e,r=!1;try{this.work(t)}catch(t){r=!0,e=t||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),e},e.prototype.unsubscribe=function(){if(!this.closed){var n=this.id,e=this.scheduler,r=e.actions;this.work=this.state=this.scheduler=null,this.pending=!1,p(r,this),null!=n&&(this.id=this.recycleAsyncId(e,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(V),L=function(){function t(n,e){void 0===e&&(e=t.now),this.schedulerActionCtor=n,this.now=e}return t.prototype.schedule=function(t,n,e){return void 0===n&&(n=0),new this.schedulerActionCtor(this,t).schedule(e,n)},t.now=W.now,t}(),Z=new(function(t){function e(n,e){void 0===e&&(e=L.now);var r=t.call(this,n,e)||this;return r.actions=[],r._active=!1,r}return n(e,t),e.prototype.flush=function(t){var n=this.actions;if(this._active)n.push(t);else{var e;this._active=!0;do{if(e=t.execute(t.state,t.delay))break}while(t=n.shift());if(this._active=!1,e){for(;t=n.shift();)t.unsubscribe();throw e}}},e}(L))(J),G=Z,K=new j(function(t){return t.complete()});function H(t){return t&&l(t.schedule)}function Q(t){return t[t.length-1]}function X(t){return H(Q(t))?t.pop():void 0}var tt=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function nt(t){return l(null==t?void 0:t.then)}function et(t){return l(t[I])}function rt(t){return Symbol.asyncIterator&&l(null==t?void 0:t[Symbol.asyncIterator])}function ot(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var it="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function ut(t){return l(null==t?void 0:t[it])}function st(t){return c(this,arguments,function(){var n,e,o;return r(this,function(r){switch(r.label){case 0:n=t.getReader(),r.label=1;case 1:r.trys.push([1,,9,10]),r.label=2;case 2:return[4,s(n.read())];case 3:return e=r.sent(),o=e.value,e.done?[4,s(void 0)]:[3,5];case 4:return[2,r.sent()];case 5:return[4,s(o)];case 6:return[4,r.sent()];case 7:return r.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function ct(t){return l(null==t?void 0:t.getReader)}function at(t){if(t instanceof j)return t;if(null!=t){if(et(t))return i=t,new j(function(t){var n=i[I]();if(l(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(tt(t))return r=t,new j(function(t){for(var n=0;n<r.length&&!t.closed;n++)t.next(r[n]);t.complete()});if(nt(t))return e=t,new j(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,w)});if(rt(t))return lt(t);if(ut(t))return n=t,new j(function(t){var e,r;try{for(var i=o(n),u=i.next();!u.done;u=i.next()){var s=u.value;if(t.next(s),t.closed)return}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}t.complete()});if(ct(t))return lt(st(t))}var n,e,r,i;throw ot(t)}function lt(t){return new j(function(n){(function(t,n){var o,i,u,s;return e(this,void 0,void 0,function(){var e,c;return r(this,function(r){switch(r.label){case 0:r.trys.push([0,5,6,11]),o=a(t),r.label=1;case 1:return[4,o.next()];case 2:if((i=r.sent()).done)return[3,4];if(e=i.value,n.next(e),n.closed)return[2];r.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=r.sent(),u={error:c},[3,11];case 6:return r.trys.push([6,,9,10]),i&&!i.done&&(s=o.return)?[4,s.call(o)]:[3,8];case 7:r.sent(),r.label=8;case 8:return[3,10];case 9:if(u)throw u.error;return[7];case 10:return[7];case 11:return n.complete(),[2]}})})})(t,n).catch(function(t){return n.error(t)})})}function ft(t,n,e,r,o){void 0===r&&(r=0),void 0===o&&(o=!1);var i=n.schedule(function(){e(),o?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(i),!o)return i}function ht(t,n){return void 0===n&&(n=0),k(function(e,r){e.subscribe(F(r,function(e){return ft(r,t,function(){return r.next(e)},n)},function(){return ft(r,t,function(){return r.complete()},n)},function(e){return ft(r,t,function(){return r.error(e)},n)}))})}function pt(t,n){return void 0===n&&(n=0),k(function(e,r){r.add(t.schedule(function(){return e.subscribe(r)},n))})}function dt(t,n){if(!t)throw new Error("Iterable cannot be null");return new j(function(e){ft(e,n,function(){var r=t[Symbol.asyncIterator]();ft(e,n,function(){r.next().then(function(t){t.done?e.complete():e.next(t.value)})},0,!0)})})}function bt(t,n){if(null!=t){if(et(t))return function(t,n){return at(t).pipe(pt(n),ht(n))}(t,n);if(tt(t))return function(t,n){return new j(function(e){var r=0;return n.schedule(function(){r===t.length?e.complete():(e.next(t[r++]),e.closed||this.schedule())})})}(t,n);if(nt(t))return function(t,n){return at(t).pipe(pt(n),ht(n))}(t,n);if(rt(t))return dt(t,n);if(ut(t))return function(t,n){return new j(function(e){var r;return ft(e,n,function(){r=t[it](),ft(e,n,function(){var t,n,o;try{n=(t=r.next()).value,o=t.done}catch(t){return void e.error(t)}o?e.complete():e.next(n)},0,!0)}),function(){return l(null==r?void 0:r.return)&&r.return()}})}(t,n);if(ct(t))return function(t,n){return dt(st(t),n)}(t,n)}throw ot(t)}function vt(t,n){return n?bt(t,n):at(t)}function yt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return vt(t,X(t))}function mt(t,n){return k(function(e,r){var o=0;e.subscribe(F(r,function(e){r.next(t.call(n,e,o++))}))})}function _t(t,n,e){return void 0===e&&(e=1/0),l(n)?_t(function(e,r){return mt(function(t,o){return n(e,t,r,o)})(at(t(e,r)))},e):("number"==typeof n&&(e=n),k(function(n,r){return function(t,n,e,r,o,i,u){var s=[],c=0,a=0,l=!1,f=function(){!l||s.length||c||n.complete()},h=function(t){c++;var o=!1;at(e(t,a++)).subscribe(F(n,function(t){n.next(t)},function(){o=!0},void 0,function(){if(o)try{c--;for(var t=function(){var t=s.shift();u||h(t)};s.length&&c<r;)t();f()}catch(t){n.error(t)}}))};return t.subscribe(F(n,function(t){return c<r?h(t):s.push(t)},function(){l=!0,f()})),function(){}}(n,r,t,e)}))}function wt(){return _t(C,1)}function gt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return wt()(vt(t,X(t)))}function xt(t){return new j(function(n){at(t()).subscribe(n)})}function St(t,n,e){void 0===t&&(t=0),void 0===e&&(e=G);var r=-1;return null!=n&&(H(n)?e=n:r=n),new j(function(n){var o,i=(o=t)instanceof Date&&!isNaN(o)?+t-e.now():t;i<0&&(i=0);var u=0;return e.schedule(function(){n.closed||(n.next(u++),0<=r?this.schedule(void 0,r):n.complete())},i)})}function At(t,n){return k(function(e,r){var o=0;e.subscribe(F(r,function(e){return t.call(n,e,o++)&&r.next(e)}))})}function Et(t){return k(function(n,e){var r,o=null,i=!1;o=n.subscribe(F(e,void 0,void 0,function(u){r=at(t(u,Et(t)(n))),o?(o.unsubscribe(),o=null,r.subscribe(e)):i=!0})),i&&(o.unsubscribe(),o=null,r.subscribe(e))})}function Ot(t,n){return l(n)?_t(t,n,1):_t(t,1)}function Pt(t){return t<=0?function(){return K}:k(function(n,e){var r=0;n.subscribe(F(e,function(n){++r<=t&&(e.next(n),t<=r&&e.complete())}))})}function It(t,n){return _t(function(n,e){return at(t(n,e)).pipe(Pt(1),function(t){return mt(function(){return t})}(n))})}function Ct(t,n){void 0===n&&(n=Z);var e=St(t,n);return It(function(){return e})}function Tt(t,n){return t===n}function $t(t,n){return n?function(e){return e.pipe($t(function(e,r){return at(t(e,r)).pipe(mt(function(t,o){return n(e,t,r,o)}))}))}:k(function(n,e){var r=0,o=null,i=!1;n.subscribe(F(e,function(n){o||(o=F(e,void 0,function(){o=null,i&&e.complete()}),at(t(n,r++)).subscribe(o))},function(){i=!0,!o&&e.complete()}))})}function jt(t,n){return k(function(t,n,e,r,o){return function(r,i){var u=e,s=n,c=0;r.subscribe(F(i,function(n){var e=c++;s=u?t(s,n,e):(u=!0,n),i.next(s)},o))}}(t,n,arguments.length>=2))}function zt(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];if(!0!==n){if(!1!==n){var o=new E({next:function(){o.unsubscribe(),t()}});return at(n.apply(void 0,u([],i(e)))).subscribe(o)}}else t()}function kt(t,n,e){var r;return r=t,function(t){void 0===t&&(t={});var n=t.connector,e=void 0===n?function(){return new B}:n,r=t.resetOnError,o=void 0===r||r,i=t.resetOnComplete,u=void 0===i||i,s=t.resetOnRefCountZero,c=void 0===s||s;return function(t){var n,r,i,s=0,a=!1,l=!1,f=function(){null==r||r.unsubscribe(),r=void 0},h=function(){f(),n=i=void 0,a=l=!1},p=function(){var t=n;h(),null==t||t.unsubscribe()};return k(function(t,d){s++,l||a||f();var b=i=null!=i?i:e();d.add(function(){0!==--s||l||a||(r=zt(p,c))}),b.subscribe(d),!n&&s>0&&(n=new E({next:function(t){return b.next(t)},error:function(t){l=!0,f(),r=zt(h,o,t),b.error(t)},complete:function(){a=!0,f(),r=zt(h,u),b.complete()}}),at(t).subscribe(n))})(t)}}({connector:function(){return new M(r,n,e)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})}function Ft(t,n){return k(function(e,r){var o=null,i=0,u=!1,s=function(){return u&&!o&&r.complete()};e.subscribe(F(r,function(e){null==o||o.unsubscribe();var u=0,c=i++;at(t(e,c)).subscribe(o=F(r,function(t){return r.next(n?n(e,t,c,u++):t)},function(){o=null,s()}))},function(){u=!0,s()}))})}function Nt(t,n,e){var r=l(t)||n||e?{next:t,error:n,complete:e}:t;return r?k(function(t,n){var e;null===(e=r.subscribe)||void 0===e||e.call(r);var o=!0;t.subscribe(F(n,function(t){var e;null===(e=r.next)||void 0===e||e.call(r,t),n.next(t)},function(){var t;o=!1,null===(t=r.complete)||void 0===t||t.call(r),n.complete()},function(t){var e;o=!1,null===(e=r.error)||void 0===e||e.call(r,t),n.error(t)},function(){var t,n;o&&(null===(t=r.unsubscribe)||void 0===t||t.call(r)),null===(n=r.finalize)||void 0===n||n.call(r)}))}):C}function Rt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e,r=l(Q(e=t))?e.pop():void 0;return k(function(n,e){for(var o=t.length,s=new Array(o),c=t.map(function(){return!1}),a=!1,l=function(n){at(t[n]).subscribe(F(e,function(t){s[n]=t,a||c[n]||(c[n]=!0,(a=c.every(C))&&(c=null))},g))},f=0;f<o;f++)l(f);n.subscribe(F(e,function(t){if(a){var n=u([t],i(s));e.next(r?r.apply(void 0,u([],i(n))):n)}}))})}class Bt{_state$;_actions$=new B;get actions$(){return this._actions$.asObservable()}_reducers=[];_context=null;constructor(t={}){const n="function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t));this._state$=new U(n);const e=this._actions$.pipe(jt((t,n)=>{let e={...t},r=!1;return this._reducers.forEach(({path:o,reducerFn:i})=>{const u=t[o],s=i(u,n);u!==s&&(e[o]=s,r=!0)}),r?e:t},n),function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=X(t);return k(function(n,r){(e?gt(t,n,e):gt(t,n)).subscribe(r)})}(t),kt(1));e.subscribe(this._state$)}registerReducers(...t){this._reducers.push(...t);const n={...this._state$.getValue()};let e=!1;t.forEach(({path:t,initialState:r})=>{void 0===n[t]&&(n[t]=r,e=!0)}),e&&this._state$.next(n)}setContext(t){this._context=t}registerEffects(...t){t.forEach(t=>{const n=t._rxEffect||{dispatch:!0};let e=t(this._actions$);n.dispatch?e.pipe(mt(t=>this._context&&!t.context?{...t,context:this._context}:t)).subscribe(t=>this.dispatch(t)):e.subscribe()})}dispatch(t){this._actions$.next(t)}select(t){return this._state$.pipe(mt(n=>t(n)),(void 0===e&&(e=C),n=null!=n?n:Tt,k(function(t,r){var o,i=!0;t.subscribe(F(r,function(t){var u=e(t);!i&&n(o,u)||(i=!1,o=u,r.next(t))}))})));var n,e}}function Dt(t){const n=n=>({type:t,...n});return n.type=t,n}function Ut(){}function Wt(...t){const n=t.pop(),e=t,r=e.includes(Ut);if(r&&e.length>1)throw new Error("The `anyAction` token cannot be mixed with other action creators in a single `on` handler.");return{types:e.map(t=>t.type),reducerFn:n,isCatchAll:r}}function Mt(t,n,...e){if(!t||"string"!=typeof t)throw new Error("Reducer featureKey must be a non-empty string.");const r=e.filter(t=>!t.isCatchAll),o=e.find(t=>t.isCatchAll);return{path:t,initialState:n,reducerFn:(t=n,e)=>{for(const n of r)if(n.types.includes(e.type))return n.reducerFn(t,e);return o?o.reducerFn(t,e):t}}}function Vt(...t){const n=t.map(t=>t.type);return At(t=>n.includes(t.type))}function Yt(t,n={dispatch:!0}){if("function"!=typeof t)throw new Error("Effect must be a function.");return Object.defineProperty(t,"_rxEffect",{value:{dispatch:!1!==n.dispatch},enumerable:!1}),t}function qt(t,n){return e=>{const r=e[t];return n?n(r):r}}function Jt(...t){const n=t.pop(),e=t;let r,o,i=!1;return t=>{const u=e.map(n=>n(t));return i&&function(t,n){if(!n||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}(u,o)||(o=u,r=n(...u),i=!0),r}}function Lt(t,n){return{onCreate(){n?(n.setContext(this),this.debug("Attach the store and a dispatch method to the App instance."),this._store=n,this.dispatch=t=>{setTimeout(()=>{const n={...t,context:this};this._store.dispatch(n)},50)},this.onAction=t=>{t&&"string"==typeof t.type?(this.debug(`Dispatching action ${t.type} from App.onAction.`),this.dispatch(t)):this.debug("Not an Action, discarding the message on App.onAction.")},this.messaging.onCall(this.onAction),this.subscribe=(t,...n)=>{this._subscriptions||(this._subscriptions=[]);const e=n.pop(),r=n,o=this._store.select(t),i=(r.length>0?o.pipe(...r):o).subscribe(e);return this._subscriptions.push(i),i}):console.error("[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseApp.use(storePlugin, store)`.")},onInit(){let t;const e="undefined"!=typeof messaging;if(e)n?(n.setContext(this),t=n,this.onAction=t=>{t&&"string"==typeof t.type?(this.debug(`Dispatching action ${t.type} from SideService.onAction.`),this.dispatch(t)):this.debug("Not an Action, discarding the message on SideService.onAction.")}):console.error("[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseSideService.use(storePlugin, store)`.");else{const n=getApp();n&&n._store?t=n._store:console.error("[rx-tiny-flux] Store not found on global App object. Ensure the plugin is registered on BaseApp."),this.onAction=()=>{}}if(!t)return this.onAction=()=>console.error("[rx-tiny-flux] OnAction failed: store not initialized."),this.messaging.onCall(this.onAction),this.dispatch=()=>console.error("[rx-tiny-flux] Dispatch failed: store not initialized."),void(this.subscribe=()=>console.error("[rx-tiny-flux] Subscribe failed: store not initialized."));this._store=t,this.messaging.onCall(this.onAction),this.debug(`Attaching store methods to the ${e?"SideService":"Page"} instance.`),this.dispatch=t=>{setTimeout(()=>{const n={...t,context:this};this._store.dispatch(n)},50)},this.subscribe=(t,...n)=>{this._subscriptions||(this._subscriptions=[]);const e=n.pop(),r=n,o=this._store.select(t),i=(r.length>0?o.pipe(...r):o).subscribe(e);return this._subscriptions.push(i),i},e||(this.listen=(t,n)=>{const e=(Array.isArray(t)?t:[t]).map(t=>"function"==typeof t?t.type:t);if(e.some(t=>"string"!=typeof t))throw new Error("[rx-tiny-flux] listen: actionTypes must be strings or action creators with a `type` property.");this._subscriptions||(this._subscriptions=[]);const r=this._store.actions$.pipe(At(t=>e.includes(t.type))).subscribe(n);this._subscriptions.push(r)})},onDestroy(){this.messaging.offOnCall(this.onAction),this._subscriptions&&this._subscriptions.length>0&&(this._subscriptions.forEach(t=>t.unsubscribe()),this._subscriptions=[])}}}const Zt=t=>n=>n.pipe(Nt(t=>{if(!t.context||!t.context._store||!t.context._store._state$)throw new Error("[rx-tiny-flux] `withLatestFromStore` could not find a valid store on `action.context._store`. Ensure the `storePlugin` is correctly configured.")}),mt(n=>{const e=n.context._store._state$.getValue();return[n,t(e)]})),Gt=()=>At(()=>"undefined"!=typeof messaging),Kt=()=>At(()=>"undefined"==typeof messaging),Ht=()=>Nt(t=>{if(t.context&&"function"==typeof t.context.call){t.context.debug(`Propagation action '${t.type}' through messaging.call(action).`);const{context:n,...e}=t;t.context.call(e)}else console.debug(`No context: Action '${t.type}' not propagated through messaging.call(action).`)});export{K as EMPTY,Bt as Store,Ut as anyAction,Et as catchError,Ot as concatMap,Dt as createAction,Yt as createEffect,qt as createFeatureSelector,Mt as createReducer,Jt as createSelector,xt as defer,Ct as delay,$t as exhaustMap,At as filter,vt as from,Kt as isApp,Gt as isSideService,mt as map,_t as mergeMap,yt as of,Vt as ofType,Wt as on,T as pipe,Ht as propagateAction,Lt as storePlugin,Ft as switchMap,Pt as take,Nt as tap,Rt as withLatestFrom,Zt as withLatestFromStore};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rx-tiny-flux",
3
- "version": "1.0.23",
3
+ "version": "1.0.26",
4
4
  "description": "A lightweight, minimalist state management library for pure JavaScript projects, inspired by NgRx and Redux, and built with RxJS.",
5
5
  "author": "Bernardo Baumblatt <baumblatt@gmail.com>",
6
6
  "license": "MIT",
@@ -29,11 +29,13 @@
29
29
  "build": "rollup -c"
30
30
  },
31
31
  "devDependencies": {
32
- "@rollup/plugin-terser": "^0.4.4",
33
32
  "@rollup/plugin-commonjs": "^25.0.7",
34
33
  "@rollup/plugin-json": "^6.1.0",
35
34
  "@rollup/plugin-node-resolve": "^15.2.3",
35
+ "@rollup/plugin-terser": "^0.4.4",
36
36
  "rollup": "^4.9.6",
37
- "rxjs": "^7.8.2"
37
+ "rollup-plugin-dts": "^6.2.3",
38
+ "rxjs": "^7.8.2",
39
+ "typescript": "^5.9.3"
38
40
  }
39
41
  }