rx-tiny-flux 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Readme.md CHANGED
@@ -201,8 +201,9 @@ This plugin injects `dispatch` and `subscribe` methods into your component's ins
201
201
  1. **Create your store** instance in `app.js`.
202
202
  2. **Import the `storePlugin`** from `rx-tiny-flux`.
203
203
  3. **Register the plugin on `BaseApp`**, passing the `store` instance: `BaseApp.use(storePlugin, store)`.
204
- 4. **Register the same plugin on `BasePage`**, but without the store: `BasePage.use(storePlugin)`. The plugin will automatically find the store from the App.
205
- 5. **Use `this.dispatch()` and `this.subscribe()`** inside your App and Pages.
204
+ 4. **Register the same plugin on `BasePage`** (without the store): `BasePage.use(storePlugin)`. The plugin will automatically find the store from the App.
205
+ 5. For a **Side Service**, you can create a separate store or use the same one, but you must pass it during registration, just like with `BaseApp`: `BaseSideService.use(storePlugin, serviceStore)`.
206
+ 6. **Use `this.dispatch()` and `this.subscribe()`** inside your App, Pages, and Side Service.
206
207
 
207
208
  Here is a complete example:
208
209
 
@@ -2208,7 +2208,7 @@ function createSelector(...args) {
2208
2208
 
2209
2209
  /**
2210
2210
  * @file zeppos.js
2211
- * @description The main entry point for ZeppOS integration.
2211
+ * @description The main entry point for ZeppOS (ZML) integration.
2212
2212
  * It exports the `storePlugin` and a curated set of custom and standard RxJS
2213
2213
  * operators needed for development in the ZeppOS environment.
2214
2214
  */
@@ -2216,7 +2216,7 @@ function createSelector(...args) {
2216
2216
  /**
2217
2217
  * Factory function that creates the store plugin for ZML's BaseApp/BasePage.
2218
2218
  * This plugin function is called by the ZML `.use()` method and adapts its behavior
2219
- * based on whether it's initializing an App or a Page.
2219
+ * based on whether it's initializing an App, a Page, or a Side Service.
2220
2220
  *
2221
2221
  * For `BaseApp.use(storePlugin, store)`, it receives the store and attaches it.
2222
2222
  * For `BasePage.use(storePlugin)`, it finds the store on the global App object.
@@ -2227,7 +2227,7 @@ function createSelector(...args) {
2227
2227
  */
2228
2228
  function storePlugin(instance, store) {
2229
2229
  // This is the core logic: return a plugin object with different behaviors
2230
- // for the App's `onCreate` and the Page's `onInit`.
2230
+ // for the App's `onCreate` and the Page/Service's `onInit`.
2231
2231
  return {
2232
2232
  // This hook is called for the App instance.
2233
2233
  onCreate() {
@@ -2260,35 +2260,46 @@ function storePlugin(instance, store) {
2260
2260
  };
2261
2261
  },
2262
2262
 
2263
- // This hook is called for Page instances.
2263
+ // This hook is called for Page and Side Service instances.
2264
2264
  onInit() {
2265
- const app = getApp();
2266
- if (!app || !app._store) {
2267
- console.error('[rx-tiny-flux] Store not found on global App object. Ensure the plugin is registered on BaseApp.');
2268
- // Provide dummy methods to prevent crashes.
2269
- this.dispatch = () => console.error('Dispatch failed: store not initialized.');
2270
- this.subscribe = () => console.error('Subscribe failed: store not initialized.');
2271
- return;
2265
+ // Check if we are in a Side Service context
2266
+ const isSideServiceContext = typeof messaging !== 'undefined';
2267
+
2268
+ if (isSideServiceContext) {
2269
+ // Side Service behaves like the App: it needs its own store instance.
2270
+ if (!store) {
2271
+ console.error('[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseSideService.use(storePlugin, store)`.');
2272
+ return;
2273
+ }
2274
+ this._store = store;
2275
+ } else {
2276
+ // Page context: find the store on the global App object.
2277
+ const app = getApp();
2278
+ if (!app || !app._store) {
2279
+ console.error('[rx-tiny-flux] Store not found on global App object. Ensure the plugin is registered on BaseApp.');
2280
+ // Provide dummy methods to prevent crashes.
2281
+ this.dispatch = () => console.error('Dispatch failed: store not initialized.');
2282
+ this.subscribe = () => console.error('Subscribe failed: store not initialized.');
2283
+ return;
2284
+ }
2285
+ this._store = app._store;
2272
2286
  }
2273
2287
 
2274
- // Delegate dispatch to the central App's dispatch method.
2288
+ // Attach dispatch, subscribe, and onCall methods.
2275
2289
  this.dispatch = (action) => {
2276
- // The context (`this`) is the Page instance, which is what we want for effects.
2277
2290
  const actionWithContext = { ...action, context: this };
2278
- app._store.dispatch(actionWithContext);
2291
+ this._store.dispatch(actionWithContext);
2279
2292
  };
2280
2293
 
2281
- // Handle subscriptions locally within the Page for lifecycle management.
2282
2294
  this.subscribe = (selector, callback) => {
2283
2295
  if (!this._subscriptions) {
2284
2296
  this._subscriptions = [];
2285
2297
  }
2286
- const subscription = app._store.select(selector).subscribe(callback);
2298
+ const subscription = this._store.select(selector).subscribe(callback);
2287
2299
  this._subscriptions.push(subscription);
2288
2300
  return subscription;
2289
2301
  };
2290
2302
 
2291
- // Handle incoming calls locally on the page.
2292
2303
  this.onCall = (message) => {
2293
2304
  if (message && typeof message.type === 'string') {
2294
2305
  this.dispatch(message);
@@ -1 +1 @@
1
- var t=function(n,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},t(n,r)};function n(n,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function e(){this.constructor=n}t(n,r),n.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}function r(t,n,r,e){return new(r||(r=Promise))(function(o,i){function u(t){try{s(e.next(t))}catch(t){i(t)}}function c(t){try{s(e.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof r?n:new r(function(t){t(n)})).then(u,c)}s((e=e.apply(t,n||[])).next())})}function e(t,n){var r,e,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=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(r=1,e&&(o=2&c[0]?e.return:c[0]?e.throw||((o=e.return)&&o.call(e),0):e.next)&&!(o=o.call(e,c[1])).done)return o;switch(e=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,e=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],e=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}function o(t){var n="function"==typeof Symbol&&Symbol.iterator,r=n&&t[n],e=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t,n){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var e,o,i=r.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(e=i.next()).done;)u.push(e.value)}catch(t){o={error:t}}finally{try{e&&!e.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function u(t,n,r){if(r||2===arguments.length)for(var e,o=0,i=n.length;o<i;o++)!e&&o in n||(e||(e=Array.prototype.slice.call(n,0,o)),e[o]=n[o]);return t.concat(e||Array.prototype.slice.call(n))}function c(t){return this instanceof c?(this.v=t,this):new c(t)}function s(t,n,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,o=r.apply(t,n||[]),i=[];return e=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)}}),e[Symbol.asyncIterator]=function(){return this},e;function u(t,n){o[t]&&(e[t]=function(n){return new Promise(function(r,e){i.push([t,n,r,e])>1||s(t,n)})},n&&(e[t]=n(e[t])))}function s(t,n){try{(r=o[t](n)).value instanceof c?Promise.resolve(r.value.v).then(a,l):f(i[0][2],r)}catch(t){f(i[0][3],t)}var r}function a(t){s("next",t)}function l(t){s("throw",t)}function f(t,n){t(n),i.shift(),i.length&&s(i[0][0],i[0][1])}}function a(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,r=t[Symbol.asyncIterator];return r?r.call(t):(t=o(t),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(r){n[r]=t[r]&&function(n){return new Promise(function(e,o){(function(t,n,r,e){Promise.resolve(e).then(function(n){t({value:n,done:r})},n)})(e,o,(n=t[r](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 r=t.indexOf(n);0<=r&&t.splice(r,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,r,e,c;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=o(s),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 s.remove(this);var p=this.initialTeardown;if(l(p))try{p()}catch(t){c=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 w=v.value;try{y(w)}catch(t){c=null!=c?c:[],t instanceof h?c=u(u([],i(c)),i(t.errors)):c.push(t)}}}catch(t){r={error:t}}finally{try{v&&!v.done&&(e=b.return)&&e.call(b)}finally{if(r)throw r.error}}}if(c)throw new h(c)}},t.prototype.add=function(n){var r;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!==(r=this._finalizers)&&void 0!==r?r:[]).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 r=this._finalizers;r&&p(r,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 w={Promise:void 0},m=function(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];return setTimeout.apply(void 0,u([t,n],i(r)))};function _(t){m(function(){throw t})}function x(){}function g(t){t()}var S=function(t){function r(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,v(n)&&n.add(r)):r.destination=I,r}return n(r,t),r.create=function(t,n,r){return new O(t,n,r)},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(d),E=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){A(t)}},t.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(t){A(t)}else A(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){A(t)}},t}(),O=function(t){function r(n,r,e){var o,i=t.call(this)||this;return o=l(n)||!n?{next:null!=n?n:void 0,error:null!=r?r:void 0,complete:null!=e?e:void 0}:n,i.destination=new E(o),i}return n(r,t),r}(S);function A(t){_(t)}var I={closed:!0,next:x,error:function(t){throw t},complete:x},P="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 z=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(n){var r=new t;return r.source=this,r.operator=n,r},t.prototype.subscribe=function(t,n,r){var e,o=this,i=(e=t)&&e instanceof S||function(t){return t&&l(t.next)&&l(t.error)&&l(t.complete)}(e)&&v(e)?t:new O(t,n,r);return g(function(){var t=o,n=t.operator,r=t.source;i.add(n?n.call(i,r):r?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 r=this;return new(n=k(n))(function(n,e){var o=new O({next:function(n){try{t(n)}catch(t){e(t),o.unsubscribe()}},error:e,complete:n});r.subscribe(o)})},t.prototype._subscribe=function(t){var n;return null===(n=this.source)||void 0===n?void 0:n.subscribe(t)},t.prototype[P]=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=k(t))(function(t,r){var e;n.subscribe(function(t){return e=t},function(t){return r(t)},function(){return t(e)})})},t.create=function(n){return new t(n)},t}();function k(t){var n;return null!==(n=null!=t?t:w.Promise)&&void 0!==n?n:Promise}function F(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 $(t,n,r,e,o){return new N(t,n,r,e,o)}var N=function(t){function r(n,r,e,o,i,u){var c=t.call(this,n)||this;return c.onFinalize=i,c.shouldUnsubscribe=u,c._next=r?function(t){try{r(t)}catch(t){n.error(t)}}:t.prototype._next,c._error=o?function(t){try{o(t)}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=e?function(){try{e()}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,c}return n(r,t),r.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&(null===(n=this.onFinalize)||void 0===n||n.call(this))}},r}(S),R=f(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),J=function(t){function r(){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(r,t),r.prototype.lift=function(t){var n=new U(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new R},r.prototype.next=function(t){var n=this;g(function(){var r,e;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){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}}})},r.prototype.error=function(t){var n=this;g(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var r=n.observers;r.length;)r.shift().error(t)}})},r.prototype.complete=function(){var t=this;g(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},r.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},r.prototype._innerSubscribe=function(t){var n=this,r=this,e=r.hasError,o=r.isStopped,i=r.observers;return e||o?b:(this.currentObservers=null,i.push(t),new d(function(){n.currentObservers=null,p(i,t)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,r=n.hasError,e=n.thrownError,o=n.isStopped;r?t.error(e):o&&t.complete()},r.prototype.asObservable=function(){var t=new z;return t.source=this,t},r.create=function(t,n){return new U(t,n)},r}(z),U=function(t){function r(n,r){var e=t.call(this)||this;return e.destination=n,e.source=r,e}return n(r,t),r.prototype.next=function(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.next)||void 0===r||r.call(n,t)},r.prototype.error=function(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.error)||void 0===r||r.call(n,t)},r.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)},r.prototype._subscribe=function(t){var n,r;return null!==(r=null===(n=this.source)||void 0===n?void 0:n.subscribe(t))&&void 0!==r?r:b},r}(J),B=function(t){function r(n){var r=t.call(this)||this;return r._value=n,r}return n(r,t),Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(n){var r=t.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},r.prototype.getValue=function(){var t=this,n=t.hasError,r=t.thrownError,e=t._value;if(n)throw r;return this._throwIfClosed(),e},r.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},r}(J),W={now:function(){return(W.delegate||Date).now()},delegate:void 0},D=function(t){function r(n,r,e){void 0===n&&(n=1/0),void 0===r&&(r=1/0),void 0===e&&(e=W);var o=t.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=e,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return n(r,t),r.prototype.next=function(n){var r=this,e=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,u=r._timestampProvider,c=r._windowTime;e||(o.push(n),!i&&o.push(u.now()+c)),this._trimBuffer(),t.prototype.next.call(this,n)},r.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),r=this._infiniteTimeWindow,e=this._buffer.slice(),o=0;o<e.length&&!t.closed;o+=r?1:2)t.next(e[o]);return this._checkFinalizedStatuses(t),n},r.prototype._trimBuffer=function(){var t=this,n=t._bufferSize,r=t._timestampProvider,e=t._buffer,o=t._infiniteTimeWindow,i=(o?1:2)*n;if(n<1/0&&i<e.length&&e.splice(0,e.length-i),!o){for(var u=r.now(),c=0,s=1;s<e.length&&e[s]<=u;s+=2)c=s;c&&e.splice(0,c+1)}},r}(J),M=function(t){function r(n,r){return t.call(this)||this}return n(r,t),r.prototype.schedule=function(t,n){return this},r}(d),Y=function(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];return setInterval.apply(void 0,u([t,n],i(r)))},q=function(t){return clearInterval(t)},V=function(t){function r(n,r){var e=t.call(this,n,r)||this;return e.scheduler=n,e.work=r,e.pending=!1,e}return n(r,t),r.prototype.schedule=function(t,n){var r;if(void 0===n&&(n=0),this.closed)return this;this.state=t;var e=this.id,o=this.scheduler;return null!=e&&(this.id=this.recycleAsyncId(o,e,n)),this.pending=!0,this.delay=n,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(o,this.id,n),this},r.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),Y(t.flush.bind(t,this),r)},r.prototype.recycleAsyncId=function(t,n,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return n;null!=n&&q(n)},r.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,n);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},r.prototype._execute=function(t,n){var r,e=!1;try{this.work(t)}catch(t){e=!0,r=t||new Error("Scheduled action threw falsy error")}if(e)return this.unsubscribe(),r},r.prototype.unsubscribe=function(){if(!this.closed){var n=this.id,r=this.scheduler,e=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,p(e,this),null!=n&&(this.id=this.recycleAsyncId(r,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},r}(M),Z=function(){function t(n,r){void 0===r&&(r=t.now),this.schedulerActionCtor=n,this.now=r}return t.prototype.schedule=function(t,n,r){return void 0===n&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},t.now=W.now,t}(),L=new(function(t){function r(n,r){void 0===r&&(r=Z.now);var e=t.call(this,n,r)||this;return e.actions=[],e._active=!1,e}return n(r,t),r.prototype.flush=function(t){var n=this.actions;if(this._active)n.push(t);else{var r;this._active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=n.shift());if(this._active=!1,r){for(;t=n.shift();)t.unsubscribe();throw r}}},r}(Z))(V),G=L,K=new z(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 rt(t){return l(t[P])}function et(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 ct(t){return s(this,arguments,function(){var n,r,o;return e(this,function(e){switch(e.label){case 0:n=t.getReader(),e.label=1;case 1:e.trys.push([1,,9,10]),e.label=2;case 2:return[4,c(n.read())];case 3:return r=e.sent(),o=r.value,r.done?[4,c(void 0)]:[3,5];case 4:return[2,e.sent()];case 5:return[4,c(o)];case 6:return[4,e.sent()];case 7:return e.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function st(t){return l(null==t?void 0:t.getReader)}function at(t){if(t instanceof z)return t;if(null!=t){if(rt(t))return i=t,new z(function(t){var n=i[P]();if(l(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(tt(t))return e=t,new z(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()});if(nt(t))return r=t,new z(function(t){r.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,_)});if(et(t))return lt(t);if(ut(t))return n=t,new z(function(t){var r,e;try{for(var i=o(n),u=i.next();!u.done;u=i.next()){var c=u.value;if(t.next(c),t.closed)return}}catch(t){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}t.complete()});if(st(t))return lt(ct(t))}var n,r,e,i;throw ot(t)}function lt(t){return new z(function(n){(function(t,n){var o,i,u,c;return r(this,void 0,void 0,function(){var r,s;return e(this,function(e){switch(e.label){case 0:e.trys.push([0,5,6,11]),o=a(t),e.label=1;case 1:return[4,o.next()];case 2:if((i=e.sent()).done)return[3,4];if(r=i.value,n.next(r),n.closed)return[2];e.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=e.sent(),u={error:s},[3,11];case 6:return e.trys.push([6,,9,10]),i&&!i.done&&(c=o.return)?[4,c.call(o)]:[3,8];case 7:e.sent(),e.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,r,e,o){void 0===e&&(e=0),void 0===o&&(o=!1);var i=n.schedule(function(){r(),o?t.add(this.schedule(null,e)):this.unsubscribe()},e);if(t.add(i),!o)return i}function ht(t,n){return void 0===n&&(n=0),F(function(r,e){r.subscribe($(e,function(r){return ft(e,t,function(){return e.next(r)},n)},function(){return ft(e,t,function(){return e.complete()},n)},function(r){return ft(e,t,function(){return e.error(r)},n)}))})}function pt(t,n){return void 0===n&&(n=0),F(function(r,e){e.add(t.schedule(function(){return r.subscribe(e)},n))})}function dt(t,n){if(!t)throw new Error("Iterable cannot be null");return new z(function(r){ft(r,n,function(){var e=t[Symbol.asyncIterator]();ft(r,n,function(){e.next().then(function(t){t.done?r.complete():r.next(t.value)})},0,!0)})})}function bt(t,n){if(null!=t){if(rt(t))return function(t,n){return at(t).pipe(pt(n),ht(n))}(t,n);if(tt(t))return function(t,n){return new z(function(r){var e=0;return n.schedule(function(){e===t.length?r.complete():(r.next(t[e++]),r.closed||this.schedule())})})}(t,n);if(nt(t))return function(t,n){return at(t).pipe(pt(n),ht(n))}(t,n);if(et(t))return dt(t,n);if(ut(t))return function(t,n){return new z(function(r){var e;return ft(r,n,function(){e=t[it](),ft(r,n,function(){var t,n,o;try{n=(t=e.next()).value,o=t.done}catch(t){return void r.error(t)}o?r.complete():r.next(n)},0,!0)}),function(){return l(null==e?void 0:e.return)&&e.return()}})}(t,n);if(st(t))return function(t,n){return dt(ct(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 wt(t,n){return F(function(r,e){var o=0;r.subscribe($(e,function(r){e.next(t.call(n,r,o++))}))})}function mt(t,n,r){return void 0===r&&(r=1/0),l(n)?mt(function(r,e){return wt(function(t,o){return n(r,t,e,o)})(at(t(r,e)))},r):("number"==typeof n&&(r=n),F(function(n,e){return function(t,n,r,e,o,i,u){var c=[],s=0,a=0,l=!1,f=function(){!l||c.length||s||n.complete()},h=function(t){s++;var o=!1;at(r(t,a++)).subscribe($(n,function(t){n.next(t)},function(){o=!0},void 0,function(){if(o)try{s--;for(var t=function(){var t=c.shift();u||h(t)};c.length&&s<e;)t();f()}catch(t){n.error(t)}}))};return t.subscribe($(n,function(t){return s<e?h(t):c.push(t)},function(){l=!0,f()})),function(){}}(n,e,t,r)}))}function _t(){return mt(C,1)}function xt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _t()(vt(t,X(t)))}function gt(t){return new z(function(n){at(t()).subscribe(n)})}function St(t,n,r){void 0===t&&(t=0),void 0===r&&(r=G);var e=-1;return null!=n&&(H(n)?r=n:e=n),new z(function(n){var o,i=(o=t)instanceof Date&&!isNaN(o)?+t-r.now():t;i<0&&(i=0);var u=0;return r.schedule(function(){n.closed||(n.next(u++),0<=e?this.schedule(void 0,e):n.complete())},i)})}function Et(t,n){return F(function(r,e){var o=0;r.subscribe($(e,function(r){return t.call(n,r,o++)&&e.next(r)}))})}function Ot(t){return F(function(n,r){var e,o=null,i=!1;o=n.subscribe($(r,void 0,void 0,function(u){e=at(t(u,Ot(t)(n))),o?(o.unsubscribe(),o=null,e.subscribe(r)):i=!0})),i&&(o.unsubscribe(),o=null,e.subscribe(r))})}function At(t,n){return l(n)?mt(t,n,1):mt(t,1)}function It(t,n){return mt(function(n,r){return at(t(n,r)).pipe((e=1)<=0?function(){return K}:F(function(t,n){var r=0;t.subscribe($(n,function(t){++r<=e&&(n.next(t),e<=r&&n.complete())}))}),function(t){return wt(function(){return t})}(n));var e})}function Pt(t,n){void 0===n&&(n=L);var r=St(t,n);return It(function(){return r})}function Ct(t,n){return t===n}function Tt(t,n){return n?function(r){return r.pipe(Tt(function(r,e){return at(t(r,e)).pipe(wt(function(t,o){return n(r,t,e,o)}))}))}:F(function(n,r){var e=0,o=null,i=!1;n.subscribe($(r,function(n){o||(o=$(r,void 0,function(){o=null,i&&r.complete()}),at(t(n,e++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function jt(t,n){return F(function(t,n,r,e,o){return function(e,i){var u=r,c=n,s=0;e.subscribe($(i,function(n){var r=s++;c=u?t(c,n,r):(u=!0,n),i.next(c)},o))}}(t,n,arguments.length>=2))}function zt(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];if(!0!==n){if(!1!==n){var o=new O({next:function(){o.unsubscribe(),t()}});return at(n.apply(void 0,u([],i(r)))).subscribe(o)}}else t()}function kt(t,n,r){var e;return e=t,function(t){void 0===t&&(t={});var n=t.connector,r=void 0===n?function(){return new J}:n,e=t.resetOnError,o=void 0===e||e,i=t.resetOnComplete,u=void 0===i||i,c=t.resetOnRefCountZero,s=void 0===c||c;return function(t){var n,e,i,c=0,a=!1,l=!1,f=function(){null==e||e.unsubscribe(),e=void 0},h=function(){f(),n=i=void 0,a=l=!1},p=function(){var t=n;h(),null==t||t.unsubscribe()};return F(function(t,d){c++,l||a||f();var b=i=null!=i?i:r();d.add(function(){0!==--c||l||a||(e=zt(p,s))}),b.subscribe(d),!n&&c>0&&(n=new O({next:function(t){return b.next(t)},error:function(t){l=!0,f(),e=zt(h,o,t),b.error(t)},complete:function(){a=!0,f(),e=zt(h,u),b.complete()}}),at(t).subscribe(n))})(t)}}({connector:function(){return new D(e,n,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})}function Ft(t,n){return F(function(r,e){var o=null,i=0,u=!1,c=function(){return u&&!o&&e.complete()};r.subscribe($(e,function(r){null==o||o.unsubscribe();var u=0,s=i++;at(t(r,s)).subscribe(o=$(e,function(t){return e.next(n?n(r,t,s,u++):t)},function(){o=null,c()}))},function(){u=!0,c()}))})}function $t(t,n,r){var e=l(t)||n||r?{next:t,error:n,complete:r}:t;return e?F(function(t,n){var r;null===(r=e.subscribe)||void 0===r||r.call(e);var o=!0;t.subscribe($(n,function(t){var r;null===(r=e.next)||void 0===r||r.call(e,t),n.next(t)},function(){var t;o=!1,null===(t=e.complete)||void 0===t||t.call(e),n.complete()},function(t){var r;o=!1,null===(r=e.error)||void 0===r||r.call(e,t),n.error(t)},function(){var t,n;o&&(null===(t=e.unsubscribe)||void 0===t||t.call(e)),null===(n=e.finalize)||void 0===n||n.call(e)}))}):C}function Nt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r,e=l(Q(r=t))?r.pop():void 0;return F(function(n,r){for(var o=t.length,c=new Array(o),s=t.map(function(){return!1}),a=!1,l=function(n){at(t[n]).subscribe($(r,function(t){c[n]=t,a||s[n]||(s[n]=!0,(a=s.every(C))&&(s=null))},x))},f=0;f<o;f++)l(f);n.subscribe($(r,function(t){if(a){var n=u([t],i(c));r.next(e?e.apply(void 0,u([],i(n))):n)}}))})}class Rt{_state$;_actions$=new J;_reducers=[];constructor(t={}){const n="function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t));this._state$=new B(n);const r=this._actions$.pipe(jt((t,n)=>{const r=JSON.parse(JSON.stringify(t));return this._reducers.forEach(({path:t,reducerFn:e})=>{const o=r[t],i=e(o,n);void 0!==i&&o!==i&&(r[t]=i)}),r},n),function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=X(t);return F(function(n,e){(r?xt(t,n,r):xt(t,n)).subscribe(e)})}(t),kt(1));r.subscribe(this._state$)}registerReducers(...t){this._reducers.push(...t);const n=this._state$.getValue(),r=JSON.parse(JSON.stringify(n));t.forEach(({path:t,initialState:n})=>{void 0===r[t]&&(r[t]=n)}),this._state$.next(r)}registerEffects(...t){t.forEach(t=>{const n=t._rxEffect||{dispatch:!0},r=t(this._actions$);n.dispatch?r.subscribe(this.dispatch.bind(this)):r.subscribe()})}dispatch(t){this._actions$.next(t)}select(t){return this._state$.pipe(wt(n=>t(n)),(void 0===r&&(r=C),n=null!=n?n:Ct,F(function(t,e){var o,i=!0;t.subscribe($(e,function(t){var u=r(t);!i&&n(o,u)||(i=!1,o=u,e.next(t))}))})));var n,r}}function Jt(t){const n=n=>({type:t,payload:n});return n.type=t,n}function Ut(){}function Bt(...t){const n=t.pop(),r=t,e=r.includes(Ut);if(e&&r.length>1)throw new Error("The `anyAction` token cannot be mixed with other action creators in a single `on` handler.");return{types:r.map(t=>t.type),reducerFn:n,isCatchAll:e}}function Wt(t,n,...r){if(!t||"string"!=typeof t)throw new Error("Reducer featureKey must be a non-empty string.");const e=r.filter(t=>!t.isCatchAll),o=r.find(t=>t.isCatchAll);return{path:t,initialState:n,reducerFn:(t=n,r)=>{for(const n of e)if(n.types.includes(r.type))return n.reducerFn(t,r);return o?o.reducerFn(t,r):t}}}function Dt(...t){const n=t.map(t=>t.type);return Et(t=>n.includes(t.type))}function Mt(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 r=>{const e=r[t];return n?n(e):e}}function qt(...t){const n=t.pop(),r=t;if("function"!=typeof n)throw new Error("The last argument to createSelector must be a projection function.");return t=>{const e=r.map(n=>n(t));return n(...e)}}function Vt(t,n){return{onCreate(){n?(this._store=n,this.dispatch=t=>{const n={...t,context:this};this._store.dispatch(n)},this.onCall=t=>{t&&"string"==typeof t.type&&this.dispatch(t)},this.subscribe=(t,n)=>{this._subscriptions||(this._subscriptions=[]);const r=this._store.select(t).subscribe(n);return this._subscriptions.push(r),r}):console.error("[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseApp.use(storePlugin, store)`.")},onInit(){const t=getApp();if(!t||!t._store)return console.error("[rx-tiny-flux] Store not found on global App object. Ensure the plugin is registered on BaseApp."),this.dispatch=()=>console.error("Dispatch failed: store not initialized."),void(this.subscribe=()=>console.error("Subscribe failed: store not initialized."));this.dispatch=n=>{const r={...n,context:this};t._store.dispatch(r)},this.subscribe=(n,r)=>{this._subscriptions||(this._subscriptions=[]);const e=t._store.select(n).subscribe(r);return this._subscriptions.push(e),e},this.onCall=t=>{t&&"string"==typeof t.type&&this.dispatch(t)}},onDestroy(){this._subscriptions&&this._subscriptions.length>0&&(this._subscriptions.forEach(t=>t.unsubscribe()),this._subscriptions=[])}}}const Zt=t=>n=>n.pipe(mt(n=>{if(!n.context||"function"!=typeof n.context.subscribe)throw new Error("[rx-tiny-flux] `withLatestFromStore` operator requires a `subscribe` method on `action.context`. Ensure you are using the `storePlugin` for ZeppOS.");return new z(r=>{const e=n.context.subscribe(t,t=>{r.next(t),r.complete()});return()=>{e.unsubscribe()}}).pipe(wt(t=>[n,t]))})),Lt=()=>Et(()=>"undefined"!=typeof messaging),Gt=()=>Et(()=>"undefined"==typeof messaging),Kt=()=>$t(t=>{if(t.context&&"function"==typeof t.context.call){const{context:n,...r}=t;t.context.call(r)}});export{K as EMPTY,Rt as Store,Ut as anyAction,Ot as catchError,At as concatMap,Jt as createAction,Mt as createEffect,Yt as createFeatureSelector,Wt as createReducer,qt as createSelector,gt as defer,Pt as delay,Tt as exhaustMap,Et as filter,vt as from,Gt as isApp,Lt as isSideService,wt as map,mt as mergeMap,yt as of,Dt as ofType,Bt as on,T as pipe,Kt as propagateAction,Vt as storePlugin,Ft as switchMap,$t as tap,Nt as withLatestFrom,Zt as withLatestFromStore};
1
+ var t=function(n,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},t(n,r)};function n(n,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function e(){this.constructor=n}t(n,r),n.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}function r(t,n,r,e){return new(r||(r=Promise))(function(o,i){function u(t){try{c(e.next(t))}catch(t){i(t)}}function s(t){try{c(e.throw(t))}catch(t){i(t)}}function c(t){var n;t.done?o(t.value):(n=t.value,n instanceof r?n:new r(function(t){t(n)})).then(u,s)}c((e=e.apply(t,n||[])).next())})}function e(t,n){var r,e,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(r)throw new TypeError("Generator is already executing.");for(;u&&(u=0,s[0]&&(i=0)),i;)try{if(r=1,e&&(o=2&s[0]?e.return:s[0]?e.throw||((o=e.return)&&o.call(e),0):e.next)&&!(o=o.call(e,s[1])).done)return o;switch(e=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++,e=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],e=0}finally{r=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,r=n&&t[n],e=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t,n){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var e,o,i=r.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(e=i.next()).done;)u.push(e.value)}catch(t){o={error:t}}finally{try{e&&!e.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function u(t,n,r){if(r||2===arguments.length)for(var e,o=0,i=n.length;o<i;o++)!e&&o in n||(e||(e=Array.prototype.slice.call(n,0,o)),e[o]=n[o]);return t.concat(e||Array.prototype.slice.call(n))}function s(t){return this instanceof s?(this.v=t,this):new s(t)}function c(t,n,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,o=r.apply(t,n||[]),i=[];return e=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)}}),e[Symbol.asyncIterator]=function(){return this},e;function u(t,n){o[t]&&(e[t]=function(n){return new Promise(function(r,e){i.push([t,n,r,e])>1||c(t,n)})},n&&(e[t]=n(e[t])))}function c(t,n){try{(r=o[t](n)).value instanceof s?Promise.resolve(r.value.v).then(a,l):f(i[0][2],r)}catch(t){f(i[0][3],t)}var r}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,r=t[Symbol.asyncIterator];return r?r.call(t):(t=o(t),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(r){n[r]=t[r]&&function(n){return new Promise(function(e,o){(function(t,n,r,e){Promise.resolve(e).then(function(n){t({value:n,done:r})},n)})(e,o,(n=t[r](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 r=t.indexOf(n);0<=r&&t.splice(r,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,r,e,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 w=v.value;try{y(w)}catch(t){s=null!=s?s:[],t instanceof h?s=u(u([],i(s)),i(t.errors)):s.push(t)}}}catch(t){r={error:t}}finally{try{v&&!v.done&&(e=b.return)&&e.call(b)}finally{if(r)throw r.error}}}if(s)throw new h(s)}},t.prototype.add=function(n){var r;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!==(r=this._finalizers)&&void 0!==r?r:[]).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 r=this._finalizers;r&&p(r,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 w={Promise:void 0},m=function(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];return setTimeout.apply(void 0,u([t,n],i(r)))};function _(t){m(function(){throw t})}function x(){}function g(t){t()}var S=function(t){function r(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,v(n)&&n.add(r)):r.destination=I,r}return n(r,t),r.create=function(t,n,r){return new O(t,n,r)},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(d),E=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){A(t)}},t.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(t){A(t)}else A(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){A(t)}},t}(),O=function(t){function r(n,r,e){var o,i=t.call(this)||this;return o=l(n)||!n?{next:null!=n?n:void 0,error:null!=r?r:void 0,complete:null!=e?e:void 0}:n,i.destination=new E(o),i}return n(r,t),r}(S);function A(t){_(t)}var I={closed:!0,next:x,error:function(t){throw t},complete:x},P="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 z=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(n){var r=new t;return r.source=this,r.operator=n,r},t.prototype.subscribe=function(t,n,r){var e,o=this,i=(e=t)&&e instanceof S||function(t){return t&&l(t.next)&&l(t.error)&&l(t.complete)}(e)&&v(e)?t:new O(t,n,r);return g(function(){var t=o,n=t.operator,r=t.source;i.add(n?n.call(i,r):r?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 r=this;return new(n=k(n))(function(n,e){var o=new O({next:function(n){try{t(n)}catch(t){e(t),o.unsubscribe()}},error:e,complete:n});r.subscribe(o)})},t.prototype._subscribe=function(t){var n;return null===(n=this.source)||void 0===n?void 0:n.subscribe(t)},t.prototype[P]=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=k(t))(function(t,r){var e;n.subscribe(function(t){return e=t},function(t){return r(t)},function(){return t(e)})})},t.create=function(n){return new t(n)},t}();function k(t){var n;return null!==(n=null!=t?t:w.Promise)&&void 0!==n?n:Promise}function F(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 $(t,n,r,e,o){return new N(t,n,r,e,o)}var N=function(t){function r(n,r,e,o,i,u){var s=t.call(this,n)||this;return s.onFinalize=i,s.shouldUnsubscribe=u,s._next=r?function(t){try{r(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=e?function(){try{e()}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,s}return n(r,t),r.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&(null===(n=this.onFinalize)||void 0===n||n.call(this))}},r}(S),R=f(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),B=function(t){function r(){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(r,t),r.prototype.lift=function(t){var n=new J(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new R},r.prototype.next=function(t){var n=this;g(function(){var r,e;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){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}}})},r.prototype.error=function(t){var n=this;g(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var r=n.observers;r.length;)r.shift().error(t)}})},r.prototype.complete=function(){var t=this;g(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},r.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},r.prototype._innerSubscribe=function(t){var n=this,r=this,e=r.hasError,o=r.isStopped,i=r.observers;return e||o?b:(this.currentObservers=null,i.push(t),new d(function(){n.currentObservers=null,p(i,t)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,r=n.hasError,e=n.thrownError,o=n.isStopped;r?t.error(e):o&&t.complete()},r.prototype.asObservable=function(){var t=new z;return t.source=this,t},r.create=function(t,n){return new J(t,n)},r}(z),J=function(t){function r(n,r){var e=t.call(this)||this;return e.destination=n,e.source=r,e}return n(r,t),r.prototype.next=function(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.next)||void 0===r||r.call(n,t)},r.prototype.error=function(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.error)||void 0===r||r.call(n,t)},r.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)},r.prototype._subscribe=function(t){var n,r;return null!==(r=null===(n=this.source)||void 0===n?void 0:n.subscribe(t))&&void 0!==r?r:b},r}(B),U=function(t){function r(n){var r=t.call(this)||this;return r._value=n,r}return n(r,t),Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(n){var r=t.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},r.prototype.getValue=function(){var t=this,n=t.hasError,r=t.thrownError,e=t._value;if(n)throw r;return this._throwIfClosed(),e},r.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},r}(B),W={now:function(){return(W.delegate||Date).now()},delegate:void 0},D=function(t){function r(n,r,e){void 0===n&&(n=1/0),void 0===r&&(r=1/0),void 0===e&&(e=W);var o=t.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=e,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return n(r,t),r.prototype.next=function(n){var r=this,e=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,u=r._timestampProvider,s=r._windowTime;e||(o.push(n),!i&&o.push(u.now()+s)),this._trimBuffer(),t.prototype.next.call(this,n)},r.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),r=this._infiniteTimeWindow,e=this._buffer.slice(),o=0;o<e.length&&!t.closed;o+=r?1:2)t.next(e[o]);return this._checkFinalizedStatuses(t),n},r.prototype._trimBuffer=function(){var t=this,n=t._bufferSize,r=t._timestampProvider,e=t._buffer,o=t._infiniteTimeWindow,i=(o?1:2)*n;if(n<1/0&&i<e.length&&e.splice(0,e.length-i),!o){for(var u=r.now(),s=0,c=1;c<e.length&&e[c]<=u;c+=2)s=c;s&&e.splice(0,s+1)}},r}(B),M=function(t){function r(n,r){return t.call(this)||this}return n(r,t),r.prototype.schedule=function(t,n){return this},r}(d),Y=function(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];return setInterval.apply(void 0,u([t,n],i(r)))},q=function(t){return clearInterval(t)},V=function(t){function r(n,r){var e=t.call(this,n,r)||this;return e.scheduler=n,e.work=r,e.pending=!1,e}return n(r,t),r.prototype.schedule=function(t,n){var r;if(void 0===n&&(n=0),this.closed)return this;this.state=t;var e=this.id,o=this.scheduler;return null!=e&&(this.id=this.recycleAsyncId(o,e,n)),this.pending=!0,this.delay=n,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(o,this.id,n),this},r.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),Y(t.flush.bind(t,this),r)},r.prototype.recycleAsyncId=function(t,n,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return n;null!=n&&q(n)},r.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,n);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},r.prototype._execute=function(t,n){var r,e=!1;try{this.work(t)}catch(t){e=!0,r=t||new Error("Scheduled action threw falsy error")}if(e)return this.unsubscribe(),r},r.prototype.unsubscribe=function(){if(!this.closed){var n=this.id,r=this.scheduler,e=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,p(e,this),null!=n&&(this.id=this.recycleAsyncId(r,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},r}(M),Z=function(){function t(n,r){void 0===r&&(r=t.now),this.schedulerActionCtor=n,this.now=r}return t.prototype.schedule=function(t,n,r){return void 0===n&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},t.now=W.now,t}(),L=new(function(t){function r(n,r){void 0===r&&(r=Z.now);var e=t.call(this,n,r)||this;return e.actions=[],e._active=!1,e}return n(r,t),r.prototype.flush=function(t){var n=this.actions;if(this._active)n.push(t);else{var r;this._active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=n.shift());if(this._active=!1,r){for(;t=n.shift();)t.unsubscribe();throw r}}},r}(Z))(V),G=L,K=new z(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 rt(t){return l(t[P])}function et(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,r,o;return e(this,function(e){switch(e.label){case 0:n=t.getReader(),e.label=1;case 1:e.trys.push([1,,9,10]),e.label=2;case 2:return[4,s(n.read())];case 3:return r=e.sent(),o=r.value,r.done?[4,s(void 0)]:[3,5];case 4:return[2,e.sent()];case 5:return[4,s(o)];case 6:return[4,e.sent()];case 7:return e.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 z)return t;if(null!=t){if(rt(t))return i=t,new z(function(t){var n=i[P]();if(l(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(tt(t))return e=t,new z(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()});if(nt(t))return r=t,new z(function(t){r.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,_)});if(et(t))return lt(t);if(ut(t))return n=t,new z(function(t){var r,e;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){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}t.complete()});if(ct(t))return lt(st(t))}var n,r,e,i;throw ot(t)}function lt(t){return new z(function(n){(function(t,n){var o,i,u,s;return r(this,void 0,void 0,function(){var r,c;return e(this,function(e){switch(e.label){case 0:e.trys.push([0,5,6,11]),o=a(t),e.label=1;case 1:return[4,o.next()];case 2:if((i=e.sent()).done)return[3,4];if(r=i.value,n.next(r),n.closed)return[2];e.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=e.sent(),u={error:c},[3,11];case 6:return e.trys.push([6,,9,10]),i&&!i.done&&(s=o.return)?[4,s.call(o)]:[3,8];case 7:e.sent(),e.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,r,e,o){void 0===e&&(e=0),void 0===o&&(o=!1);var i=n.schedule(function(){r(),o?t.add(this.schedule(null,e)):this.unsubscribe()},e);if(t.add(i),!o)return i}function ht(t,n){return void 0===n&&(n=0),F(function(r,e){r.subscribe($(e,function(r){return ft(e,t,function(){return e.next(r)},n)},function(){return ft(e,t,function(){return e.complete()},n)},function(r){return ft(e,t,function(){return e.error(r)},n)}))})}function pt(t,n){return void 0===n&&(n=0),F(function(r,e){e.add(t.schedule(function(){return r.subscribe(e)},n))})}function dt(t,n){if(!t)throw new Error("Iterable cannot be null");return new z(function(r){ft(r,n,function(){var e=t[Symbol.asyncIterator]();ft(r,n,function(){e.next().then(function(t){t.done?r.complete():r.next(t.value)})},0,!0)})})}function bt(t,n){if(null!=t){if(rt(t))return function(t,n){return at(t).pipe(pt(n),ht(n))}(t,n);if(tt(t))return function(t,n){return new z(function(r){var e=0;return n.schedule(function(){e===t.length?r.complete():(r.next(t[e++]),r.closed||this.schedule())})})}(t,n);if(nt(t))return function(t,n){return at(t).pipe(pt(n),ht(n))}(t,n);if(et(t))return dt(t,n);if(ut(t))return function(t,n){return new z(function(r){var e;return ft(r,n,function(){e=t[it](),ft(r,n,function(){var t,n,o;try{n=(t=e.next()).value,o=t.done}catch(t){return void r.error(t)}o?r.complete():r.next(n)},0,!0)}),function(){return l(null==e?void 0:e.return)&&e.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 wt(t,n){return F(function(r,e){var o=0;r.subscribe($(e,function(r){e.next(t.call(n,r,o++))}))})}function mt(t,n,r){return void 0===r&&(r=1/0),l(n)?mt(function(r,e){return wt(function(t,o){return n(r,t,e,o)})(at(t(r,e)))},r):("number"==typeof n&&(r=n),F(function(n,e){return function(t,n,r,e,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(r(t,a++)).subscribe($(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<e;)t();f()}catch(t){n.error(t)}}))};return t.subscribe($(n,function(t){return c<e?h(t):s.push(t)},function(){l=!0,f()})),function(){}}(n,e,t,r)}))}function _t(){return mt(C,1)}function xt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _t()(vt(t,X(t)))}function gt(t){return new z(function(n){at(t()).subscribe(n)})}function St(t,n,r){void 0===t&&(t=0),void 0===r&&(r=G);var e=-1;return null!=n&&(H(n)?r=n:e=n),new z(function(n){var o,i=(o=t)instanceof Date&&!isNaN(o)?+t-r.now():t;i<0&&(i=0);var u=0;return r.schedule(function(){n.closed||(n.next(u++),0<=e?this.schedule(void 0,e):n.complete())},i)})}function Et(t,n){return F(function(r,e){var o=0;r.subscribe($(e,function(r){return t.call(n,r,o++)&&e.next(r)}))})}function Ot(t){return F(function(n,r){var e,o=null,i=!1;o=n.subscribe($(r,void 0,void 0,function(u){e=at(t(u,Ot(t)(n))),o?(o.unsubscribe(),o=null,e.subscribe(r)):i=!0})),i&&(o.unsubscribe(),o=null,e.subscribe(r))})}function At(t,n){return l(n)?mt(t,n,1):mt(t,1)}function It(t,n){return mt(function(n,r){return at(t(n,r)).pipe((e=1)<=0?function(){return K}:F(function(t,n){var r=0;t.subscribe($(n,function(t){++r<=e&&(n.next(t),e<=r&&n.complete())}))}),function(t){return wt(function(){return t})}(n));var e})}function Pt(t,n){void 0===n&&(n=L);var r=St(t,n);return It(function(){return r})}function Ct(t,n){return t===n}function Tt(t,n){return n?function(r){return r.pipe(Tt(function(r,e){return at(t(r,e)).pipe(wt(function(t,o){return n(r,t,e,o)}))}))}:F(function(n,r){var e=0,o=null,i=!1;n.subscribe($(r,function(n){o||(o=$(r,void 0,function(){o=null,i&&r.complete()}),at(t(n,e++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function jt(t,n){return F(function(t,n,r,e,o){return function(e,i){var u=r,s=n,c=0;e.subscribe($(i,function(n){var r=c++;s=u?t(s,n,r):(u=!0,n),i.next(s)},o))}}(t,n,arguments.length>=2))}function zt(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];if(!0!==n){if(!1!==n){var o=new O({next:function(){o.unsubscribe(),t()}});return at(n.apply(void 0,u([],i(r)))).subscribe(o)}}else t()}function kt(t,n,r){var e;return e=t,function(t){void 0===t&&(t={});var n=t.connector,r=void 0===n?function(){return new B}:n,e=t.resetOnError,o=void 0===e||e,i=t.resetOnComplete,u=void 0===i||i,s=t.resetOnRefCountZero,c=void 0===s||s;return function(t){var n,e,i,s=0,a=!1,l=!1,f=function(){null==e||e.unsubscribe(),e=void 0},h=function(){f(),n=i=void 0,a=l=!1},p=function(){var t=n;h(),null==t||t.unsubscribe()};return F(function(t,d){s++,l||a||f();var b=i=null!=i?i:r();d.add(function(){0!==--s||l||a||(e=zt(p,c))}),b.subscribe(d),!n&&s>0&&(n=new O({next:function(t){return b.next(t)},error:function(t){l=!0,f(),e=zt(h,o,t),b.error(t)},complete:function(){a=!0,f(),e=zt(h,u),b.complete()}}),at(t).subscribe(n))})(t)}}({connector:function(){return new D(e,n,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})}function Ft(t,n){return F(function(r,e){var o=null,i=0,u=!1,s=function(){return u&&!o&&e.complete()};r.subscribe($(e,function(r){null==o||o.unsubscribe();var u=0,c=i++;at(t(r,c)).subscribe(o=$(e,function(t){return e.next(n?n(r,t,c,u++):t)},function(){o=null,s()}))},function(){u=!0,s()}))})}function $t(t,n,r){var e=l(t)||n||r?{next:t,error:n,complete:r}:t;return e?F(function(t,n){var r;null===(r=e.subscribe)||void 0===r||r.call(e);var o=!0;t.subscribe($(n,function(t){var r;null===(r=e.next)||void 0===r||r.call(e,t),n.next(t)},function(){var t;o=!1,null===(t=e.complete)||void 0===t||t.call(e),n.complete()},function(t){var r;o=!1,null===(r=e.error)||void 0===r||r.call(e,t),n.error(t)},function(){var t,n;o&&(null===(t=e.unsubscribe)||void 0===t||t.call(e)),null===(n=e.finalize)||void 0===n||n.call(e)}))}):C}function Nt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r,e=l(Q(r=t))?r.pop():void 0;return F(function(n,r){for(var o=t.length,s=new Array(o),c=t.map(function(){return!1}),a=!1,l=function(n){at(t[n]).subscribe($(r,function(t){s[n]=t,a||c[n]||(c[n]=!0,(a=c.every(C))&&(c=null))},x))},f=0;f<o;f++)l(f);n.subscribe($(r,function(t){if(a){var n=u([t],i(s));r.next(e?e.apply(void 0,u([],i(n))):n)}}))})}class Rt{_state$;_actions$=new B;_reducers=[];constructor(t={}){const n="function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t));this._state$=new U(n);const r=this._actions$.pipe(jt((t,n)=>{const r=JSON.parse(JSON.stringify(t));return this._reducers.forEach(({path:t,reducerFn:e})=>{const o=r[t],i=e(o,n);void 0!==i&&o!==i&&(r[t]=i)}),r},n),function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=X(t);return F(function(n,e){(r?xt(t,n,r):xt(t,n)).subscribe(e)})}(t),kt(1));r.subscribe(this._state$)}registerReducers(...t){this._reducers.push(...t);const n=this._state$.getValue(),r=JSON.parse(JSON.stringify(n));t.forEach(({path:t,initialState:n})=>{void 0===r[t]&&(r[t]=n)}),this._state$.next(r)}registerEffects(...t){t.forEach(t=>{const n=t._rxEffect||{dispatch:!0},r=t(this._actions$);n.dispatch?r.subscribe(this.dispatch.bind(this)):r.subscribe()})}dispatch(t){this._actions$.next(t)}select(t){return this._state$.pipe(wt(n=>t(n)),(void 0===r&&(r=C),n=null!=n?n:Ct,F(function(t,e){var o,i=!0;t.subscribe($(e,function(t){var u=r(t);!i&&n(o,u)||(i=!1,o=u,e.next(t))}))})));var n,r}}function Bt(t){const n=n=>({type:t,payload:n});return n.type=t,n}function Jt(){}function Ut(...t){const n=t.pop(),r=t,e=r.includes(Jt);if(e&&r.length>1)throw new Error("The `anyAction` token cannot be mixed with other action creators in a single `on` handler.");return{types:r.map(t=>t.type),reducerFn:n,isCatchAll:e}}function Wt(t,n,...r){if(!t||"string"!=typeof t)throw new Error("Reducer featureKey must be a non-empty string.");const e=r.filter(t=>!t.isCatchAll),o=r.find(t=>t.isCatchAll);return{path:t,initialState:n,reducerFn:(t=n,r)=>{for(const n of e)if(n.types.includes(r.type))return n.reducerFn(t,r);return o?o.reducerFn(t,r):t}}}function Dt(...t){const n=t.map(t=>t.type);return Et(t=>n.includes(t.type))}function Mt(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 r=>{const e=r[t];return n?n(e):e}}function qt(...t){const n=t.pop(),r=t;if("function"!=typeof n)throw new Error("The last argument to createSelector must be a projection function.");return t=>{const e=r.map(n=>n(t));return n(...e)}}function Vt(t,n){return{onCreate(){n?(this._store=n,this.dispatch=t=>{const n={...t,context:this};this._store.dispatch(n)},this.onCall=t=>{t&&"string"==typeof t.type&&this.dispatch(t)},this.subscribe=(t,n)=>{this._subscriptions||(this._subscriptions=[]);const r=this._store.select(t).subscribe(n);return this._subscriptions.push(r),r}):console.error("[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseApp.use(storePlugin, store)`.")},onInit(){if("undefined"!=typeof messaging){if(!n)return void console.error("[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseSideService.use(storePlugin, store)`.");this._store=n}else{const t=getApp();if(!t||!t._store)return console.error("[rx-tiny-flux] Store not found on global App object. Ensure the plugin is registered on BaseApp."),this.dispatch=()=>console.error("Dispatch failed: store not initialized."),void(this.subscribe=()=>console.error("Subscribe failed: store not initialized."));this._store=t._store}this.dispatch=t=>{const n={...t,context:this};this._store.dispatch(n)},this.subscribe=(t,n)=>{this._subscriptions||(this._subscriptions=[]);const r=this._store.select(t).subscribe(n);return this._subscriptions.push(r),r},this.onCall=t=>{t&&"string"==typeof t.type&&this.dispatch(t)}},onDestroy(){this._subscriptions&&this._subscriptions.length>0&&(this._subscriptions.forEach(t=>t.unsubscribe()),this._subscriptions=[])}}}const Zt=t=>n=>n.pipe(mt(n=>{if(!n.context||"function"!=typeof n.context.subscribe)throw new Error("[rx-tiny-flux] `withLatestFromStore` operator requires a `subscribe` method on `action.context`. Ensure you are using the `storePlugin` for ZeppOS.");return new z(r=>{const e=n.context.subscribe(t,t=>{r.next(t),r.complete()});return()=>{e.unsubscribe()}}).pipe(wt(t=>[n,t]))})),Lt=()=>Et(()=>"undefined"!=typeof messaging),Gt=()=>Et(()=>"undefined"==typeof messaging),Kt=()=>$t(t=>{if(t.context&&"function"==typeof t.context.call){const{context:n,...r}=t;t.context.call(r)}});export{K as EMPTY,Rt as Store,Jt as anyAction,Ot as catchError,At as concatMap,Bt as createAction,Mt as createEffect,Yt as createFeatureSelector,Wt as createReducer,qt as createSelector,gt as defer,Pt as delay,Tt as exhaustMap,Et as filter,vt as from,Gt as isApp,Lt as isSideService,wt as map,mt as mergeMap,yt as of,Dt as ofType,Ut as on,T as pipe,Kt as propagateAction,Vt as storePlugin,Ft as switchMap,$t as tap,Nt 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.8",
3
+ "version": "1.0.10",
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",