@tanstack/router
Advanced tools
Comparing version 0.0.1-beta.141 to 0.0.1-beta.142
@@ -49,6 +49,6 @@ /** | ||
} | ||
// onUpdate() | ||
if (!opts.listener) { | ||
onUpdate(); | ||
} | ||
}; | ||
const queueTask = task => { | ||
@@ -68,3 +68,3 @@ queue.push(task); | ||
if (listeners.size === 0) { | ||
unsub = opts.listener(onUpdate); | ||
unsub = typeof opts.listener === 'function' ? opts.listener(onUpdate) : () => {}; | ||
} | ||
@@ -182,5 +182,3 @@ listeners.add(cb); | ||
getLocation, | ||
listener: () => { | ||
return () => {}; | ||
}, | ||
listener: false, | ||
pushState: (path, state) => { | ||
@@ -187,0 +185,0 @@ currentState = { |
@@ -14,7 +14,7 @@ { | ||
"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js", | ||
"uid": "742e-47" | ||
"uid": "a8fe-47" | ||
}, | ||
{ | ||
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js", | ||
"uid": "742e-49" | ||
"uid": "a8fe-49" | ||
} | ||
@@ -30,35 +30,35 @@ ] | ||
{ | ||
"uid": "742e-51", | ||
"uid": "a8fe-51", | ||
"name": "history.ts" | ||
}, | ||
{ | ||
"uid": "742e-53", | ||
"uid": "a8fe-53", | ||
"name": "utils.ts" | ||
}, | ||
{ | ||
"uid": "742e-55", | ||
"uid": "a8fe-55", | ||
"name": "path.ts" | ||
}, | ||
{ | ||
"uid": "742e-57", | ||
"uid": "a8fe-57", | ||
"name": "qss.ts" | ||
}, | ||
{ | ||
"uid": "742e-65", | ||
"uid": "a8fe-65", | ||
"name": "react.tsx" | ||
}, | ||
{ | ||
"uid": "742e-67", | ||
"uid": "a8fe-67", | ||
"name": "route.ts" | ||
}, | ||
{ | ||
"uid": "742e-69", | ||
"uid": "a8fe-69", | ||
"name": "searchParams.ts" | ||
}, | ||
{ | ||
"uid": "742e-71", | ||
"uid": "a8fe-71", | ||
"name": "router.ts" | ||
}, | ||
{ | ||
"uid": "742e-73", | ||
"uid": "a8fe-73", | ||
"name": "index.ts" | ||
@@ -70,7 +70,7 @@ } | ||
"name": "store/build/esm/index.js", | ||
"uid": "742e-61" | ||
"uid": "a8fe-61" | ||
}, | ||
{ | ||
"name": "react-store/build/esm/index.js", | ||
"uid": "742e-63" | ||
"uid": "a8fe-63" | ||
} | ||
@@ -80,3 +80,3 @@ ] | ||
{ | ||
"uid": "742e-59", | ||
"uid": "a8fe-59", | ||
"name": "\u0000rollupPluginBabelHelpers.js" | ||
@@ -90,92 +90,92 @@ } | ||
"nodeParts": { | ||
"742e-47": { | ||
"a8fe-47": { | ||
"renderedLength": 199, | ||
"gzipLength": 134, | ||
"brotliLength": 0, | ||
"mainUid": "742e-46" | ||
"mainUid": "a8fe-46" | ||
}, | ||
"742e-49": { | ||
"a8fe-49": { | ||
"renderedLength": 48, | ||
"gzipLength": 65, | ||
"brotliLength": 0, | ||
"mainUid": "742e-48" | ||
"mainUid": "a8fe-48" | ||
}, | ||
"742e-51": { | ||
"renderedLength": 6378, | ||
"gzipLength": 1522, | ||
"a8fe-51": { | ||
"renderedLength": 6426, | ||
"gzipLength": 1539, | ||
"brotliLength": 0, | ||
"mainUid": "742e-50" | ||
"mainUid": "a8fe-50" | ||
}, | ||
"742e-53": { | ||
"a8fe-53": { | ||
"renderedLength": 2821, | ||
"gzipLength": 990, | ||
"brotliLength": 0, | ||
"mainUid": "742e-52" | ||
"mainUid": "a8fe-52" | ||
}, | ||
"742e-55": { | ||
"a8fe-55": { | ||
"renderedLength": 6028, | ||
"gzipLength": 1423, | ||
"brotliLength": 0, | ||
"mainUid": "742e-54" | ||
"mainUid": "a8fe-54" | ||
}, | ||
"742e-57": { | ||
"a8fe-57": { | ||
"renderedLength": 1371, | ||
"gzipLength": 552, | ||
"brotliLength": 0, | ||
"mainUid": "742e-56" | ||
"mainUid": "a8fe-56" | ||
}, | ||
"742e-59": { | ||
"a8fe-59": { | ||
"renderedLength": 457, | ||
"gzipLength": 241, | ||
"brotliLength": 0, | ||
"mainUid": "742e-58" | ||
"mainUid": "a8fe-58" | ||
}, | ||
"742e-61": { | ||
"a8fe-61": { | ||
"renderedLength": 1969, | ||
"gzipLength": 653, | ||
"brotliLength": 0, | ||
"mainUid": "742e-60" | ||
"mainUid": "a8fe-60" | ||
}, | ||
"742e-63": { | ||
"a8fe-63": { | ||
"renderedLength": 1070, | ||
"gzipLength": 485, | ||
"brotliLength": 0, | ||
"mainUid": "742e-62" | ||
"mainUid": "a8fe-62" | ||
}, | ||
"742e-65": { | ||
"a8fe-65": { | ||
"renderedLength": 17156, | ||
"gzipLength": 3732, | ||
"brotliLength": 0, | ||
"mainUid": "742e-64" | ||
"mainUid": "a8fe-64" | ||
}, | ||
"742e-67": { | ||
"a8fe-67": { | ||
"renderedLength": 3937, | ||
"gzipLength": 969, | ||
"brotliLength": 0, | ||
"mainUid": "742e-66" | ||
"mainUid": "a8fe-66" | ||
}, | ||
"742e-69": { | ||
"a8fe-69": { | ||
"renderedLength": 1387, | ||
"gzipLength": 483, | ||
"brotliLength": 0, | ||
"mainUid": "742e-68" | ||
"mainUid": "a8fe-68" | ||
}, | ||
"742e-71": { | ||
"a8fe-71": { | ||
"renderedLength": 38274, | ||
"gzipLength": 8514, | ||
"brotliLength": 0, | ||
"mainUid": "742e-70" | ||
"mainUid": "a8fe-70" | ||
}, | ||
"742e-73": { | ||
"a8fe-73": { | ||
"renderedLength": 0, | ||
"gzipLength": 0, | ||
"brotliLength": 0, | ||
"mainUid": "742e-72" | ||
"mainUid": "a8fe-72" | ||
} | ||
}, | ||
"nodeMetas": { | ||
"742e-46": { | ||
"a8fe-46": { | ||
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js", | ||
"moduleParts": { | ||
"index.production.js": "742e-47" | ||
"index.production.js": "a8fe-47" | ||
}, | ||
@@ -185,19 +185,19 @@ "imported": [], | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
}, | ||
{ | ||
"uid": "742e-66" | ||
"uid": "a8fe-66" | ||
}, | ||
{ | ||
"uid": "742e-70" | ||
"uid": "a8fe-70" | ||
}, | ||
{ | ||
"uid": "742e-64" | ||
"uid": "a8fe-64" | ||
} | ||
] | ||
}, | ||
"742e-48": { | ||
"a8fe-48": { | ||
"id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js", | ||
"moduleParts": { | ||
"index.production.js": "742e-49" | ||
"index.production.js": "a8fe-49" | ||
}, | ||
@@ -207,13 +207,13 @@ "imported": [], | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
}, | ||
{ | ||
"uid": "742e-64" | ||
"uid": "a8fe-64" | ||
} | ||
] | ||
}, | ||
"742e-50": { | ||
"a8fe-50": { | ||
"id": "/packages/router/src/history.ts", | ||
"moduleParts": { | ||
"index.production.js": "742e-51" | ||
"index.production.js": "a8fe-51" | ||
}, | ||
@@ -223,13 +223,13 @@ "imported": [], | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
}, | ||
{ | ||
"uid": "742e-70" | ||
"uid": "a8fe-70" | ||
} | ||
] | ||
}, | ||
"742e-52": { | ||
"a8fe-52": { | ||
"id": "/packages/router/src/utils.ts", | ||
"moduleParts": { | ||
"index.production.js": "742e-53" | ||
"index.production.js": "a8fe-53" | ||
}, | ||
@@ -239,23 +239,23 @@ "imported": [], | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
}, | ||
{ | ||
"uid": "742e-54" | ||
"uid": "a8fe-54" | ||
}, | ||
{ | ||
"uid": "742e-70" | ||
"uid": "a8fe-70" | ||
}, | ||
{ | ||
"uid": "742e-64" | ||
"uid": "a8fe-64" | ||
} | ||
] | ||
}, | ||
"742e-54": { | ||
"a8fe-54": { | ||
"id": "/packages/router/src/path.ts", | ||
"moduleParts": { | ||
"index.production.js": "742e-55" | ||
"index.production.js": "a8fe-55" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "742e-52" | ||
"uid": "a8fe-52" | ||
} | ||
@@ -265,16 +265,16 @@ ], | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
}, | ||
{ | ||
"uid": "742e-66" | ||
"uid": "a8fe-66" | ||
}, | ||
{ | ||
"uid": "742e-70" | ||
"uid": "a8fe-70" | ||
} | ||
] | ||
}, | ||
"742e-56": { | ||
"a8fe-56": { | ||
"id": "/packages/router/src/qss.ts", | ||
"moduleParts": { | ||
"index.production.js": "742e-57" | ||
"index.production.js": "a8fe-57" | ||
}, | ||
@@ -284,13 +284,13 @@ "imported": [], | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
}, | ||
{ | ||
"uid": "742e-68" | ||
"uid": "a8fe-68" | ||
} | ||
] | ||
}, | ||
"742e-58": { | ||
"a8fe-58": { | ||
"id": "\u0000rollupPluginBabelHelpers.js", | ||
"moduleParts": { | ||
"index.production.js": "742e-59" | ||
"index.production.js": "a8fe-59" | ||
}, | ||
@@ -300,10 +300,10 @@ "imported": [], | ||
{ | ||
"uid": "742e-64" | ||
"uid": "a8fe-64" | ||
} | ||
] | ||
}, | ||
"742e-60": { | ||
"a8fe-60": { | ||
"id": "/packages/store/build/esm/index.js", | ||
"moduleParts": { | ||
"index.production.js": "742e-61" | ||
"index.production.js": "a8fe-61" | ||
}, | ||
@@ -313,17 +313,17 @@ "imported": [], | ||
{ | ||
"uid": "742e-62" | ||
"uid": "a8fe-62" | ||
} | ||
] | ||
}, | ||
"742e-62": { | ||
"a8fe-62": { | ||
"id": "/packages/react-store/build/esm/index.js", | ||
"moduleParts": { | ||
"index.production.js": "742e-63" | ||
"index.production.js": "a8fe-63" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "742e-77" | ||
"uid": "a8fe-77" | ||
}, | ||
{ | ||
"uid": "742e-60" | ||
"uid": "a8fe-60" | ||
} | ||
@@ -333,32 +333,32 @@ ], | ||
{ | ||
"uid": "742e-70" | ||
"uid": "a8fe-70" | ||
}, | ||
{ | ||
"uid": "742e-64" | ||
"uid": "a8fe-64" | ||
} | ||
] | ||
}, | ||
"742e-64": { | ||
"a8fe-64": { | ||
"id": "/packages/router/src/react.tsx", | ||
"moduleParts": { | ||
"index.production.js": "742e-65" | ||
"index.production.js": "a8fe-65" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "742e-58" | ||
"uid": "a8fe-58" | ||
}, | ||
{ | ||
"uid": "742e-76" | ||
"uid": "a8fe-76" | ||
}, | ||
{ | ||
"uid": "742e-62" | ||
"uid": "a8fe-62" | ||
}, | ||
{ | ||
"uid": "742e-46" | ||
"uid": "a8fe-46" | ||
}, | ||
{ | ||
"uid": "742e-48" | ||
"uid": "a8fe-48" | ||
}, | ||
{ | ||
"uid": "742e-52" | ||
"uid": "a8fe-52" | ||
} | ||
@@ -368,23 +368,23 @@ ], | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
}, | ||
{ | ||
"uid": "742e-66" | ||
"uid": "a8fe-66" | ||
} | ||
] | ||
}, | ||
"742e-66": { | ||
"a8fe-66": { | ||
"id": "/packages/router/src/route.ts", | ||
"moduleParts": { | ||
"index.production.js": "742e-67" | ||
"index.production.js": "a8fe-67" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "742e-46" | ||
"uid": "a8fe-46" | ||
}, | ||
{ | ||
"uid": "742e-54" | ||
"uid": "a8fe-54" | ||
}, | ||
{ | ||
"uid": "742e-64" | ||
"uid": "a8fe-64" | ||
} | ||
@@ -394,14 +394,14 @@ ], | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
} | ||
] | ||
}, | ||
"742e-68": { | ||
"a8fe-68": { | ||
"id": "/packages/router/src/searchParams.ts", | ||
"moduleParts": { | ||
"index.production.js": "742e-69" | ||
"index.production.js": "a8fe-69" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "742e-56" | ||
"uid": "a8fe-56" | ||
} | ||
@@ -411,32 +411,32 @@ ], | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
}, | ||
{ | ||
"uid": "742e-70" | ||
"uid": "a8fe-70" | ||
} | ||
] | ||
}, | ||
"742e-70": { | ||
"a8fe-70": { | ||
"id": "/packages/router/src/router.ts", | ||
"moduleParts": { | ||
"index.production.js": "742e-71" | ||
"index.production.js": "a8fe-71" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "742e-62" | ||
"uid": "a8fe-62" | ||
}, | ||
{ | ||
"uid": "742e-46" | ||
"uid": "a8fe-46" | ||
}, | ||
{ | ||
"uid": "742e-54" | ||
"uid": "a8fe-54" | ||
}, | ||
{ | ||
"uid": "742e-68" | ||
"uid": "a8fe-68" | ||
}, | ||
{ | ||
"uid": "742e-52" | ||
"uid": "a8fe-52" | ||
}, | ||
{ | ||
"uid": "742e-50" | ||
"uid": "a8fe-50" | ||
} | ||
@@ -446,47 +446,47 @@ ], | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
} | ||
] | ||
}, | ||
"742e-72": { | ||
"a8fe-72": { | ||
"id": "/packages/router/src/index.ts", | ||
"moduleParts": { | ||
"index.production.js": "742e-73" | ||
"index.production.js": "a8fe-73" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "742e-46" | ||
"uid": "a8fe-46" | ||
}, | ||
{ | ||
"uid": "742e-48" | ||
"uid": "a8fe-48" | ||
}, | ||
{ | ||
"uid": "742e-50" | ||
"uid": "a8fe-50" | ||
}, | ||
{ | ||
"uid": "742e-74" | ||
"uid": "a8fe-74" | ||
}, | ||
{ | ||
"uid": "742e-54" | ||
"uid": "a8fe-54" | ||
}, | ||
{ | ||
"uid": "742e-56" | ||
"uid": "a8fe-56" | ||
}, | ||
{ | ||
"uid": "742e-66" | ||
"uid": "a8fe-66" | ||
}, | ||
{ | ||
"uid": "742e-75" | ||
"uid": "a8fe-75" | ||
}, | ||
{ | ||
"uid": "742e-70" | ||
"uid": "a8fe-70" | ||
}, | ||
{ | ||
"uid": "742e-68" | ||
"uid": "a8fe-68" | ||
}, | ||
{ | ||
"uid": "742e-52" | ||
"uid": "a8fe-52" | ||
}, | ||
{ | ||
"uid": "742e-64" | ||
"uid": "a8fe-64" | ||
} | ||
@@ -497,3 +497,3 @@ ], | ||
}, | ||
"742e-74": { | ||
"a8fe-74": { | ||
"id": "/packages/router/src/link.ts", | ||
@@ -504,7 +504,7 @@ "moduleParts": {}, | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
} | ||
] | ||
}, | ||
"742e-75": { | ||
"a8fe-75": { | ||
"id": "/packages/router/src/routeInfo.ts", | ||
@@ -515,7 +515,7 @@ "moduleParts": {}, | ||
{ | ||
"uid": "742e-72" | ||
"uid": "a8fe-72" | ||
} | ||
] | ||
}, | ||
"742e-76": { | ||
"a8fe-76": { | ||
"id": "react", | ||
@@ -526,3 +526,3 @@ "moduleParts": {}, | ||
{ | ||
"uid": "742e-64" | ||
"uid": "a8fe-64" | ||
} | ||
@@ -532,3 +532,3 @@ ], | ||
}, | ||
"742e-77": { | ||
"a8fe-77": { | ||
"id": "use-sync-external-store/shim/with-selector", | ||
@@ -539,3 +539,3 @@ "moduleParts": {}, | ||
{ | ||
"uid": "742e-62" | ||
"uid": "a8fe-62" | ||
} | ||
@@ -542,0 +542,0 @@ ], |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim/with-selector"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RouterCore={},t.React,t.withSelector)}(this,(function(t,e,r){"use strict";function s(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var o=s(e);function n(t,e){if(!t)throw new Error("Invariant failed")}const a="pushstate",i="popstate",c="beforeunload",h=t=>(t.preventDefault(),t.returnValue=""),u=()=>{removeEventListener(c,h,{capture:!0})};function l(t){let e=t.getLocation(),r=()=>{},s=new Set,o=[],n=[];const a=()=>{if(o.length)o[0]?.(a,(()=>{o=[],u()}));else for(;n.length;)n.shift()?.()},i=t=>{n.push(t),a()},l=()=>{e=t.getLocation(),s.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===s.size&&(r=t.listener(l)),s.add(e),()=>{s.delete(e),0===s.size&&r()}),push:(e,r)=>{i((()=>{t.pushState(e,r)}))},replace:(e,r)=>{i((()=>{t.replaceState(e,r)}))},go:e=>{i((()=>{t.go(e)}))},back:()=>{i((()=>{t.back()}))},forward:()=>{i((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(o.push(t),1===o.length&&addEventListener(c,h,{capture:!0}),()=>{o=o.filter((e=>e!==t)),o.length||u()})}}function d(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=t?.createHref??(t=>t);return l({getLocation:()=>f(e(),history.state),listener:t=>{window.addEventListener(a,t),window.addEventListener(i,t);var e=window.history.pushState;window.history.pushState=function(){let r=e.apply(history,arguments);return t(),r};var r=window.history.replaceState;return window.history.replaceState=function(){let e=r.apply(history,arguments);return t(),e},()=>{window.history.pushState=e,window.history.replaceState=r,window.removeEventListener(a,t),window.removeEventListener(i,t)}},pushState:(t,e)=>{window.history.pushState({...e,key:m()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:m()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function p(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,s={};return l({getLocation:()=>f(e[r],s),listener:()=>()=>{},pushState:(t,o)=>{s={...o,key:m()},e.push(t),r++},replaceState:(t,o)=>{s={...o,key:m()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function f(t,e){let r=t.indexOf("#"),s=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?s>0?Math.min(r,s):r:s>0?s:t.length),hash:r>-1?t.substring(r):"",search:s>-1?t.slice(s,-1===r?void 0:r):"",state:e}}function m(){return(Math.random()+1).toString(36).substring(7)}function y(t){return t[t.length-1]}function g(t,e){return"function"==typeof t?t(e):t}function v(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function w(t,e){if(t===e)return t;const r=e,s=Array.isArray(t)&&Array.isArray(r);if(s||b(t)&&b(r)){const e=s?t.length:Object.keys(t).length,o=s?r:Object.keys(r),n=o.length,a=s?[]:{};let i=0;for(let e=0;e<n;e++){const n=s?e:o[e];a[n]=w(t[n],r[n]),a[n]===t[n]&&i++}return e===n&&i===e?t:a}return r}function b(t){if(!S(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!S(r)&&!!r.hasOwnProperty("isPrototypeOf")}function S(t){return"[object Object]"===Object.prototype.toString.call(t)}function x(t,e){return t===e||typeof t==typeof e&&(b(t)&&b(e)?!Object.keys(e).some((r=>!x(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>x(t,e[r])))))}function E(t){return R(t.filter(Boolean).join("/"))}function R(t){return t.replace(/\/{2,}/g,"/")}function I(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function P(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function _(t){return P(I(t))}function C(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let s=M(e);const o=M(r);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&s.push(t):s=[t];else if(".."===t.value)s.length>1&&"/"===y(s)?.value&&s.pop(),s.pop();else{if("."===t.value)return;s.push(t)}}));return R(E([t,...s.map((t=>t.value))]))}function M(t){if(!t)return[];const e=[];if("/"===(t=R(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function L(t,e,r=!1){return E(M(t).map((t=>{if("wildcard"===t.type){const s=e[t.value];return r?`${t.value}${s??""}`:s}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function O(t,e,r){const s=j(t,e,r);if(!r.to||s)return s??{}}function j(t,e,r){e="/"!=t?e.substring(t.length):e;const s=`${r.to??"$"}`,o=M(e),n=M(s);e.startsWith("/")||o.unshift({type:"pathname",value:"/"}),s.startsWith("/")||n.unshift({type:"pathname",value:"/"});const a={};return(()=>{for(let t=0;t<Math.max(o.length,n.length);t++){const e=o[t],s=n[t],i=t>=o.length-1,c=t>=n.length-1;if(s){if("wildcard"===s.type)return!!e?.value&&(a["*"]=E(o.slice(t).map((t=>t.value))),!0);if("pathname"===s.type){if("/"===s.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(s.value!==e.value)return!1}else if(s.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===s.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[s.value.substring(1)]=e.value)}}if(!i&&c)return!!r.fuzzy}return!0})()?a:void 0}function k(t,e){var r,s,o,n="";for(r in t)if(void 0!==(o=t[r]))if(Array.isArray(o))for(s=0;s<o.length;s++)n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(o[s]);else n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(o);return(e||"")+n}function A(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function D(t){for(var e,r,s={},o=t.split("&");e=o.shift();)void 0!==s[r=(e=e.split("=")).shift()]?s[r]=[].concat(s[r],A(e.shift())):s[r]=A(e.shift());return s}function B(){return B=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},B.apply(this,arguments)} | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim/with-selector"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RouterCore={},t.React,t.withSelector)}(this,(function(t,e,r){"use strict";function s(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var o=s(e);function n(t,e){if(!t)throw new Error("Invariant failed")}const a="pushstate",i="popstate",c="beforeunload",h=t=>(t.preventDefault(),t.returnValue=""),u=()=>{removeEventListener(c,h,{capture:!0})};function l(t){let e=t.getLocation(),r=()=>{},s=new Set,o=[],n=[];const a=()=>{if(o.length)o[0]?.(a,(()=>{o=[],u()}));else{for(;n.length;)n.shift()?.();t.listener||l()}},i=t=>{n.push(t),a()},l=()=>{e=t.getLocation(),s.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===s.size&&(r="function"==typeof t.listener?t.listener(l):()=>{}),s.add(e),()=>{s.delete(e),0===s.size&&r()}),push:(e,r)=>{i((()=>{t.pushState(e,r)}))},replace:(e,r)=>{i((()=>{t.replaceState(e,r)}))},go:e=>{i((()=>{t.go(e)}))},back:()=>{i((()=>{t.back()}))},forward:()=>{i((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(o.push(t),1===o.length&&addEventListener(c,h,{capture:!0}),()=>{o=o.filter((e=>e!==t)),o.length||u()})}}function d(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=t?.createHref??(t=>t);return l({getLocation:()=>f(e(),history.state),listener:t=>{window.addEventListener(a,t),window.addEventListener(i,t);var e=window.history.pushState;window.history.pushState=function(){let r=e.apply(history,arguments);return t(),r};var r=window.history.replaceState;return window.history.replaceState=function(){let e=r.apply(history,arguments);return t(),e},()=>{window.history.pushState=e,window.history.replaceState=r,window.removeEventListener(a,t),window.removeEventListener(i,t)}},pushState:(t,e)=>{window.history.pushState({...e,key:m()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:m()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function p(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,s={};return l({getLocation:()=>f(e[r],s),listener:!1,pushState:(t,o)=>{s={...o,key:m()},e.push(t),r++},replaceState:(t,o)=>{s={...o,key:m()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function f(t,e){let r=t.indexOf("#"),s=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?s>0?Math.min(r,s):r:s>0?s:t.length),hash:r>-1?t.substring(r):"",search:s>-1?t.slice(s,-1===r?void 0:r):"",state:e}}function m(){return(Math.random()+1).toString(36).substring(7)}function y(t){return t[t.length-1]}function g(t,e){return"function"==typeof t?t(e):t}function v(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function w(t,e){if(t===e)return t;const r=e,s=Array.isArray(t)&&Array.isArray(r);if(s||b(t)&&b(r)){const e=s?t.length:Object.keys(t).length,o=s?r:Object.keys(r),n=o.length,a=s?[]:{};let i=0;for(let e=0;e<n;e++){const n=s?e:o[e];a[n]=w(t[n],r[n]),a[n]===t[n]&&i++}return e===n&&i===e?t:a}return r}function b(t){if(!S(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!S(r)&&!!r.hasOwnProperty("isPrototypeOf")}function S(t){return"[object Object]"===Object.prototype.toString.call(t)}function x(t,e){return t===e||typeof t==typeof e&&(b(t)&&b(e)?!Object.keys(e).some((r=>!x(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>x(t,e[r])))))}function E(t){return R(t.filter(Boolean).join("/"))}function R(t){return t.replace(/\/{2,}/g,"/")}function I(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function P(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function _(t){return P(I(t))}function C(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let s=M(e);const o=M(r);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&s.push(t):s=[t];else if(".."===t.value)s.length>1&&"/"===y(s)?.value&&s.pop(),s.pop();else{if("."===t.value)return;s.push(t)}}));return R(E([t,...s.map((t=>t.value))]))}function M(t){if(!t)return[];const e=[];if("/"===(t=R(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function L(t,e,r=!1){return E(M(t).map((t=>{if("wildcard"===t.type){const s=e[t.value];return r?`${t.value}${s??""}`:s}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function O(t,e,r){const s=j(t,e,r);if(!r.to||s)return s??{}}function j(t,e,r){e="/"!=t?e.substring(t.length):e;const s=`${r.to??"$"}`,o=M(e),n=M(s);e.startsWith("/")||o.unshift({type:"pathname",value:"/"}),s.startsWith("/")||n.unshift({type:"pathname",value:"/"});const a={};return(()=>{for(let t=0;t<Math.max(o.length,n.length);t++){const e=o[t],s=n[t],i=t>=o.length-1,c=t>=n.length-1;if(s){if("wildcard"===s.type)return!!e?.value&&(a["*"]=E(o.slice(t).map((t=>t.value))),!0);if("pathname"===s.type){if("/"===s.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(s.value!==e.value)return!1}else if(s.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===s.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[s.value.substring(1)]=e.value)}}if(!i&&c)return!!r.fuzzy}return!0})()?a:void 0}function k(t,e){var r,s,o,n="";for(r in t)if(void 0!==(o=t[r]))if(Array.isArray(o))for(s=0;s<o.length;s++)n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(o[s]);else n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(o);return(e||"")+n}function A(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function D(t){for(var e,r,s={},o=t.split("&");e=o.shift();)void 0!==s[r=(e=e.split("=")).shift()]?s[r]=[].concat(s[r],A(e.shift())):s[r]=A(e.shift());return s}function B(){return B=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},B.apply(this,arguments)} | ||
/** | ||
@@ -14,0 +14,0 @@ * @tanstack/store/src/index.ts |
{ | ||
"name": "@tanstack/router", | ||
"author": "Tanner Linsley", | ||
"version": "0.0.1-beta.141", | ||
"version": "0.0.1-beta.142", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "tanstack/router", |
@@ -48,3 +48,3 @@ // While the public API was clearly inspired by the "history" npm package, | ||
getLocation: () => RouterLocation | ||
listener: (onUpdate: () => void) => () => void | ||
listener: false | ((onUpdate: () => void) => () => void) | ||
pushState: (path: string, state: any) => void | ||
@@ -76,3 +76,5 @@ replaceState: (path: string, state: any) => void | ||
// onUpdate() | ||
if (!opts.listener) { | ||
onUpdate() | ||
} | ||
} | ||
@@ -96,3 +98,6 @@ | ||
if (listeners.size === 0) { | ||
unsub = opts.listener(onUpdate) | ||
unsub = | ||
typeof opts.listener === 'function' | ||
? opts.listener(onUpdate) | ||
: () => {} | ||
} | ||
@@ -235,5 +240,3 @@ listeners.add(cb) | ||
getLocation, | ||
listener: () => { | ||
return () => {} | ||
}, | ||
listener: false, | ||
pushState: (path, state) => { | ||
@@ -240,0 +243,0 @@ currentState = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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 too big to display
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
1440588
13323