@tanstack/router-core 1.131.26 → 1.131.28
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/load-matches.cjs +8 -23
- package/dist/cjs/load-matches.cjs.map +1 -1
- package/dist/cjs/qss.cjs +19 -19
- package/dist/cjs/qss.cjs.map +1 -1
- package/dist/cjs/qss.d.cts +6 -4
- package/dist/cjs/router.cjs +15 -22
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.cjs +21 -26
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/searchParams.cjs +7 -15
- package/dist/cjs/searchParams.cjs.map +1 -1
- package/dist/esm/load-matches.js +8 -23
- package/dist/esm/load-matches.js.map +1 -1
- package/dist/esm/qss.d.ts +6 -4
- package/dist/esm/qss.js +19 -19
- package/dist/esm/qss.js.map +1 -1
- package/dist/esm/router.js +15 -22
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/scroll-restoration.js +21 -26
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/searchParams.js +7 -15
- package/dist/esm/searchParams.js.map +1 -1
- package/package.json +1 -1
- package/src/load-matches.ts +12 -29
- package/src/qss.ts +27 -24
- package/src/router.ts +31 -36
- package/src/scroll-restoration.ts +25 -32
- package/src/searchParams.ts +8 -19
package/dist/esm/qss.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qss.js","sources":["../../src/qss.ts"],"sourcesContent":["/**\n * Program is a reimplementation of the `qss` package:\n * Copyright (c) Luke Edwards luke.edwards05@gmail.com, MIT License\n * https://github.com/lukeed/qss/blob/master/license.md\n *\n * This reimplementation uses modern browser APIs\n * (namely URLSearchParams) and TypeScript while still\n * maintaining the original functionality and interface.\n */\n\n/**\n * Encodes an object into a query string.\n * @param obj - The object to encode into a query string.\n * @param
|
|
1
|
+
{"version":3,"file":"qss.js","sources":["../../src/qss.ts"],"sourcesContent":["/**\n * Program is a reimplementation of the `qss` package:\n * Copyright (c) Luke Edwards luke.edwards05@gmail.com, MIT License\n * https://github.com/lukeed/qss/blob/master/license.md\n *\n * This reimplementation uses modern browser APIs\n * (namely URLSearchParams) and TypeScript while still\n * maintaining the original functionality and interface.\n *\n * Update: this implementation has also been mangled to\n * fit exactly our use-case (single value per key in encoding).\n */\n\n/**\n * Encodes an object into a query string.\n * @param obj - The object to encode into a query string.\n * @param stringify - An optional custom stringify function.\n * @returns The encoded query string.\n * @example\n * ```\n * // Example input: encode({ token: 'foo', key: 'value' })\n * // Expected output: \"token=foo&key=value\"\n * ```\n */\nexport function encode(\n obj: Record<string, any>,\n stringify: (value: any) => string = String,\n): string {\n const result = new URLSearchParams()\n\n for (const key in obj) {\n const val = obj[key]\n if (val !== undefined) {\n result.set(key, stringify(val))\n }\n }\n\n return result.toString()\n}\n\n/**\n * Converts a string value to its appropriate type (string, number, boolean).\n * @param mix - The string value to convert.\n * @returns The converted value.\n * @example\n * // Example input: toValue(\"123\")\n * // Expected output: 123\n */\nfunction toValue(str: unknown) {\n if (!str) return ''\n\n if (str === 'false') return false\n if (str === 'true') return true\n return +str * 0 === 0 && +str + '' === str ? +str : str\n}\n\n/**\n * Decodes a query string into an object.\n * @param str - The query string to decode.\n * @returns The decoded key-value pairs in an object format.\n * @example\n * // Example input: decode(\"token=foo&key=value\")\n * // Expected output: { \"token\": \"foo\", \"key\": \"value\" }\n */\nexport function decode(str: any): any {\n const searchParams = new URLSearchParams(str)\n\n const result: Record<string, unknown> = {}\n\n for (const [key, value] of searchParams.entries()) {\n const previousValue = result[key]\n if (previousValue == null) {\n result[key] = toValue(value)\n } else if (Array.isArray(previousValue)) {\n previousValue.push(toValue(value))\n } else {\n result[key] = [previousValue, toValue(value)]\n }\n }\n\n return result\n}\n"],"names":[],"mappings":"AAwBgB,SAAA,OACd,KACA,YAAoC,QAC5B;AACF,QAAA,SAAS,IAAI,gBAAgB;AAEnC,aAAW,OAAO,KAAK;AACf,UAAA,MAAM,IAAI,GAAG;AACnB,QAAI,QAAQ,QAAW;AACrB,aAAO,IAAI,KAAK,UAAU,GAAG,CAAC;AAAA,IAAA;AAAA,EAChC;AAGF,SAAO,OAAO,SAAS;AACzB;AAUA,SAAS,QAAQ,KAAc;AACzB,MAAA,CAAC,IAAY,QAAA;AAEb,MAAA,QAAQ,QAAgB,QAAA;AACxB,MAAA,QAAQ,OAAe,QAAA;AACpB,SAAA,CAAC,MAAM,MAAM,KAAK,CAAC,MAAM,OAAO,MAAM,CAAC,MAAM;AACtD;AAUO,SAAS,OAAO,KAAe;AAC9B,QAAA,eAAe,IAAI,gBAAgB,GAAG;AAE5C,QAAM,SAAkC,CAAC;AAEzC,aAAW,CAAC,KAAK,KAAK,KAAK,aAAa,WAAW;AAC3C,UAAA,gBAAgB,OAAO,GAAG;AAChC,QAAI,iBAAiB,MAAM;AAClB,aAAA,GAAG,IAAI,QAAQ,KAAK;AAAA,IAClB,WAAA,MAAM,QAAQ,aAAa,GAAG;AACzB,oBAAA,KAAK,QAAQ,KAAK,CAAC;AAAA,IAAA,OAC5B;AACL,aAAO,GAAG,IAAI,CAAC,eAAe,QAAQ,KAAK,CAAC;AAAA,IAAA;AAAA,EAC9C;AAGK,SAAA;AACT;"}
|
package/dist/esm/router.js
CHANGED
|
@@ -235,30 +235,23 @@ class RouterCore {
|
|
|
235
235
|
_buildLocation: true
|
|
236
236
|
});
|
|
237
237
|
const lastMatch = last(allCurrentLocationMatches);
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return comparePaths(d.fullPath, fromPath);
|
|
252
|
-
});
|
|
253
|
-
const matchedCurrent = findLast(allFromMatches, (d) => {
|
|
254
|
-
return comparePaths(d.fullPath, currentLocation.pathname);
|
|
255
|
-
});
|
|
256
|
-
if (!matchedFrom && !matchedCurrent) {
|
|
257
|
-
console.warn(`Could not find match for from: ${fromPath}`);
|
|
258
|
-
}
|
|
238
|
+
if (dest.from && process.env.NODE_ENV !== "production" && dest._isNavigate) {
|
|
239
|
+
const allFromMatches = this.getMatchedRoutes(
|
|
240
|
+
dest.from,
|
|
241
|
+
void 0
|
|
242
|
+
).matchedRoutes;
|
|
243
|
+
const matchedFrom = findLast(allCurrentLocationMatches, (d) => {
|
|
244
|
+
return comparePaths(d.fullPath, dest.from);
|
|
245
|
+
});
|
|
246
|
+
const matchedCurrent = findLast(allFromMatches, (d) => {
|
|
247
|
+
return comparePaths(d.fullPath, lastMatch.fullPath);
|
|
248
|
+
});
|
|
249
|
+
if (!matchedFrom && !matchedCurrent) {
|
|
250
|
+
console.warn(`Could not find match for from: ${dest.from}`);
|
|
259
251
|
}
|
|
260
252
|
}
|
|
261
|
-
|
|
253
|
+
const defaultedFromPath = dest.unsafeRelative === "path" ? currentLocation.pathname : dest.from ?? lastMatch.fullPath;
|
|
254
|
+
const fromPath = this.resolvePathWithBase(defaultedFromPath, ".");
|
|
262
255
|
const fromSearch = lastMatch.search;
|
|
263
256
|
const fromParams = { ...lastMatch.params };
|
|
264
257
|
const nextTo = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
|