@tanstack/react-router 1.97.19 → 1.97.21
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/Match.cjs +4 -5
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs +0 -10
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +3 -30
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +2 -2
- package/dist/cjs/Transitioner.cjs +2 -2
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/awaited.cjs +6 -6
- package/dist/cjs/awaited.cjs.map +1 -1
- package/dist/cjs/awaited.d.cts +1 -1
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +2 -3
- package/dist/cjs/index.cjs +136 -42
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +12 -26
- package/dist/cjs/link.cjs +8 -9
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +2 -49
- package/dist/cjs/redirects.cjs.map +1 -1
- package/dist/cjs/redirects.d.cts +1 -1
- package/dist/cjs/route.cjs +14 -15
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +4 -151
- package/dist/cjs/routeInfo.d.cts +2 -3
- package/dist/cjs/router.cjs +51 -70
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +4 -19
- package/dist/cjs/routerContext.d.cts +1 -1
- package/dist/cjs/scroll-restoration.cjs +2 -2
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.d.cts +1 -1
- package/dist/cjs/structuralSharing.d.cts +1 -4
- package/dist/cjs/typePrimitives.d.cts +1 -1
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderData.d.cts +2 -1
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.d.cts +2 -1
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useMatch.d.cts +2 -1
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +2 -1
- package/dist/cjs/useRouteContext.cjs.map +1 -1
- package/dist/cjs/useRouteContext.d.cts +2 -1
- package/dist/cjs/useRouterState.cjs +2 -2
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +2 -1
- package/dist/cjs/utils.cjs +0 -152
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +1 -79
- package/dist/esm/Match.js +1 -2
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.d.ts +3 -30
- package/dist/esm/Matches.js +0 -10
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +2 -2
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/Transitioner.js +1 -1
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/awaited.d.ts +1 -1
- package/dist/esm/awaited.js +1 -1
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +2 -3
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +12 -26
- package/dist/esm/index.js +5 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/link.d.ts +2 -49
- package/dist/esm/link.js +2 -3
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/redirects.d.ts +1 -1
- package/dist/esm/redirects.js.map +1 -1
- package/dist/esm/route.d.ts +4 -151
- package/dist/esm/route.js +1 -2
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/routeInfo.d.ts +2 -3
- package/dist/esm/router.d.ts +4 -19
- package/dist/esm/router.js +1 -20
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.d.ts +1 -1
- package/dist/esm/scroll-restoration.d.ts +1 -1
- package/dist/esm/scroll-restoration.js +1 -1
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/structuralSharing.d.ts +1 -4
- package/dist/esm/typePrimitives.d.ts +1 -1
- package/dist/esm/useLoaderData.d.ts +2 -1
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.d.ts +2 -1
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useMatch.d.ts +2 -1
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useParams.d.ts +2 -1
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.d.ts +2 -1
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouterState.js +1 -1
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.d.ts +2 -1
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -79
- package/dist/esm/utils.js +0 -152
- package/dist/esm/utils.js.map +1 -1
- package/package.json +3 -2
- package/src/Match.tsx +5 -2
- package/src/Matches.tsx +8 -101
- package/src/RouterProvider.tsx +4 -2
- package/src/Transitioner.tsx +1 -1
- package/src/awaited.tsx +2 -2
- package/src/fileRoute.ts +6 -3
- package/src/index.tsx +128 -127
- package/src/link.tsx +27 -155
- package/src/redirects.ts +1 -1
- package/src/route.ts +43 -316
- package/src/routeInfo.ts +7 -3
- package/src/router.ts +32 -52
- package/src/scroll-restoration.tsx +2 -3
- package/src/structuralSharing.ts +5 -7
- package/src/typePrimitives.ts +1 -1
- package/src/useLoaderData.tsx +2 -1
- package/src/useLoaderDeps.tsx +2 -1
- package/src/useMatch.tsx +2 -1
- package/src/useParams.tsx +2 -1
- package/src/useRouteContext.ts +2 -1
- package/src/useRouterState.tsx +1 -1
- package/src/useSearch.tsx +2 -1
- package/src/utils.ts +1 -389
- package/dist/cjs/defer.cjs +0 -25
- package/dist/cjs/defer.cjs.map +0 -1
- package/dist/cjs/defer.d.cts +0 -20
- package/dist/cjs/location.d.cts +0 -12
- package/dist/cjs/manifest.d.cts +0 -24
- package/dist/cjs/path.cjs +0 -289
- package/dist/cjs/path.cjs.map +0 -1
- package/dist/cjs/path.d.cts +0 -34
- package/dist/cjs/qss.cjs +0 -51
- package/dist/cjs/qss.cjs.map +0 -1
- package/dist/cjs/qss.d.cts +0 -27
- package/dist/cjs/root.cjs +0 -5
- package/dist/cjs/root.cjs.map +0 -1
- package/dist/cjs/root.d.cts +0 -2
- package/dist/cjs/searchMiddleware.cjs +0 -42
- package/dist/cjs/searchMiddleware.cjs.map +0 -1
- package/dist/cjs/searchMiddleware.d.cts +0 -5
- package/dist/cjs/searchParams.cjs +0 -61
- package/dist/cjs/searchParams.cjs.map +0 -1
- package/dist/cjs/searchParams.d.cts +0 -7
- package/dist/cjs/serializer.d.cts +0 -15
- package/dist/cjs/validators.d.cts +0 -51
- package/dist/esm/defer.d.ts +0 -20
- package/dist/esm/defer.js +0 -25
- package/dist/esm/defer.js.map +0 -1
- package/dist/esm/location.d.ts +0 -12
- package/dist/esm/manifest.d.ts +0 -24
- package/dist/esm/path.d.ts +0 -34
- package/dist/esm/path.js +0 -289
- package/dist/esm/path.js.map +0 -1
- package/dist/esm/qss.d.ts +0 -27
- package/dist/esm/qss.js +0 -51
- package/dist/esm/qss.js.map +0 -1
- package/dist/esm/root.d.ts +0 -2
- package/dist/esm/root.js +0 -5
- package/dist/esm/root.js.map +0 -1
- package/dist/esm/searchMiddleware.d.ts +0 -5
- package/dist/esm/searchMiddleware.js +0 -42
- package/dist/esm/searchMiddleware.js.map +0 -1
- package/dist/esm/searchParams.d.ts +0 -7
- package/dist/esm/searchParams.js +0 -61
- package/dist/esm/searchParams.js.map +0 -1
- package/dist/esm/serializer.d.ts +0 -15
- package/dist/esm/validators.d.ts +0 -51
- package/src/defer.ts +0 -52
- package/src/location.ts +0 -13
- package/src/manifest.ts +0 -32
- package/src/path.ts +0 -427
- package/src/qss.ts +0 -91
- package/src/root.ts +0 -2
- package/src/searchMiddleware.ts +0 -54
- package/src/searchParams.ts +0 -77
- package/src/serializer.ts +0 -24
- package/src/validators.ts +0 -121
package/dist/esm/qss.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
function encode(obj, pfx) {
|
|
2
|
-
let k, i, tmp, str = "";
|
|
3
|
-
for (k in obj) {
|
|
4
|
-
if ((tmp = obj[k]) !== void 0) {
|
|
5
|
-
if (Array.isArray(tmp)) {
|
|
6
|
-
for (i = 0; i < tmp.length; i++) {
|
|
7
|
-
str && (str += "&");
|
|
8
|
-
str += encodeURIComponent(k) + "=" + encodeURIComponent(tmp[i]);
|
|
9
|
-
}
|
|
10
|
-
} else {
|
|
11
|
-
str && (str += "&");
|
|
12
|
-
str += encodeURIComponent(k) + "=" + encodeURIComponent(tmp);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return (pfx || "") + str;
|
|
17
|
-
}
|
|
18
|
-
function toValue(mix) {
|
|
19
|
-
if (!mix) return "";
|
|
20
|
-
const str = decodeURIComponent(mix);
|
|
21
|
-
if (str === "false") return false;
|
|
22
|
-
if (str === "true") return true;
|
|
23
|
-
return +str * 0 === 0 && +str + "" === str ? +str : str;
|
|
24
|
-
}
|
|
25
|
-
function decode(str, pfx) {
|
|
26
|
-
let tmp, k;
|
|
27
|
-
const out = {}, arr = (pfx ? str.substr(pfx.length) : str).split("&");
|
|
28
|
-
while (tmp = arr.shift()) {
|
|
29
|
-
const equalIndex = tmp.indexOf("=");
|
|
30
|
-
if (equalIndex !== -1) {
|
|
31
|
-
k = tmp.slice(0, equalIndex);
|
|
32
|
-
k = decodeURIComponent(k);
|
|
33
|
-
const value = tmp.slice(equalIndex + 1);
|
|
34
|
-
if (out[k] !== void 0) {
|
|
35
|
-
out[k] = [].concat(out[k], toValue(value));
|
|
36
|
-
} else {
|
|
37
|
-
out[k] = toValue(value);
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
k = tmp;
|
|
41
|
-
k = decodeURIComponent(k);
|
|
42
|
-
out[k] = "";
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return out;
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
decode,
|
|
49
|
-
encode
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=qss.js.map
|
package/dist/esm/qss.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"qss.js","sources":["../../src/qss.ts"],"sourcesContent":["/**\n * Program uses a modified version 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\n/**\n * Encodes an object into a query string.\n * @param obj - The object to encode into a query string.\n * @param [pfx] - An optional prefix to add before the query string.\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(obj: any, pfx?: string) {\n let k,\n i,\n tmp,\n str = ''\n\n for (k in obj) {\n if ((tmp = obj[k]) !== void 0) {\n if (Array.isArray(tmp)) {\n for (i = 0; i < tmp.length; i++) {\n str && (str += '&')\n str += encodeURIComponent(k) + '=' + encodeURIComponent(tmp[i])\n }\n } else {\n str && (str += '&')\n str += encodeURIComponent(k) + '=' + encodeURIComponent(tmp)\n }\n }\n }\n\n return (pfx || '') + str\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(mix: any) {\n if (!mix) return ''\n const str = decodeURIComponent(mix)\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 * @param [pfx] - An optional prefix to filter out from the query string.\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, pfx?: string) {\n let tmp, k\n const out: any = {},\n arr = (pfx ? str.substr(pfx.length) : str).split('&')\n\n while ((tmp = arr.shift())) {\n const equalIndex = tmp.indexOf('=')\n if (equalIndex !== -1) {\n k = tmp.slice(0, equalIndex)\n k = decodeURIComponent(k)\n const value = tmp.slice(equalIndex + 1)\n if (out[k] !== void 0) {\n // @ts-expect-error\n out[k] = [].concat(out[k], toValue(value))\n } else {\n out[k] = toValue(value)\n }\n } else {\n k = tmp\n k = decodeURIComponent(k)\n out[k] = ''\n }\n }\n\n return out\n}\n"],"names":[],"mappings":"AAiBgB,SAAA,OAAO,KAAU,KAAc;AACzC,MAAA,GACF,GACA,KACA,MAAM;AAER,OAAK,KAAK,KAAK;AACb,SAAK,MAAM,IAAI,CAAC,OAAO,QAAQ;AACzB,UAAA,MAAM,QAAQ,GAAG,GAAG;AACtB,aAAK,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AAC/B,kBAAQ,OAAO;AACf,iBAAO,mBAAmB,CAAC,IAAI,MAAM,mBAAmB,IAAI,CAAC,CAAC;AAAA,QAAA;AAAA,MAChE,OACK;AACL,gBAAQ,OAAO;AACf,eAAO,mBAAmB,CAAC,IAAI,MAAM,mBAAmB,GAAG;AAAA,MAAA;AAAA,IAC7D;AAAA,EACF;AAGF,UAAQ,OAAO,MAAM;AACvB;AAUA,SAAS,QAAQ,KAAU;AACrB,MAAA,CAAC,IAAY,QAAA;AACX,QAAA,MAAM,mBAAmB,GAAG;AAC9B,MAAA,QAAQ,QAAgB,QAAA;AACxB,MAAA,QAAQ,OAAe,QAAA;AACpB,SAAA,CAAC,MAAM,MAAM,KAAK,CAAC,MAAM,OAAO,MAAM,CAAC,MAAM;AACtD;AAWgB,SAAA,OAAO,KAAU,KAAc;AAC7C,MAAI,KAAK;AACT,QAAM,MAAW,CACf,GAAA,OAAO,MAAM,IAAI,OAAO,IAAI,MAAM,IAAI,KAAK,MAAM,GAAG;AAE9C,SAAA,MAAM,IAAI,SAAU;AACpB,UAAA,aAAa,IAAI,QAAQ,GAAG;AAClC,QAAI,eAAe,IAAI;AACjB,UAAA,IAAI,MAAM,GAAG,UAAU;AAC3B,UAAI,mBAAmB,CAAC;AACxB,YAAM,QAAQ,IAAI,MAAM,aAAa,CAAC;AAClC,UAAA,IAAI,CAAC,MAAM,QAAQ;AAEjB,YAAA,CAAC,IAAI,CAAA,EAAG,OAAO,IAAI,CAAC,GAAG,QAAQ,KAAK,CAAC;AAAA,MAAA,OACpC;AACD,YAAA,CAAC,IAAI,QAAQ,KAAK;AAAA,MAAA;AAAA,IACxB,OACK;AACD,UAAA;AACJ,UAAI,mBAAmB,CAAC;AACxB,UAAI,CAAC,IAAI;AAAA,IAAA;AAAA,EACX;AAGK,SAAA;AACT;"}
|
package/dist/esm/root.d.ts
DELETED
package/dist/esm/root.js
DELETED
package/dist/esm/root.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"root.js","sources":["../../src/root.ts"],"sourcesContent":["export const rootRouteId = '__root__'\nexport type RootRouteId = typeof rootRouteId\n"],"names":[],"mappings":"AAAO,MAAM,cAAc;"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { NoInfer, PickOptional } from './utils.js';
|
|
2
|
-
import { SearchMiddleware } from './route.js';
|
|
3
|
-
import { IsRequiredParams } from './link.js';
|
|
4
|
-
export declare function retainSearchParams<TSearchSchema extends object>(keys: Array<keyof TSearchSchema> | true): SearchMiddleware<TSearchSchema>;
|
|
5
|
-
export declare function stripSearchParams<TSearchSchema, TOptionalProps = PickOptional<NoInfer<TSearchSchema>>, const TValues = Partial<NoInfer<TOptionalProps>> | Array<keyof TOptionalProps>, const TInput = IsRequiredParams<TSearchSchema> extends never ? TValues | true : TValues>(input: NoInfer<TInput>): SearchMiddleware<TSearchSchema>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { deepEqual } from "./utils.js";
|
|
2
|
-
function retainSearchParams(keys) {
|
|
3
|
-
return ({ search, next }) => {
|
|
4
|
-
const result = next(search);
|
|
5
|
-
if (keys === true) {
|
|
6
|
-
return { ...search, ...result };
|
|
7
|
-
}
|
|
8
|
-
keys.forEach((key) => {
|
|
9
|
-
if (!(key in result)) {
|
|
10
|
-
result[key] = search[key];
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
return result;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function stripSearchParams(input) {
|
|
17
|
-
return ({ search, next }) => {
|
|
18
|
-
if (input === true) {
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
const result = next(search);
|
|
22
|
-
if (Array.isArray(input)) {
|
|
23
|
-
input.forEach((key) => {
|
|
24
|
-
delete result[key];
|
|
25
|
-
});
|
|
26
|
-
} else {
|
|
27
|
-
Object.entries(input).forEach(
|
|
28
|
-
([key, value]) => {
|
|
29
|
-
if (deepEqual(result[key], value)) {
|
|
30
|
-
delete result[key];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
retainSearchParams,
|
|
40
|
-
stripSearchParams
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=searchMiddleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchMiddleware.js","sources":["../../src/searchMiddleware.ts"],"sourcesContent":["import { deepEqual } from './utils'\nimport type { NoInfer, PickOptional } from './utils'\nimport type { SearchMiddleware } from './route'\nimport type { IsRequiredParams } from './link'\n\nexport function retainSearchParams<TSearchSchema extends object>(\n keys: Array<keyof TSearchSchema> | true,\n): SearchMiddleware<TSearchSchema> {\n return ({ search, next }) => {\n const result = next(search)\n if (keys === true) {\n return { ...search, ...result }\n }\n // add missing keys from search to result\n keys.forEach((key) => {\n if (!(key in result)) {\n result[key] = search[key]\n }\n })\n return result\n }\n}\n\nexport function stripSearchParams<\n TSearchSchema,\n TOptionalProps = PickOptional<NoInfer<TSearchSchema>>,\n const TValues =\n | Partial<NoInfer<TOptionalProps>>\n | Array<keyof TOptionalProps>,\n const TInput = IsRequiredParams<TSearchSchema> extends never\n ? TValues | true\n : TValues,\n>(input: NoInfer<TInput>): SearchMiddleware<TSearchSchema> {\n return ({ search, next }) => {\n if (input === true) {\n return {}\n }\n const result = next(search) as Record<string, unknown>\n if (Array.isArray(input)) {\n input.forEach((key) => {\n delete result[key]\n })\n } else {\n Object.entries(input as Record<string, unknown>).forEach(\n ([key, value]) => {\n if (deepEqual(result[key], value)) {\n delete result[key]\n }\n },\n )\n }\n return result as any\n }\n}\n"],"names":[],"mappings":";AAKO,SAAS,mBACd,MACiC;AACjC,SAAO,CAAC,EAAE,QAAQ,WAAW;AACrB,UAAA,SAAS,KAAK,MAAM;AAC1B,QAAI,SAAS,MAAM;AACjB,aAAO,EAAE,GAAG,QAAQ,GAAG,OAAO;AAAA,IAAA;AAG3B,SAAA,QAAQ,CAAC,QAAQ;AAChB,UAAA,EAAE,OAAO,SAAS;AACb,eAAA,GAAG,IAAI,OAAO,GAAG;AAAA,MAAA;AAAA,IAC1B,CACD;AACM,WAAA;AAAA,EACT;AACF;AAEO,SAAS,kBASd,OAAyD;AACzD,SAAO,CAAC,EAAE,QAAQ,WAAW;AAC3B,QAAI,UAAU,MAAM;AAClB,aAAO,CAAC;AAAA,IAAA;AAEJ,UAAA,SAAS,KAAK,MAAM;AACtB,QAAA,MAAM,QAAQ,KAAK,GAAG;AAClB,YAAA,QAAQ,CAAC,QAAQ;AACrB,eAAO,OAAO,GAAG;AAAA,MAAA,CAClB;AAAA,IAAA,OACI;AACE,aAAA,QAAQ,KAAgC,EAAE;AAAA,QAC/C,CAAC,CAAC,KAAK,KAAK,MAAM;AAChB,cAAI,UAAU,OAAO,GAAG,GAAG,KAAK,GAAG;AACjC,mBAAO,OAAO,GAAG;AAAA,UAAA;AAAA,QACnB;AAAA,MAEJ;AAAA,IAAA;AAEK,WAAA;AAAA,EACT;AACF;"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AnySchema } from './validators.js';
|
|
2
|
-
export declare const defaultParseSearch: (searchStr: string) => AnySchema;
|
|
3
|
-
export declare const defaultStringifySearch: (search: Record<string, any>) => string;
|
|
4
|
-
export declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySchema;
|
|
5
|
-
export declare function stringifySearchWith(stringify: (search: any) => string, parser?: (str: string) => any): (search: Record<string, any>) => string;
|
|
6
|
-
export type SearchSerializer = (searchObj: Record<string, any>) => string;
|
|
7
|
-
export type SearchParser = (searchStr: string) => Record<string, any>;
|
package/dist/esm/searchParams.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { decode, encode } from "./qss.js";
|
|
2
|
-
const defaultParseSearch = parseSearchWith(JSON.parse);
|
|
3
|
-
const defaultStringifySearch = stringifySearchWith(
|
|
4
|
-
JSON.stringify,
|
|
5
|
-
JSON.parse
|
|
6
|
-
);
|
|
7
|
-
function parseSearchWith(parser) {
|
|
8
|
-
return (searchStr) => {
|
|
9
|
-
if (searchStr.substring(0, 1) === "?") {
|
|
10
|
-
searchStr = searchStr.substring(1);
|
|
11
|
-
}
|
|
12
|
-
const query = decode(searchStr);
|
|
13
|
-
for (const key in query) {
|
|
14
|
-
const value = query[key];
|
|
15
|
-
if (typeof value === "string") {
|
|
16
|
-
try {
|
|
17
|
-
query[key] = parser(value);
|
|
18
|
-
} catch (err) {
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return query;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function stringifySearchWith(stringify, parser) {
|
|
26
|
-
function stringifyValue(val) {
|
|
27
|
-
if (typeof val === "object" && val !== null) {
|
|
28
|
-
try {
|
|
29
|
-
return stringify(val);
|
|
30
|
-
} catch (err) {
|
|
31
|
-
}
|
|
32
|
-
} else if (typeof val === "string" && typeof parser === "function") {
|
|
33
|
-
try {
|
|
34
|
-
parser(val);
|
|
35
|
-
return stringify(val);
|
|
36
|
-
} catch (err) {
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return val;
|
|
40
|
-
}
|
|
41
|
-
return (search) => {
|
|
42
|
-
search = { ...search };
|
|
43
|
-
Object.keys(search).forEach((key) => {
|
|
44
|
-
const val = search[key];
|
|
45
|
-
if (typeof val === "undefined" || val === void 0) {
|
|
46
|
-
delete search[key];
|
|
47
|
-
} else {
|
|
48
|
-
search[key] = stringifyValue(val);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
const searchStr = encode(search).toString();
|
|
52
|
-
return searchStr ? `?${searchStr}` : "";
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
export {
|
|
56
|
-
defaultParseSearch,
|
|
57
|
-
defaultStringifySearch,
|
|
58
|
-
parseSearchWith,
|
|
59
|
-
stringifySearchWith
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=searchParams.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchParams.js","sources":["../../src/searchParams.ts"],"sourcesContent":["import { decode, encode } from './qss'\nimport type { AnySchema } from './validators'\n\nexport const defaultParseSearch = parseSearchWith(JSON.parse)\nexport const defaultStringifySearch = stringifySearchWith(\n JSON.stringify,\n JSON.parse,\n)\n\nexport function parseSearchWith(parser: (str: string) => any) {\n return (searchStr: string): AnySchema => {\n if (searchStr.substring(0, 1) === '?') {\n searchStr = searchStr.substring(1)\n }\n\n const query: Record<string, unknown> = decode(searchStr)\n\n // Try to parse any query params that might be json\n for (const key in query) {\n const value = query[key]\n if (typeof value === 'string') {\n try {\n query[key] = parser(value)\n } catch (err) {\n //\n }\n }\n }\n\n return query\n }\n}\n\nexport function stringifySearchWith(\n stringify: (search: any) => string,\n parser?: (str: string) => any,\n) {\n function stringifyValue(val: any) {\n if (typeof val === 'object' && val !== null) {\n try {\n return stringify(val)\n } catch (err) {\n // silent\n }\n } else if (typeof val === 'string' && typeof parser === 'function') {\n try {\n // Check if it's a valid parseable string.\n // If it is, then stringify it again.\n parser(val)\n return stringify(val)\n } catch (err) {\n // silent\n }\n }\n return val\n }\n\n return (search: Record<string, any>) => {\n search = { ...search }\n\n Object.keys(search).forEach((key) => {\n const val = search[key]\n if (typeof val === 'undefined' || val === undefined) {\n delete search[key]\n } else {\n search[key] = stringifyValue(val)\n }\n })\n\n const searchStr = encode(search as Record<string, string>).toString()\n\n return searchStr ? `?${searchStr}` : ''\n }\n}\n\nexport type SearchSerializer = (searchObj: Record<string, any>) => string\nexport type SearchParser = (searchStr: string) => Record<string, any>\n"],"names":[],"mappings":";AAGa,MAAA,qBAAqB,gBAAgB,KAAK,KAAK;AACrD,MAAM,yBAAyB;AAAA,EACpC,KAAK;AAAA,EACL,KAAK;AACP;AAEO,SAAS,gBAAgB,QAA8B;AAC5D,SAAO,CAAC,cAAiC;AACvC,QAAI,UAAU,UAAU,GAAG,CAAC,MAAM,KAAK;AACzB,kBAAA,UAAU,UAAU,CAAC;AAAA,IAAA;AAG7B,UAAA,QAAiC,OAAO,SAAS;AAGvD,eAAW,OAAO,OAAO;AACjB,YAAA,QAAQ,MAAM,GAAG;AACnB,UAAA,OAAO,UAAU,UAAU;AACzB,YAAA;AACI,gBAAA,GAAG,IAAI,OAAO,KAAK;AAAA,iBAClB,KAAK;AAAA,QAAA;AAAA,MAEd;AAAA,IACF;AAGK,WAAA;AAAA,EACT;AACF;AAEgB,SAAA,oBACd,WACA,QACA;AACA,WAAS,eAAe,KAAU;AAChC,QAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AACvC,UAAA;AACF,eAAO,UAAU,GAAG;AAAA,eACb,KAAK;AAAA,MAAA;AAAA,eAGL,OAAO,QAAQ,YAAY,OAAO,WAAW,YAAY;AAC9D,UAAA;AAGF,eAAO,GAAG;AACV,eAAO,UAAU,GAAG;AAAA,eACb,KAAK;AAAA,MAAA;AAAA,IAEd;AAEK,WAAA;AAAA,EAAA;AAGT,SAAO,CAAC,WAAgC;AAC7B,aAAA,EAAE,GAAG,OAAO;AAErB,WAAO,KAAK,MAAM,EAAE,QAAQ,CAAC,QAAQ;AAC7B,YAAA,MAAM,OAAO,GAAG;AACtB,UAAI,OAAO,QAAQ,eAAe,QAAQ,QAAW;AACnD,eAAO,OAAO,GAAG;AAAA,MAAA,OACZ;AACE,eAAA,GAAG,IAAI,eAAe,GAAG;AAAA,MAAA;AAAA,IAClC,CACD;AAED,UAAM,YAAY,OAAO,MAAgC,EAAE,SAAS;AAE7D,WAAA,YAAY,IAAI,SAAS,KAAK;AAAA,EACvC;AACF;"}
|
package/dist/esm/serializer.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface StartSerializer {
|
|
2
|
-
stringify: (obj: unknown) => string;
|
|
3
|
-
parse: (str: string) => unknown;
|
|
4
|
-
encode: <T>(value: T) => T;
|
|
5
|
-
decode: <T>(value: T) => T;
|
|
6
|
-
}
|
|
7
|
-
export type SerializerStringifyBy<T, TSerializable> = T extends TSerializable ? T : T extends (...args: Array<any>) => any ? 'Function is not serializable' : {
|
|
8
|
-
[K in keyof T]: SerializerStringifyBy<T[K], TSerializable>;
|
|
9
|
-
};
|
|
10
|
-
export type SerializerParseBy<T, TSerializable> = T extends TSerializable ? T : T extends React.JSX.Element ? ReadableStream : {
|
|
11
|
-
[K in keyof T]: SerializerParseBy<T[K], TSerializable>;
|
|
12
|
-
};
|
|
13
|
-
export type Serializable = Date | undefined | Error | FormData;
|
|
14
|
-
export type SerializerStringify<T> = SerializerStringifyBy<T, Serializable>;
|
|
15
|
-
export type SerializerParse<T> = SerializerParseBy<T, Serializable>;
|
package/dist/esm/validators.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { SearchSchemaInput } from './route.js';
|
|
2
|
-
export interface StandardSchemaValidatorProps<TInput, TOutput> {
|
|
3
|
-
readonly types?: StandardSchemaValidatorTypes<TInput, TOutput> | undefined;
|
|
4
|
-
readonly validate: AnyStandardSchemaValidate;
|
|
5
|
-
}
|
|
6
|
-
export interface StandardSchemaValidator<TInput, TOutput> {
|
|
7
|
-
readonly '~standard': StandardSchemaValidatorProps<TInput, TOutput>;
|
|
8
|
-
}
|
|
9
|
-
export type AnyStandardSchemaValidator = StandardSchemaValidator<any, any>;
|
|
10
|
-
export interface StandardSchemaValidatorTypes<TInput, TOutput> {
|
|
11
|
-
readonly input: TInput;
|
|
12
|
-
readonly output: TOutput;
|
|
13
|
-
}
|
|
14
|
-
export interface AnyStandardSchemaValidateSuccess {
|
|
15
|
-
readonly value: any;
|
|
16
|
-
readonly issues?: undefined;
|
|
17
|
-
}
|
|
18
|
-
export interface AnyStandardSchemaValidateFailure {
|
|
19
|
-
readonly issues: ReadonlyArray<AnyStandardSchemaValidateIssue>;
|
|
20
|
-
}
|
|
21
|
-
export interface AnyStandardSchemaValidateIssue {
|
|
22
|
-
readonly message: string;
|
|
23
|
-
}
|
|
24
|
-
export interface AnyStandardSchemaValidateInput {
|
|
25
|
-
readonly value: any;
|
|
26
|
-
}
|
|
27
|
-
export type AnyStandardSchemaValidate = (value: unknown) => (AnyStandardSchemaValidateSuccess | AnyStandardSchemaValidateFailure) | Promise<AnyStandardSchemaValidateSuccess | AnyStandardSchemaValidateFailure>;
|
|
28
|
-
export interface ValidatorObj<TInput, TOutput> {
|
|
29
|
-
parse: ValidatorFn<TInput, TOutput>;
|
|
30
|
-
}
|
|
31
|
-
export type AnyValidatorObj = ValidatorObj<any, any>;
|
|
32
|
-
export interface ValidatorAdapter<TInput, TOutput> {
|
|
33
|
-
types: {
|
|
34
|
-
input: TInput;
|
|
35
|
-
output: TOutput;
|
|
36
|
-
};
|
|
37
|
-
parse: (input: unknown) => TOutput;
|
|
38
|
-
}
|
|
39
|
-
export type AnyValidatorAdapter = ValidatorAdapter<any, any>;
|
|
40
|
-
export type AnyValidatorFn = ValidatorFn<any, any>;
|
|
41
|
-
export type ValidatorFn<TInput, TOutput> = (input: TInput) => TOutput;
|
|
42
|
-
export type Validator<TInput, TOutput> = ValidatorObj<TInput, TOutput> | ValidatorFn<TInput, TOutput> | ValidatorAdapter<TInput, TOutput> | StandardSchemaValidator<TInput, TOutput> | undefined;
|
|
43
|
-
export type AnyValidator = Validator<any, any>;
|
|
44
|
-
export type AnySchema = {};
|
|
45
|
-
export type DefaultValidator = Validator<Record<string, unknown>, AnySchema>;
|
|
46
|
-
export type ResolveSearchValidatorInputFn<TValidator> = TValidator extends (input: infer TSchemaInput) => any ? TSchemaInput extends SearchSchemaInput ? Omit<TSchemaInput, keyof SearchSchemaInput> : ResolveValidatorOutputFn<TValidator> : AnySchema;
|
|
47
|
-
export type ResolveSearchValidatorInput<TValidator> = TValidator extends AnyStandardSchemaValidator ? NonNullable<TValidator['~standard']['types']>['input'] : TValidator extends AnyValidatorAdapter ? TValidator['types']['input'] : TValidator extends AnyValidatorObj ? ResolveSearchValidatorInputFn<TValidator['parse']> : ResolveSearchValidatorInputFn<TValidator>;
|
|
48
|
-
export type ResolveValidatorInputFn<TValidator> = TValidator extends (input: infer TInput) => any ? TInput : undefined;
|
|
49
|
-
export type ResolveValidatorInput<TValidator> = TValidator extends AnyStandardSchemaValidator ? NonNullable<TValidator['~standard']['types']>['input'] : TValidator extends AnyValidatorAdapter ? TValidator['types']['input'] : TValidator extends AnyValidatorObj ? ResolveValidatorInputFn<TValidator['parse']> : ResolveValidatorInputFn<TValidator>;
|
|
50
|
-
export type ResolveValidatorOutputFn<TValidator> = TValidator extends (...args: any) => infer TSchema ? TSchema : AnySchema;
|
|
51
|
-
export type ResolveValidatorOutput<TValidator> = unknown extends TValidator ? TValidator : TValidator extends AnyStandardSchemaValidator ? NonNullable<TValidator['~standard']['types']>['output'] : TValidator extends AnyValidatorAdapter ? TValidator['types']['output'] : TValidator extends AnyValidatorObj ? ResolveValidatorOutputFn<TValidator['parse']> : ResolveValidatorOutputFn<TValidator>;
|
package/src/defer.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { defaultSerializeError } from './router'
|
|
2
|
-
|
|
3
|
-
export const TSR_DEFERRED_PROMISE = Symbol.for('TSR_DEFERRED_PROMISE')
|
|
4
|
-
|
|
5
|
-
export type DeferredPromiseState<T> =
|
|
6
|
-
| {
|
|
7
|
-
status: 'pending'
|
|
8
|
-
data?: T
|
|
9
|
-
error?: unknown
|
|
10
|
-
}
|
|
11
|
-
| {
|
|
12
|
-
status: 'success'
|
|
13
|
-
data: T
|
|
14
|
-
}
|
|
15
|
-
| {
|
|
16
|
-
status: 'error'
|
|
17
|
-
data?: T
|
|
18
|
-
error: unknown
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type DeferredPromise<T> = Promise<T> & {
|
|
22
|
-
[TSR_DEFERRED_PROMISE]: DeferredPromiseState<T>
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function defer<T>(
|
|
26
|
-
_promise: Promise<T>,
|
|
27
|
-
options?: {
|
|
28
|
-
serializeError?: typeof defaultSerializeError
|
|
29
|
-
},
|
|
30
|
-
) {
|
|
31
|
-
const promise = _promise as DeferredPromise<T>
|
|
32
|
-
// this is already deferred promise
|
|
33
|
-
if ((promise as any)[TSR_DEFERRED_PROMISE]) {
|
|
34
|
-
return promise
|
|
35
|
-
}
|
|
36
|
-
promise[TSR_DEFERRED_PROMISE] = { status: 'pending' }
|
|
37
|
-
|
|
38
|
-
promise
|
|
39
|
-
.then((data) => {
|
|
40
|
-
promise[TSR_DEFERRED_PROMISE].status = 'success'
|
|
41
|
-
promise[TSR_DEFERRED_PROMISE].data = data
|
|
42
|
-
})
|
|
43
|
-
.catch((error) => {
|
|
44
|
-
promise[TSR_DEFERRED_PROMISE].status = 'error'
|
|
45
|
-
;(promise[TSR_DEFERRED_PROMISE] as any).error = {
|
|
46
|
-
data: (options?.serializeError ?? defaultSerializeError)(error),
|
|
47
|
-
__isServerError: true,
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
return promise
|
|
52
|
-
}
|
package/src/location.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ParsedHistoryState } from '@tanstack/history'
|
|
2
|
-
import type { AnySchema } from './validators'
|
|
3
|
-
|
|
4
|
-
export interface ParsedLocation<TSearchObj extends AnySchema = {}> {
|
|
5
|
-
href: string
|
|
6
|
-
pathname: string
|
|
7
|
-
search: TSearchObj
|
|
8
|
-
searchStr: string
|
|
9
|
-
state: ParsedHistoryState
|
|
10
|
-
hash: string
|
|
11
|
-
maskedLocation?: ParsedLocation<TSearchObj>
|
|
12
|
-
unmaskOnReload?: boolean
|
|
13
|
-
}
|
package/src/manifest.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export type Manifest = {
|
|
2
|
-
routes: Record<
|
|
3
|
-
string,
|
|
4
|
-
{
|
|
5
|
-
filePath?: string
|
|
6
|
-
preloads?: Array<string>
|
|
7
|
-
assets?: Array<RouterManagedTag>
|
|
8
|
-
}
|
|
9
|
-
>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type RouterManagedTag =
|
|
13
|
-
| {
|
|
14
|
-
tag: 'title'
|
|
15
|
-
attrs?: Record<string, any>
|
|
16
|
-
children: string
|
|
17
|
-
}
|
|
18
|
-
| {
|
|
19
|
-
tag: 'meta' | 'link'
|
|
20
|
-
attrs?: Record<string, any>
|
|
21
|
-
children?: never
|
|
22
|
-
}
|
|
23
|
-
| {
|
|
24
|
-
tag: 'script'
|
|
25
|
-
attrs?: Record<string, any>
|
|
26
|
-
children?: string
|
|
27
|
-
}
|
|
28
|
-
| {
|
|
29
|
-
tag: 'style'
|
|
30
|
-
attrs?: Record<string, any>
|
|
31
|
-
children?: string
|
|
32
|
-
}
|