Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stackflow/plugin-history-sync

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackflow/plugin-history-sync - npm Package Compare versions

Comparing version 0.4.1-alpha.1 to 0.4.1-alpha.2

2

dist/index.js

@@ -1,2 +0,2 @@

var G=Object.create;var S=Object.defineProperty,U=Object.defineProperties,$=Object.getOwnPropertyDescriptor,L=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertyNames,_=Object.getOwnPropertySymbols,M=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var A=(t,e,a)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,f=(t,e)=>{for(var a in e||(e={}))E.call(e,a)&&A(t,a,e[a]);if(_)for(var a of _(e))j.call(e,a)&&A(t,a,e[a]);return t},T=(t,e)=>U(t,L(e));var C=(t,e)=>{for(var a in e)S(t,a,{get:e[a],enumerable:!0})},N=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of O(e))!E.call(t,n)&&n!==a&&S(t,n,{get:()=>e[n],enumerable:!(r=$(e,n))||r.enumerable});return t};var D=(t,e,a)=>(a=t!=null?G(M(t)):{},N(e||!t||!t.__esModule?S(a,"default",{value:t,enumerable:!0}):a,t)),q=t=>N(S({},"__esModule",{value:!0}),t);var X={};C(X,{historySyncPlugin:()=>J});module.exports=q(X);var y=require("@stackflow/core");var H=D(require("url-pattern"));function F(t){return new URL(t,"file://")}function K(t){let e={};return t.forEach((a,r)=>{e[r]=a}),e}function z(t){return t.endsWith("/")?t:`${t}/`}function Q(t){return t.toString().length>0?`?${t}`:t}function h(t){let e=new H.default(`${t}(/)`);return{fill(a){var l;let r=e.stringify(a),n=(l=e.match(r))!=null?l:{},s=f({},a);Object.keys(n).forEach(u=>{delete s[u]});let o=new URLSearchParams(s);return z(r)+Q(o)},parse(a){let r=F(a),n=e.match(r.pathname),s=K(r.searchParams);return n?f(f({},s),n):null}}}var g="@stackflow/plugin-history-sync@0.4.0",V=1e3,I=60*V;function b(){return window.history.state}function m(t){return typeof t=="string"?[t]:t}function k(t){let e=t;return typeof e=="object"&&e!==null&&"_TAG"in e&&typeof e._TAG=="string"&&e._TAG===g?t:null}function W({state:t,url:e,useHash:a}){let r=a?`${window.location.pathname}#${e}`:e;window.history.pushState(t,"",r)}function x({state:t,url:e,useHash:a}){let r=a?`${window.location.pathname}#${e}`:e;window.history.replaceState(t,"",r)}function J(t){return({context:e})=>{let a=!1,r=null;return{key:"historySync",initialPushedEvent(){var v,c,d;let n=k(b());if(n)return T(f({},n.activity.pushedBy),{name:"Pushed"});let s=(v=e==null?void 0:e.req)!=null&&v.path?e.req.path:typeof window!="undefined"?window.location.pathname+window.location.search:null;if(!s)return null;let o=Object.keys(t.routes);for(let i=0;i<o.length;i+=1){let P=o[i],w=m(t.routes[P]);for(let p=0;p<w.length;p+=1){let B=w[p],R=h(B).parse(s);if(!!R)return(0,y.makeEvent)("Pushed",{activityId:(0,y.id)(),activityName:P,params:f({},R),preloadRef:(c=t.experimental_initialPreloadRef)==null?void 0:c.call(t,s),eventDate:new Date().getTime()-I})}}let l=t.fallbackActivity({context:e}),u=m(t.routes[l]);return(0,y.makeEvent)("Pushed",{activityId:(0,y.id)(),activityName:l,params:{},preloadRef:(d=t.experimental_initialPreloadRef)==null?void 0:d.call(t,u[0]),eventDate:new Date().getTime()-I})},onInit({actions:{getStack:n,dispatchEvent:s}}){let o=n().activities[0],l=h(m(t.routes[o.name])[0]);x({url:l.fill(o.params),state:{_TAG:g,activity:o},useHash:t.useHash});let u=v=>{let c=k(v.state);if(!c)return;let{activities:d}=n(),i=d.find(p=>p.id===c.activity.pushedBy.activityId),P=!i&&c.activity.pushedBy.activityId<d[0].id||(i==null?void 0:i.transitionState)==="enter-active"||(i==null?void 0:i.transitionState)==="enter-done",w=!i&&c.activity.pushedBy.activityId>d[d.length-1].id||(i==null?void 0:i.transitionState)==="exit-active"||(i==null?void 0:i.transitionState)==="exit-done";P&&(s("Popped",{}),i||(a=!0,s("Pushed",f({},c.activity.pushedBy)))),w&&(a=!0,s("Pushed",{activityId:c.activity.pushedBy.activityId,activityName:c.activity.pushedBy.activityName,params:c.activity.pushedBy.params}))};r==null||r(),window.addEventListener("popstate",u),r=()=>{window.removeEventListener("popstate",u)}},onPushed({effect:{activity:n}}){if(a){a=!1;return}let s=h(m(t.routes[n.name])[0]);W({url:s.fill(n.params),state:{_TAG:g,activity:n},useHash:t.useHash})},onReplaced({effect:{activity:n}}){let s=h(m(t.routes[n.name])[0]);x({url:s.fill(n.params),state:{_TAG:g,activity:n},useHash:t.useHash})},onBeforePush({params:n,actions:{overrideParams:s}}){var u;let l=h(m(t.routes[n.activityName])[0]).fill(n.params);s(T(f({},n),{preloadRef:(u=t.experimental_preloadRef)==null?void 0:u.call(t,l)}))},onBeforePop({actions:{preventDefault:n}}){n();do window.history.back();while(!k(b()))}}}}
var G=Object.create;var w=Object.defineProperty,U=Object.defineProperties,$=Object.getOwnPropertyDescriptor,L=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertyNames,_=Object.getOwnPropertySymbols,M=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var A=(t,e,n)=>e in t?w(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,f=(t,e)=>{for(var n in e||(e={}))E.call(e,n)&&A(t,n,e[n]);if(_)for(var n of _(e))j.call(e,n)&&A(t,n,e[n]);return t},T=(t,e)=>U(t,L(e));var C=(t,e)=>{for(var n in e)w(t,n,{get:e[n],enumerable:!0})},N=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of O(e))!E.call(t,a)&&a!==n&&w(t,a,{get:()=>e[a],enumerable:!(i=$(e,a))||i.enumerable});return t};var D=(t,e,n)=>(n=t!=null?G(M(t)):{},N(e||!t||!t.__esModule?w(n,"default",{value:t,enumerable:!0}):n,t)),q=t=>N(w({},"__esModule",{value:!0}),t);var X={};C(X,{historySyncPlugin:()=>J});module.exports=q(X);var m=require("@stackflow/core");var H=D(require("url-pattern"));function F(t){return new URL(t,"file://")}function K(t){let e={};return t.forEach((n,i)=>{e[i]=n}),e}function z(t){return t.endsWith("/")?t:`${t}/`}function Q(t){return t.toString().length>0?`?${t}`:t}function y(t){let e=new H.default(`${t}(/)`);return{fill(n){var u;let i=e.stringify(n),a=(u=e.match(i))!=null?u:{},s=f({},n);Object.keys(a).forEach(l=>{delete s[l]});let c=new URLSearchParams(s);return z(i)+Q(c)},parse(n){let i=F(n),a=e.match(i.pathname),s=K(i.searchParams);return a?f(f({},s),a):null}}}var g="@stackflow/plugin-history-sync@0.4.0",V=1e3,I=60*V;function b(){return typeof window=="undefined"?null:window.history.state}function h(t){return typeof t=="string"?[t]:t}function k(t){let e=t;return typeof e=="object"&&e!==null&&"_TAG"in e&&typeof e._TAG=="string"&&e._TAG===g?t:null}function W({state:t,url:e,useHash:n}){if(typeof window=="undefined")return;let i=n?`${window.location.pathname}#${e}`:e;window.history.pushState(t,"",i)}function x({state:t,url:e,useHash:n}){if(typeof window=="undefined")return;let i=n?`${window.location.pathname}#${e}`:e;window.history.replaceState(t,"",i)}function J(t){return({context:e})=>{let n=!1,i=null;return{key:"historySync",initialPushedEvent(){var S,o,d;let a=k(b());if(a)return T(f({},a.activity.pushedBy),{name:"Pushed"});let s=(S=e==null?void 0:e.req)!=null&&S.path?e.req.path:typeof window!="undefined"?window.location.pathname+window.location.search:null;if(!s)return null;let c=Object.keys(t.routes);for(let r=0;r<c.length;r+=1){let v=c[r],P=h(t.routes[v]);for(let p=0;p<P.length;p+=1){let B=P[p],R=y(B).parse(s);if(!!R)return(0,m.makeEvent)("Pushed",{activityId:(0,m.id)(),activityName:v,params:f({},R),preloadRef:(o=t.experimental_initialPreloadRef)==null?void 0:o.call(t,s),eventDate:new Date().getTime()-I})}}let u=t.fallbackActivity({context:e}),l=h(t.routes[u]);return(0,m.makeEvent)("Pushed",{activityId:(0,m.id)(),activityName:u,params:{},preloadRef:(d=t.experimental_initialPreloadRef)==null?void 0:d.call(t,l[0]),eventDate:new Date().getTime()-I})},onInit({actions:{getStack:a,dispatchEvent:s}}){let c=a().activities[0],u=y(h(t.routes[c.name])[0]);x({url:u.fill(c.params),state:{_TAG:g,activity:c},useHash:t.useHash});let l=S=>{let o=k(S.state);if(!o)return;let{activities:d}=a(),r=d.find(p=>p.id===o.activity.pushedBy.activityId),v=!r&&o.activity.pushedBy.activityId<d[0].id||(r==null?void 0:r.transitionState)==="enter-active"||(r==null?void 0:r.transitionState)==="enter-done",P=!r&&o.activity.pushedBy.activityId>d[d.length-1].id||(r==null?void 0:r.transitionState)==="exit-active"||(r==null?void 0:r.transitionState)==="exit-done";v&&(s("Popped",{}),r||(n=!0,s("Pushed",f({},o.activity.pushedBy)))),P&&(n=!0,s("Pushed",{activityId:o.activity.pushedBy.activityId,activityName:o.activity.pushedBy.activityName,params:o.activity.pushedBy.params}))};i==null||i(),typeof window!="undefined"&&window.addEventListener("popstate",l),i=()=>{typeof window!="undefined"&&window.removeEventListener("popstate",l)}},onPushed({effect:{activity:a}}){if(n){n=!1;return}let s=y(h(t.routes[a.name])[0]);W({url:s.fill(a.params),state:{_TAG:g,activity:a},useHash:t.useHash})},onReplaced({effect:{activity:a}}){let s=y(h(t.routes[a.name])[0]);x({url:s.fill(a.params),state:{_TAG:g,activity:a},useHash:t.useHash})},onBeforePush({params:a,actions:{overrideParams:s}}){var l;let u=y(h(t.routes[a.activityName])[0]).fill(a.params);s(T(f({},a),{preloadRef:(l=t.experimental_preloadRef)==null?void 0:l.call(t,u)}))},onBeforePop({actions:{preventDefault:a}}){a();do typeof window!="undefined"&&window.history.back();while(!k(b()))}}}}
//# sourceMappingURL=index.js.map
{
"name": "@stackflow/plugin-history-sync",
"version": "0.4.1-alpha.1+58734b0",
"version": "0.4.1-alpha.2+f09174e",
"license": "Apache-2.0",

@@ -52,3 +52,3 @@ "exports": {

},
"gitHead": "58734b0d14c21f4141f21b900d7e260ce7abc115"
"gitHead": "f09174e5860adb00c04deec2000d8b34eb5587d9"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc