@tanstack/history
Advanced tools
Comparing version 0.0.1-beta.204 to 0.0.1-beta.205
@@ -52,3 +52,2 @@ /** | ||
} | ||
onUpdate(); | ||
}; | ||
@@ -113,3 +112,3 @@ const queueTask = task => { | ||
destroy: () => opts.destroy?.(), | ||
update: onUpdate | ||
notify: onUpdate | ||
}; | ||
@@ -200,3 +199,3 @@ } | ||
currentLocation = parseLocation(getHref(), window.history.state); | ||
history.update(); | ||
history.notify(); | ||
}; | ||
@@ -225,3 +224,3 @@ var originalPushState = window.history.pushState; | ||
let res = originalPushState.apply(window.history, arguments); | ||
if (tracking) history.update(); | ||
if (tracking) history.notify(); | ||
return res; | ||
@@ -231,3 +230,3 @@ }; | ||
let res = originalReplaceState.apply(window.history, arguments); | ||
if (tracking) history.update(); | ||
if (tracking) history.notify(); | ||
return res; | ||
@@ -234,0 +233,0 @@ }; |
@@ -48,3 +48,2 @@ /** | ||
} | ||
onUpdate(); | ||
}; | ||
@@ -109,3 +108,3 @@ const queueTask = task => { | ||
destroy: () => opts.destroy?.(), | ||
update: onUpdate | ||
notify: onUpdate | ||
}; | ||
@@ -196,3 +195,3 @@ } | ||
currentLocation = parseLocation(getHref(), window.history.state); | ||
history.update(); | ||
history.notify(); | ||
}; | ||
@@ -221,3 +220,3 @@ var originalPushState = window.history.pushState; | ||
let res = originalPushState.apply(window.history, arguments); | ||
if (tracking) history.update(); | ||
if (tracking) history.notify(); | ||
return res; | ||
@@ -227,3 +226,3 @@ }; | ||
let res = originalReplaceState.apply(window.history, arguments); | ||
if (tracking) history.update(); | ||
if (tracking) history.notify(); | ||
return res; | ||
@@ -230,0 +229,0 @@ }; |
@@ -11,3 +11,3 @@ { | ||
"name": "packages/history/src/index.ts", | ||
"uid": "8e4c-3" | ||
"uid": "d6b9-3" | ||
} | ||
@@ -20,14 +20,14 @@ ] | ||
"nodeParts": { | ||
"8e4c-3": { | ||
"renderedLength": 8906, | ||
"d6b9-3": { | ||
"renderedLength": 8888, | ||
"gzipLength": 2610, | ||
"brotliLength": 0, | ||
"mainUid": "8e4c-2" | ||
"mainUid": "d6b9-2" | ||
} | ||
}, | ||
"nodeMetas": { | ||
"8e4c-2": { | ||
"d6b9-2": { | ||
"id": "/packages/history/src/index.ts", | ||
"moduleParts": { | ||
"index.production.js": "8e4c-3" | ||
"index.production.js": "d6b9-3" | ||
}, | ||
@@ -34,0 +34,0 @@ "imported": [], |
@@ -23,3 +23,3 @@ /** | ||
destroy: () => void; | ||
update: () => void; | ||
notify: () => void; | ||
} | ||
@@ -26,0 +26,0 @@ interface HistoryLocation extends ParsedPath { |
@@ -54,3 +54,2 @@ /** | ||
} | ||
onUpdate(); | ||
}; | ||
@@ -115,3 +114,3 @@ const queueTask = task => { | ||
destroy: () => opts.destroy?.(), | ||
update: onUpdate | ||
notify: onUpdate | ||
}; | ||
@@ -202,3 +201,3 @@ } | ||
currentLocation = parseLocation(getHref(), window.history.state); | ||
history.update(); | ||
history.notify(); | ||
}; | ||
@@ -227,3 +226,3 @@ var originalPushState = window.history.pushState; | ||
let res = originalPushState.apply(window.history, arguments); | ||
if (tracking) history.update(); | ||
if (tracking) history.notify(); | ||
return res; | ||
@@ -233,3 +232,3 @@ }; | ||
let res = originalReplaceState.apply(window.history, arguments); | ||
if (tracking) history.update(); | ||
if (tracking) history.notify(); | ||
return res; | ||
@@ -236,0 +235,0 @@ }; |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TanStackHistory={})}(this,(function(e){"use strict";const t="pushstate",n="popstate",o="beforeunload",r=e=>(e.preventDefault(),e.returnValue=""),i=()=>{removeEventListener(o,r,{capture:!0})};function s(e){let t=e.getLocation(),n=new Set,s=[],h=[];const c=()=>{t=e.getLocation(),n.forEach((e=>e()))},d=()=>{if(s.length)s[0]?.(d,(()=>{s=[],i()}));else{for(;h.length;)h.shift()?.();c()}},u=e=>{h.push(e),d()};return{get location(){return t},subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(t,n)=>{n=a(n),u((()=>{e.pushState(t,n,c)}))},replace:(t,n)=>{n=a(n),u((()=>{e.replaceState(t,n,c)}))},go:t=>{u((()=>{e.go(t)}))},back:()=>{u((()=>{e.back()}))},forward:()=>{u((()=>{e.forward()}))},createHref:t=>e.createHref(t),block:e=>(s.push(e),1===s.length&&addEventListener(o,r,{capture:!0}),()=>{s=s.filter((t=>t!==e)),s.length||i()}),flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),update:c}}function a(e){return e||(e={}),e.key=d(),e}function h(e){const o=e?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=e?.createHref??(e=>e);let i=c(o(),window.history.state);let a,h,d=!0;const u=()=>{d=!1,(()=>{a&&(window.history[a.isPush?"pushState":"replaceState"](a.state,"",a.href),a=void 0,h=void 0)})(),d=!0},l=(e,t,n,o)=>{const s=r(t);i=c(s,n),a={href:s,state:n,isPush:a?.isPush||"push"===e},o(),h||(h=Promise.resolve().then((()=>u())))},w=()=>{i=c(o(),window.history.state),y.update()};var f=window.history.pushState,p=window.history.replaceState;const y=s({getLocation:()=>i,pushState:(e,t,n)=>l("push",e,t,n),replaceState:(e,t,n)=>l("replace",e,t,n),back:()=>window.history.back(),forward:()=>window.history.forward(),go:e=>window.history.go(e),createHref:e=>r(e),flush:u,destroy:()=>{window.history.pushState=f,window.history.replaceState=p,window.removeEventListener(t,w),window.removeEventListener(n,w)}});return window.addEventListener(t,w),window.addEventListener(n,w),window.history.pushState=function(){let e=f.apply(window.history,arguments);return d&&y.update(),e},window.history.replaceState=function(){let e=p.apply(window.history,arguments);return d&&y.update(),e},y}function c(e,t){let n=e.indexOf("#"),o=e.indexOf("?");return{href:e,pathname:e.substring(0,n>0?o>0?Math.min(n,o):n:o>0?o:e.length),hash:n>-1?e.substring(n):"",search:o>-1?e.slice(o,-1===n?void 0:n):"",state:t||{}}}function d(){return(Math.random()+1).toString(36).substring(7)}e.createBrowserHistory=h,e.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:e=>`#${e}`})},e.createMemoryHistory=function(e={initialEntries:["/"]}){const t=e.initialEntries;let n=e.initialIndex??t.length-1,o={key:d()};return s({getLocation:()=>c(t[n],o),pushState:(e,r)=>{o=r,t.push(e),n++},replaceState:(e,r)=>{o=r,t[n]=e},back:()=>{n--},forward:()=>{n=Math.min(n+1,t.length-1)},go:e=>window.history.go(e),createHref:e=>e})},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TanStackHistory={})}(this,(function(e){"use strict";const t="pushstate",n="popstate",o="beforeunload",r=e=>(e.preventDefault(),e.returnValue=""),i=()=>{removeEventListener(o,r,{capture:!0})};function s(e){let t=e.getLocation(),n=new Set,s=[],h=[];const c=()=>{t=e.getLocation(),n.forEach((e=>e()))},d=()=>{if(s.length)s[0]?.(d,(()=>{s=[],i()}));else for(;h.length;)h.shift()?.()},u=e=>{h.push(e),d()};return{get location(){return t},subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(t,n)=>{n=a(n),u((()=>{e.pushState(t,n,c)}))},replace:(t,n)=>{n=a(n),u((()=>{e.replaceState(t,n,c)}))},go:t=>{u((()=>{e.go(t)}))},back:()=>{u((()=>{e.back()}))},forward:()=>{u((()=>{e.forward()}))},createHref:t=>e.createHref(t),block:e=>(s.push(e),1===s.length&&addEventListener(o,r,{capture:!0}),()=>{s=s.filter((t=>t!==e)),s.length||i()}),flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:c}}function a(e){return e||(e={}),e.key=d(),e}function h(e){const o=e?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=e?.createHref??(e=>e);let i=c(o(),window.history.state);let a,h,d=!0;const u=()=>{d=!1,(()=>{a&&(window.history[a.isPush?"pushState":"replaceState"](a.state,"",a.href),a=void 0,h=void 0)})(),d=!0},f=(e,t,n,o)=>{const s=r(t);i=c(s,n),a={href:s,state:n,isPush:a?.isPush||"push"===e},o(),h||(h=Promise.resolve().then((()=>u())))},l=()=>{i=c(o(),window.history.state),y.notify()};var w=window.history.pushState,p=window.history.replaceState;const y=s({getLocation:()=>i,pushState:(e,t,n)=>f("push",e,t,n),replaceState:(e,t,n)=>f("replace",e,t,n),back:()=>window.history.back(),forward:()=>window.history.forward(),go:e=>window.history.go(e),createHref:e=>r(e),flush:u,destroy:()=>{window.history.pushState=w,window.history.replaceState=p,window.removeEventListener(t,l),window.removeEventListener(n,l)}});return window.addEventListener(t,l),window.addEventListener(n,l),window.history.pushState=function(){let e=w.apply(window.history,arguments);return d&&y.notify(),e},window.history.replaceState=function(){let e=p.apply(window.history,arguments);return d&&y.notify(),e},y}function c(e,t){let n=e.indexOf("#"),o=e.indexOf("?");return{href:e,pathname:e.substring(0,n>0?o>0?Math.min(n,o):n:o>0?o:e.length),hash:n>-1?e.substring(n):"",search:o>-1?e.slice(o,-1===n?void 0:n):"",state:t||{}}}function d(){return(Math.random()+1).toString(36).substring(7)}e.createBrowserHistory=h,e.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:e=>`#${e}`})},e.createMemoryHistory=function(e={initialEntries:["/"]}){const t=e.initialEntries;let n=e.initialIndex??t.length-1,o={key:d()};return s({getLocation:()=>c(t[n],o),pushState:(e,r)=>{o=r,t.push(e),n++},replaceState:(e,r)=>{o=r,t[n]=e},back:()=>{n--},forward:()=>{n=Math.min(n+1,t.length-1)},go:e=>window.history.go(e),createHref:e=>e})},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.production.js.map |
{ | ||
"name": "@tanstack/history", | ||
"author": "Tanner Linsley", | ||
"version": "0.0.1-beta.204", | ||
"version": "0.0.1-beta.205", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "tanstack/history", |
@@ -17,3 +17,3 @@ // While the public API was clearly inspired by the "history" npm package, | ||
destroy: () => void | ||
update: () => void | ||
notify: () => void | ||
} | ||
@@ -87,4 +87,2 @@ | ||
} | ||
onUpdate() | ||
} | ||
@@ -155,3 +153,3 @@ | ||
destroy: () => opts.destroy?.(), | ||
update: onUpdate, | ||
notify: onUpdate, | ||
} | ||
@@ -273,3 +271,3 @@ } | ||
currentLocation = parseLocation(getHref(), window.history.state) | ||
history.update() | ||
history.notify() | ||
} | ||
@@ -304,3 +302,3 @@ | ||
let res = originalPushState.apply(window.history, arguments as any) | ||
if (tracking) history.update() | ||
if (tracking) history.notify() | ||
return res | ||
@@ -311,3 +309,3 @@ } | ||
let res = originalReplaceState.apply(window.history, arguments as any) | ||
if (tracking) history.update() | ||
if (tracking) history.notify() | ||
return res | ||
@@ -314,0 +312,0 @@ } |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
258742
1291