@real-router/sources 0.2.6 → 0.2.7

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/route-utils"),t=require("@real-router/core"),s=require("@real-router/core/api"),r=class{#e;#t=!1;#s=new Set;#r;#o;#n;constructor(e,t){this.#e=e,this.#r=t?.onFirstSubscribe,this.#o=t?.onLastUnsubscribe,this.#n=t?.onDestroy,this.subscribe=this.subscribe.bind(this),this.getSnapshot=this.getSnapshot.bind(this),this.destroy=this.destroy.bind(this)}subscribe(e){return this.#t?()=>{}:(0===this.#s.size&&this.#r&&this.#r(),this.#s.add(e),()=>{this.#s.delete(e),!this.#t&&0===this.#s.size&&this.#o&&this.#o()})}getSnapshot(){return this.#e}updateSnapshot(e){this.#t||(this.#e=e,this.#s.forEach(e=>{e()}))}destroy(){this.#t||(this.#t=!0,this.#n?.(),this.#s.clear())}};function o(e,t,s,r){const o=r?.route??t.getState(),n=r?.previousRoute,i=""===s||void 0!==o&&(o.name===s||o.name.startsWith(`${s}.`))?o:void 0;return i===e.route&&n===e.previousRoute?e:{route:i,previousRoute:n}}var n=new WeakMap,i={isTransitioning:!1,toRoute:null,fromRoute:null};exports.createActiveRouteSource=function(t,s,o,n){const i=n?.strict??!1,u=n?.ignoreQueryParams??!0,a=t.isActiveRoute(s,o,i,u),c=new r(a,{onDestroy:()=>{h()}}),h=t.subscribe(r=>{const n=e.areRoutesRelated(s,r.route.name),a=r.previousRoute&&e.areRoutesRelated(s,r.previousRoute.name);if(!n&&!a)return;const h=!!n&&t.isActiveRoute(s,o,i,u);Object.is(c.getSnapshot(),h)||c.updateSnapshot(h)});return c},exports.createRouteNodeSource=function(e,t){let s=null;const i=function(e,t){let s=n.get(e);s||(s=new Map,n.set(e,s));let r=s.get(t);return r||(r=e.shouldUpdateNode(t),s.set(t,r)),r}(e,t),u=()=>{const e=s;s=null,e?.()},a=new r(o({route:void 0,previousRoute:void 0},e,t),{onFirstSubscribe:()=>{a.updateSnapshot(o(a.getSnapshot(),e,t)),s=e.subscribe(s=>{if(!i(s.route,s.previousRoute))return;const r=o(a.getSnapshot(),e,t,s);Object.is(a.getSnapshot(),r)||a.updateSnapshot(r)})},onLastUnsubscribe:u,onDestroy:u});return a},exports.createRouteSource=function(e){let t=null;const s=()=>{const e=t;t=null,e?.()},o=new r({route:e.getState(),previousRoute:void 0},{onFirstSubscribe:()=>{t=e.subscribe(e=>{o.updateSnapshot({route:e.route,previousRoute:e.previousRoute})})},onLastUnsubscribe:s,onDestroy:s});return o},exports.createTransitionSource=function(e){const o=new r(i,{onDestroy:()=>{a.forEach(e=>{e()})}}),n=s.getPluginApi(e),u=()=>{o.updateSnapshot(i)},a=[n.addEventListener(t.events.TRANSITION_START,(e,t)=>{o.updateSnapshot({isTransitioning:!0,toRoute:e,fromRoute:t??null})}),n.addEventListener(t.events.TRANSITION_SUCCESS,u),n.addEventListener(t.events.TRANSITION_ERROR,u),n.addEventListener(t.events.TRANSITION_CANCEL,u)];return o};//# sourceMappingURL=index.js.map
1
+ "use strict";var e=require("@real-router/route-utils"),t=require("@real-router/core"),s=require("@real-router/core/api"),r=class{#e;#t=!1;#s=new Set;#r;#o;#n;constructor(e,t){this.#e=e,this.#r=t?.onFirstSubscribe,this.#o=t?.onLastUnsubscribe,this.#n=t?.onDestroy,this.subscribe=this.subscribe.bind(this),this.getSnapshot=this.getSnapshot.bind(this),this.destroy=this.destroy.bind(this)}subscribe(e){return this.#t?()=>{}:(0===this.#s.size&&this.#r&&this.#r(),this.#s.add(e),()=>{this.#s.delete(e),!this.#t&&0===this.#s.size&&this.#o&&this.#o()})}getSnapshot(){return this.#e}updateSnapshot(e){this.#t||(this.#e=e,this.#s.forEach(e=>{e()}))}destroy(){this.#t||(this.#t=!0,this.#n?.(),this.#s.clear())}};function o(e,t,s,r){const o=r?.route??t.getState(),n=r?.previousRoute,i=""===s||void 0!==o&&(o.name===s||o.name.startsWith(`${s}.`))?o:void 0;return i===e.route&&n===e.previousRoute?e:{route:i,previousRoute:n}}var n=new WeakMap,i={isTransitioning:!1,toRoute:null,fromRoute:null};exports.createActiveRouteSource=function(t,s,o,n){const i=n?.strict??!1,u=n?.ignoreQueryParams??!0,a=t.isActiveRoute(s,o,i,u),c=new r(a,{onDestroy:()=>{h()}}),h=t.subscribe(r=>{const n=e.areRoutesRelated(s,r.route.name),a=r.previousRoute&&e.areRoutesRelated(s,r.previousRoute.name);if(!n&&!a)return;const h=!!n&&t.isActiveRoute(s,o,i,u);Object.is(c.getSnapshot(),h)||c.updateSnapshot(h)});return c},exports.createRouteNodeSource=function(e,t){let s=null;const i=function(e,t){let s=n.get(e);s||(s=new Map,n.set(e,s));let r=s.get(t);return r||(r=e.shouldUpdateNode(t),s.set(t,r)),r}(e,t),u=()=>{const e=s;s=null,e?.()},a=new r(o({route:void 0,previousRoute:void 0},e,t),{onFirstSubscribe:()=>{a.updateSnapshot(o(a.getSnapshot(),e,t)),s=e.subscribe(s=>{if(!i(s.route,s.previousRoute))return;const r=o(a.getSnapshot(),e,t,s);Object.is(a.getSnapshot(),r)||a.updateSnapshot(r)})},onLastUnsubscribe:u,onDestroy:u});return a},exports.createRouteSource=function(e){let t=null;const s=()=>{const e=t;t=null,e?.()},o=new r({route:e.getState(),previousRoute:void 0},{onFirstSubscribe:()=>{t=e.subscribe(e=>{o.updateSnapshot({route:e.route,previousRoute:e.previousRoute})})},onLastUnsubscribe:s,onDestroy:s});return o},exports.createTransitionSource=function(e){const o=new r(i,{onDestroy:()=>{a.forEach(e=>{e()})}}),n=s.getPluginApi(e),u=()=>{o.updateSnapshot(i)},a=[n.addEventListener(t.events.TRANSITION_START,(e,t)=>{o.updateSnapshot({isTransitioning:!0,toRoute:e,fromRoute:t??null})}),n.addEventListener(t.events.TRANSITION_SUCCESS,u),n.addEventListener(t.events.TRANSITION_ERROR,u),n.addEventListener(t.events.TRANSITION_CANCEL,u)];return o};//# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@real-router/sources",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "type": "commonjs",
5
5
  "description": "Framework-agnostic subscription layer for Real-Router state",
6
6
  "main": "./dist/cjs/index.js",
@@ -43,7 +43,7 @@
43
43
  "homepage": "https://github.com/greydragon888/real-router",
44
44
  "sideEffects": false,
45
45
  "dependencies": {
46
- "@real-router/core": "^0.39.0",
46
+ "@real-router/core": "^0.40.0",
47
47
  "@real-router/route-utils": "^0.1.6"
48
48
  },
49
49
  "devDependencies": {