@tanstack/history
Advanced tools
Comparing version 0.0.1-beta.225 to 0.0.1-beta.226
@@ -139,2 +139,3 @@ /** | ||
function createBrowserHistory(opts) { | ||
console.log('hello'); | ||
const getHref = opts?.getHref ?? (() => `${window.location.pathname}${window.location.search}${window.location.hash}`); | ||
@@ -141,0 +142,0 @@ const createHref = opts?.createHref ?? (path => path); |
@@ -137,2 +137,3 @@ /** | ||
function createBrowserHistory(opts) { | ||
console.log('hello'); | ||
const getHref = opts?.getHref ?? (() => `${window.location.pathname}${window.location.search}${window.location.hash}`); | ||
@@ -139,0 +140,0 @@ const createHref = opts?.createHref ?? (path => path); |
@@ -11,3 +11,3 @@ { | ||
"name": "packages/history/src/index.ts", | ||
"uid": "600f-3" | ||
"uid": "bd4a-3" | ||
} | ||
@@ -20,14 +20,14 @@ ] | ||
"nodeParts": { | ||
"600f-3": { | ||
"renderedLength": 8900, | ||
"gzipLength": 2605, | ||
"bd4a-3": { | ||
"renderedLength": 8926, | ||
"gzipLength": 2619, | ||
"brotliLength": 0, | ||
"metaUid": "600f-2" | ||
"metaUid": "bd4a-2" | ||
} | ||
}, | ||
"nodeMetas": { | ||
"600f-2": { | ||
"bd4a-2": { | ||
"id": "/packages/history/src/index.ts", | ||
"moduleParts": { | ||
"index.production.js": "600f-3" | ||
"index.production.js": "bd4a-3" | ||
}, | ||
@@ -34,0 +34,0 @@ "imported": [], |
@@ -143,2 +143,3 @@ /** | ||
function createBrowserHistory(opts) { | ||
console.log('hello'); | ||
const getHref = opts?.getHref ?? (() => `${window.location.pathname}${window.location.search}${window.location.hash}`); | ||
@@ -145,0 +146,0 @@ const createHref = opts?.createHref ?? (path => path); |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TanStackHistory={})}(this,(function(t){"use strict";const e="pushstate",n="popstate",o="beforeunload",r=t=>(t.preventDefault(),t.returnValue=""),i=()=>{removeEventListener(o,r,{capture:!0})};function s(t){let e=t.getLocation(),n=new Set,s=[],h=[];const c=()=>{e=t.getLocation(),n.forEach((t=>t()))},d=()=>{if(s.length)s[0]?.(d,(()=>{s=[],i()}));else for(;h.length;)h.shift()?.()},u=t=>{h.push(t),d()};return{get location(){return e},subscribe:t=>(n.add(t),()=>{n.delete(t)}),push:(e,n)=>{n=a(n),u((()=>{t.pushState(e,n,c)}))},replace:(e,n)=>{n=a(n),u((()=>{t.replaceState(e,n,c)}))},go:e=>{u((()=>{t.go(e)}))},back:()=>{u((()=>{t.back()}))},forward:()=>{u((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(s.push(t),1===s.length&&addEventListener(o,r,{capture:!0}),()=>{s=s.filter((e=>e!==t)),s.length||i()}),flush:()=>t.flush?.(),destroy:()=>t.destroy?.(),notify:c}}function a(t){return t||(t={}),{...t,key:d()}}function h(t){const o=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=t?.createHref??(t=>t);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=(t,e,n,o)=>{const s=r(e);i=c(s,n),a={href:s,state:n,isPush:a?.isPush||"push"===t},o(),h||(h=Promise.resolve().then((()=>u())))},w=()=>{i=c(o(),window.history.state),y.notify()};var l=window.history.pushState,p=window.history.replaceState;const y=s({getLocation:()=>i,pushState:(t,e,n)=>f("push",t,e,n),replaceState:(t,e,n)=>f("replace",t,e,n),back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t),flush:u,destroy:()=>{window.history.pushState=l,window.history.replaceState=p,window.removeEventListener(e,w),window.removeEventListener(n,w)}});return window.addEventListener(e,w),window.addEventListener(n,w),window.history.pushState=function(){let t=l.apply(window.history,arguments);return d&&y.notify(),t},window.history.replaceState=function(){let t=p.apply(window.history,arguments);return d&&y.notify(),t},y}function c(t,e){let n=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,n>0?o>0?Math.min(n,o):n:o>0?o:t.length),hash:n>-1?t.substring(n):"",search:o>-1?t.slice(o,-1===n?void 0:n):"",state:e||{}}}function d(){return(Math.random()+1).toString(36).substring(7)}t.createBrowserHistory=h,t.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=function(t={initialEntries:["/"]}){const e=t.initialEntries;let n=t.initialIndex??e.length-1,o={key:d()};return s({getLocation:()=>c(e[n],o),pushState:(t,r)=>{o=r,e.push(t),n++},replaceState:(t,r)=>{o=r,e[n]=t},back:()=>{n--},forward:()=>{n=Math.min(n+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TanStackHistory={})}(this,(function(t){"use strict";const e="pushstate",o="popstate",n="beforeunload",r=t=>(t.preventDefault(),t.returnValue=""),i=()=>{removeEventListener(n,r,{capture:!0})};function s(t){let e=t.getLocation(),o=new Set,s=[],h=[];const c=()=>{e=t.getLocation(),o.forEach((t=>t()))},d=()=>{if(s.length)s[0]?.(d,(()=>{s=[],i()}));else for(;h.length;)h.shift()?.()},u=t=>{h.push(t),d()};return{get location(){return e},subscribe:t=>(o.add(t),()=>{o.delete(t)}),push:(e,o)=>{o=a(o),u((()=>{t.pushState(e,o,c)}))},replace:(e,o)=>{o=a(o),u((()=>{t.replaceState(e,o,c)}))},go:e=>{u((()=>{t.go(e)}))},back:()=>{u((()=>{t.back()}))},forward:()=>{u((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(s.push(t),1===s.length&&addEventListener(n,r,{capture:!0}),()=>{s=s.filter((e=>e!==t)),s.length||i()}),flush:()=>t.flush?.(),destroy:()=>t.destroy?.(),notify:c}}function a(t){return t||(t={}),{...t,key:d()}}function h(t){console.log("hello");const n=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=t?.createHref??(t=>t);let i=c(n(),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=(t,e,o,n)=>{const s=r(e);i=c(s,o),a={href:s,state:o,isPush:a?.isPush||"push"===t},n(),h||(h=Promise.resolve().then((()=>u())))},f=()=>{i=c(n(),window.history.state),y.notify()};var w=window.history.pushState,p=window.history.replaceState;const y=s({getLocation:()=>i,pushState:(t,e,o)=>l("push",t,e,o),replaceState:(t,e,o)=>l("replace",t,e,o),back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t),flush:u,destroy:()=>{window.history.pushState=w,window.history.replaceState=p,window.removeEventListener(e,f),window.removeEventListener(o,f)}});return window.addEventListener(e,f),window.addEventListener(o,f),window.history.pushState=function(){let t=w.apply(window.history,arguments);return d&&y.notify(),t},window.history.replaceState=function(){let t=p.apply(window.history,arguments);return d&&y.notify(),t},y}function c(t,e){let o=t.indexOf("#"),n=t.indexOf("?");return{href:t,pathname:t.substring(0,o>0?n>0?Math.min(o,n):o:n>0?n:t.length),hash:o>-1?t.substring(o):"",search:n>-1?t.slice(n,-1===o?void 0:o):"",state:e||{}}}function d(){return(Math.random()+1).toString(36).substring(7)}t.createBrowserHistory=h,t.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=function(t={initialEntries:["/"]}){const e=t.initialEntries;let o=t.initialIndex??e.length-1,n={key:d()};return s({getLocation:()=>c(e[o],n),pushState:(t,r)=>{n=r,e.push(t),o++},replaceState:(t,r)=>{n=r,e[o]=t},back:()=>{o--},forward:()=>{o=Math.min(o+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}})); | ||
//# sourceMappingURL=index.production.js.map |
{ | ||
"name": "@tanstack/history", | ||
"author": "Tanner Linsley", | ||
"version": "0.0.1-beta.225", | ||
"version": "0.0.1-beta.226", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "tanstack/history", |
@@ -185,2 +185,3 @@ // While the public API was clearly inspired by the "history" npm package, | ||
}): RouterHistory { | ||
console.log('hello') | ||
const getHref = | ||
@@ -372,4 +373,4 @@ opts?.getHref ?? | ||
: searchIndex > 0 | ||
? searchIndex | ||
: href.length, | ||
? searchIndex | ||
: href.length, | ||
), | ||
@@ -376,0 +377,0 @@ hash: hashIndex > -1 ? href.substring(hashIndex) : '', |
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
279625
1301