@real-router/rx 0.1.24 → 0.1.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.
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- var e=require("@real-router/core"),t=class{#e;constructor(e){this.#e=e}subscribe(e,t){const r="function"==typeof e?{next:e}:e,{signal:n}=t??{};if(n?.aborted)return{unsubscribe:()=>{},closed:!0};let o,s=!1;const i=e=>{if(!s)try{r.next?.(e)}catch(e){u(e)}},u=e=>{if(!s)try{r.error?r.error(e):console.error("Unhandled error in RxObservable:",e)}catch{}},c=()=>{if(!s){s=!0;try{r.complete?.()}catch{}}},b={unsubscribe:()=>{if(!s&&(s=!0,a&&n?.removeEventListener("abort",a),o))try{o()}catch{}},get closed(){return s}};let a;n&&(a=()=>{b.unsubscribe()},n.addEventListener("abort",a));try{o=this.#e({next:i,error:u,complete:c})}catch(e){u(e)}return b}pipe(...e){if(0===e.length)return this;let t=this;for(const r of e)t=r(t);return t}[Symbol.observable](){return this}"@@observable"(){return this}async*[Symbol.asyncIterator](){let e,t=null,r=!1,n=!1,o=null;const s=this.subscribe({next:n=>{if(e=n,r=!0,t){const e=t;t=null,e()}},error:e=>{if(o=e,n=!0,t){const e=t;t=null,e()}},complete:()=>{if(n=!0,t){const e=t;t=null,e()}}});try{for(;!n;)if(r){const t=e;r=!1,yield t}else if(await new Promise(e=>{t=e}),null!==o)throw o}finally{s.unsubscribe()}}};function r(e){return r=>new t(t=>{const n=r.subscribe({next:r=>{e(r,t)},error:e=>t.error?.(e),complete:()=>t.complete?.()});return()=>{n.unsubscribe()}})}function n(r,n){const{replay:o=!0}=n??{};return new t(t=>{const n=e.getPluginApi(r).addEventListener(e.events.TRANSITION_SUCCESS,(e,r)=>{t.next?.({route:e,previousRoute:r})});if(o){const e=r.getState();e&&queueMicrotask(()=>{t.next?.({route:e,previousRoute:void 0})})}return n})}exports.RxObservable=t,exports.debounceTime=function(e){if(!Number.isFinite(e)||e<0)throw new RangeError(`debounceTime: duration must be a non-negative finite number, got ${e}`);return r=>new t(t=>{let n,o,s=!1;const i=r.subscribe({next:r=>{o=r,s=!0,void 0!==n&&clearTimeout(n),n=setTimeout(()=>{s&&(t.next?.(o),s=!1),n=void 0},e)},error:e=>{void 0!==n&&(clearTimeout(n),n=void 0),t.error?.(e)},complete:()=>{void 0!==n&&(clearTimeout(n),n=void 0),s&&(t.next?.(o),s=!1),t.complete?.()}});return()=>{void 0!==n&&(clearTimeout(n),n=void 0),i.unsubscribe()}})},exports.distinctUntilChanged=function(e){return r=(t,r)=>{let n,o=!1;const s=e??((e,t)=>e===t),i=t.subscribe({next:e=>{if(!o)return o=!0,n=e,void r.next?.(e);try{s(n,e)||(n=e,r.next?.(e))}catch(e){r.error?.(e)}},error:e=>r.error?.(e),complete:()=>r.complete?.()});return()=>{i.unsubscribe()}},e=>new t(t=>r(e,t));var r},exports.events$=function(r){return new t(t=>{const n=e.getPluginApi(r),o=[];try{o.push(n.addEventListener(e.events.ROUTER_START,()=>{t.next?.({type:"ROUTER_START"})})),o.push(n.addEventListener(e.events.ROUTER_STOP,()=>{t.next?.({type:"ROUTER_STOP"})})),o.push(n.addEventListener(e.events.TRANSITION_START,(e,r)=>{t.next?.({type:"TRANSITION_START",toState:e,fromState:r})})),o.push(n.addEventListener(e.events.TRANSITION_SUCCESS,(e,r,n)=>{t.next?.({type:"TRANSITION_SUCCESS",toState:e,fromState:r,options:n})})),o.push(n.addEventListener(e.events.TRANSITION_ERROR,(e,r,n)=>{t.next?.({type:"TRANSITION_ERROR",toState:e,fromState:r,error:n})})),o.push(n.addEventListener(e.events.TRANSITION_CANCEL,(e,r)=>{t.next?.({type:"TRANSITION_CANCEL",toState:e,fromState:r})}))}catch(e){for(const e of o)e();throw e}return()=>{for(const e of o)e()}})},exports.filter=function(e){return r((t,r)=>{try{e(t)&&r.next?.(t)}catch(e){r.error?.(e)}})},exports.map=function(e){return r((t,r)=>{try{const n=e(t);r.next?.(n)}catch(e){r.error?.(e)}})},exports.observable=function(e){return n(e)},exports.state$=n,exports.takeUntil=function(e){return r=>new t(t=>{let n,o,s=!1;const i=()=>{s||(s=!0,n&&n.unsubscribe(),o&&o.unsubscribe(),t.complete?.())};if(o=e.subscribe({next:()=>{i()},error:e=>{s||(s=!0,n&&n.unsubscribe(),t.error?.(e))}}),!s)return n=r.subscribe({next:e=>{s||t.next?.(e)},error:e=>{s||(s=!0,o.unsubscribe(),t.error?.(e))},complete:()=>{i()}}),()=>{n.unsubscribe(),o.unsubscribe()}})};//# sourceMappingURL=index.js.map
1
+ "use strict";var e=require("@real-router/core"),t=class{#e;constructor(e){this.#e=e}subscribe(e,t){const r="function"==typeof e?{next:e}:e,{signal:n}=t??{};if(n?.aborted)return{unsubscribe:()=>{},closed:!0};let o,s=!1;const i=e=>{if(!s)try{r.next?.(e)}catch(e){u(e)}},u=e=>{if(!s)try{r.error?r.error(e):console.error("Unhandled error in RxObservable:",e)}catch{}},c=()=>{if(!s){s=!0;try{r.complete?.()}catch{}}},b={unsubscribe:()=>{if(!s&&(s=!0,a&&n?.removeEventListener("abort",a),o))try{o()}catch{}},get closed(){return s}};let a;n&&(a=()=>{b.unsubscribe()},n.addEventListener("abort",a));try{o=this.#e({next:i,error:u,complete:c})}catch(e){u(e)}return b}pipe(...e){if(0===e.length)return this;let t=this;for(const r of e)t=r(t);return t}[Symbol.observable](){return this}"@@observable"(){return this}async*[Symbol.asyncIterator](){let e,t=null,r=!1,n=!1,o=null;const s=this.subscribe({next:n=>{if(e=n,r=!0,t){const e=t;t=null,e()}},error:e=>{if(o=e,n=!0,t){const e=t;t=null,e()}},complete:()=>{if(n=!0,t){const e=t;t=null,e()}}});try{for(;!n;)if(r){const t=e;r=!1,yield t}else if(await new Promise(e=>{t=e}),null!==o)throw o}finally{s.unsubscribe()}}};function r(e){return r=>new t(t=>{const n=r.subscribe({next:r=>{e(r,t)},error:e=>t.error?.(e),complete:()=>t.complete?.()});return()=>{n.unsubscribe()}})}function n(r,n){const{replay:o=!0}=n??{};return new t(t=>{const n=e.getPluginApi(r).addEventListener(e.events.TRANSITION_SUCCESS,(e,r)=>{t.next?.({route:e,previousRoute:r})});if(o){const e=r.getState();e&&queueMicrotask(()=>{t.next?.({route:e,previousRoute:void 0})})}return n})}exports.RxObservable=t,exports.debounceTime=function(e){if(!Number.isFinite(e)||e<0)throw new RangeError(`debounceTime: duration must be a non-negative finite number, got ${e}`);return r=>new t(t=>{let n,o,s=!1;const i=r.subscribe({next:r=>{o=r,s=!0,void 0!==n&&clearTimeout(n),n=setTimeout(()=>{s&&(t.next?.(o),s=!1),n=void 0},e)},error:e=>{void 0!==n&&(clearTimeout(n),n=void 0),t.error?.(e)},complete:()=>{void 0!==n&&(clearTimeout(n),n=void 0),s&&(t.next?.(o),s=!1),t.complete?.()}});return()=>{void 0!==n&&(clearTimeout(n),n=void 0),i.unsubscribe()}})},exports.distinctUntilChanged=function(e){return r=(t,r)=>{let n,o=!1;const s=e??((e,t)=>e===t),i=t.subscribe({next:e=>{if(!o)return o=!0,n=e,void r.next?.(e);try{s(n,e)||(n=e,r.next?.(e))}catch(e){r.error?.(e)}},error:e=>r.error?.(e),complete:()=>r.complete?.()});return()=>{i.unsubscribe()}},e=>new t(t=>r(e,t));var r},exports.events$=function(r){return new t(t=>{const n=e.getPluginApi(r),o=[];try{o.push(n.addEventListener(e.events.ROUTER_START,()=>{t.next?.({type:"ROUTER_START"})})),o.push(n.addEventListener(e.events.ROUTER_STOP,()=>{t.next?.({type:"ROUTER_STOP"})})),o.push(n.addEventListener(e.events.TRANSITION_START,(e,r)=>{t.next?.({type:"TRANSITION_START",toState:e,fromState:r})})),o.push(n.addEventListener(e.events.TRANSITION_SUCCESS,(e,r,n)=>{t.next?.({type:"TRANSITION_SUCCESS",toState:e,fromState:r,options:n})})),o.push(n.addEventListener(e.events.TRANSITION_ERROR,(e,r,n)=>{t.next?.({type:"TRANSITION_ERROR",toState:e,fromState:r,error:n})})),o.push(n.addEventListener(e.events.TRANSITION_CANCEL,(e,r)=>{t.next?.({type:"TRANSITION_CANCEL",toState:e,fromState:r})}))}catch(e){for(const e of o)e();throw e}return()=>{for(const e of o)e()}})},exports.filter=function(e){return r((t,r)=>{try{e(t)&&r.next?.(t)}catch(e){r.error?.(e)}})},exports.map=function(e){return r((t,r)=>{try{const n=e(t);r.next?.(n)}catch(e){r.error?.(e)}})},exports.observable=function(e){return n(e)},exports.state$=n,exports.takeUntil=function(e){return r=>new t(t=>{let n,o,s=!1;const i=()=>{s||(s=!0,n&&n.unsubscribe(),o&&o.unsubscribe(),t.complete?.())};if(o=e.subscribe({next:()=>{i()},error:e=>{s||(s=!0,n&&n.unsubscribe(),t.error?.(e))}}),!s)return n=r.subscribe({next:e=>{s||t.next?.(e)},error:e=>{s||(s=!0,o.unsubscribe(),t.error?.(e))},complete:()=>{i()}}),()=>{n.unsubscribe(),o.unsubscribe()}})};//# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@real-router/rx",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "type": "commonjs",
5
5
  "description": "Reactive Observable API for Real-Router — state$, events$, operators, and TC39 Observable support",
6
6
  "main": "./dist/cjs/index.js",
@@ -44,7 +44,7 @@
44
44
  "homepage": "https://github.com/greydragon888/real-router",
45
45
  "sideEffects": false,
46
46
  "dependencies": {
47
- "@real-router/core": "^0.32.0"
47
+ "@real-router/core": "^0.34.0"
48
48
  },
49
49
  "scripts": {
50
50
  "test": "vitest",